Use =default for skeleton copy constructor
[ACE_TAO.git] / ACE / ASNMP / asnmp / vb.h
blob8242e31fcdf9406e85f17691ebd8891d755a42a3
3 #ifndef VB_CLS_
4 #define VB_CLS_
5 //=============================================================================
6 /**
7 * @file vb.h
9 * This module contains the class definition for the variable binding (VB)
10 * class. The VB class is an encapsulation of a SNMP VB. A VB object is
11 * composed of one SNMP++ Oid and one SMI value. The Vb class utilizes Oid
12 * objects and thus requires the Oid class. To use this class,
13 * set oid, value then call valid() to be sure object was constructed correctly.
15 * @author Peter E Mellquist
17 //=============================================================================
19 /*===================================================================
20 Copyright (c) 1996
21 Hewlett-Packard Company
23 ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
24 Permission to use, copy, modify, distribute and/or sell this software
25 and/or its documentation is hereby granted without fee. User agrees
26 to display the above copyright notice and this license notice in all
27 copies of the software and any documentation of the software. User
28 agrees to assume all liability for the use of the software; Hewlett-Packard
29 makes no representations about the suitability of this software for any
30 purpose. It is provided "AS-IS without warranty of any kind,either express
31 or implied. User hereby grants a royalty-free license to any and all
32 derivatives based upon this software code base.
33 =====================================================================*/
35 //----[ external calls ]----------------------------------------------
36 #include "ace/config-all.h"
38 #if !defined (ACE_LACKS_PRAGMA_ONCE)
39 # pragma once
40 #endif /* ACE_LACKS_PRAGMA_ONCE */
42 #include "asnmp/smival.h"
43 #include "asnmp/snmperrs.h" // V2c error def
44 #include "asnmp/oid.h" // oid class def
45 #include "asnmp/timetick.h" // time ticks
46 #include "asnmp/counter.h" // counter
47 #include "asnmp/gauge.h" // gauge class
48 #include "asnmp/ctr64.h" // 64 bit counters
49 #include "asnmp/octet.h" // octet class
50 #include "asnmp/address.h" // address class def
51 #include "asnmp/integer.h" // integer class
54 //------------[ VB Class Def ]-------------------------------------
55 // The Vb class is the encapsulation of the SNMP variable binding.
56 // Variable binding lists in SNMP++ are represented as arrays of
57 // Vb objects. Vb objects are passed to and from SNMP objects to
58 // provide getting or setting MIB values.
59 // The vb class keeps its own memory for objects and does not
60 // utilize pointers to external data structures.
62 /**
63 * @class Vb
65 * @brief Implement the concrete Variable Bindings aka Varbind
66 * composite type. Varbinds hold 1 Oid and 1 Value (Any SMI value)
68 class ASNMP_Export Vb
70 public:
71 /// constructor with no arguments
72 /// makes an vb, unitialized (does not make object valid)
73 Vb();
75 /// constructor to initialize the oid
76 /// makes a vb with oid portion initialized (does not make object valid)
77 Vb( const Oid &oid);
79 /// constructor to initialize the oid
80 /// makes a vb with oid portion and value portion initialized, (valid)
81 Vb( const Oid& vb, const SnmpSyntax &val, const SmiUINT32=SNMP_CLASS_SUCCESS);
83 /// copy constructor
84 Vb( const Vb &vb);
86 /**
87 * destructor
88 * if the vb has a oid or an octect string then
89 * the associated memory needs to be freed
91 ~Vb();
93 /// return validity of Vb object (both oid and value set return 1 else 0)
94 int valid() const;
96 /// assignment to another Vb object overloaded
97 Vb& operator=( const Vb &vb);
99 /// equivlence operator overloaded
100 friend ASNMP_Export bool operator==( const Vb &lhs, const Vb &rhs);
102 //-----[ set oid / get oid part]------------------------------------------
104 /// set value oid only with another oid
105 void set_oid( const Oid& oid);
107 /// get oid portion
108 void get_oid( Oid &oid) const;
110 //-----[ set value part]--------------------------------------------------
112 /// set a Vb null, if its not already
113 void set_null();
115 /// returns 0 on success and a value
116 void set_value( const TimeTicks& ticks);
118 /// returns 0 on success and a value
119 void set_value( const Oid& oid);
121 /// returns 0 on success and a value
122 void set_value( const Counter32& ctr);
124 /// returns 0 on success and a value
125 void set_value( const Counter64& ctr);
127 /// returns 0 on success and a value
128 void set_value( const Gauge32& ctr);
130 /// returns 0 on success and a value
131 void set_value( const SnmpUInt32& ctr);
133 /// returns 0 on success and a value
134 void set_value( const SnmpInt32& ctr);
136 /// get an octet string object
137 void set_value( const OctetStr& oct_str);
139 //----[ get value ]------------------------------------------------
141 /// returns 0 on success and a value
142 int get_value( TimeTicks& ticks);
144 /// returns 0 on success and a value
145 int get_value( Oid& oid);
147 /// returns 0 on success and a value
148 int get_value( Counter32& ctr);
150 /// returns 0 on success and a value
151 int get_value( Counter64& ctr);
153 /// returns 0 on success and a value
154 int get_value( Gauge32& ctr);
156 /// returns 0 on success and a value
157 int get_value( SnmpUInt32& ctr);
159 /// returns 0 on success and a value
160 int get_value( SnmpInt32& ctr);
162 /// get an octet string object
163 int get_value( OctetStr& oct_str);
165 // escape hatch
166 /// for other derived types that can be casted
167 void set_value( const SnmpSyntax &val);
169 /// gets a general value
170 int get_value( SnmpSyntax &val);
172 /// return the current syntax
173 /// Or.. if a V2 VB exception is present then return the exception value
174 SmiUINT32 get_syntax();
176 /// set the exception status
177 friend ASNMP_Export void set_exception_status( Vb *vb, const SmiUINT32 status);
179 /// return fomatted version of this object
180 const char *to_string();
182 /// returns a formatted version of the value
183 const char *to_string_value();
185 /// returns a formatted version of the value
186 const char *to_string_oid();
188 protected:
189 /// display vb as [ oid / value ]
190 char *output_;
192 /// a vb is made up of a oid
193 Oid iv_vb_oid_;
195 /// and a value...
196 SnmpSyntax *iv_vb_value_;
198 /// are there any vb exceptions??
199 SmiUINT32 exception_status_;
201 void free_vb();
204 #endif // VB_CLS_