]> git.stg.codes - ssmd.git/blob - 3rdparty/snmp++/include/snmp_pp/smival.h
Initial adding
[ssmd.git] / 3rdparty / snmp++ / include / snmp_pp / smival.h
1 /*_############################################################################
2   _## 
3   _##  smival.h  
4   _##
5   _##  SNMP++v3.2.25
6   _##  -----------------------------------------------
7   _##  Copyright (c) 2001-2010 Jochen Katz, Frank Fock
8   _##
9   _##  This software is based on SNMP++2.6 from Hewlett Packard:
10   _##  
11   _##    Copyright (c) 1996
12   _##    Hewlett-Packard Company
13   _##  
14   _##  ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
15   _##  Permission to use, copy, modify, distribute and/or sell this software 
16   _##  and/or its documentation is hereby granted without fee. User agrees 
17   _##  to display the above copyright notice and this license notice in all 
18   _##  copies of the software and any documentation of the software. User 
19   _##  agrees to assume all liability for the use of the software; 
20   _##  Hewlett-Packard and Jochen Katz make no representations about the 
21   _##  suitability of this software for any purpose. It is provided 
22   _##  "AS-IS" without warranty of any kind, either express or implied. User 
23   _##  hereby grants a royalty-free license to any and all derivatives based
24   _##  upon this software code base. 
25   _##  
26   _##  Stuttgart, Germany, Thu Sep  2 00:07:47 CEST 2010 
27   _##  
28   _##########################################################################*/
29 /*===================================================================
30
31   Copyright (c) 1999
32   Hewlett-Packard Company
33
34   ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
35   Permission to use, copy, modify, distribute and/or sell this software
36   and/or its documentation is hereby granted without fee. User agrees
37   to display the above copyright notice and this license notice in all
38   copies of the software and any documentation of the software. User
39   agrees to assume all liability for the use of the software; Hewlett-Packard
40   makes no representations about the suitability of this software for any
41   purpose. It is provided "AS-IS without warranty of any kind,either express
42   or implied. User hereby grants a royalty-free license to any and all
43   derivatives based upon this software code base.
44
45
46   SNMP++ S M I V A L . H
47
48   SMIVALUE CLASS DEFINITION
49
50   DESIGN + AUTHOR: Jeff Meyer
51
52   DESCRIPTION:
53   SMIValue class definition. Superclass for the various types
54   of SNMP values (Address, Oid, Octet, etc.).  Provides
55   only a few functions, most info is in subclass.
56
57 =====================================================================*/
58 // $Id: smival.h 1541 2009-05-29 11:29:22Z katz $
59
60 #ifndef _SMIVALUE
61 #define _SMIVALUE
62
63 //----[ includes ]-----------------------------------------------------
64 #include "snmp_pp/smi.h"
65
66 #ifdef SNMP_PP_NAMESPACE
67 namespace Snmp_pp {
68 #endif
69
70
71 //----[ macros ]-------------------------------------------------------
72 #if defined(USE_CPP_CASTS)
73 #define PP_CONST_CAST(___type, ___ptr)    const_cast< ___type >(___ptr)
74 #else
75 #define PP_CONST_CAST(___type, ___ptr)    ((___type)(___ptr))
76 #endif
77
78 //======================================================================
79 // SMI value structure conforming with SMI RFC
80 //
81 typedef struct {                /* smiVALUE portion of VarBind */
82           SmiUINT32 syntax;     /* Insert SNMP_SYNTAX_<type> */
83         union   {
84           SmiINT    sNumber;    /* SNMP_SYNTAX_INT
85                                    SNMP_SYNTAX_INT32 */
86           SmiUINT32 uNumber;    /* SNMP_SYNTAX_UINT32
87                                    SNMP_SYNTAX_CNTR32
88                                    SNMP_SYNTAX_GAUGE32
89                                    SNMP_SYNTAX_TIMETICKS */
90           SmiCNTR64 hNumber;    /* SNMP_SYNTAX_CNTR64 */
91           SmiOCTETS string;     /* SNMP_SYNTAX_OCTETS
92                                    SNMP_SYNTAX_BITS
93                                    SNMP_SYNTAX_OPAQUE
94                                    SNMP_SYNTAX_IPADDR
95                                    SNMP_SYNTAX_NSAPADDR */
96           SmiOID    oid;        /* SNMP_SYNTAX_OID */
97           SmiBYTE   empty;      /* SNMP_SYNTAX_NULL
98                                    SNMP_SYNTAX_NOSUCHOBJECT
99                                    SNMP_SYNTAX_NOSUCHINSTANCE
100                                    SNMP_SYNTAX_ENDOFMIBVIEW */
101                   }   value;
102                }    SmiVALUE, *SmiLPVALUE;
103 //=================================================================
104
105 //--------------------------------------------------------------------
106 //----[ SnmpSyntax class ]--------------------------------------------
107 //--------------------------------------------------------------------
108
109 /**
110  * An "abstract" (pure virtual) class that serves as the base class
111  * for all specific SNMP syntax types.
112  */
113 class DLLOPT SnmpSyntax {
114
115 public:
116
117   /**
118    * Virtual function for getting a printable ASCII value for any SNMP
119    * value. 
120    *
121    * @note The returned string is valid as long as the object is not
122    *       modified.
123    * @note This function is NOT thread safe.
124    */
125   virtual const char *get_printable() const = 0;
126
127   /**
128    * Return the current syntax.
129    */
130   virtual SmiUINT32 get_syntax() const = 0;
131
132   /**
133    * Virtual clone operation for creating a new Value from an existing
134    * value. 
135    * 
136    * @note The caller MUST use the delete operation on the return
137    *       value when done.
138    */
139   virtual  SnmpSyntax * clone() const = 0;
140
141   /**
142    * Virtual destructor to ensure deletion of derived classes...
143    */
144   virtual ~SnmpSyntax() {};
145
146   /**
147    * Overloaded assignment operator.
148    *
149    * @note This should be pure virtual, but buggy VC++ compiler
150    *       complains about unresolved reference at link time.
151    */
152   virtual SnmpSyntax& operator=(const SnmpSyntax &/*val*/) { return *this; };
153
154   /**
155    * Return validity of the object.
156    */
157   virtual bool valid() const = 0;
158
159   /**
160    * Return the space needed for serialization.
161    */
162   virtual int get_asn1_length() const = 0;
163
164   /**
165    * Reset the object.
166    */
167   virtual void clear() = 0;
168
169 protected:
170
171   SmiVALUE smival;
172 };
173
174 #ifdef SNMP_PP_NAMESPACE
175 } // end of namespace Snmp_pp
176 #endif 
177
178 #endif  // _SMIVALUE