00001 //<<<<<< INCLUDES >>>>>> 00002 00003 #include "Iguana/WebFramework/interface/IgSessionManager.h" 00004 #include "Iguana/Framework/interface/IgState.h" 00005 00006 //<<<<<< PRIVATE DEFINES >>>>>> 00007 //<<<<<< PRIVATE CONSTANTS >>>>>> 00008 //<<<<<< PRIVATE TYPES >>>>>> 00009 //<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>> 00010 //<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>> 00011 //<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>> 00012 00013 IG_DEFINE_STATE_ELEMENT (IgSessionManager, "Session Manager"); 00014 00015 //<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>> 00016 //<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>> 00017 //<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>> 00018 00019 IgSessionManager::IgSessionManager (IgState *state) 00020 : m_state (state) 00021 { 00022 m_state->put (s_key, this); 00023 } 00024 00025 IgSessionManager::~IgSessionManager (void) 00026 { 00027 m_state->detach (s_key); 00028 } 00029 00030 void 00031 IgSessionManager::setSession (const std::string &idCookie, 00032 IgState *state) 00033 { 00034 if (m_stateMap.find (idCookie) == m_stateMap.end ()) 00035 { 00036 m_stateMap.insert (StateMapElement (idCookie, state)); 00037 } 00038 else 00039 { 00040 m_stateMap [idCookie] = state; 00041 } 00042 } 00043 00044 IgState * 00045 IgSessionManager::getSession (const std::string &idCookie) 00046 { 00047 if (m_stateMap.find (idCookie) != m_stateMap.end ()) 00048 { 00049 return m_stateMap[idCookie]; 00050 } 00051 return 0; 00052 } 00053 00054 IgState * 00055 IgSessionManager::createSession (const std::string &idCookie, 00056 IgState *parent) 00057 { 00058 IgState *state = new IgState (parent); 00059 m_stateMap.insert (StateMapElement (idCookie, state)); 00060 return state; 00061 } 00062