source: Evidence/Evidence.h@ 3174

Last change on this file since 3174 was 263, checked in by ogrimm, 14 years ago
Bug fix in RequestNB(), return value was not void
  • Property svn:keywords set to Revision
File size: 2.6 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 <sstream>
8#include <iomanip>
9#include <errno.h>
10#include <vector>
11#include <map>
12#include <set>
13
14#include <exception>
15#include <cxxabi.h>
16
17#include "dis.hxx"
18#include "dic.hxx"
19
20#define NO_LINK (char *) "__&DIM&NOLINK&__" // Data if no link available
21#define EVIDENCE_REVISION "$Revision: 263 $"
22
23void ConfigChanged();
24
25// Class declation of Evidence server
26class EvidenceServer: public DimServer {
27
28 // Internal class for configuration requests
29 class Config: public DimInfo, public DimCommand, public DimRpcInfo {
30
31 DimInfo *Service;
32 std::string CurrentItem;
33
34 void rpcInfoHandler();
35 void commandHandler();
36 void infoHandler();
37
38 public:
39 Config();
40 ~Config();
41
42 int ConfigTimeStamp;
43 void RequestNB(std::string);
44 };
45
46 struct Item {
47 std::string Value;
48 int Time;
49 };
50 std::map<std::string, struct Item> List;
51
52 struct Message {
53 int Severity;
54 char Text[];
55 };
56
57 std::string Name;
58 DimService *MessageService;
59 struct Message *MessageData;
60 class Config *ConfClass;
61 static pthread_mutex_t Mutex;
62 static std::set<pthread_t> Threads;
63 static EvidenceServer *This;
64
65 static void SignalHandler(int); // static for signal()
66 static void Terminate(); // static for set_terminate()
67 virtual void errorHandler(int, int, char *);
68 virtual void exitHandler(int);
69 static void CallConfigChanged(); // static for phread_create()
70
71 public:
72 EvidenceServer(std::string);
73 ~EvidenceServer();
74
75 enum MessageType {INFO=0, WARN=1, ERROR=2, FATAL=3};
76
77 void Message(MessageType, const char *, ...);
78 static void SendToLog(const char *, ...);
79 std::string GetConfig(std::string, std::string = std::string());
80 virtual void ConfigChanged() {};
81 static void Lock();
82 static void Unlock();
83 static std::string ToString(char *, void *, int);
84 static bool ServiceOK(DimInfo *);
85 static bool ServiceOK(DimRpcInfo *);
86 static bool ServiceOK(DimCurrentInfo *);
87 static std::vector<std::string> Tokenize(const std::string &, const std::string & = " ");
88
89 bool ExitRequest;
90};
91
92// Class declaration of EvidenceHistory
93class EvidenceHistory {
94
95 public:
96 struct Item {
97 int Time;
98 int Size;
99 char Data[]; // Size bytes follow
100 } __attribute__((packed));
101
102 static const struct Item WrapMark;
103 static const struct Item EndMark;
104
105 private:
106 std::string Name;
107 char *Buffer;
108 int BufferSize;
109 char *DataStart;
110 struct Item *Pointer;
111
112 public:
113 EvidenceHistory(std::string);
114 ~EvidenceHistory();
115
116 bool GetHistory();
117 char *GetFormat();
118 const struct Item *Next();
119 void Rewind();
120};
121#endif
Note: See TracBrowser for help on using the repository browser.