SNMP++  3.3.4
timetick.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## timetick.h
4  _##
5  _## SNMP++ v3.3
6  _## -----------------------------------------------
7  _## Copyright (c) 2001-2013 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  _##########################################################################*/
27 /*===================================================================
28 
29  Copyright (c) 1999
30  Hewlett-Packard Company
31 
32  ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
33  Permission to use, copy, modify, distribute and/or sell this software
34  and/or its documentation is hereby granted without fee. User agrees
35  to display the above copyright notice and this license notice in all
36  copies of the software and any documentation of the software. User
37  agrees to assume all liability for the use of the software; Hewlett-Packard
38  makes no representations about the suitability of this software for any
39  purpose. It is provided "AS-IS without warranty of any kind,either express
40  or implied. User hereby grants a royalty-free license to any and all
41  derivatives based upon this software code base.
42 
43 
44  SNMP++ T I M E T I C K. H
45 
46  TIMETICK CLASS DEFINITION
47 
48  DESIGN + AUTHOR: Peter E Mellquist
49 
50  DESCRIPTION:
51  Class definition for SMI Timeticks class.
52 
53 =====================================================================*/
54 // $Id: timetick.h 2359 2013-05-09 20:07:01Z fock $
55 
56 #ifndef _TIMETICKS
57 #define _TIMETICKS
58 
59 #include "snmp_pp/integer.h"
60 
61 #ifdef SNMP_PP_NAMESPACE
62 namespace Snmp_pp {
63 #endif
64 
65 #define TICKOUTBUF 30 // max formatted time string
66 
67 //------------[ TimeTicks Class ]-----------------------------------
68 /**
69  * The timeticks class allows all the functionality of unsigned
70  * integers but is recognized as a distinct SMI type. TimeTicks
71  * objects may be get or set into Vb objects.
72  */
73 class DLLOPT TimeTicks : public SnmpUInt32
74 {
75  public:
76 #if 0
77  /**
78  * Constructs a zero TimeTicks object.
79  */
80  TimeTicks() : SnmpUInt32()
81  { smival.syntax = sNMP_SYNTAX_TIMETICKS; };
82 #endif
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 = 0)
90  : SnmpUInt32(val)
91  {
92  smival.syntax = sNMP_SYNTAX_TIMETICKS;
93  }
94 
95  /**
96  * Copy constructor.
97  *
98  * @param t - Time for the new object.
99  */
101  : SnmpUInt32(t)
102  {
103  smival.syntax = sNMP_SYNTAX_TIMETICKS;
104  }
105 
106  /**
107  * Destructor.
108  */
110 
111  /**
112  * Return the syntax.
113  *
114  * @return Always returns sNMP_SYNTAX_TIMETICKS.
115  */
117 
118  /**
119  * Get a printable ASCII value.
120  */
121  const char *get_printable() const;
122 
123  /**
124  * Clone operator.
125  *
126  * @return Pointer to a newly created copy of the object.
127  */
128  SnmpSyntax *clone() const { return (SnmpSyntax *) new TimeTicks(*this); }
129 
130  /**
131  * Map other SnmpSyntax objects to TimeTicks.
132  */
133  using SnmpUInt32::operator = ;
134 
135  /**
136  * Overloaded assignment for TimeTicks.
137  *
138  * @param uli - new value
139  * @return self reference
140  */
142  {
143  smival.value.uNumber = uli.smival.value.uNumber;
144  valid_flag = uli.valid_flag;
145  m_changed = true;
146  return *this;
147  }
148 
149  /**
150  * Overloaded assignment for unsigned longs.
151  *
152  * @param ul - new value in hundrets of seconds
153  * @return self reference
154  */
155  TimeTicks& operator=(const unsigned long ul)
156  {
158  return *this;
159  }
160 
161 #if 0
162  // XXX this operator is already provided by SnmpUInt32
163  /**
164  * Casting to unsigned long.
165  *
166  * @return Current value as hundrets of seconds
167  */
168  operator unsigned long() { return smival.value.uNumber; };
169 
170  /**
171  * Reset the object.
172  */
173  void clear()
174  { smival.value.uNumber = 0; m_changed = true; };
175 #endif
176  protected:
177  SNMP_PP_MUTABLE char output_buffer[TICKOUTBUF]; // for storing printed form
178 };
179 
180 #ifdef SNMP_PP_NAMESPACE
181 } // end of namespace Snmp_pp
182 #endif
183 
184 #endif
SnmpUInt32 & operator=(const unsigned long i)
Overloaded assignment for unsigned longs.
Definition: integer.h:127
unsigned long SmiUINT32
Definition: smi.h:157
TimeTicks(const TimeTicks &t)
Copy constructor.
Definition: timetick.h:100
TimeTicks(const unsigned long val=0)
Constructs a TimeTicks object with the given value.
Definition: timetick.h:89
SmiVALUE smival
Definition: smival.h:179
#define SNMP_PP_MUTABLE
#define TICKOUTBUF
Definition: timetick.h:65
SmiUINT32 uNumber
Definition: smival.h:89
TimeTicks & operator=(const unsigned long ul)
Overloaded assignment for unsigned longs.
Definition: timetick.h:155
#define sNMP_SYNTAX_TIMETICKS
Definition: smi.h:109
bool valid_flag
Definition: integer.h:196
The timeticks class allows all the functionality of unsigned integers but is recognized as a distinct...
Definition: timetick.h:73
#define DLLOPT
TimeTicks & operator=(const TimeTicks &uli)
Overloaded assignment for TimeTicks.
Definition: timetick.h:141
SmiUINT32 get_syntax() const
Return the syntax.
Definition: timetick.h:116
32 bit unsigned integer class.
Definition: integer.h:77
union SmiVALUE::@1 value
SnmpSyntax * clone() const
Clone operator.
Definition: timetick.h:128
~TimeTicks()
Destructor.
Definition: timetick.h:109
An "abstract" (pure virtual) class that serves as the base class for all specific SNMP syntax types...
Definition: smival.h:116