source: fact/Evidence/Evidence.h@ 10776

Last change on this file since 10776 was 10143, checked in by ogrimm, 14 years ago
Non-blocking configuration request did not recognize default value
  • 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
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: 10143 $"
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
33 void rpcInfoHandler();
34 void commandHandler();
35 void infoHandler();
36
37 public:
38 Config();
39 ~Config();
40
41 int ConfigTimeStamp;
42 std::string CurrentItem;
43 };
44
45 struct Item {
46 std::string Value;
47 int Time;
48 };
49 std::map<std::string, struct Item> List;
50
51 struct Message {
52 int Severity;
53 char Text[];
54 };
55
56 std::string Name;
57 DimService *MessageService;
58 struct Message *MessageData;
59 class Config *ConfClass;
60 static pthread_mutex_t Mutex;
61 static std::set<pthread_t> Threads;
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 *, 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.