AgentX++  2.0.5
agentx_index.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## agentx_index.h
4  _##
5  _##
6  _## AgentX++ 2
7  _## -------------------------------------
8  _## Copyright (C) 2000-2013 - Frank Fock
9  _##
10  _## Use of this software is subject to the license agreement you received
11  _## with this software and which can be downloaded from
12  _## http://www.agentpp.com
13  _##
14  _## This is licensed software and may not be used in a commercial
15  _## environment, except for evaluation purposes, unless a valid
16  _## license has been purchased.
17  _##
18  _##########################################################################*/
19 
20 #ifndef agentx_index_h_
21 #define agentx_index_h_
22 
23 #include <agent_pp/mib_complex_entry.h>
24 
25 #ifdef AGENTPP_NAMESPACE
26 namespace Agentpp {
27 #endif
28 
29 /*------------------- class AgentXIndexEntry -----------------------*/
30 
31 class AgentXIndexEntry: public MibStaticEntry {
32  public:
33  AgentXIndexEntry(u_int sid, const Oidx& o, const NS_SNMP SnmpSyntax& v):
34  MibStaticEntry(o, v) { session_id = sid; }
35  AgentXIndexEntry(const AgentXIndexEntry& o): MibStaticEntry(o)
36  { session_id = o.session_id; }
37  virtual ~AgentXIndexEntry() { }
38 
39  u_int get_session_id() { return session_id; }
40  protected:
41  u_int session_id;
42 };
43 
44 
45 /*--------------------- class AgentXIndex -----------------------*/
46 
47 class AgentXIndex: public MibStaticEntry {
48  public:
49  AgentXIndex(const Vbx&);
50 
52 
53  virtual ~AgentXIndex();
54 
55  virtual int allocate(u_int, const Vbx&, bool);
56  virtual int release(u_int, const Vbx&, bool);
57 
58  virtual int new_index(u_int, Vbx&, bool);
59  virtual int any_index(u_int, Vbx&, bool);
60 
61  virtual void remove_session(u_int);
62 
63  protected:
64 
65  virtual Oidx* get_index_value(const Vbx&);
66 
67  virtual bool is_simple_syntax();
68 
69  OidList<AgentXIndexEntry> allocatedValues;
70  OidList<AgentXIndexEntry> usedValues;
71 };
72 
73 
74 /*--------------------- class AgentXIndexDB -----------------------*/
75 
76 class AgentXIndexDB: public Synchronized {
77 
78  public:
79  AgentXIndexDB(const Oidx& c) { context = c; }
80 
84  virtual ~AgentXIndexDB();
85 
86  static bool is_valid_syntax(NS_SNMP SmiUINT32);
87 
88  virtual int allocate(u_int, const Vbx&, bool);
89  virtual int release(u_int, const Vbx&, bool);
90  virtual void remove_session(u_int);
91 
92  virtual int new_index(u_int, Vbx&, bool);
93  virtual int any_index(u_int, Vbx&, bool);
94 
95  Oidx* key() { return &context; }
96 
97  protected:
98 
99  OidList<AgentXIndex> indexes;
100  Oidx context;
101 };
102 
103 #ifdef AGENTPP_NAMESPACE
104 }
105 #endif
106 
107 
108 #endif