]> git.stg.codes - ssmd.git/blob - 3rdparty/snmp++/include/snmp_pp/timetick.h
Initial adding
[ssmd.git] / 3rdparty / snmp++ / include / snmp_pp / timetick.h
1 /*_############################################################################
2   _## 
3   _##  timetick.h  
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
46   SNMP++ T I M E T I C K. H
47
48   TIMETICK CLASS DEFINITION
49
50   DESIGN + AUTHOR:  Peter E Mellquist
51
52   DESCRIPTION:
53   Class definition for SMI Timeticks class.
54
55 =====================================================================*/
56 // $Id: timetick.h 1541 2009-05-29 11:29:22Z katz $
57
58 #ifndef _TIMETICKS
59 #define _TIMETICKS
60
61 #include "snmp_pp/integer.h"
62
63 #ifdef SNMP_PP_NAMESPACE
64 namespace Snmp_pp {
65 #endif
66
67 #define TICKOUTBUF 30 // max formatted time string
68
69 //------------[ TimeTicks Class ]-----------------------------------
70 /**
71  * The timeticks class allows all the functionality of unsigned
72  * integers but is recognized as a distinct SMI type. TimeTicks
73  * objects may be get or set into Vb objects.
74  */
75 class DLLOPT TimeTicks : public SnmpUInt32
76 {
77  public:
78   /**
79    * Constructs a zero TimeTicks object.
80    */
81   TimeTicks() : SnmpUInt32()
82     { smival.syntax = sNMP_SYNTAX_TIMETICKS; };
83
84   /**
85    * Constructs a TimeTicks object with the given value.
86    *
87    * @param val - time in hundredths of seconds.
88    */
89   TimeTicks(const unsigned long val) : SnmpUInt32(val)
90     { smival.syntax = sNMP_SYNTAX_TIMETICKS; };
91
92   /**
93    * Copy constructor.
94    *
95    * @param t - Time for the new object.
96    */
97   TimeTicks(const TimeTicks &t);
98
99   /**
100    * Destructor.
101    */
102   ~TimeTicks() {};
103
104   /**
105    * Return the syntax.
106    *
107    * @return Always returns sNMP_SYNTAX_TIMETICKS.
108    */
109   SmiUINT32 get_syntax() const { return sNMP_SYNTAX_TIMETICKS; };
110
111   /**
112    * Get a printable ASCII value.
113    */
114   const char *get_printable() const;
115
116   /**
117    * Clone operator.
118    *
119    * @return Pointer to a newly created copy of the object.
120    */
121   SnmpSyntax *clone() const { return (SnmpSyntax *) new TimeTicks(*this); };
122
123   /**
124    * Map other SnmpSyntax objects to TimeTicks.
125    */
126   SnmpSyntax& operator=(const SnmpSyntax &val);
127
128   /**
129    * Overloaded assignment for TimeTicks.
130    *
131    * @param uli - new value
132    * @return self reference
133    */
134   TimeTicks& operator=(const TimeTicks &uli)
135     { smival.value.uNumber = uli.smival.value.uNumber;
136       m_changed = true; return *this; };
137
138   /**
139    * Overloaded assignment for unsigned longs.
140    *
141    * @param i - new value in hundrets of seconds
142    * @return self reference
143    */
144   TimeTicks& operator=(const unsigned long i)
145     { smival.value.uNumber = i; m_changed = true; return *this; };
146
147   /**
148    * Casting to unsigned long.
149    *
150    * @return Current value as hundrets of seconds
151    */
152   operator unsigned long() { return smival.value.uNumber; };
153
154   /**
155    * Reset the object.
156    */
157   void clear()
158     { smival.value.uNumber = 0; m_changed = true; };
159
160  protected:
161   SNMP_PP_MUTABLE char output_buffer[TICKOUTBUF];  // for storing printed form
162 };
163
164 #ifdef SNMP_PP_NAMESPACE
165 } // end of namespace Snmp_pp
166 #endif 
167
168 #endif