FACT++  1.0
DimDescriptionService::DimDescriptionService ( const std::string &  name,
const std::string &  desc 
)

Local storage for the applied description.

When the constructor is first called, a service with the name SERVER/SERVICE_DESC is created. The server name SERVER is retrieved from DimServer::itsName. If DimServer::itsName is empty, the server name is extracted from the given name as the part before the first '/'. A string "name=format\n" is added to fData and stored in fDescription.

A counter fCount for the number of instantiations is increased.

Parameters
nameThe name of the service or command to be described, e.g. SERVER/COMMAND
descA description string. For details see class reference
Exceptions
Ifa server name couldn't be reliably determined a logic_error exception is thrown; if the given description contains a '
' also a logic_error is thrown.

Definition at line 71 of file DimDescriptionService.cc.

References fData, DimServer::itsName, Time::ms(), t, and Time::Time_t().

72 {
73  string server = DimServer::itsName ? DimServer::itsName : "";
74  if (server.empty())
75  {
76  const size_t p = name.find_first_of('/');
77  if (p==string::npos)
78  throw logic_error("Could not determine server name");
79 
80  server = name.substr(0, p);
81  }
82 
83  if (desc.find_first_of('\n')!=string::npos)
84  throw logic_error("Description for "+name+" contains '\\n'");
85 
86  if (!fService)
87  {
88  fService = new DimService((server+"/SERVICE_DESC").c_str(), const_cast<char*>(""));
89  fData =
90  server + "/SERVICE_DESC"
91  "=Descriptions of services or commands and there arguments"
92  "|Description[string]:For a detailed "
93  "explanation of the descriptive string see the class reference "
94  "of DimDescriptionService.\n" +
95  server + "/CLIENT_LIST"
96  "=Native Dim service: A list of all connected clients\n" +
97  server + "/VERSION_NUMBER"
98  "=Native Dim service: Version number of Dim in use"
99  "|DimVer[int]:Version*100+Release (e.g. V19r17 = 1917)\n" +
100  server + "/EXIT"
101  "=This is a native Dim command: Exit program"
102  "remotely. FACT++ programs use the given number as return code."
103  "|Rc[int]:Return code, under normal circumstances this should be 0 or 1 (42 will call exit() directly, 0x42 will call abort() directly.\n" +
104  server + "/SERVICE_LIST"
105  "=Native Dim service: List of services, commands and formats"
106  "|ServiceList[string]:For details see the Dim manual.\n";
107  }
108 
109 
110  fCount++;
111 
112  fDescription = name + '=' + desc;
113 
114  if (fData.find(fDescription+'\n')!=std::string::npos)
115  return;
116 
117  fData += fDescription + '\n';
118 
119  const Time t;
120  fService->setTimestamp(t.Time_t(), t.ms());
121  fService->setData(const_cast<char*>(fData.c_str()));
123 }
unsigned int ms() const
Definition: Time.h:102
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
static DimService * fService
Counter to count the number of instatiations.
void setTimestamp(int secs, int millisecs)
Definition: discpp.cxx:1263
time_t Time_t() const
Definition: Time.cc:213
int updateService()
Definition: discpp.cxx:1016
std::string fDescription
Data to be distributed with the service.
void setData(void *data, int size)
Definition: discpp.cxx:1270
TT t
Definition: test_client.c:26
static char * itsName
Definition: dis.hxx:92
static std::string fData
Pointer to the DimService distributing the desscriptions.

+ Here is the call graph for this function: