source: Evidence/Evidence.h@ 178

Last change on this file since 178 was 178, checked in by ogrimm, 15 years ago
Server name added automatically to configuration request
  • Property svn:keywords set to Revision
File size: 2.0 KB
Line 
1#ifndef EVIDENCE_H_SEEN
2#define EVIDENCE_H_SEEN
3
4#include <stdio.h>
5#include <stdarg.h>
6#include <string>
7#include <errno.h>
8#include <vector>
9#include <exception>
10#include <cxxabi.h>
11
12#include "dis.hxx"
13#include "dic.hxx"
14
15#define NO_LINK (char *) "__&DIM&NOLINK&__" // Data if no link available
16#define STATUS_SIZE 1000 // Bytes for status service string
17#define EVIDENCE_REVISION "$Revision: 178 $"
18
19// Class declation of Evidence server
20class EvidenceServer: public DimServer {
21 private:
22
23 // This class will contain in LastModifyTime always
24 // the unix time of the last config file update
25 class ConfigUpdate: public DimClient {
26 DimInfo *ModifyInfo;
27
28 public:
29 ConfigUpdate() {
30 LastModifyTime = 0;
31 ModifyInfo = new DimInfo("Config/ModifyTime", NO_LINK, this);
32 }
33 ~ConfigUpdate() {
34 delete ModifyInfo;
35 }
36 void infoHandler(){
37 if (EvidenceServer::ServiceOK(getInfo())) LastModifyTime = getInfo()->getInt();
38 }
39 int LastModifyTime;
40 };
41
42 struct ConfigItem {
43 std::string Name;
44 char *Value;
45 int Time;
46 };
47 std::vector<struct ConfigItem> ConfigList;
48
49 std::string ServerName;
50 DimService *Status;
51 class ConfigUpdate *ModifyInfo;
52
53 char *InitMsg;
54 int LastModifyTime;
55
56 static void SignalHandler(int); // static for signal()
57 static void Terminate(); // static for set_terminate()
58 void errorHandler(int, int, char *);
59 void exitHandler(int);
60
61 public:
62 EvidenceServer(const char *);
63 ~EvidenceServer();
64
65 enum StateType {INFO=0, WARN=1, ERROR=2, FATAL=3};
66
67 void State(StateType, const char *, ...);
68 char* GetConfig(std::string, const char * = NULL);
69 static char* ToString(DimInfo *);
70 static bool ServiceOK(DimInfo *);
71
72 bool ExitRequest;
73};
74
75class EvidenceHistory: public DimClient {
76
77 static const int WrapMark[];
78 static const int EndMark[];
79
80 std::string Name;
81 char *Buffer;
82 int BufferSize;
83 int Offset;
84 int Delay;
85 int LastUpdate;
86
87 public:
88 EvidenceHistory(std::string, int = 10);
89 ~EvidenceHistory();
90
91 bool GetHistory();
92 bool Next(int &, int &, void *&);
93};
94#endif
Note: See TracBrowser for help on using the repository browser.