CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/EventFilter/Utilities/interface/ModuleWeb.h

Go to the documentation of this file.
00001 #ifndef EVF_MODULEWEB_H
00002 #define EVF_MODULEWEB_H
00003 
00004 #include "toolbox/lang/Class.h"
00005 #include "xdata/InfoSpace.h"
00006 #include <string>
00007 #include <pthread.h>
00008 #include <semaphore.h>
00009 
00010 namespace xgi{
00011   class Input;
00012   class Output;
00013 }
00014 
00015 
00016 namespace evf
00017 {
00018 
00019 
00020 namespace moduleweb {
00021   class ForkParams {
00022     public:
00023       ForkParams():slotId(-1),restart(0),isMaster(-1){}
00024       int slotId;
00025       bool restart;
00026       int isMaster;
00027   };
00028   class ForkInfoObj {
00029     public:
00030       ForkInfoObj()
00031       {
00032         control_sem_ = new sem_t;
00033         sem_init(control_sem_,0,0);
00034         stopCondition=0;
00035         receivedStop_=false;
00036       }
00037       ~ForkInfoObj()
00038       {
00039         sem_destroy(control_sem_);
00040         delete control_sem_;
00041       }
00042       void lock() {if (mst_lock_) pthread_mutex_lock(mst_lock_);}
00043       void unlock() {if (mst_lock_) pthread_mutex_unlock(mst_lock_);}
00044       void (*forkHandler) (void *);
00045       ForkParams forkParams;
00046       unsigned int stopCondition;
00047       bool receivedStop_;
00048       sem_t *control_sem_;
00049       pthread_mutex_t * mst_lock_;
00050       void * fuAddr;
00051   };
00052 }
00053 
00054   class ModuleWeb : public toolbox::lang::Class
00055     {
00056     public:
00057       ModuleWeb(const std::string &);
00058       virtual ~ModuleWeb(){}
00059       virtual void defaultWebPage(xgi::Input *in, xgi::Output *out); 
00060       virtual void publish(xdata::InfoSpace *) = 0;
00061       virtual void publishToXmas(xdata::InfoSpace *){};
00062     protected:
00063       std::string moduleName_;
00064     private:
00065       virtual void openBackDoor(unsigned int timeout_sec = 0, bool * started = 0){};
00066       virtual void closeBackDoor(){};
00067       virtual void publishForkInfo(moduleweb::ForkInfoObj *forkInfoObj);
00068       friend class ModuleWebRegistry;
00069     };
00070 }
00071 #endif