AGENT++  4.0.3
mib_context.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## AGENT++ 4.0 - mib_context.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_context_h_
22 #define _mib_context_h_
23 
24 #include <agent_pp/threads.h>
25 #include <agent_pp/snmp_pp_ext.h>
26 #include <agent_pp/List.h>
27 #include <agent_pp/mib_entry.h>
28 
29 #ifdef AGENTPP_NAMESPACE
30 namespace Agentpp {
31 #endif
32 
33 
34 /*--------------------------- class MibGroup --------------------------*/
35 
52 #if !defined (AGENTPP_DECL_TEMPL_LIST_MIBENTRY)
53 #define AGENTPP_DECL_TEMPL_LIST_MIBENTRY
55 #endif
56 
58 friend class Mib;
59 public:
74  MibGroup(const Oidx&);
75 
97  MibGroup(const Oidx&, const NS_SNMP OctetStr&);
98 
102  virtual ~MibGroup();
103 
109  mib_type type() const;
110 
117  MibEntryPtr add(MibEntryPtr item);
118 
128  void remove(const Oidx&);
129 
130 
137  ListCursor<MibEntry> get_content();
138 
147  void clearAll();
148 
154  virtual void load_from_file(const char*);
155 
161  virtual void save_to_file(const char*);
162 
170  bool is_persistent() { return (persistencyName!=0);}
171 
172  NS_SNMP OctetStr get_persistency_name()
173  { return *persistencyName; }
174 
188  void set_timeout(unsigned int t) { timeout = t; }
189 
198  unsigned int get_timeout() { return timeout; }
199 
200 protected:
201 
204  unsigned int timeout;
205 };
206 
207 
208 /*--------------------------- class MibContext --------------------------*/
209 
223 #if !defined (AGENTPP_DECL_TEMPL_OIDLIST_MIBENTRY)
224 #define AGENTPP_DECL_TEMPL_OIDLIST_MIBENTRY
226 #endif
227 #if !defined (AGENTPP_DECL_TEMPL_OIDLIST_MIBGROUP)
228 #define AGENTPP_DECL_TEMPL_OIDLIST_MIBGROUP
230 #endif
231 
233 {
234  public:
238  MibContext();
239 
246  MibContext(const NS_SNMP OctetStr&);
247 
251  virtual ~MibContext();
252 
262  virtual bool init_from(const NS_SNMP OctetStr&);
263 
273  virtual bool load_from(const NS_SNMP OctetStr&);
274 
285  virtual bool save_to(const NS_SNMP OctetStr&);
286 
293  OidxPtr key();
294 
306  virtual MibEntry* add(MibEntry*);
307 
320  virtual MibEntry* remove(const Oidx&);
321 
331  virtual MibEntry* get(const Oidx&);
332 
343  virtual MibEntry* seek(const Oidx&);
344 
357  virtual int find(const Oidx&, MibEntryPtr&);
358 
371  virtual int find_lower(const Oidx&, MibEntryPtr&);
372 
385  virtual int find_upper(const Oidx&, MibEntryPtr&);
386 
397  virtual MibEntry* find_next(const Oidx&);
398 
405  OidListCursor<MibEntry> get_content();
406 
413  OidListCursor<MibGroup> get_groups();
414 
424  virtual MibGroup* find_group(const Oidx&);
425 
436  virtual bool remove_group(const Oidx&);
437 
448  virtual MibGroup* find_group_of(const Oidx&);
449 
456  NS_SNMP OctetStr get_name() { return context; }
457 
464  unsigned int get_num_groups() const
465  { return groups.size(); }
466 
477  MibGroup* get_group(int n)
478  { return ((n>=0) && (n<groups.size())) ? groups.getNth(n) : 0; }
479 
486  unsigned int get_num_entries() const
487  { return content.size(); }
488 
489  protected:
493  NS_SNMP OctetStr context;
495 };
496 
497 #ifdef AGENTPP_NAMESPACE
498 }
499 #endif
500 
501 
502 #endif