AGENT++  4.0.3
mib_entry.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## AGENT++ 4.0 - mib_entry.h
4  _##
5  _## Copyright (C) 2000-2013 Frank Fock and Jochen Katz (agentpp.com)
6  _##
7  _## Licensed under the Apache License, Version 2.0 (the "License");
8  _## you may not use this file except in compliance with the License.
9  _## You may obtain a copy of the License at
10  _##
11  _## http://www.apache.org/licenses/LICENSE-2.0
12  _##
13  _## Unless required by applicable law or agreed to in writing, software
14  _## distributed under the License is distributed on an "AS IS" BASIS,
15  _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  _## See the License for the specific language governing permissions and
17  _## limitations under the License.
18  _##
19  _##########################################################################*/
20 
21 #ifndef mib_entry_h_
22 #define mib_entry_h_
23 
24 
25 #include <agent_pp/agent++.h>
26 
27 #include <agent_pp/snmp_pp_ext.h>
28 #include <agent_pp/oidx_ptr.h>
29 #include <agent_pp/threads.h>
30 
31 #ifdef AGENTPP_NAMESPACE
32 namespace Agentpp {
33 #endif
34 
36 
40 
41 #define REMOVE 0x01
42 #define CREATE 0x02
43 #define CHANGE 0x04
44 #define UPDATE (REMOVE | CREATE | CHANGE)
45 
46 
47 
48 typedef unsigned char mib_change;
49 
50 /*--------------------------- class MibEntry --------------------------*/
51 
52 
53 class Mib;
54 
64 #if !defined (AGENTPP_DECL_TEMPL_LIST_MIBENTRY)
65 #define AGENTPP_DECL_TEMPL_LIST_MIBENTRY
67 #endif
68 
70 friend class Mib;
71 public:
75  MibEntry();
76 
84  MibEntry(const Oidx&, mib_access);
85 
91  MibEntry(const MibEntry&);
92 
96  virtual ~MibEntry();
97 
98 
107  virtual mib_type type() const;
108 
114  virtual MibEntry* clone();
115 
129  virtual Oidx find_succ(const Oidx&, Request* req = 0)
130  { (void)req; return Oidx(); }
131 
132  // interfaces dispatch table <-> management instrumentation
133 
140  virtual void get_request(Request*, int) { }
141 
153  virtual void get_next_request(Request*, int) { }
154 
163  virtual int commit_set_request(Request*, int)
164  { return SNMP_ERROR_COMITFAIL; }
165 
175  virtual int prepare_set_request(Request*, int&)
176  { return SNMP_ERROR_NO_SUCH_NAME; }
177 
184  virtual int undo_set_request(Request*, int&)
185  { return SNMP_ERROR_SUCCESS; }
186 
194  virtual void cleanup_set_request(Request*, int&) { }
195 
196 
197  // load/save mib objects from/to hard disk
198 
204  virtual void load_from_file(const char*);
205 
211  virtual void save_to_file(const char*);
212 
220  virtual bool serialize(char*&, int&);
221 
233  virtual bool deserialize(char*, int&);
234 
241  virtual bool is_empty() { return FALSE; }
242 
243 
244  // communication between mib objects
245 
254  virtual void notify_change(const Oidx&, mib_change);
255 
262  virtual void register_for_notifications(MibEntry*);
263 
268  virtual void add_change_notification(MibEntry* e)
269  { register_for_notifications(e); }
279  virtual void change_notification(const Oidx&, mib_change) {}
280 
281 
287  OidxPtr key();
288 
297  virtual OidxPtr max_key();
298 
306  virtual mib_access get_access();
307 
314  virtual bool is_volatile();
315 
321  virtual void reset() { }
322 
323 
328  int operator<(const MibEntry&) const;
329  int operator>(const MibEntry&) const;
330  int operator==(const MibEntry&) const;
331 
332  int operator<(const Oidx&) const;
333  int operator>(const Oidx&) const;
334  int operator<=(const Oidx&) const;
335  int operator>=(const Oidx&) const;
336  int operator==(const Oidx&) const;
338 
339 protected:
340 
346  void set_oid(const Oidx&);
347 
348  // Oidx oid;
352 
353 };
354 
356 
357 #ifdef AGENTPP_NAMESPACE
358 }
359 #endif
360 
361 
362 #endif
363