Index: trunk/BNC/src/combination/bnccomb.h
===================================================================
--- trunk/BNC/src/combination/bnccomb.h	(revision 9821)
+++ trunk/BNC/src/combination/bnccomb.h	(revision 10038)
@@ -4,6 +4,8 @@
 
 #include <fstream>
+#include <iostream>
 #include <map>
 #include <newmat.h>
+#include <deque>
 #include "bncephuser.h"
 #include "satObs.h"
@@ -20,5 +22,4 @@
  Q_OBJECT
  public:
-  bncComb();
   virtual ~bncComb();
   static bncComb* instance();
@@ -42,4 +43,9 @@
 
  private:
+  static bncComb* _instPtr;   // The one, single instance
+  bncComb();                  // private constructor
+  bncComb(const bncComb&);
+  bncComb& operator=(const bncComb&);
+
   enum e_method{singleEpoch, filter};
 
@@ -85,7 +91,11 @@
     cmbCorr() {
       _eph                        = 0;
+      _orbCorr                    = 0;
+      _clkCorr                    = 0;
+      _satCodeBias                = 0;
       _iod                        = 0;
       _dClkResult                 = 0.0;
       _satCodeBiasIF              = 0.0;
+      _weightFactor               = 1.0;
     }
     ~cmbCorr() {}
@@ -94,7 +104,7 @@
     unsigned long  _iod;
     t_eph*         _eph;
-    t_orbCorr      _orbCorr;
-    t_clkCorr      _clkCorr;
-    t_satCodeBias  _satCodeBias;
+    t_orbCorr*      _orbCorr;
+    t_clkCorr*      _clkCorr;
+    t_satCodeBias* _satCodeBias;
     QString        _acName;
     double         _satCodeBiasIF;
@@ -109,4 +119,7 @@
     cmbEpoch() {}
     ~cmbEpoch() {
+      clear();
+    }
+    void clear() {
       QVectorIterator<cmbCorr*> it(corrs);
       while (it.hasNext()) {
@@ -115,4 +128,16 @@
     }
     QVector<cmbCorr*> corrs;
+  };
+
+  class epoClkData {
+   public:
+    epoClkData() {}
+    ~epoClkData() {
+      for (unsigned ii = 0; ii < _clkCorr.size(); ii++) {
+        delete _clkCorr[ii];
+      }
+    }
+    bncTime                 _time;
+    std::vector<t_clkCorr*> _clkCorr;
   };
 
@@ -196,23 +221,22 @@
   };
 
-
-  void  processEpoch(char sys);
-  t_irc processEpoch_filter(char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr,
-                            ColumnVector& dx);
-  t_irc processEpoch_singleEpoch(char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr,
-                                 ColumnVector& dx);
+  void  processEpoch(bncTime epoTime, const std::vector<t_clkCorr*>& clkCorrVec);
+  void  processSystem(bncTime epoTime, char sys, QTextStream& out);
+  t_irc processEpoch_filter(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr, ColumnVector& dx);
+  t_irc processEpoch_singleEpoch(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr, ColumnVector& dx);
   t_irc createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
                    const ColumnVector& x0, QMap<QString, cmbCorr*>& resCorr);
-  void  dumpResults(const QMap<QString, cmbCorr*>& resCorr);
-  void  printResults(QTextStream& out, const QMap<QString, cmbCorr*>& resCorr);
+  void  dumpResults(bncTime epoTime, const QMap<QString, cmbCorr*>& resCorr);
+  void  printResults(bncTime epoTime, QTextStream& out, const QMap<QString, cmbCorr*>& resCorr);
   void  switchToLastEph(t_eph* lastEph, cmbCorr* corr);
-  t_irc checkOrbits(char sys, QTextStream& out);
-  QVector<cmbCorr*>& corrs(char sys) {return _buffer[sys][_resTime].corrs;}
+  t_irc checkOrbits(bncTime epoTime, char sys, QTextStream& out);
+  QVector<cmbCorr*>& corrs(char sys) {return _buffer[sys].corrs;}
 
   QMutex                                     _mutex;
   QList<cmbAC*>                              _ACs;
-  bncTime                                    _resTime;
+  std::deque<epoClkData*>                    _epoClkData;
+  bncTime                                    _lastClkCorrTime;
   QMap<char, QVector<cmbParam*>>             _params;
-  QMap<char, QMap<bncTime, cmbEpoch>>        _buffer;
+  QMap<char, cmbEpoch>                       _buffer;
   bncRtnetDecoder*                           _rtnetDecoder;
   QMap<char, SymmetricMatrix>                _QQ;
@@ -227,6 +251,6 @@
   int                                        _ms;
   QString                                    _cmbRefAttributes;
-  QMap<QString, QMap<t_prn, t_orbCorr> >     _orbCorrections;
-  QMap<QString, QMap<t_prn, t_satCodeBias> > _satCodeBiases;
+  QMap<QString, QMap<t_prn, t_orbCorr*> >     _orbCorrections;
+  QMap<QString, QMap<t_prn, t_satCodeBias*> > _satCodeBiases;
   bncEphUser                                 _ephUser;
   SsrCorr*                                   _ssrCorr;
