source: Evidence/Evidence.h@ 188

Last change on this file since 188 was 187, checked in by ogrimm, 15 years ago
Updates to signal handling
  • 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: 187 $"
18
19// Class declation of Evidence server
20class EvidenceServer: public DimServer {
21 private:
22 // This class will contain in LastModifyTime always
23 // the unix time of the last config file update
24 class ConfigUpdate: public DimClient {
25 DimInfo *ModifyInfo;
26
27 public:
28 ConfigUpdate() {
29 LastModifyTime = 0;
30 ModifyInfo = new DimInfo("Config/ModifyTime", NO_LINK, this);
31 }
32 ~ConfigUpdate() {
33 delete ModifyInfo;
34 }
35 void infoHandler(){
36 if (EvidenceServer::ServiceOK(getInfo())) LastModifyTime = getInfo()->getInt();
37 }
38 int LastModifyTime;
39 };
40
41 struct ConfigItem {
42 std::string Name;
43 char *Value;
44 int Time;
45 };
46 std::vector<struct ConfigItem> ConfigList;
47
48 std::string ServerName;
49 DimService *Status;
50 class ConfigUpdate *ModifyInfo;
51
52 char InitMsg[STATUS_SIZE];
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(std::string, 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.