SNMP++  3.3.4
gauge.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## gauge.h
4  _##
5  _## SNMP++ v3.3
6  _## -----------------------------------------------
7  _## Copyright (c) 2001-2013 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  _##########################################################################*/
27 /*===================================================================
28 
29  Copyright (c) 1999
30  Hewlett-Packard Company
31 
32  ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
33  Permission to use, copy, modify, distribute and/or sell this software
34  and/or its documentation is hereby granted without fee. User agrees
35  to display the above copyright notice and this license notice in all
36  copies of the software and any documentation of the software. User
37  agrees to assume all liability for the use of the software; Hewlett-Packard
38  makes no representations about the suitability of this software for any
39  purpose. It is provided "AS-IS without warranty of any kind,either express
40  or implied. User hereby grants a royalty-free license to any and all
41  derivatives based upon this software code base.
42 
43 
44  SNMP++ G A U G E. H
45 
46  GAUGE32 CLASS DEFINITION
47 
48  DESIGN + AUTHOR: Peter E Mellquist
49 
50  DESCRIPTION:
51  Class definition for SMI Gauge32 class.
52 =====================================================================*/
53 // $Id: gauge.h 2359 2013-05-09 20:07:01Z fock $
54 
55 #ifndef _GAUGE_H_
56 #define _GAUGE_H_
57 
58 #include "snmp_pp/integer.h"
59 
60 #ifdef SNMP_PP_NAMESPACE
61 namespace Snmp_pp {
62 #endif
63 
64 //------------[ Gauge32 Class ]------------------------------------------
65 /**
66  * The gauge class allows all the functionality of unsigned integers
67  * but is recognized as a distinct SMI type. Gauge32 objects may be
68  * set or get into Vb objects.
69  */
70 class DLLOPT Gauge32: public SnmpUInt32
71 {
72  public:
73 
74  //-----------[ Constructors and Destrucotr ]----------------------
75 #if 0
76  /**
77  * Constructs a valid Gauge32 with value 0.
78  */
79  Gauge32() : SnmpUInt32() { smival.syntax = sNMP_SYNTAX_GAUGE32; }
80 #endif
81 
82  /**
83  * Constructs a valid Gauge32 with the given value.
84  *
85  * @param ul - value (0..MAX_UINT32)
86  */
87  Gauge32(const unsigned long ul = 0)
88  : SnmpUInt32(ul)
89  {
90  smival.syntax = sNMP_SYNTAX_GAUGE32;
91  }
92 
93  /**
94  * Copy constructor.
95  *
96  * @param g32 - value
97  */
98  Gauge32(const Gauge32 &g32)
99  : SnmpUInt32(g32)
100  {
101  smival.syntax = sNMP_SYNTAX_GAUGE32;
102  }
103 
104  /**
105  * Destructor (ensure that SnmpUInt32::~SnmpUInt32() is overridden).
106  */
107  ~Gauge32() {}
108 
109  //-----------[ SnmpSyntax methods ]----------------------
110 
111  /**
112  * Get the Syntax of the object.
113  *
114  * @return This method always returns sNMP_SYNTAX_GAUGE32.
115  */
117 
118  /**
119  * Clone the object.
120  *
121  * @return A cloned Gauge32 object allocated through new.
122  */
123  SnmpSyntax *clone() const { return (SnmpSyntax *) new Gauge32(*this); }
124 
125  //-----------[ Overload some operators ]----------------------
126 
127  using SnmpUInt32::operator = ;
128 
129  /**
130  * Assign a Gauge32 to a Gauge32.
131  */
132  Gauge32& operator=(const Gauge32 &uli)
133  {
134  smival.value.uNumber = uli.smival.value.uNumber;
135  valid_flag = uli.valid_flag;
136  m_changed = true;
137  return *this;
138  }
139 
140  /**
141  * Assign a unsigned long to a Gauge32.
142  *
143  * @param ul - New value
144  */
145  Gauge32& operator=(const unsigned long ul)
146  {
148  return *this;
149  }
150 #if 0
151  // XXX this operator is already provided by SnmpUInt32
152  // otherwise, behave like an unsigned int
153  /**
154  * Cast a Gauge32 to unsigned long.
155  *
156  * @return Current value as unsigned long.
157  */
158  operator unsigned long() { return smival.value.uNumber; }
159 #endif
160 };
161 
162 #ifdef SNMP_PP_NAMESPACE
163 } // end of namespace Snmp_pp
164 #endif
165 
166 #endif // _GAUGE_H_
SnmpUInt32 & operator=(const unsigned long i)
Overloaded assignment for unsigned longs.
Definition: integer.h:127
unsigned long SmiUINT32
Definition: smi.h:157
SmiVALUE smival
Definition: smival.h:179
SmiUINT32 uNumber
Definition: smival.h:89
SmiUINT32 get_syntax() const
Get the Syntax of the object.
Definition: gauge.h:116
bool valid_flag
Definition: integer.h:196
#define DLLOPT
The gauge class allows all the functionality of unsigned integers but is recognized as a distinct SMI...
Definition: gauge.h:70
~Gauge32()
Destructor (ensure that SnmpUInt32::~SnmpUInt32() is overridden).
Definition: gauge.h:107
32 bit unsigned integer class.
Definition: integer.h:77
union SmiVALUE::@1 value
Gauge32 & operator=(const unsigned long ul)
Assign a unsigned long to a Gauge32.
Definition: gauge.h:145
Gauge32 & operator=(const Gauge32 &uli)
Assign a Gauge32 to a Gauge32.
Definition: gauge.h:132
Gauge32(const unsigned long ul=0)
Constructs a valid Gauge32 with the given value.
Definition: gauge.h:87
An "abstract" (pure virtual) class that serves as the base class for all specific SNMP syntax types...
Definition: smival.h:116
Gauge32(const Gauge32 &g32)
Copy constructor.
Definition: gauge.h:98
SnmpSyntax * clone() const
Clone the object.
Definition: gauge.h:123
#define sNMP_SYNTAX_GAUGE32
Definition: smi.h:108