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

eventlistholder.h

Go to the documentation of this file.
00001 /*_############################################################################
00002   _## 
00003   _##  eventlistholder.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 #ifndef _EVENTLISTHOLDER_H_
00031 #define _EVENTLISTHOLDER_H_
00032 
00033 //----[ includes ]-----------------------------------------------------
00034 #include "snmp_pp/config_snmp_pp.h"
00035 #include "snmp_pp/snmperrs.h"
00036 #include "snmp_pp/eventlist.h"
00037 #include "snmp_pp/reentrant.h"
00038 #include "snmp_pp/usertimeout.h"
00039 #include "snmp_pp/userdefined.h"
00040 
00041 #ifdef SNMP_PP_NAMESPACE
00042 namespace Snmp_pp {
00043 #endif
00044 
00045 class CSNMPMessageQueue;
00046 class CNotifyEventQueue;
00047 class CUDEventQueue;
00048 class CUTEventQueue;
00049 class Pdu;
00050 class v3MP;
00051 class Snmp;
00052 
00053 typedef unsigned long Uint32;
00054 
00055 //------------[ if using X11... ]
00056 #ifdef SNMPX11
00057 #include <X11/Intrinsic.h>
00058 #define TIMER_NOT_SET ((unsigned long) -1)
00059 #define CONTEXT_NOT_SET ((XtAppContext) NULL)
00060 
00061 void SnmpX11TimerCallback(XtPointer client_data, XtIntervalId *id);
00062 void SnmpX11InputCallback(XtPointer client_data, int *source, XtInputId *id);
00063 int SNMPX11Initialize(const XtAppContext app_context);
00064 
00065 #endif // SNMPX11
00066 
00067 class DLLOPT EventListHolder
00068 {
00069  public:
00070   EventListHolder(Snmp *snmp_session);
00071   ~EventListHolder();
00072 
00073   CSNMPMessageQueue *&snmpEventList()   { return m_snmpMessageQueue; };
00074   CNotifyEventQueue *&notifyEventList() { return m_notifyEventQueue; };
00075 #ifdef _USER_DEFINED_EVENTS
00076   CUDEventQueue     *&udEventList()     { return m_udEventQueue;     };
00077 #endif
00078 #ifdef _USER_DEFINED_TIMEOUTS
00079   CUTEventQueue     *&utEventList()     { return m_utEventQueue;     };
00080 #endif
00081 
00082 #ifdef SNMPX11
00083   // these are not user-callable functions
00084   int SnmpX11AddInput(int inputFd, XtInputId &inputId);
00085   int SnmpX11RemoveInput(XtInputId &inputId);
00086   void SnmpX11SetTimer();
00087 #endif // SNMPX11
00088 
00089   Uint32 SNMPGetNextTimeout();
00090 
00091   void SNMPGetFdSets(int &  maxfds,
00092                      fd_set & readfds,
00093                      fd_set & writefds,
00094                      fd_set & exceptfds);
00095 
00096   //---------[ Main Loop ]------------------------------------------
00097   /**
00098    * Infinite loop which blocks when there is nothing to do and handles
00099    * any events.
00100    *
00101    * @note If no messages are outstanding, select() is called with the
00102    *       given timeout, so any async messages that are sent out later
00103    *       are not processed until this select call returns.
00104    */
00105   void SNMPMainLoop(const int max_block_milliseconds = 0 /* = infinite */);
00106 
00107   //---------[ Exit Main Loop ]---------------------------------------
00108   // Force the SNMP Main Loop to terminate immediately
00109   void SNMPExitMainLoop();
00110 
00111   /**
00112    * Block until an event shows up - then handle the event(s).
00113    *
00114    * @note If no messages are outstanding, select() is called with the
00115    *       given timeout, so any async messages that are sent out later
00116    *       are not processed until this select call returns.
00117    */
00118   int SNMPProcessEvents(const int max_block_milliseconds = 0 /* = infinite */);
00119 
00120   //---------[ Process Pending Events ]-------------------------------
00121   // Pull all available events out of their sockets - do not block
00122   int SNMPProcessPendingEvents();
00123 
00124   //---------[ Block For Response ]-----------------------------------
00125   // Wait for the completion of an outstanding SNMP event (msg).
00126   // Handle any other events as they occur.
00127   int SNMPBlockForResponse(const unsigned long req_id,
00128                            Pdu &    pdu);
00129 
00130   //--------[ usertimeout ]---------------------------------------------------
00131 #ifdef _USER_DEFINED_TIMEOUTS
00132   UtId SNMPAddTimeOut(const unsigned long interval,
00133                       const ut_callback callBack,
00134                       const void * callData);
00135   void SNMPRemoveTimeOut(const UtId utId) { m_utEventQueue->DeleteEntry(utId);};
00136 #endif
00137 
00138 //--------[ userdefined ]---------------------------------------------------
00139 #ifdef _USER_DEFINED_EVENTS
00140   UdId SNMPAddInput(const int source,
00141                     const UdInputMask condition,
00142                     const ud_callback callBack,
00143                     const void * callData);
00144   void SNMPRemoveInput(const UdId udId) { m_udEventQueue->DeleteEntry(udId); };
00145 #endif
00146 
00147  private:
00148 
00149   CSNMPMessageQueue *m_snmpMessageQueue;  // contains all outstanding messages
00150   CNotifyEventQueue *m_notifyEventQueue; // contains all sessions waiting for notifications
00151 #ifdef _USER_DEFINED_EVENTS
00152   CUDEventQueue     *m_udEventQueue;  // contains all user-defined events
00153 #endif
00154 #ifdef _USER_DEFINED_TMEOUTS
00155   CUTEventQueue     *m_utEventQueue;  // contains all user-defined timeouts
00156 #endif
00157   CEventList   m_eventList;  // contains all expected events
00158 
00159   SnmpSynchronized      pevents_mutex;
00160 };
00161 
00162 #ifdef SNMP_PP_NAMESPACE
00163 }; // end of namespace Snmp_pp
00164 #endif 
00165 
00166 #endif // _EVENTLISTHOLDER_H_

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