SNMP++  3.3.11
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$
55 
56 #ifndef _SNMP_COUNTER_H_
57 #define _SNMP_COUNTER_H_
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 
75  /**
76  * Constructor with a value - defaults to 0.
77  *
78  * @param i - unsigned 32 bit value
79  */
80  Counter32(const unsigned long i = 0)
81  : SnmpUInt32(i)
82  {
83  smival.syntax = sNMP_SYNTAX_CNTR32;
84  }
85 
86  /**
87  * Copy constructor.
88  *
89  * @param c - Object to copy from
90  */
91  Counter32(const Counter32 &c)
92  : SnmpUInt32(c)
93  {
94  smival.syntax = sNMP_SYNTAX_CNTR32;
95  }
96 
97  /**
98  * Return the syntax.
99  *
100  * @return Returns always sNMP_SYNTAX_CNTR32
101  */
103 
104  /**
105  * Clone operator.
106  *
107  * @return Pointer to a newly created copy of the object.
108  */
109  SnmpSyntax *clone() const { return (SnmpSyntax *)new Counter32(*this); }
110 
111  /**
112  * Map other SnmpSyntax objects to Counter32.
113  */
114  // SnmpSyntax& operator=(const SnmpSyntax &val);
115  using SnmpUInt32::operator = ;
116 
117  /**
118  * Overloaded assignment for Counter32.
119  *
120  * @param uli - new value
121  * @return self reference
122  */
124  {
125  smival.value.uNumber = uli.smival.value.uNumber;
126  valid_flag = uli.valid_flag;
127  m_changed = true;
128  return *this;
129  }
130 
131  /**
132  * Overloaded assignment for unsigned longs.
133  *
134  * @param ul - new value
135  * @return self reference
136  */
137  Counter32& operator=(const unsigned long ul)
138  {
140  return *this;
141  }
142 };
143 
144 #ifdef SNMP_PP_NAMESPACE
145 } // end of namespace Snmp_pp
146 #endif
147 
148 #endif // _SNMP_COUNTER_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 operator.
Definition: counter.h:109
Counter32(const Counter32 &c)
Copy constructor.
Definition: counter.h:91
bool valid_flag
Definition: integer.h:193
#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:78
union SmiVALUE::@1 value
Counter32(const unsigned long i=0)
Constructor with a value - defaults to 0.
Definition: counter.h:80
Counter32 & operator=(const Counter32 &uli)
Overloaded assignment for Counter32.
Definition: counter.h:123
An "abstract" (pure virtual) class that serves as the base class for all specific SNMP syntax types...
Definition: smival.h:117
Counter32 & operator=(const unsigned long ul)
Overloaded assignment for unsigned longs.
Definition: counter.h:137
SmiUINT32 get_syntax() const
Return the syntax.
Definition: counter.h:102