source: Evidence/Evidence.h@ 257

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