Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / ASNMP / asnmp / gauge.cpp
blob485d002a22fdc4b0859719bf33fc7b2ed5835033
2 //=============================================================================
3 /**
4 * @file gauge.cpp
6 * Class implemtation for SMI Gauge32 class.
7 * NOTES: This does not behave exactly as a Gauge described in RFC 1155
9 * @author Peter E MellquistMichael R MacFaden mrm@cisco.com - rework & ACE port
11 //=============================================================================
13 /*===================================================================
14 Copyright (c) 1996
15 Hewlett-Packard Company
17 ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
18 Permission to use, copy, modify, distribute and/or sell this software
19 and/or its documentation is hereby granted without fee. User agrees
20 to display the above copyright notice and this license notice in all
21 copies of the software and any documentation of the software. User
22 agrees to assume all liability for the use of the software; Hewlett-Packard
23 makes no representations about the suitability of this software for any
24 purpose. It is provided "AS-IS without warranty of any kind,either express
25 or implied. User hereby grants a royalty-free license to any and all
26 derivatives based upon this software code base.
27 =====================================================================*/
29 #include "asnmp/gauge.h" // header file for gauge class
31 // constructor with a value
32 Gauge32::Gauge32( const unsigned long i):SnmpUInt32(i)
34 smival.syntax = sNMP_SYNTAX_GAUGE32;
37 // copy constructor
38 Gauge32::Gauge32 ( const Gauge32 &g)
39 : SnmpUInt32 (g)
40 { this->smival.value.uNumber = g.smival.value.uNumber;
41 smival.syntax = sNMP_SYNTAX_GAUGE32;
42 valid_flag = 1;
45 // destructor
46 Gauge32::~Gauge32()
50 // syntax type
51 SmiUINT32 Gauge32::get_syntax()
53 return sNMP_SYNTAX_GAUGE32;
56 // overloaded assignment
57 Gauge32& Gauge32::operator=( const Gauge32 &uli)
59 this->smival.value.uNumber = uli.smival.value.uNumber;
60 return *this;
63 // overloaded assignment
64 Gauge32& Gauge32::operator=( const unsigned long int i)
66 smival.value.uNumber=i; return *this;
69 // general assignment from any Value
70 // TODO: this is broken if not inherited from UInt32 (see UInt32 code).
71 SnmpSyntax& Gauge32::operator=( SnmpSyntax &in_val)
73 if ( this == &in_val ) // handle assignement from itself
74 return *this;
76 valid_flag = 0; // will get set true if really valid
77 if (in_val.valid())
79 switch (in_val.get_syntax())
81 case sNMP_SYNTAX_UINT32:
82 case sNMP_SYNTAX_GAUGE32:
83 case sNMP_SYNTAX_CNTR32:
84 case sNMP_SYNTAX_TIMETICKS:
85 case sNMP_SYNTAX_INT32: // implied cast int -> uint
86 this->smival.value.uNumber =
87 ((Gauge32 &)in_val).smival.value.uNumber;
88 valid_flag = 1;
89 break;
92 return *this;
95 // otherwise, act as unsigned long
96 Gauge32::operator unsigned long()
98 return smival.value.uNumber;
101 // clone - create a new instance of this Value
102 SnmpSyntax* Gauge32::clone() const
104 return ( SnmpSyntax *) new Gauge32(*this);