CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/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       }
00036       ~ForkInfoObj()
00037       {
00038         sem_destroy(control_sem_);
00039         delete control_sem_;
00040       }
00041       void lock() {if (mst_lock_) pthread_mutex_lock(mst_lock_);}
00042       void unlock() {if (mst_lock_) pthread_mutex_unlock(mst_lock_);}
00043       void (*forkHandler) (void *);
00044       ForkParams forkParams;
00045       unsigned int stopCondition;
00046       sem_t *control_sem_;
00047       pthread_mutex_t * mst_lock_;
00048       void * fuAddr;
00049   };
00050 }
00051 
00052   class ModuleWeb : public toolbox::lang::Class
00053     {
00054     public:
00055       ModuleWeb(const std::string &);
00056       virtual ~ModuleWeb(){}
00057       virtual void defaultWebPage(xgi::Input *in, xgi::Output *out); 
00058       virtual void publish(xdata::InfoSpace *) = 0;
00059       virtual void publishToXmas(xdata::InfoSpace *){};
00060     protected:
00061       std::string moduleName_;
00062     private:
00063       virtual void openBackDoor(unsigned int timeout_sec = 0, bool * started = 0){};
00064       virtual void closeBackDoor(){};
00065       virtual void publishForkInfo(moduleweb::ForkInfoObj *forkInfoObj);
00066       friend class ModuleWebRegistry;
00067     };
00068 }
00069 #endif