1 /*_############################################################################
6 _## -----------------------------------------------
7 _## Copyright (c) 2001-2010 Jochen Katz, Frank Fock
9 _## This software is based on SNMP++2.6 from Hewlett Packard:
11 _## Copyright (c) 1996
12 _## Hewlett-Packard Company
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.
26 _## Stuttgart, Germany, Thu Sep 2 00:07:47 CEST 2010
28 _##########################################################################*/
29 /*===================================================================
32 Hewlett-Packard Company
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.
46 SNMP++ T I M E T I C K. H
48 TIMETICK CLASS DEFINITION
50 DESIGN + AUTHOR: Peter E Mellquist
53 Class definition for SMI Timeticks class.
55 =====================================================================*/
56 // $Id: timetick.h 1541 2009-05-29 11:29:22Z katz $
61 #include "snmp_pp/integer.h"
63 #ifdef SNMP_PP_NAMESPACE
67 #define TICKOUTBUF 30 // max formatted time string
69 //------------[ TimeTicks Class ]-----------------------------------
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.
75 class DLLOPT TimeTicks : public SnmpUInt32
79 * Constructs a zero TimeTicks object.
81 TimeTicks() : SnmpUInt32()
82 { smival.syntax = sNMP_SYNTAX_TIMETICKS; };
85 * Constructs a TimeTicks object with the given value.
87 * @param val - time in hundredths of seconds.
89 TimeTicks(const unsigned long val) : SnmpUInt32(val)
90 { smival.syntax = sNMP_SYNTAX_TIMETICKS; };
95 * @param t - Time for the new object.
97 TimeTicks(const TimeTicks &t);
107 * @return Always returns sNMP_SYNTAX_TIMETICKS.
109 SmiUINT32 get_syntax() const { return sNMP_SYNTAX_TIMETICKS; };
112 * Get a printable ASCII value.
114 const char *get_printable() const;
119 * @return Pointer to a newly created copy of the object.
121 SnmpSyntax *clone() const { return (SnmpSyntax *) new TimeTicks(*this); };
124 * Map other SnmpSyntax objects to TimeTicks.
126 SnmpSyntax& operator=(const SnmpSyntax &val);
129 * Overloaded assignment for TimeTicks.
131 * @param uli - new value
132 * @return self reference
134 TimeTicks& operator=(const TimeTicks &uli)
135 { smival.value.uNumber = uli.smival.value.uNumber;
136 m_changed = true; return *this; };
139 * Overloaded assignment for unsigned longs.
141 * @param i - new value in hundrets of seconds
142 * @return self reference
144 TimeTicks& operator=(const unsigned long i)
145 { smival.value.uNumber = i; m_changed = true; return *this; };
148 * Casting to unsigned long.
150 * @return Current value as hundrets of seconds
152 operator unsigned long() { return smival.value.uNumber; };
158 { smival.value.uNumber = 0; m_changed = true; };
161 SNMP_PP_MUTABLE char output_buffer[TICKOUTBUF]; // for storing printed form
164 #ifdef SNMP_PP_NAMESPACE
165 } // end of namespace Snmp_pp