$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 // StdAir 00008 #include <stdair/STDAIR_Service.hpp> 00009 #include <stdair/basic/BasConst_General.hpp> 00010 #include <stdair/factory/FacBom.hpp> 00011 // SEvMgr 00012 #include <sevmgr/basic/BasConst_EventQueueManager.hpp> 00013 #include <sevmgr/bom/EventQueue.hpp> 00014 #include <sevmgr/service/SEVMGR_ServiceContext.hpp> 00015 00016 namespace SEVMGR { 00017 00018 // ////////////////////////////////////////////////////////////////////// 00019 SEVMGR_ServiceContext::SEVMGR_ServiceContext() 00020 : _eventQueue (NULL) { 00021 init(); 00022 } 00023 00024 // ////////////////////////////////////////////////////////////////////// 00025 SEVMGR_ServiceContext:: 00026 SEVMGR_ServiceContext (const SEVMGR_ServiceContext& iServiceContext) 00027 : _eventQueue (iServiceContext._eventQueue) { 00028 } 00029 00030 // ////////////////////////////////////////////////////////////////////// 00031 SEVMGR_ServiceContext::~SEVMGR_ServiceContext() { 00032 } 00033 00034 // ////////////////////////////////////////////////////////////////////// 00035 void SEVMGR_ServiceContext::init() { 00036 // 00037 initEventQueue(); 00038 } 00039 00040 // ////////////////////////////////////////////////////////////////////// 00041 void SEVMGR_ServiceContext::initEventQueue() { 00042 00043 // The event queue key is just a string. For now, it is not used. 00044 const EventQueueKey lKey ("EQ01"); 00045 00046 // Create an EventQueue object instance 00047 EventQueue& lEventQueue = stdair::FacBom<EventQueue>::instance().create (lKey); 00048 00049 // Store the event queue object 00050 _eventQueue = &lEventQueue; 00051 } 00052 00053 // ////////////////////////////////////////////////////////////////////// 00054 const std::string SEVMGR_ServiceContext::shortDisplay() const { 00055 std::ostringstream oStr; 00056 oStr << "SEVMGR_ServiceContext -- Owns StdAir service: " 00057 << _ownStdairService; 00058 if (_eventQueue != NULL) { 00059 oStr << " -- Queue: " << _eventQueue->toString(); 00060 } 00061 return oStr.str(); 00062 } 00063 00064 // ////////////////////////////////////////////////////////////////////// 00065 const std::string SEVMGR_ServiceContext::display() const { 00066 std::ostringstream oStr; 00067 oStr << shortDisplay(); 00068 return oStr.str(); 00069 } 00070 00071 // ////////////////////////////////////////////////////////////////////// 00072 const std::string SEVMGR_ServiceContext::describe() const { 00073 return shortDisplay(); 00074 } 00075 00076 // ////////////////////////////////////////////////////////////////////// 00077 void SEVMGR_ServiceContext::reset() { 00078 00079 // The shared_ptr<>::reset() method drops the refcount by one. 00080 // If the count result is dropping to zero, the resource pointed to 00081 // by the shared_ptr<> will be freed. 00082 00083 // Reset the stdair shared pointer 00084 _stdairService.reset(); 00085 } 00086 00087 // ////////////////////////////////////////////////////////////////////// 00088 EventQueue& SEVMGR_ServiceContext::getEventQueue() const { 00089 assert (_eventQueue != NULL); 00090 return *_eventQueue; 00091 } 00092 00093 }