timetick.h
上传用户:uncom666
上传日期:2020-03-30
资源大小:1426k
文件大小:5k
源码类别:

SNMP编程

开发平台:

Visual C++

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