Use =default for skeleton copy constructor
[ACE_TAO.git] / ACE / ASNMP / asnmp / counter.cpp
blob6000dd6563a7282bf85bc2edfee51a8cb6d22dd1
2 //=============================================================================
3 /**
4 * @file counter.cpp
6 * Class implementation for SMI Counter32 class.
8 * @author Peter E MellquistMichael R MacFaden mrm@cisco.com - rework & ACE port
9 */
10 //=============================================================================
12 /*===================================================================
13 Copyright (c) 1996
14 Hewlett-Packard Company
16 ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
17 Permission to use, copy, modify, distribute and/or sell this software
18 and/or its documentation is hereby granted without fee. User agrees
19 to display the above copyright notice and this license notice in all
20 copies of the software and any documentation of the software. User
21 agrees to assume all liability for the use of the software; Hewlett-Packard
22 makes no representations about the suitability of this software for any
23 purpose. It is provided "AS-IS without warranty of any kind,either express
24 or implied. User hereby grants a royalty-free license to any and all
25 derivatives based upon this software code base.
26 =====================================================================*/
28 #include "asnmp/counter.h"
30 // constructor with a value
31 Counter32::Counter32( const unsigned long i):SnmpUInt32(i)
33 smival.syntax = sNMP_SYNTAX_CNTR32;
36 // copy constructor
37 Counter32::Counter32( const Counter32 &c)
38 : SnmpUInt32 (c)
40 this->smival.value.uNumber = c.smival.value.uNumber;
41 smival.syntax = sNMP_SYNTAX_CNTR32;
42 valid_flag = 1;
45 // syntax type
46 SmiUINT32 Counter32::get_syntax()
48 return sNMP_SYNTAX_CNTR32;
51 // general assignment from any Value
52 SnmpSyntax& Counter32::operator=( SnmpSyntax &in_val){
53 if ( this == &in_val ) // handle assignement from itself
54 return *this;
56 valid_flag = 0; // will get set true if really valid
57 if (in_val.valid())
59 switch (in_val.get_syntax())
61 case sNMP_SYNTAX_UINT32:
62 // case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
63 case sNMP_SYNTAX_CNTR32:
64 case sNMP_SYNTAX_TIMETICKS:
65 case sNMP_SYNTAX_INT32: // implied cast int -> uint
66 this->smival.value.uNumber =
67 ((Counter32 &)in_val).smival.value.uNumber;
68 valid_flag = 1;
69 break;
72 return *this;
75 // overloaded assignment
76 Counter32& Counter32::operator=( const unsigned long int i)
78 this->smival.value.uNumber=i;
79 return *this;
82 // overloaded assignment
83 Counter32& Counter32::operator=( const Counter32 &uli)
85 this->smival.value.uNumber = uli.smival.value.uNumber;
86 return *this;
89 // otherwise, behave like an unsigned long int
90 Counter32::operator unsigned long()
92 return this->smival.value.uNumber;
95 // clone
96 SnmpSyntax * Counter32::clone() const
98 return ( SnmpSyntax *) new Counter32(*this);