SNMP++  3.6.3
timetick.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## timetick.h
4  _##
5  _## SNMP++ v3.4
6  _## -----------------------------------------------
7  _## Copyright (c) 2001-2021 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, Frank Fock, and Jochen Katz make no representations
21  _## about the 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 
55 #ifndef _SNMP_TIMETICK_H_
56 #define _SNMP_TIMETICK_H_
57 
58 #include <libsnmp.h>
59 #include "snmp_pp/integer.h"
60 
61 #ifdef SNMP_PP_NAMESPACE
62 namespace Snmp_pp {
63 #endif
64 
65 #define TICKOUTBUF 32 // 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 
77  /**
78  * Constructs a TimeTicks object with the given value.
79  *
80  * @param val - time in hundredths of seconds.
81  */
82  TimeTicks(const unsigned long val = 0)
83  : SnmpUInt32(val)
84  {
85  smival.syntax = sNMP_SYNTAX_TIMETICKS;
86  }
87 
88  /**
89  * Copy constructor.
90  *
91  * @param t - Time for the new object.
92  */
93  TimeTicks(const TimeTicks &t)
94  : SnmpUInt32(t)
95  {
96  smival.syntax = sNMP_SYNTAX_TIMETICKS;
97  }
98 
99  /**
100  * Destructor.
101  */
103 
104  /**
105  * Return the syntax.
106  *
107  * @return Always returns sNMP_SYNTAX_TIMETICKS.
108  */
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  using SnmpUInt32::operator=;
127 
128  /**
129  * Overloaded assignment for TimeTicks.
130  *
131  * @param uli - new value
132  * @return self reference
133  */
135  {
136  smival.value.uNumber = uli.smival.value.uNumber;
137  valid_flag = uli.valid_flag;
138  m_changed = true;
139  return *this;
140  }
141 
142  /**
143  * Overloaded assignment for unsigned longs.
144  *
145  * @param ul - new value in hundrets of seconds
146  * @return self reference
147  */
148  TimeTicks& operator=(const unsigned long ul)
149  {
151  return *this;
152  }
153 
154  protected:
155  SNMP_PP_MUTABLE char output_buffer[TICKOUTBUF]; // for storing printed form
156 };
157 
158 #ifdef SNMP_PP_NAMESPACE
159 } // end of namespace Snmp_pp
160 #endif
161 
162 #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:93
TimeTicks(const unsigned long val=0)
Constructs a TimeTicks object with the given value.
Definition: timetick.h:82
SmiVALUE smival
Definition: smival.h:175
SmiUINT32 get_syntax() const
Return the syntax.
Definition: timetick.h:109
#define SNMP_PP_MUTABLE
#define TICKOUTBUF
Definition: timetick.h:65
SmiUINT32 uNumber
Definition: smival.h:90
TimeTicks & operator=(const unsigned long ul)
Overloaded assignment for unsigned longs.
Definition: timetick.h:148
#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:73
#define DLLOPT
TimeTicks & operator=(const TimeTicks &uli)
Overloaded assignment for TimeTicks.
Definition: timetick.h:134
SnmpSyntax * clone() const
Clone operator.
Definition: timetick.h:121
32 bit unsigned integer class.
Definition: integer.h:78
union SmiVALUE::@1 value
~TimeTicks()
Destructor.
Definition: timetick.h:102
An "abstract" (pure virtual) class that serves as the base class for all specific SNMP syntax types...
Definition: smival.h:117