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