| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

# DataListenerSvc.h

Go to the documentation of this file.

    00001 #ifndef GAUDIKERNEL_DATALISTENERSVC_H
    00002 #define GAUDIKERNEL_DATALISTENERSVC_H
    00003
    00004
    00005 #include "GaudiKernel/Service.h"
    00006 #include "GaudiKernel/IIncidentSvc.h"
    00007 #include "GaudiKernel/IMonitorSvc.h"
    00008 #include "GaudiKernel/IIncidentListener.h"
    00009 #include "ValueMap.h"
    00010 #include "XmlCode.h"
    00011 #include "ApMon.h"
    00012 #include <iostream>
    00013 #include <fstream>
    00014 #include <ctime>
    00015 #include <string>
    00016 #include <map>
    00017 #include <set>
    00018
    00019
    00020 #include <stdio.h>
    00021
    00022
    00023 // Forward declarations
    00024 class ISvcLocator;
    00025
    00112 class DataListenerSvc : public extends2<Service, IMonitorSvc, IIncidentListener> {
    00113 public:
    00114   DataListenerSvc(const std::string& name, ISvcLocator* sl);
    00115
    00116   virtual ~DataListenerSvc() {}
    00117
    00118   // Service pure virtual member functions
    00119   StatusCode initialize();
    00120   StatusCode finalize();
    00121
    00129   void declareInfo(const std::string& name, const bool&  var,
    00130                    const std::string& desc, const IInterface* owner) ;
    00131   void declareInfo(const std::string& name, const int&  var,
    00132                    const std::string& desc, const IInterface* owner) ;
    00133   void declareInfo(const std::string& name, const long&  var,
    00134                    const std::string& desc, const IInterface* owner) ;
    00135   void declareInfo(const std::string& name, const double& var,
    00136                    const std::string& desc, const IInterface* owner) ;
    00137   void declareInfo(const std::string& name, const std::string& var,
    00138                    const std::string& desc, const IInterface* owner) ;
    00139   void declareInfo(const std::string& name, const std::pair<double,double>&var,
    00140                    const std::string& desc, const IInterface* owner) ;
    00141   void declareInfo(const std::string& name, const AIDA::IBaseHistogram* var,
    00142                    const std::string& desc, const IInterface* owner) ;
    00143   void declareInfo(const std::string& name, const StatEntity& var,
    00144                    const std::string& desc, const IInterface* owner) ;
    00145   void declareInfo(const std::string& name, const std::string& format,
    00146                    const void * var, int size, const std::string& desc,
    00147                    const IInterface* owner) ;
    00148
    00149   // Declaration of declareProperty which is virtual in one of my includes
    00150   // (that would be service.h)
    00151   //  StatusCode declareProperty(const std::string& name, const int& var);
    00152
    00153
    00158   void undeclareInfo( const std::string& name, const IInterface* owner ) ;
    00159
    00163   void undeclareAll( const IInterface* owner ) ;
    00164
    00166   virtual void handle(const Incident&);
    00167
    00168
    00172   std::set<std::string> * getInfos(const IInterface* owner = 0);
    00173
    00174
    00181
    00182   void apmSend(char* clusterName, char* moduleName, char* key, double val);
    00184   void apmSend(char* clusterName, char* moduleName, char* key, int val);
    00186   void apmSend(char* clusterName, char* moduleName, char* key, long val);
    00188   void apmSend(char* clusterName, char* moduleName, char* key, bool val);
    00190   void apmSend(char* clusterName, char* moduleName, char* key, char* val);
    00191
    00192 private:
    00193
    00194
    00195   ApMon *apm;
    00196
    00197
    00198   // ValueMap stores declared data information
    00199   ValueMap m_ValueMap;
    00200   ValueMap m_ValueMapTemp;
    00201
    00202   time_t rawTime;
    00203   time_t rawTime2;
    00204
    00205   char buffer[50];
    00206   char buffer2[50];
    00207   std::string timeDate;
    00208   std::string timeDate2;
    00209   std::string valToWrite;
    00210
    00211
    00212   // Used to hold variable name and data information
    00213   typedef std::pair< std::string, ValueMap > Entry;
    00214   typedef std::map<const IInterface*, std::set<std::string> > InfoNamesMap;
    00215
    00216   typedef std::map< std::string, ValueMap > ValNamesMap;
    00217
    00218   void writeMap(ValNamesMap*, const Incident&, std::ofstream*);
    00219   void writeXML(ValNamesMap*, const Incident&, std::ofstream*);
    00220   std::string resizeString ( const std::string, const unsigned int );
    00221
    00222   // Converts types INTO a string with a stringstream
    00223   std::string stringConverter ( const int convertee );
    00224   std::string stringConverter ( const double convertee );
    00225   std::string stringConverter ( const bool convertee );
    00226   std::string stringConverter ( const long convertee );
    00227
    00228
    00229
    00230   InfoNamesMap m_InfoNamesMap;
    00231   InfoNamesMap::iterator m_InfoNamesMapIt;
    00232
    00233   ValNamesMap m_ValNamesMap;
    00234   ValNamesMap::iterator m_ValNamesMapIt;
    00235   XmlCode xml;
    00236
    00237
    00238   // Map associating to each algorithm name a set with the info
    00239   // names from this algorithm
    00240   IIncidentSvc* m_incidentSvc;
    00241   FILE* MonitorLog;
    00242   std::ofstream Log4;
    00243   std::ofstream XMLLog;
    00244
    00245
    00246   int FreqCriterion;
    00247   int m_EventFrequency;
    00248
    00249
    00251   void sendData(ValNamesMap*);
    00252
    00253   // The container below is necessary because usually the descriptions of
    00254   // the services are constant strings, not variables. DimService expects
    00255   // a variable address to monitor as its second argument and we are using
    00256   // a DimService for strings to publish the descriptions.
    00257   std::map<std::string,std::string> m_infoDescriptions;
    00258   std::string infoOwnerName( const IInterface* owner );
    00259
    00260   // MonALISA optionsfile variables
    00261   int m_MLjobID;
    00262   int m_MLEventFrequency;
    00263   std::string m_MLClusterName;
    00264   std::string m_ApMonSettingsFile;
    00265   std::string jobIDString;
    00266   int m_MonALISAMonitoring;
    00267   int m_XMLMonitoring;
    00268   int m_FileMonitoring;
    00269
    00270
    00271   char *keyToSend;
    00272
    00273
    00274 };
    00275
    00276 #endif // GAUDIKERNEL_DATALISTENERSVC_H

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines