]> git.stg.codes - ssmd.git/blob - 3rdparty/snmp++/src/counter.cpp
Initial adding
[ssmd.git] / 3rdparty / snmp++ / src / counter.cpp
1 /*_############################################################################
2   _## 
3   _##  counter.cpp  
4   _##
5   _##  SNMP++v3.2.25
6   _##  -----------------------------------------------
7   _##  Copyright (c) 2001-2010 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   _##  Stuttgart, Germany, Thu Sep  2 00:07:47 CEST 2010 
27   _##  
28   _##########################################################################*/
29 /*===================================================================
30
31   Copyright (c) 1999
32   Hewlett-Packard Company
33
34   ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
35   Permission to use, copy, modify, distribute and/or sell this software
36   and/or its documentation is hereby granted without fee. User agrees
37   to display the above copyright notice and this license notice in all
38   copies of the software and any documentation of the software. User
39   agrees to assume all liability for the use of the software; Hewlett-Packard
40   makes no representations about the suitability of this software for any
41   purpose. It is provided "AS-IS" without warranty of any kind,either express
42   or implied. User hereby grants a royalty-free license to any and all
43   derivatives based upon this software code base.
44
45   C O U N T E R. C P P
46
47   COUNTER32 CLASS IMPLEMENTATION
48
49   DESIGN + AUTHOR:  Peter E Mellquist
50
51   DESCRIPTION:
52   Class implementation for SMI Counter32 class.
53 =====================================================================*/
54 char counter_cpp_version[]="@(#) SNMP++ $Id: counter.cpp 1542 2009-05-29 11:38:48Z katz $";
55
56 #include "snmp_pp/counter.h"
57
58 #ifdef SNMP_PP_NAMESPACE
59 namespace Snmp_pp {
60 #endif
61
62 // copy constructor
63 Counter32::Counter32(const Counter32 &c)
64 {
65   smival.value.uNumber = c.smival.value.uNumber;
66   smival.syntax = sNMP_SYNTAX_CNTR32;
67   m_changed = true;
68   valid_flag = true;
69 }
70
71 // general assignment from any Value
72 SnmpSyntax& Counter32::operator=(const SnmpSyntax &in_val)
73 {
74   if (this == &in_val) return *this; // handle assignement from itself
75
76   valid_flag = false;           // will get set true if really valid
77   if (in_val.valid())
78   {
79     switch (in_val.get_syntax())
80     {
81       case sNMP_SYNTAX_UINT32:
82    // case sNMP_SYNTAX_GAUGE32:         .. indistinquishable from UINT32
83       case sNMP_SYNTAX_CNTR32:
84       case sNMP_SYNTAX_TIMETICKS:
85       case sNMP_SYNTAX_INT32:           // implied cast int -> uint
86           smival.value.uNumber = ((Counter32 &)in_val).smival.value.uNumber;
87           valid_flag = true;
88           break;
89     }
90   }
91   m_changed = true; 
92   return *this;
93 }
94
95 #ifdef SNMP_PP_NAMESPACE
96 }; // end of namespace Snmp_pp
97 #endif