audit.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006-2008 The FLWOR Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ZORBA_AUDIT_H
18 #define ZORBA_AUDIT_H
19 
20 #include <iostream>
21 #include <vector>
22 #include <zorba/config.h>
23 #include <zorba/zorba_string.h>
24 
25 namespace zorba {
26 namespace audit {
27 
28  /**
29  * an identifier for a set of pieces of information that can be audited
30  * together.
31  * It is assumed that all instances of PropertyGroup are created statically
32  * and that they exist while a process exists.
33  */
34  class ZORBA_DLL_PUBLIC PropertyGroup {
35  public:
36  virtual size_t pathLength() const = 0;
37  virtual const char* getSegment(size_t) const = 0;
38  };
39 
40  /**
41  * an identifier for a specific piece of information that can be audited.
42  * It is assumed that all instances of Property are created statically
43  * and that they exist while a process exists.
44  */
45  class ZORBA_DLL_PUBLIC Property {
46  public:
47  enum Type {
48  INT,
49  STRING
50  };
51 
52  virtual ~Property();
53 
54  virtual const PropertyGroup& group() const = 0;
55  virtual const char* name() const = 0;
56  virtual long id() const = 0;
57  virtual Type type() const = 0;
58  };
59 
60  class ZORBA_DLL_PUBLIC Observation {
61  public:
62  virtual const Property& property() const = 0;
63  virtual const String& stringValue() const = 0;
64  virtual long long longValue() const = 0;
65 
66  virtual ~Observation();
67  };
68 
69  class ZORBA_DLL_PUBLIC Configuration {
70  public:
71  static void getPropertyNames(std::vector<String>&);
72  static size_t getPropertyCount();
73  static const Property& getProperty(size_t i);
74  static bool enableProperty(Configuration*, const std::vector<String>&, const String&);
75 
76  virtual size_t size() const = 0;
77  virtual void enableAudit(size_t i) = 0;
78  virtual void enableAudit(const String& aPropertyName) = 0;
79  virtual bool auditEnabled(size_t i) const = 0;
80  virtual bool auditEnabled(const String& aPropertyName) const = 0;
81 
82  virtual const Property* getDynamicProperty(const String&) const = 0;
83 
84  virtual std::ostream& write(std::ostream&) const = 0;
85 
86  virtual ~Configuration();
87  };
88 
89  class ZORBA_DLL_PUBLIC Record {
90  public:
91  virtual const PropertyGroup& group() const = 0;
92 
93  virtual size_t size() const = 0;
94  virtual const Observation& at(size_t i) const = 0;
95 
96  virtual void add(const Property& prop, long long val) = 0;
97  virtual void add(const Property& prop, const String& val) = 0;
98 
99  virtual ~Record();
100  };
101 
102  class ZORBA_DLL_PUBLIC Event {
103  public:
104  static Event* get();
105 
106  virtual bool audit(const Property&) const = 0;
107  virtual bool audit(const String&) const = 0;
108 
109  virtual const Property* getDynamicProperty(const String&) const = 0;
110 
111  virtual Record* createRecord() = 0;
112  virtual void submitRecord(Record*) = 0;
113 
114  virtual size_t size() const = 0;
115  virtual const Record* at(size_t) const = 0;
116 
117  virtual std::ostream& write(std::ostream&) const = 0;
118 
119  virtual ~Event();
120  };
121 
122  class ZORBA_DLL_PUBLIC Provider {
123  public:
124  virtual Configuration* createConfiguration(size_t = 0) = 0;
125  virtual void destroyConfiguration(Configuration*) = 0;
126 
127  virtual Event* createEvent(const Configuration*) = 0;
128  virtual void submitEvent(Event*) = 0;
129 
130  virtual ~Provider();
131  };
132 
133 } /* namespace audit */
134 } /* namespace zorba */
135 
136 inline std::ostream& operator<<(std::ostream& os, const zorba::audit::Configuration& c) {
137  return c.write(os);
138 }
139 
140 inline std::ostream& operator<<(std::ostream& os, const zorba::audit::Event& e) {
141  return e.write(os);
142 }
143 
144 #endif
145 /* vim:set et sw=2 ts=2: */
Indonesian (formerly in)
Definition: locale.h:96
Ossetian; Ossetic.
Definition: locale.h:157
an identifier for a specific piece of information that can be audited.
Definition: audit.h:45
virtual std::ostream & write(std::ostream &) const =0
The Zorba string class.
Definition: zorba_string.h:33
virtual std::ostream & write(std::ostream &) const =0
std::ostream & operator<<(std::ostream &os, const zorba::audit::Configuration &c)
Definition: audit.h:136
an identifier for a set of pieces of information that can be audited together.
Definition: audit.h:34