appkit  1.5.1
RoadNarrows Robotics Application Kit
rnr::Session Class Reference

Session Class. More...

#include <Session.h>

Inheritance diagram for rnr::Session:
rnr::SessionWin

Public Member Functions

 Session (int nSessionId=0, const std::string &strSessionName="Session")
 Default initialization contructor. More...
 
 ~Session ()
 Destructor.
 
StateMachsm ()
 Session's state machine. More...
 
int getSessionId () const
 Get session id. More...
 
std::string getSessionName () const
 Get session name. More...
 
void setContext (void *pContext)
 Set state relevant context. More...
 
void * getContext ()
 Get state relevant context. More...
 
void setError (int ecode, const char *sFmt,...)
 Set session error. More...
 
void setFatal (int ecode, const char *sFmt,...)
 Set session fatal error. More...
 
int getErrorCode ()
 Get the last error code. More...
 
std::string getErrorMsg ()
 Get the last error message. More...
 
bool isFatal ()
 Test if session is in fatal condition. More...
 

Protected Attributes

int m_nSessionId
 session id
 
std::string m_strSessionName
 session name
 
StateMach m_sm
 session state machine
 
void * m_pContext
 state specific data
 
int m_ecode
 last error code
 
char m_bufErrorMsg [256]
 error message
 
bool m_bHasFatal
 does [not] have fatal condition
 

Detailed Description

Session Class.

Session state data persist throughout the lifetime of an application or user session. Applications may support multiple sessions simultaneously.

Definition at line 84 of file Session.h.

Constructor & Destructor Documentation

rnr::Session::Session ( int  nSessionId = 0,
const std::string &  strSessionName = "Session" 
)
inline

Default initialization contructor.

Parameters
nSessionIdSession id.
strSessionNameSession name.

Definition at line 93 of file Session.h.

93  :
94  m_nSessionId(nSessionId), m_strSessionName(strSessionName),
95  m_sm(nSessionId, strSessionName)
96  {
97  }
int m_nSessionId
session id
Definition: Session.h:205
std::string m_strSessionName
session name
Definition: Session.h:206
StateMach m_sm
session state machine
Definition: Session.h:207

Member Function Documentation

void* rnr::Session::getContext ( )
inline

Get state relevant context.

Returns
State specific context data.

Definition at line 151 of file Session.h.

References m_pContext, setError(), and setFatal().

152  {
153  return m_pContext;
154  }
void * m_pContext
state specific data
Definition: Session.h:208
int rnr::Session::getErrorCode ( )
inline

Get the last error code.

Returns
Application specific error code.

Definition at line 179 of file Session.h.

References m_ecode.

180  {
181  return m_ecode;
182  }
int m_ecode
last error code
Definition: Session.h:209
std::string rnr::Session::getErrorMsg ( )
inline

Get the last error message.

Returns
Error message.

Definition at line 189 of file Session.h.

References m_bufErrorMsg.

190  {
191  return m_bufErrorMsg;
192  }
char m_bufErrorMsg[256]
error message
Definition: Session.h:210
int rnr::Session::getSessionId ( ) const
inline

Get session id.

Returns
Session id.

Definition at line 121 of file Session.h.

References m_nSessionId.

122  {
123  return m_nSessionId;
124  }
int m_nSessionId
session id
Definition: Session.h:205
std::string rnr::Session::getSessionName ( ) const
inline

Get session name.

Returns
String.

Definition at line 131 of file Session.h.

References m_strSessionName.

132  {
133  return m_strSessionName;
134  }
std::string m_strSessionName
session name
Definition: Session.h:206
bool rnr::Session::isFatal ( )
inline

Test if session is in fatal condition.

Returns
Returns true or false.

Definition at line 199 of file Session.h.

References m_bHasFatal.

200  {
201  return m_bHasFatal;
202  }
bool m_bHasFatal
does [not] have fatal condition
Definition: Session.h:211
void rnr::Session::setContext ( void *  pContext)
inline

Set state relevant context.

Parameters
pContextState specific context data.

Definition at line 141 of file Session.h.

References m_pContext.

142  {
143  m_pContext = pContext;
144  }
void * m_pContext
state specific data
Definition: Session.h:208
void Session::setError ( int  ecode,
const char *  sFmt,
  ... 
)

Set session error.

Parameters
ecodeApplication specific error code.
sFmtFormat string.
...Formatted variable arguments.

Definition at line 72 of file Session.cxx.

Referenced by getContext().

73 {
74  va_list ap;
75 
76  m_ecode = ecode;
77 
78  // format error message
79  va_start(ap, sFmt);
80  vsnprintf(m_bufErrorMsg, sizeof(m_bufErrorMsg), sFmt, ap);
81  m_bufErrorMsg[sizeof(m_bufErrorMsg)-1] = 0;
82  va_end(ap);
83 }
int m_ecode
last error code
Definition: Session.h:209
char m_bufErrorMsg[256]
error message
Definition: Session.h:210
void Session::setFatal ( int  ecode,
const char *  sFmt,
  ... 
)

Set session fatal error.

Parameters
ecodeApplication specific error code.
sFmtFormat string.
...Formatted variable arguments.

Definition at line 85 of file Session.cxx.

Referenced by getContext().

86 {
87  va_list ap;
88 
89  m_ecode = ecode;
90  m_bHasFatal = true;
91 
92  // format error message
93  va_start(ap, sFmt);
94  vsnprintf(m_bufErrorMsg, sizeof(m_bufErrorMsg), sFmt, ap);
95  m_bufErrorMsg[sizeof(m_bufErrorMsg)-1] = 0;
96  va_end(ap);
97 }
int m_ecode
last error code
Definition: Session.h:209
bool m_bHasFatal
does [not] have fatal condition
Definition: Session.h:211
char m_bufErrorMsg[256]
error message
Definition: Session.h:210
StateMach& rnr::Session::sm ( )
inline

Session's state machine.

Returns
State machine reference.

Definition at line 111 of file Session.h.

References m_sm.

112  {
113  return m_sm;
114  }
StateMach m_sm
session state machine
Definition: Session.h:207

The documentation for this class was generated from the following files: