SNMP++  3.3.4
counter.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## counter.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++ C O U N T E R. H
45 
46  COUNTER32 CLASS DEFINITION
47 
48  DESIGN + AUTHOR: Peter E Mellquist
49 
50  DESCRIPTION:
51  Class definition for SMI Counter32 class.
52 
53 =====================================================================*/
54 // $Id: counter.h 2359 2013-05-09 20:07:01Z fock $
55 
56 #ifndef _COUNTER
57 #define _COUNTER
58 
59 #include "snmp_pp/integer.h"
60 
61 #ifdef SNMP_PP_NAMESPACE
62 namespace Snmp_pp {
63 #endif
64 
65 //------------[ Counter32 Class ]------------------------------------------
66 /**
67  * The counter class allows all the functionality of unsigned
68  * integers but is recognized as a distinct SMI type. Counter32
69  * class objects may be set or get into Vb objects.
70  */
72 {
73  public:
74 #if 0
75  /**
76  * Constructor to create a Counter object with value zero.
77  */
78  Counter32() : SnmpUInt32() { smival.syntax = sNMP_SYNTAX_CNTR32; };
79 #endif
80 
81  /**
82  * Constructor with a value - defaults to 0.
83  *
84  * @param i - unsigned 32 bit value
85  */
86  Counter32(const unsigned long i = 0)
87  : SnmpUInt32(i)
88  {
89  smival.syntax = sNMP_SYNTAX_CNTR32;
90  }
91 
92  /**
93  * Copy constructor.
94  *
95  * @param c - Object to copy from
96  */
97  Counter32(const Counter32 &c)
98  : SnmpUInt32(c)
99  {
100  smival.syntax = sNMP_SYNTAX_CNTR32;
101  }
102 
103  /**
104  * Return the syntax.
105  *
106  * @return Returns always sNMP_SYNTAX_CNTR32
107  */
109 
110  /**
111  * Clone operator.
112  *
113  * @return Pointer to a newly created copy of the object.
114  */
115  SnmpSyntax *clone() const { return (SnmpSyntax *)new Counter32(*this); }
116 
117  /**
118  * Map other SnmpSyntax objects to Counter32.
119  */
120  // SnmpSyntax& operator=(const SnmpSyntax &val);
121  using SnmpUInt32::operator = ;
122 
123  /**
124  * Overloaded assignment for Counter32.
125  *
126  * @param uli - new value
127  * @return self reference
128  */
130  {
131  smival.value.uNumber = uli.smival.value.uNumber;
132  valid_flag = uli.valid_flag;
133  m_changed = true;
134  return *this;
135  }
136 
137  /**
138  * Overloaded assignment for unsigned longs.
139  *
140  * @param ul - new value
141  * @return self reference
142  */
143  Counter32& operator=(const unsigned long ul)
144  {
146  return *this;
147  }
148 
149 #if 0
150  // XXX this operator is already provided by SnmpUInt32
151  /**
152  * Casting to unsigned long.
153  *
154  * @return Current value as an unsigned long
155  */
156  operator unsigned long() { return smival.value.uNumber; };
157 #endif
158 };
159 
160 #ifdef SNMP_PP_NAMESPACE
161 } // end of namespace Snmp_pp
162 #endif
163 
164 #endif // _COUNTER
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
Counter32(const Counter32 &c)
Copy constructor.
Definition: counter.h:97
SmiUINT32 get_syntax() const
Return the syntax.
Definition: counter.h:108
bool valid_flag
Definition: integer.h:196
SnmpSyntax * clone() const
Clone operator.
Definition: counter.h:115
#define DLLOPT
The counter class allows all the functionality of unsigned integers but is recognized as a distinct S...
Definition: counter.h:71
#define sNMP_SYNTAX_CNTR32
Definition: smi.h:107
32 bit unsigned integer class.
Definition: integer.h:77
union SmiVALUE::@1 value
Counter32(const unsigned long i=0)
Constructor with a value - defaults to 0.
Definition: counter.h:86
Counter32 & operator=(const Counter32 &uli)
Overloaded assignment for Counter32.
Definition: counter.h:129
An "abstract" (pure virtual) class that serves as the base class for all specific SNMP syntax types...
Definition: smival.h:116
Counter32 & operator=(const unsigned long ul)
Overloaded assignment for unsigned longs.
Definition: counter.h:143