source: Evidence/Evidence.h@ 175

Last change on this file since 175 was 174, checked in by ogrimm, 16 years ago
Update to configuration handling: Dim request only made if configuration file was modified since last 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: 174 $"
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 char *Name;
44 char *Value;
45 int Time;
46 };
47 std::vector<struct ConfigItem> ConfigList;
48
49 DimService *Status;
50 class ConfigUpdate *ModifyInfo;
51
52 char *InitMsg;
53 int LastModifyTime;
54
55 static void SignalHandler(int); // static for signal()
56 static void Terminate(); // static for set_terminate()
57 void errorHandler(int, int, char *);
58 void exitHandler(int);
59
60 public:
61 EvidenceServer(const char *);
62 ~EvidenceServer();
63
64 enum StateType {INFO=0, WARN=1, ERROR=2, FATAL=3};
65
66 void State(StateType, const char *, ...);
67 char* GetConfig(const char *, const char * = NULL);
68 static char* ToString(DimInfo *);
69 static bool ServiceOK(DimInfo *);
70
71 bool ExitRequest;
72};
73
74class EvidenceHistory: public DimClient {
75
76 static const int WrapMark[];
77 static const int EndMark[];
78
79 std::string Name;
80 char *Buffer;
81 int BufferSize;
82 int Offset;
83 int Delay;
84 int LastUpdate;
85
86 public:
87 EvidenceHistory(std::string, int = 10);
88 ~EvidenceHistory();
89
90 bool GetHistory();
91 bool Next(int &, int &, void *&);
92};
93#endif
Note: See TracBrowser for help on using the repository browser.