Cat
Public Member Functions | Private Attributes | List of all members
Server Class Reference

#include <inc/Server.h>

Public Member Functions

 Server (Application *)
 Standard constructor. More...
 
virtual ~Server ()
 Destructor. More...
 
StatusCode start ()
 Start Service. More...
 
StatusCode updateState ()
 Update State Service. More...
 
StatusCode updateConfig ()
 Update Config Service. More...
 
StatusCode cmdline (std::vector< std::string >)
 
void setUpdateDelay (int updateDelay)
 
int updateDelay ()
 

Private Attributes

Applicationm_app
 
int m_updateDelay
 

Detailed Description

Author
Frederic Machefert
Date
2005-03-03

Definition at line 22 of file Server.h.

Constructor & Destructor Documentation

◆ Server()

Server::Server ( Application application)

Standard constructor.

Definition at line 26 of file Server.cpp.

References application(), Object::info(), m_app, m_updateDelay, and Object::warning().

26  {
28 #ifdef _NETWORK_
29  m_updateDelay = 1;
30  m_app->info("Server built.","Server::Server");
31  m_servCmd = new CmndServ ( m_app );
32  m_servCtrl = new CtrlServ ( m_app );
33  m_servTimer = 0;
34  m_servState = 0;
35  m_servConfig = 0;
36 #else
37  m_app->warning("Compilation without NETWORK capabilities","Server::Server");
38 #endif
39 }
void info(std::string mymsg)
Definition: Object.h:38
Application * m_app
Definition: Server.h:79
Application * application()
Definition: Tools.cpp:42
int m_updateDelay
Definition: Server.h:80
void warning(std::string mymsg)
Definition: Object.h:39

◆ ~Server()

Server::~Server ( )
virtual

Destructor.

Definition at line 44 of file Server.cpp.

44  {
45 #ifdef _NETWORK_
46  delete m_servCmd;
47  delete m_servCtrl;
48  if ( 0 != m_servState ) {
49  delete m_servState;
50  }
51  if ( 0 != m_servTimer ) {
52  delete m_servTimer;
53  }
54  if ( 0 != m_servConfig ) {
55  delete m_servConfig;
56  }
57  m_servCmd = 0;
58  m_servCtrl = 0;
59  m_servTimer = 0;
60  m_servState = 0;
61  m_servConfig = 0;
62 #endif
63 }

Member Function Documentation

◆ cmdline()

StatusCode Server::cmdline ( std::vector< std::string >  cmd)

Definition at line 128 of file Server.cpp.

References StatusCode::FAILURE, Object::info(), m_app, setUpdateDelay(), StatusCode::SUCCESS, updateConfig(), updateDelay(), and updateState().

128  {
129  if ( cmd.size()==0){
130  char line[200];
131  std::string tmp;
132  sprintf(line,"Timer [timer] : %i", updateDelay() );
133  m_app->info(line,"Server::cmdline");
134  return StatusCode::SUCCESS;
135  }
136 
137  transform(cmd[0].begin(),cmd[0].end(),cmd[0].begin(),tolower);
138 
139  if (cmd[0].compare("timer")==0){
140  if ( cmd.size() == 2 ) {
141  setUpdateDelay ( atoi(cmd[1].c_str()) );
142  this -> updateConfig();
143  this -> updateState();
144  }
145  this -> updateConfig();
146  this -> updateState();
147  return StatusCode::SUCCESS;
148  }
149  return StatusCode::FAILURE;
150 }
void info(std::string mymsg)
Definition: Object.h:38
Application * m_app
Definition: Server.h:79
StatusCode updateConfig()
Update Config Service.
Definition: Server.cpp:83
int updateDelay()
Definition: Server.h:54
StatusCode updateState()
Update State Service.
Definition: Server.cpp:68
void setUpdateDelay(int updateDelay)
Definition: Server.h:41

◆ setUpdateDelay()

void Server::setUpdateDelay ( int  updateDelay)
inline

Set accessor to member m_updateDelay

Parameters
updateDelaythe new value for m_updateDelay

Definition at line 41 of file Server.h.

References m_updateDelay, and updateDelay().

Referenced by cmdline().

41  {
43 #ifdef _NETWORK_
44  if ( 0 != m_servTimer ){
45  m_servTimer->setDelay ( m_updateDelay );
46  }
47 #endif
48  }
int updateDelay()
Definition: Server.h:54
int m_updateDelay
Definition: Server.h:80

◆ start()

StatusCode Server::start ( )

Start Service.

Definition at line 98 of file Server.cpp.

References application(), Application::config(), StatusCode::FAILURE, Object::info(), m_app, Object::name(), Application::procDb(), Application::state(), StatusCode::SUCCESS, updateDelay(), and Object::warning().

Referenced by Application::network(), and Application::server().

98  {
99 #ifdef _NETWORK_
100  m_app->info("Starting CAT server " + application()->name(),"Server::start");
101  DimServer::start(m_app->name().c_str());
102  std::string str = m_app->name() ;
103  str = m_app->name() ;
104  str.append ("/state");
105  m_servState = new DimService ( str.c_str(),"I:4;C",
106  m_app->state(),
107  sizeof(*(m_app->state())) );
108  m_servTimer = new Timer ( updateDelay() , m_servState );
109  str = application()->name() ;
110  str.append ("/config");
111  m_servConfig = new DimService ( str.c_str(),"C",
112  m_app->config(),
113  sizeof(*(m_app->config())) );
114 
115  m_app->procDb()->startServices();
116 #else
117  m_app->warning("compilation without NETWORK capabilities. Cannot start server.",
118  "Server::star");
119  return StatusCode::FAILURE;
120 #endif
121  return StatusCode::SUCCESS;
122 }
void info(std::string mymsg)
Definition: Object.h:38
Application * m_app
Definition: Server.h:79
Config * config()
Application * application()
Definition: Tools.cpp:42
int updateDelay()
Definition: Server.h:54
ProcDataBase * procDb()
Definition: Application.h:111
State * state()
std::string name() const
Definition: Object.h:28
void warning(std::string mymsg)
Definition: Object.h:39

◆ updateConfig()

StatusCode Server::updateConfig ( )

Update Config Service.

Definition at line 83 of file Server.cpp.

References Object::debug(), StatusCode::FAILURE, m_app, StatusCode::SUCCESS, and Object::warning().

Referenced by cmdline(), and Application::setConfig().

83  {
84 #ifdef _NETWORK_
85  m_servConfig->updateService();
86  m_app->debug("Updating proc database service.","Server::updateConfig");
87 #else
88  m_app->warning("Updating server services not available (NETWORK mode off).",
89  "Server::updateConfig");
90  return StatusCode::FAILURE;
91 #endif
92  return StatusCode::SUCCESS;
93 }
Application * m_app
Definition: Server.h:79
void debug(std::string mymsg)
Definition: Object.h:37
void warning(std::string mymsg)
Definition: Object.h:39

◆ updateDelay()

int Server::updateDelay ( )
inline

Get accessor to member m_updateDelay

Returns
the current value of m_updateDelay

Definition at line 54 of file Server.h.

References m_updateDelay.

Referenced by cmdline(), setUpdateDelay(), and start().

54  {
55  return m_updateDelay;
56  }
int m_updateDelay
Definition: Server.h:80

◆ updateState()

StatusCode Server::updateState ( )

Update State Service.

Definition at line 68 of file Server.cpp.

References Object::debug(), StatusCode::FAILURE, m_app, StatusCode::SUCCESS, and Object::warning().

Referenced by cmdline(), and Application::setState().

68  {
69 #ifdef _NETWORK_
70  m_servState->updateService();
71  m_app->debug("Updating state service.","Server::updateState");
72 #else
73  m_app->warning("Updating server services not available (NETWORK mode off).",
74  "Server::updateState");
75  return StatusCode::FAILURE;
76 #endif
77  return StatusCode::SUCCESS;
78 }
Application * m_app
Definition: Server.h:79
void debug(std::string mymsg)
Definition: Object.h:37
void warning(std::string mymsg)
Definition: Object.h:39

Member Data Documentation

◆ m_app

Application* Server::m_app
private

Definition at line 79 of file Server.h.

Referenced by cmdline(), Server(), start(), updateConfig(), and updateState().

◆ m_updateDelay

int Server::m_updateDelay
private

Definition at line 80 of file Server.h.

Referenced by Server(), setUpdateDelay(), and updateDelay().


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