Changeset 10348
- Timestamp:
- 04/10/11 10:27:43 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/logtime.cc
r10347 r10348 6 6 #include <iostream> 7 7 8 class DimDescriptionService9 {10 static int fCount;11 static DimService *fService;12 static std::string fFormat;13 14 std::string fFmt;15 16 public:17 DimDescriptionService(const std::string &name, const std::string &format)18 {19 // FIXME: throw is DimServer::itsName==020 21 std::string n = std::string(DimServer::itsName)+"/SERVICE_DESC";22 23 if (!fService)24 fService = new DimService(n.c_str(), const_cast<char*>(""));25 26 fCount++;27 28 fFmt = name + '=' + format + '\n';29 30 if (fFormat.find(fFmt)!=std::string::npos)31 return;32 33 fFormat += fFmt;34 35 fService->setData(const_cast<char*>(fFormat.c_str()));36 fService->updateService();37 38 }39 ~DimDescriptionService()40 {41 const size_t pos = fFormat.find(fFmt);42 if (pos!=std::string::npos)43 fFormat.replace(pos, fFmt.size(), "");44 45 if (--fCount>0)46 return;47 48 delete fService;49 fService=0;50 }51 };52 53 class DimDescribedService : public DimDescriptionService, public DimService54 {55 public:56 template<typename T>57 DimDescribedService(const char *name, T &val, const char *desc)58 : DimDescriptionService(name, desc), DimService(name, val)59 {60 }61 62 DimDescribedService(const char *name, const char *val, const char *desc)63 : DimDescriptionService(name, desc), DimService(name, const_cast<char*>(val)) { }64 65 DimDescribedService(const char *name, char *format, void *structure, int size, const char *desc)66 : DimDescriptionService(name, desc), DimService(name, format, structure, size)67 {68 // FIXME: compare number of ; with number of |69 }70 };71 72 DimService *DimDescriptionService::fService = 0;73 int DimDescriptionService::fCount = 0;74 std::string DimDescriptionService::fFormat;75 76 77 8 int main(int, const char **) 78 9 { 79 10 // We could use putenv to make the Configure class change the value... 80 11 setenv("DIM_DNS_NODE", "localhost", 0); 81 12 … … 86 17 std::cout << "Offering TIME/MESSAGE...\n" << std::endl; 87 18 88 short s;89 int i;90 long long ll;91 float f;92 DimDescribedService servt("TIME/TEST", "C:1;I:1;C", NULL, 0,93 "Char[c]:This is a char| Int This is an int|String[s]:This is a string");94 95 DimDescribedService servs("TIME/SHORT", s, "[a]");96 DimDescribedService servx("TIME/LONGLONG", ll, ": This is my long long");97 DimDescribedService servi("TIME/INT", i, "MyInt{mi}");98 DimDescribedService servf("TIME/FLOAT", f, " MyFloat : This is my float");99 DimDescribedService servc("TIME/TIME", const_cast<char*>(""), "MyTime[T]:This is my time");100 101 DimCommand cmd("TIME/CMD", "I:2;F:2");102 103 DimDescriptionService des("TIME/CMD", "range[addr]:From DAC to DAC|values[DAC]:DAC values to be set");104 105 19 // Setup a DimService called TIME/MESSAGE 106 20 MessageDimTX msg("TIME"); … … 109 23 // Send current time 110 24 msg.Message(Time().GetAsStr()); 111 // servx.Update(); 112 /* 113 servs.updateService(); 114 servi.updateService(); 115 servf.updateService(); 116 servc.updateService(); 117 */ 25 118 26 // wait approximately one second 119 usleep(100000 );27 usleep(1000000); 120 28 } 121 29
Note:
See TracChangeset
for help on using the changeset viewer.