SNMP++  3.3.11
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$
54 
55 #ifndef _SNMP_GAUGE_H_
56 #define _SNMP_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 
76  /**
77  * Constructs a valid Gauge32 with the given value.
78  *
79  * @param ul - value (0..MAX_UINT32)
80  */
81  Gauge32(const unsigned long ul = 0)
82  : SnmpUInt32(ul)
83  {
84  smival.syntax = sNMP_SYNTAX_GAUGE32;
85  }
86 
87  /**
88  * Copy constructor.
89  *
90  * @param g32 - value
91  */
92  Gauge32(const Gauge32 &g32)
93  : SnmpUInt32(g32)
94  {
95  smival.syntax = sNMP_SYNTAX_GAUGE32;
96  }
97 
98  /**
99  * Destructor (ensure that SnmpUInt32::~SnmpUInt32() is overridden).
100  */
101  ~Gauge32() {}
102 
103  //-----------[ SnmpSyntax methods ]----------------------
104 
105  /**
106  * Get the Syntax of the object.
107  *
108  * @return This method always returns sNMP_SYNTAX_GAUGE32.
109  */
111 
112  /**
113  * Clone the object.
114  *
115  * @return A cloned Gauge32 object allocated through new.
116  */
117  SnmpSyntax *clone() const { return (SnmpSyntax *) new Gauge32(*this); }
118 
119  //-----------[ Overload some operators ]----------------------
120 
121  using SnmpUInt32::operator = ;
122 
123  /**
124  * Assign a Gauge32 to a Gauge32.
125  */
126  Gauge32& operator=(const Gauge32 &uli)
127  {
128  smival.value.uNumber = uli.smival.value.uNumber;
129  valid_flag = uli.valid_flag;
130  m_changed = true;
131  return *this;
132  }
133 
134  /**
135  * Assign a unsigned long to a Gauge32.
136  *
137  * @param ul - New value
138  */
139  Gauge32& operator=(const unsigned long ul)
140  {
142  return *this;
143  }
144 };
145 
146 #ifdef SNMP_PP_NAMESPACE
147 } // end of namespace Snmp_pp
148 #endif
149 
150 #endif // _SNMP_GAUGE_H_
SnmpUInt32 & operator=(const unsigned long i)
Overloaded assignment for unsigned longs.
Definition: integer.h:124
unsigned long SmiUINT32
Definition: smi.h:157
SmiVALUE smival
Definition: smival.h:175
SmiUINT32 uNumber
Definition: smival.h:90
SnmpSyntax * clone() const
Clone the object.
Definition: gauge.h:117
bool valid_flag
Definition: integer.h:193
#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:101
32 bit unsigned integer class.
Definition: integer.h:78
union SmiVALUE::@1 value
SmiUINT32 get_syntax() const
Get the Syntax of the object.
Definition: gauge.h:110
Gauge32 & operator=(const unsigned long ul)
Assign a unsigned long to a Gauge32.
Definition: gauge.h:139
Gauge32 & operator=(const Gauge32 &uli)
Assign a Gauge32 to a Gauge32.
Definition: gauge.h:126
Gauge32(const unsigned long ul=0)
Constructs a valid Gauge32 with the given value.
Definition: gauge.h:81
An "abstract" (pure virtual) class that serves as the base class for all specific SNMP syntax types...
Definition: smival.h:117
Gauge32(const Gauge32 &g32)
Copy constructor.
Definition: gauge.h:92
#define sNMP_SYNTAX_GAUGE32
Definition: smi.h:108