00001 /*----------------------------------------------------------------------------* 00002 * Copyright (c) 2005 Southeastern Universities Research Association, * 00003 * Thomas Jefferson National Accelerator Facility * 00004 * * 00005 * This software was developed under a United States Government license * 00006 * described in the NOTICE file included as part of this distribution. * 00007 * * 00008 * E.Wolin, 25-Feb-2005, Jefferson Lab * 00009 * * 00010 * Authors: Elliott Wolin * 00011 * wolin@jlab.org Jefferson Lab, MS-6B * 00012 * Phone: (757) 269-7365 12000 Jefferson Ave. * 00013 * Fax: (757) 269-5519 Newport News, VA 23606 * 00014 * 00015 *----------------------------------------------------------------------------*/ 00016 00017 #ifndef _SessionObject_hxx 00018 #define _SessionObject_hxx 00019 00020 00021 #include <CodaObject.hxx> 00022 00023 00024 #define MIN_REPORTING_INTERVAL 0.5 00025 #define MAX_REPORTING_INTERVAL 10.0 00026 00027 00028 00029 namespace codaObject { 00030 00031 using namespace std; 00032 using namespace cmsg; 00033 00034 00035 //----------------------------------------------------------------------------- 00036 //----------------------------------------------------------------------------- 00037 00038 00045 class SessionObject : public CodaObject { 00046 00047 public: 00048 SessionObject(const string& UDL, const string& name, const string& descr, const string &codaClass = "USER", 00049 const cMsgSubscriptionConfig *scfg = NULL) throw(CodaException); 00050 virtual ~SessionObject(void) throw(); 00051 00052 00053 protected: 00054 virtual void handleSetSession(const string &newSession) throw(CodaException); 00055 virtual void handleSetSession(const cMsgMessage *msg) throw(CodaException); 00056 virtual void handleSessionConfigure(const cMsgMessage *msg) throw(CodaException); 00057 virtual void handleExit(const cMsgMessage *msg) throw(CodaException); 00058 virtual void handleSessionReset(const cMsgMessage *msg) throw(CodaException); 00059 virtual void handleStartReporting(const cMsgMessage *msg) throw(CodaException); 00060 virtual void handleStopReporting(const cMsgMessage *msg) throw(); 00061 virtual void fillReport(cMsgMessage *msg) throw(); 00062 00063 00064 public: 00065 string getSession(void) const throw() ; 00066 string getConfig(void) const throw() ; 00067 00068 00069 private: 00070 void sessionControlCallback(cMsgMessage *msg, void* userArg) throw(CodaException); 00071 void *reportingThread(void *arg); 00072 00073 00074 protected: 00075 virtual bool setSession(const string& newSession) throw(CodaException); 00076 00077 virtual bool sessionConfigure(const string& fileName,const string& fileContent) throw(CodaException); 00078 virtual void exit(const string& s) throw(CodaException); 00079 virtual void sessionReset(const string& s) throw(CodaException); 00080 00081 00082 private: 00083 string sessionFileContent; 00084 cMsgCallback *sessionControlCBD; 00085 cMsgCallback *sessionOptionCBD; 00086 void *scSubId; 00087 double reportingInterval; 00088 pthread_t reportingThreadId; 00089 pthreadDispatcher<SessionObject,void*,void*> *reportingThreadDispatcher; 00091 protected: 00092 string session; 00093 virtual void daLogMsgFill(cMsgMessage &msg) const throw(CodaException); 00094 }; 00095 00096 00097 //----------------------------------------------------------------------------- 00098 //----------------------------------------------------------------------------- 00099 00100 00101 } // namespace codaObject 00102 00103 00104 #endif /* _SessionObject_hxx */