source: fact/Evidence/Evidence.h@ 13036

Last change on this file since 13036 was 12910, checked in by ogrimm, 13 years ago
EvidenceServer::ToString() can handle all DIM formats as long as padding is disabled
  • Property svn:keywords set to Revision
File size: 2.5 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#include <limits>
14
15#include <exception>
16#include <cxxabi.h>
17
18#include "dis.hxx"
19#include "dic.hxx"
20
21#define NO_LINK (char *) "__&DIM&NOLINK&__" // Data if no link available
22#define EVIDENCE_REVISION "$Revision: 12910 $"
23
24void ConfigChanged();
25
26// Class declation of Evidence server
27class EvidenceServer: public DimServer {
28
29 // Internal class for configuration requests
30 class Config: public DimInfo, public DimCommand, public DimRpcInfo {
31
32 DimInfo *Service;
33
34 void rpcInfoHandler();
35 void commandHandler();
36 void infoHandler();
37
38 public:
39 Config();
40 ~Config();
41
42 int ConfigTimeStamp;
43 std::string CurrentItem;
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 EvidenceServer *This;
63
64 static void SignalHandler(int); // static for signal()
65 static void Terminate(); // static for set_terminate()
66 virtual void errorHandler(int, int, char *);
67 virtual void exitHandler(int);
68 static void CallConfigChanged(); // static for phread_create()
69
70 public:
71 EvidenceServer(std::string);
72 ~EvidenceServer();
73
74 enum {INFO=0, WARN=10, ERROR=20, FATAL=30};
75
76 void Message(int, const char *, ...);
77 static void SendToLog(const char *, ...);
78 std::string GetConfig(std::string, std::string = std::string());
79 virtual void ConfigChanged() {};
80 static void Lock();
81 static void Unlock();
82 static std::string ToString(char *, const void *, int);
83 static bool ServiceOK(DimInfo *);
84 static bool ServiceOK(DimRpcInfo *);
85 static bool ServiceOK(DimCurrentInfo *);
86 static std::vector<std::string> Tokenize(const std::string &, const std::string & = " ");
87
88 bool ExitRequest;
89};
90
91// Class declaration of EvidenceHistory
92class EvidenceHistory {
93
94 public:
95 struct Item {
96 int Time;
97 int Size;
98 char Data[]; // Size bytes follow
99 } __attribute__((packed));
100
101 static const struct Item WrapMark;
102 static const struct Item EndMark;
103
104 private:
105 std::string Name;
106 char *Buffer;
107 int BufferSize;
108 char *DataStart;
109 struct Item *Pointer;
110
111 public:
112 EvidenceHistory(std::string);
113 ~EvidenceHistory();
114
115 bool GetHistory();
116 char *GetFormat();
117 const struct Item *Next();
118 void Rewind();
119};
120#endif
Note: See TracBrowser for help on using the repository browser.