Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

userdefined.h

Go to the documentation of this file.
00001 /*_############################################################################
00002   _## 
00003   _##  userdefined.h  
00004   _##
00005   _##  SNMP++v3.2.15
00006   _##  -----------------------------------------------
00007   _##  Copyright (c) 2001-2004 Jochen Katz, Frank Fock
00008   _##
00009   _##  This software is based on SNMP++2.6 from Hewlett Packard:
00010   _##  
00011   _##    Copyright (c) 1996
00012   _##    Hewlett-Packard Company
00013   _##  
00014   _##  ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
00015   _##  Permission to use, copy, modify, distribute and/or sell this software 
00016   _##  and/or its documentation is hereby granted without fee. User agrees 
00017   _##  to display the above copyright notice and this license notice in all 
00018   _##  copies of the software and any documentation of the software. User 
00019   _##  agrees to assume all liability for the use of the software; 
00020   _##  Hewlett-Packard and Jochen Katz make no representations about the 
00021   _##  suitability of this software for any purpose. It is provided 
00022   _##  "AS-IS" without warranty of any kind, either express or implied. User 
00023   _##  hereby grants a royalty-free license to any and all derivatives based
00024   _##  upon this software code base. 
00025   _##  
00026   _##  Stuttgart, Germany, Tue Jan  4 21:42:42 CET 2005 
00027   _##  
00028   _##########################################################################*/
00029 /*===================================================================
00030 
00031   Copyright (c) 1999
00032   Hewlett-Packard Company
00033 
00034   ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
00035   Permission to use, copy, modify, distribute and/or sell this software
00036   and/or its documentation is hereby granted without fee. User agrees
00037   to display the above copyright notice and this license notice in all
00038   copies of the software and any documentation of the software. User
00039   agrees to assume all liability for the use of the software; Hewlett-Packard
00040   makes no representations about the suitability of this software for any
00041   purpose. It is provided "AS-IS without warranty of any kind,either express
00042   or implied. User hereby grants a royalty-free license to any and all
00043   derivatives based upon this software code base.
00044 
00045       U S E R D E F I N E D . H
00046 
00047       CUDEventQueue CLASS DEFINITION
00048 
00049       COPYRIGHT HEWLETT PACKARD COMPANY 1999
00050 
00051       INFORMATION NETWORKS DIVISION
00052 
00053       NETWORK MANAGEMENT SECTION
00054 
00055 
00056       DESIGN + AUTHOR:
00057         Tom Murray
00058 
00059       LANGUAGE:
00060         ANSI C++
00061 
00062       DESCRIPTION:
00063         Queue for holding callback associated with user defined
00064         input sources
00065 
00066 =====================================================================*/
00067 // $Id: userdefined.h,v 1.6 2004/03/03 23:11:21 katz Exp $
00068 
00069 #ifndef _USERDEFINED
00070 #define _USERDEFINED
00071 
00072 //----[ includes ]-----------------------------------------------------
00073 #include <sys/types.h>          // NOTE:  due to 10.10 bug, order is important
00074                                 //   in that all routines must include types.h
00075                                 //   and time.h in same order otherwise you
00076                                 //   will get conflicting definitions of
00077                                 //   "fd_set" resulting in link time errors.
00078 #ifdef WIN32
00079 #include <winsock.h>
00080 #else
00081 #include <sys/time.h>           // time stuff and fd_set
00082 #endif
00083 #ifdef SNMPX11
00084 #include <X11/Intrinsic.h>
00085 #endif
00086 
00087 //----[ snmp++ includes ]----------------------------------------------
00088 #include "snmp_pp/eventlist.h"
00089 #include "snmp_pp/snmperrs.h"
00090 
00091 #ifdef SNMP_PP_NAMESPACE
00092 namespace Snmp_pp {
00093 #endif
00094 
00095 class msec;
00096 class EventListHolder;
00097 
00098 //----[ defines ]------------------------------------------------------
00099 
00100 // Modeled after XtInputMask
00101 typedef unsigned long   UdInputMask;
00102 #define UdInputNoneMask         0L
00103 #define UdInputReadMask         (1L<<0)
00104 #define UdInputWriteMask        (1L<<1)
00105 #define UdInputExceptMask       (1L<<2)
00106 
00107 typedef unsigned long   UdId;
00108 
00109 /* User-defined callback*/
00110 typedef void (*ud_callback)(void * callData, int source, UdId id);
00111 
00112 
00113 //----[ CUDEvent class ]-----------------------------------------------
00114 
00115 
00116 class DLLOPT CUDEvent
00117 {
00118  public:
00119   CUDEvent (const UdId uniqueId, const int fd,
00120             const UdInputMask mask, const ud_callback callBack,
00121             const void * callData);
00122   ~CUDEvent() {};
00123   UdId          GetId()   const { return m_uniqueId; };
00124   int           GetFd()   const { return m_fd; };
00125   UdInputMask   GetMask() const { return m_mask; };
00126 
00127   int Callback();
00128 
00129  protected:
00130   UdId            m_uniqueId;
00131   int             m_fd;
00132   UdInputMask     m_mask;
00133   ud_callback     m_callBack;
00134   void *          m_callData;
00135 };
00136 
00137   /*-----------------------------------------------------------*/
00138   /* CUDEventQueue                                             */
00139   /*   class describing a collection of outstanding SNMP msgs. */
00140   /*-----------------------------------------------------------*/
00141 class DLLOPT CUDEventQueue : public CEvents
00142 {
00143  public:
00144     CUDEventQueue(EventListHolder *holder)
00145       : m_head(0, 0, 0), m_msgCount(0), m_id(1), my_holder(holder) {};
00146     ~CUDEventQueue();
00147     UdId AddEntry(const int fd, const UdInputMask mask,
00148                   const ud_callback callBack, const void * callData);
00149     CUDEvent *GetEntry(const UdId uniqueId);
00150     void DeleteEntry(const UdId uniqueId);
00151 
00152     UdId MakeId();
00153 
00154     // find the next timeout
00155     int GetNextTimeout(msec &/*sendTime*/)
00156       { return SNMP_CLASS_INVALID_OPERATION; }; // We never have a timeout
00157 
00158     // set up parameters for select
00159     void GetFdSets(int &maxfds, fd_set &readfds, fd_set &writefds,
00160                    fd_set &exceptfds);
00161     // return number of user-defined event handlers
00162     int GetCount() { return m_msgCount; };
00163 
00164     int HandleEvents(const int maxfds, const fd_set &readfds,
00165                      const fd_set &writefds, const fd_set &exceptfds);
00166 
00167     int DoRetries(const msec &/*sendtime*/)
00168       { return SNMP_CLASS_SUCCESS; }; // no timeouts, so just return;
00169 
00170     int Done() { return 0; }; // we are never done
00171 
00172   protected:
00173 
00174     /*-----------------------------------------------------------*/
00175     /* CUDEventQueueElt                                          */
00176     /*   a container for a single item on a linked lists of      */
00177     /*  CUDEvents.                                               */
00178     /*-----------------------------------------------------------*/
00179     class DLLOPT CUDEventQueueElt
00180     {
00181      public:
00182       CUDEventQueueElt(CUDEvent *udevent,
00183                        CUDEventQueueElt *next,
00184                        CUDEventQueueElt *previous);
00185 
00186       ~CUDEventQueueElt();
00187       CUDEventQueueElt *GetNext() { return m_next; };
00188       CUDEvent *GetUDEvent() { return m_udevent ; };
00189       CUDEvent *TestId(const UdId uniqueId);
00190 
00191      private:
00192 
00193       CUDEvent *m_udevent;
00194       class CUDEventQueueElt *m_next;
00195       class CUDEventQueueElt *m_previous;
00196     };
00197 
00198     CUDEventQueueElt m_head;
00199     int              m_msgCount;
00200     UdId             m_id;
00201 #ifdef SNMPX11
00202     XtInputId        m_inputId;
00203 #endif // SNMPX11
00204     EventListHolder *my_holder;
00205 };
00206 
00207 #ifdef SNMP_PP_NAMESPACE
00208 }; // end of namespace Snmp_pp
00209 #endif 
00210 
00211 #endif

Generated on Tue Jan 4 22:42:14 2005 for SNMP++ by doxygen 1.3.2