SNMP++  3.3.11
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$
55 
56 #ifndef _SNMP_TIMETICK_H_
57 #define _SNMP_TIMETICK_H_
58 
59 #include <libsnmp.h>
60 #include "snmp_pp/integer.h"
61 
62 #ifdef SNMP_PP_NAMESPACE
63 namespace Snmp_pp {
64 #endif
65 
66 #define TICKOUTBUF 30 // max formatted time string
67 
68 //------------[ TimeTicks Class ]-----------------------------------
69 /**
70  * The timeticks class allows all the functionality of unsigned
71  * integers but is recognized as a distinct SMI type. TimeTicks
72  * objects may be get or set into Vb objects.
73  */
74 class DLLOPT TimeTicks : public SnmpUInt32
75 {
76  public:
77 
78  /**
79  * Constructs a TimeTicks object with the given value.
80  *
81  * @param val - time in hundredths of seconds.
82  */
83  TimeTicks(const unsigned long val = 0)
84  : SnmpUInt32(val)
85  {
86  smival.syntax = sNMP_SYNTAX_TIMETICKS;
87  }
88 
89  /**
90  * Copy constructor.
91  *
92  * @param t - Time for the new object.
93  */
94  TimeTicks(const TimeTicks &t)
95  : SnmpUInt32(t)
96  {
97  smival.syntax = sNMP_SYNTAX_TIMETICKS;
98  }
99 
100  /**
101  * Destructor.
102  */
104 
105  /**
106  * Return the syntax.
107  *
108  * @return Always returns sNMP_SYNTAX_TIMETICKS.
109  */
111 
112  /**
113  * Get a printable ASCII value.
114  */
115  const char *get_printable() const;
116 
117  /**
118  * Clone operator.
119  *
120  * @return Pointer to a newly created copy of the object.
121  */
122  SnmpSyntax *clone() const { return (SnmpSyntax *) new TimeTicks(*this); }
123 
124  /**
125  * Map other SnmpSyntax objects to TimeTicks.
126  */
127  using SnmpUInt32::operator = ;
128 
129  /**
130  * Overloaded assignment for TimeTicks.
131  *
132  * @param uli - new value
133  * @return self reference
134  */
136  {
137  smival.value.uNumber = uli.smival.value.uNumber;
138  valid_flag = uli.valid_flag;
139  m_changed = true;
140  return *this;
141  }
142 
143  /**
144  * Overloaded assignment for unsigned longs.
145  *
146  * @param ul - new value in hundrets of seconds
147  * @return self reference
148  */
149  TimeTicks& operator=(const unsigned long ul)
150  {
152  return *this;
153  }
154 
155  protected:
156  SNMP_PP_MUTABLE char output_buffer[TICKOUTBUF]; // for storing printed form
157 };
158 
159 #ifdef SNMP_PP_NAMESPACE
160 } // end of namespace Snmp_pp
161 #endif
162 
163 #endif // _SNMP_TIMETICK_H_
SnmpUInt32 & operator=(const unsigned long i)
Overloaded assignment for unsigned longs.
Definition: integer.h:124
unsigned long SmiUINT32
Definition: smi.h:157
TimeTicks(const TimeTicks &t)
Copy constructor.
Definition: timetick.h:94
TimeTicks(const unsigned long val=0)
Constructs a TimeTicks object with the given value.
Definition: timetick.h:83
SmiVALUE smival
Definition: smival.h:175
SmiUINT32 get_syntax() const
Return the syntax.
Definition: timetick.h:110
#define SNMP_PP_MUTABLE
#define TICKOUTBUF
Definition: timetick.h:66
SmiUINT32 uNumber
Definition: smival.h:90
TimeTicks & operator=(const unsigned long ul)
Overloaded assignment for unsigned longs.
Definition: timetick.h:149
#define sNMP_SYNTAX_TIMETICKS
Definition: smi.h:109
bool valid_flag
Definition: integer.h:193
The timeticks class allows all the functionality of unsigned integers but is recognized as a distinct...
Definition: timetick.h:74
#define DLLOPT
TimeTicks & operator=(const TimeTicks &uli)
Overloaded assignment for TimeTicks.
Definition: timetick.h:135
SnmpSyntax * clone() const
Clone operator.
Definition: timetick.h:122
32 bit unsigned integer class.
Definition: integer.h:78
union SmiVALUE::@1 value
~TimeTicks()
Destructor.
Definition: timetick.h:103
An "abstract" (pure virtual) class that serves as the base class for all specific SNMP syntax types...
Definition: smival.h:117