Index: /trunk/FACT++/src/dataLogger.cc
===================================================================
--- /trunk/FACT++/src/dataLogger.cc	(revision 10930)
+++ /trunk/FACT++/src/dataLogger.cc	(revision 10931)
@@ -77,5 +77,5 @@
 
 //Dim structures
-///Distributes the writting statistics
+///Distributes the writing statistics
 struct DataLoggerStats {
     long sizeWritten;
@@ -129,6 +129,4 @@
 #endif
         runNumber = 0;
-        //give it a meaningless, 0 time to distinguish with actual, valid times
-        time = Time(0,0);
     }
     ///default destructor
@@ -138,4 +136,5 @@
     }
     ///copy operator
+    /*
     void operator = (const RunNumberType& other)
     {
@@ -151,5 +150,6 @@
         runFitsFile = other.runFitsFile;
 #endif
-    }
+}*/
+
     ///copy constructor
     RunNumberType(const RunNumberType& other)
@@ -169,15 +169,11 @@
 
     void addServiceToOpenedFits(const string& fileName, const string& serviceName)
-    {//most likely I should add this service name.
-     //the only case for which I should not add it is if a service disapeared, hence the file was closed
-     //and reopened again. Unlikely to happen, but well it may
-        bool found = false;
-        for (vector<string>::iterator it=openedFits[fileName].begin(); it!=openedFits[fileName].end(); it++)
-            if (*it == serviceName)
-            {
-                found = true;
-                break;
-            }
-        if (!found)
+    {
+         //most likely I should add this service name.
+         //the only case for which I should not add it is if a service disapeared, hence the file was closed
+         //and reopened again. Unlikely to happen, but well it may
+
+         if (find(openedFits[fileName].begin(), openedFits[fileName].end(),
+                  serviceName)==openedFits[fileName].end())
             openedFits[fileName].push_back(serviceName);
     }
@@ -203,4 +199,5 @@
     uint32_t runNumber;
     ///copy operator
+    /*
     void operator = (const SubscriptionType& other)
     {
@@ -214,6 +211,7 @@
         fConv = other.fConv;
         runNumber = other.runNumber;
-    }
-    ///copy constructor
+        }*/
+
+/*    ///copy constructor
     SubscriptionType(const SubscriptionType& other)
     {
@@ -227,7 +225,7 @@
         fConv = other.fConv;
         runNumber = other.runNumber;
-    }
+    }*/
     ///Dim info constructor
-    SubscriptionType(DimStampedInfo* info)
+    SubscriptionType(DimStampedInfo* info=NULL)
     {
         dimInfo = shared_ptr<DimStampedInfo>(info);
@@ -236,10 +234,10 @@
     }
     ///default constructor
-    SubscriptionType()
+/*    SubscriptionType()
     {
         dimInfo = shared_ptr<DimStampedInfo>();
         fConv = shared_ptr<Converter>();
         runNumber = 0;
-    }
+    }*/
     ///default destructor
     ~SubscriptionType()
@@ -380,5 +378,5 @@
     NumSubAndFitsType fNumSubAndFitsData;
     ///Small function for calculating the total size written so far
-    void calculateTotalSizeWritten(DataLoggerStats& statVar, bool& shouldWarn, bool isPrinting);
+    bool calculateTotalSizeWritten(DataLoggerStats& statVar, bool isPrinting);
 
     /***************************************************
@@ -417,5 +415,5 @@
     void RemoveOldestRunNumber();
     ///retrieves the size of a file
-    off_t GetFileSize(string&);
+    off_t GetFileSize(const string&);
     ///Get the digits of year, month and day for filenames and paths
     void GetYearMonthDayForFiles(unsigned short& year, unsigned short& month, unsigned short& day);
@@ -616,14 +614,13 @@
 {
     //get the size of the file we're about to open
-    if (fFileSizesMap.find(fileName) == fFileSizesMap.end())
-    {
-        if (nightly)
-            fBaseSizeNightly += GetFileSize(fileName);
-        else
-            fBaseSizeRun += GetFileSize(fileName);
-        fFileSizesMap[fileName] = 0;
-        return true;
-    }
-    return false;
+    if (fFileSizesMap.find(fileName) != fFileSizesMap.end())
+        return false;
+
+    if (nightly)
+        fBaseSizeNightly += GetFileSize(fileName);
+    else
+        fBaseSizeRun += GetFileSize(fileName);
+    fFileSizesMap[fileName] = 0;
+    return true;
 }
 
@@ -754,5 +751,5 @@
 //! @return the size of the file on disk, in bytes. 0 if the file does not exist or if an error occured
 //
-off_t DataLogger::GetFileSize(string& fileName)
+off_t DataLogger::GetFileSize(const string& fileName)
 {
     errno = 0;
@@ -784,9 +781,10 @@
     }
     CreateFitsGrouping(fRunNumber.front().openedFits, fRunNumber.front().runNumber);
+
     //crawl through the subscriptions to see if there are still corresponding fits files opened.
-    SubscriptionsListType::iterator x;
-    map<string, SubscriptionType>::iterator y;
-    for (x=fServiceSubscriptions.begin(); x != fServiceSubscriptions.end(); x++)
-        for (y=x->second.begin(); y != x->second.end(); y++)
+    for (SubscriptionsListType::iterator x=fServiceSubscriptions.begin();
+         x!=fServiceSubscriptions.end(); x++)
+        for (map<string, SubscriptionType>::iterator y=x->second.begin();
+             y!=x->second.end(); y++)
             if (y->second.runFile.fRunNumber == fRunNumber.front().runNumber && y->second.runFile.IsOpen())
             {
@@ -813,5 +811,5 @@
 //! @param isPrinting whether this function was called from the PRINT command or not. If so, displays relevant information
 //
-void DataLogger::calculateTotalSizeWritten(DataLoggerStats& statVar, bool& shouldWarn, bool isPrinting)
+bool DataLogger::calculateTotalSizeWritten(DataLoggerStats& statVar, bool isPrinting)
 {
 #ifdef HAVE_FITS
@@ -822,10 +820,11 @@
         Message(str);
     }
-    SubscriptionsListType::iterator x;
-    map<string, SubscriptionType>::iterator y;
-///TODO the grouping file is dealt with several times. This should not be a problem but well, better to fix it I guess.
-    for (x=fServiceSubscriptions.begin(); x != fServiceSubscriptions.end(); x++)
-    {
-        for (y=x->second.begin(); y != x->second.end(); y++)
+
+    ///TODO the grouping file is dealt with several times. This should not be a problem but well, better to fix it I guess.
+    for (SubscriptionsListType::const_iterator x=fServiceSubscriptions.begin();
+         x!=fServiceSubscriptions.end(); x++)
+    {
+        for (map<string, SubscriptionType>::const_iterator y=x->second.begin();
+             y!=x->second.end(); y++)
         {
             if (y->second.runFile.IsOpen())
@@ -861,10 +860,9 @@
 #endif
     }
+
+    bool shouldWarn = false;
     struct statvfs vfs;
     if (!statvfs(fNightlyFilePath.c_str(), &vfs))
-    {
         statVar.freeSpace = vfs.f_bsize*vfs.f_bavail;
-        shouldWarn = false;
-    }
     else
     {
@@ -873,13 +871,14 @@
         if (!shouldWarn)
             Error(str);
-        shouldWarn = true;
         statVar.freeSpace = -1;
     }
     //sum up all the file sizes. past and present
     statVar.sizeWritten = 0;
-    for (map<string, long>::iterator it=fFileSizesMap.begin(); it != fFileSizesMap.end();  it++)
+    for (map<string, long>::const_iterator it=fFileSizesMap.begin(); it != fFileSizesMap.end();  it++)
         statVar.sizeWritten += it->second;
     statVar.sizeWritten -= fBaseSizeNightly;
     statVar.sizeWritten -= fBaseSizeRun;
+
+    return shouldWarn;
 }
 //static members initialization
@@ -922,5 +921,5 @@
         DimDescribedService srvc ("DATA_LOGGER/STATS", "X:3", statVar, "Add description here");
         fPreviousSize = 0;
-        bool statWarning = false;
+        //bool statWarning = false;
         bool resetDone = false;
         //loop-wait for broadcast
@@ -967,5 +966,5 @@
                 sleep(fStatsPeriodDuration);
             //update the fits files sizes
-            calculateTotalSizeWritten(statVar, statWarning, false);
+            /*statWarning =*/ calculateTotalSizeWritten(statVar, false);
             if (fStatsPeriodDuration == 0.0f)
                 continue;
@@ -979,5 +978,5 @@
                 {
                     ostringstream str;
-                    str << "Size written: " << statVar.sizeWritten/1000 << " kB; writting rate: ";
+                    str << "Size written: " << statVar.sizeWritten/1000 << " kB; writing rate: ";
                     str << statVar.writingRate/1000 << " kB/s; free space: ";
                     str << statVar.freeSpace/(1000*100) << " MB";
@@ -1081,7 +1080,4 @@
                                "|NumOpenFiles[int]:number of files currently open by the data logger");
 
-     //black/white list
-     fBlackList.clear();
-     fWhiteList.clear();
      //services parameters
      fDebugIsOn = false;
@@ -1094,5 +1090,5 @@
              (boost::bind(&DataLogger::SetDebugOnOff, this, _1))
              ("Switch debug mode on off. Debug mode prints ifnormation about every service written to a file."
-              "|Enable[bool]:Enable of disable debuig mode (yes/no).");
+              "|Enable[bool]:Enable of disable debug mode (yes/no).");
 
      AddEvent(fStatsPeriod, "F", kSM_NightlyOpen, kSM_Logging, kSM_WaitingRun, kSM_Ready)
@@ -1367,5 +1363,5 @@
     {
         list<RunNumberType>::reverse_iterator rit;
-        for (rit=fRunNumber.rbegin(); rit != fRunNumber.rend(); rit++)
+        for (rit=fRunNumber.rbegin(); rit!=fRunNumber.rend(); rit++)
         {
             if (rit->time < cTime) //this is the run number that we want to use
@@ -1497,5 +1493,5 @@
     ostringstream str;
     str << "Active Run Numbers:";
-    for (list<RunNumberType>::iterator it=fRunNumber.begin(); it!=fRunNumber.end(); it++)
+    for (list<RunNumberType>::const_iterator it=fRunNumber.begin(); it!=fRunNumber.end(); it++)
         str << " " << it->runNumber;
     if (fRunNumber.size()==0)
@@ -1511,5 +1507,5 @@
         Message("Nightly report-file: OPEN");
 
-    for (list<RunNumberType>::iterator it=fRunNumber.begin(); it!=fRunNumber.end(); it++)
+    for (list<RunNumberType>::const_iterator it=fRunNumber.begin(); it!=fRunNumber.end(); it++)
     {
 #ifdef RUN_LOGS
@@ -1521,7 +1517,7 @@
     }
 
-    bool statWarning = false;
     DataLoggerStats statVar;
-    calculateTotalSizeWritten(statVar, statWarning, false);
+    /*const bool statWarning =*/ calculateTotalSizeWritten(statVar, false);
+
     Message("----------------- STATS ------------------");
     str.str("");
@@ -1551,5 +1547,5 @@
 
     Message("--------------- BLOCK LIST ---------------");
-    for (set<string>::iterator it=fBlackList.begin(); it != fBlackList.end(); it++)
+    for (set<string>::const_iterator it=fBlackList.begin(); it != fBlackList.end(); it++)
         Message(" -> "+*it);
     if (fBlackList.size()==0)
@@ -1557,5 +1553,5 @@
 
     Message("--------------- ALLOW LIST ---------------");
-    for (set<string>::iterator it=fWhiteList.begin(); it != fWhiteList.end(); it++)
+    for (set<string>::const_iterator it=fWhiteList.begin(); it != fWhiteList.end(); it++)
         Message(" -> "+*it);
     if (fWhiteList.size()==0)
@@ -1565,5 +1561,5 @@
     Message("The following servers and/or services will");
     Message("be grouped into a single fits file:");
-    for (set<string>::iterator it=fGrouping.begin(); it != fGrouping.end(); it++)
+    for (set<string>::const_iterator it=fGrouping.begin(); it != fGrouping.end(); it++)
         Message(" -> "+*it);
     if (fGrouping.size()==0)
@@ -1841,5 +1837,5 @@
     if (!sub.runFile.IsOpen() && (GetCurrentState() == kSM_Logging))
     {//will we find this service in the grouping list ?
-        for (set<string>::iterator it=fGrouping.begin(); it!=fGrouping.end(); it++)
+        for (set<string>::const_iterator it=fGrouping.begin(); it!=fGrouping.end(); it++)
         {
             if (serviceName.find(*it) != string::npos)
@@ -2087,5 +2083,5 @@
     CCfits::FITS* groupFile;
     unsigned int numFilesToGroup = 0;
-    for (map<string, vector<string> >::iterator it=filesToGroup.begin(); it != filesToGroup.end(); it++)
+    for (map<string, vector<string> >::const_iterator it=filesToGroup.begin(); it != filesToGroup.end(); it++)
     {
         numFilesToGroup += it->second.size();
@@ -2158,6 +2154,6 @@
 
     int i=1;
-    for (map<string, vector<string> >::iterator it=filesToGroup.begin(); it!=filesToGroup.end(); it++)
-        for (vector<string>::iterator jt=it->second.begin(); jt != it->second.end(); jt++, i++)
+    for (map<string, vector<string> >::const_iterator it=filesToGroup.begin(); it!=filesToGroup.end(); it++)
+        for (vector<string>::const_iterator jt=it->second.begin(); jt != it->second.end(); jt++, i++)
         {
             strcpy(startOfLocation, it->first.c_str());
@@ -2199,5 +2195,5 @@
         Debug("Stopping Run Logging...");    
     }
-    for (list<RunNumberType>::iterator it=fRunNumber.begin(); it != fRunNumber.end(); it++)
+    for (list<RunNumberType>::const_iterator it=fRunNumber.begin(); it != fRunNumber.end(); it++)
     {
 #ifdef RUN_LOGS
@@ -2300,4 +2296,9 @@
     fWhiteList.clear();
 
+    //Adding entries that should ALWAYS be ignored
+    //fBlackList.insert("DATA_LOGGER/");
+    fBlackList.insert("/SERVICE_LIST");
+    fBlackList.insert("DIS_DNS/");
+
     if (conf.Has("block"))
     {
@@ -2305,9 +2306,4 @@
 
         fBlackList.insert(vec.begin(), vec.end());
-
-        //Adding entries that should ALWAYS be ignored
-        fBlackList.insert("DATA_LOGGER/");
-        fBlackList.insert("/SERVICE_LIST");
-        fBlackList.insert("DIS_DNS/");
     }
 
