]> git.ipfire.org Git - thirdparty/squid.git/blob - src/snmp/Var.h
-Rename snmplib/libsnmp.a to snmplib/libsnmplib.a
[thirdparty/squid.git] / src / snmp / Var.h
1 /*
2 * $Id$
3 *
4 * DEBUG: section 49 SNMP Interface
5 *
6 */
7
8 #ifndef SQUID_SNMPX_VAR_H
9 #define SQUID_SNMPX_VAR_H
10
11 #include "config.h"
12 #include "ipc/forward.h"
13 #include "Range.h"
14 #include "snmp_vars.h"
15
16
17 namespace Snmp
18 {
19
20 /// variable_list wrapper implement the feature to change
21 /// the name/value of variable and to pack/unpack message
22 class Var: public variable_list
23 {
24 public:
25 Var();
26 Var(const Var& var);
27 Var& operator = (const Var& var);
28 ~Var();
29
30 Var& operator += (const Var& var);
31 Var& operator /= (int num);
32 bool operator < (const Var& var) const;
33 bool operator > (const Var& var) const;
34
35 void pack(Ipc::TypedMsgHdr& msg) const; ///< prepare for sendmsg()
36 void unpack(const Ipc::TypedMsgHdr& msg); ///< restore struct from the message
37
38 Range<const oid*> getName() const; ///< returns variable name
39 void setName(const Range<const oid*>& aName); ///< set new variable name
40 void clearName(); ///< clear variable name
41
42 bool isNull() const;
43
44 int asInt() const; ///< returns variable value as integer
45 unsigned int asGauge() const; ///< returns variable value as unsigned int
46 int asCounter() const; ///< returns variable value as Counter32
47 long long int asCounter64() const; ///< returns variable value as Counter64
48 unsigned int asTimeTicks() const; ///< returns variable value as time ticks
49 Range<const oid*> asObject() const; ///< returns variable value as object oid
50 Range<const u_char*> asString() const; ///< returns variable value as chars string
51
52 void setInt(int value); ///< assign int value to variable
53 void setCounter(int value); ///< assign Counter32 value to variable
54 void setGauge(unsigned int value); ///< assign unsigned int value to variable
55 void setString(const Range<const u_char*>& string); ///< assign string to variable
56 void setObject(const Range<const oid*>& object); ///< assign object oid to variable
57 void setTimeTicks(unsigned int ticks); ///<assign unsigned int (time) value to variable
58 void setCounter64(long long int counter); ///< assign Counter64 value to variable
59
60 void copyValue(const Var& var); ///< copy variable from another one
61 void clearValue(); ///< clear .val member
62 void clear(); ///< clear all internal members
63
64 private:
65 void init(); ///< initialize members
66 void assign(const Var& var); ///< perform full assignment
67 void setValue(const void* value, int length, int aType); ///< set new variable value
68 };
69
70 } // namespace Snmp
71
72 #endif /* SQUID_SNMPX_VAR_H */