00001 /*************************************************************************** 00002 l1394_eventhandle.h - description 00003 ------------------- 00004 begin : Tue Oct 24 2000 00005 copyright : (C) 2000-2004 by Michael Repplinger 00006 email : repplinger@cs.uni-sb.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef L1394EVENTHANDLE_H 00019 #define L1394EVENTHANDLE_H 00020 00021 00022 00023 #include <list> 00024 #include <iostream> 00025 #include <iterator> 00026 00027 00028 namespace L1394{ 00029 /*! \class EventHandle 00030 * \ingroup L1394_Event 00031 * \brief This class represents the eventhandle to get information about an event. 00032 * 00033 * The idea of this class is, to inherit external classes from this class, 00034 * to get information about changes on FireWire bus. This Class provides functions for 00035 * every defined event. After creating an EventHandle you can add it to every Node 00036 * (see example).<BR> 00037 * By default all functions do nothing and only the interest functions must be re-implemented. 00038 * At this time there are five functions (and events) that can be used: <BR> 00039 * 00040 * Method busreset(const Card*): <BR> 00041 * This method is called if a busreset occur. This method is only called from 00042 * Card objects. 00043 * 00044 * Method nodeDisabled(const Node*): <BR> 00045 * This method is called, if a node is disconnected form the bus. The Node object 00046 * is moved in the inactive_node_list, but not deleted. 00047 * 00048 * Method nodeEnabled(const Node*): <BR> 00049 * This method is called, if a known node is reconnect to the bus. A known node, 00050 * is a node which object is in the inactive_node_list. 00051 * 00052 * Method nodeDestroy(const Node*): <BR> 00053 * This method is called, if the destructor of a Node object is called. After 00054 * a defined time interval a Node object in the inactive_node_list is deleted. 00055 * 00056 * A little example show the idea 00057 * \code 00058 * #include <l1394_session.h> 00059 * using namespace l1394; 00060 * class MyEventHandle : public EventHandle 00061 * { 00062 * MyEventHandle(Node* node) {my_node = node; my_node->addEventHandle(this);} //connect this handle to all events 00063 * ~MyEventHandle() { if (my_node != NULL) my_node->removeEventHandle(this);} 00064 * 00065 * void busreset(const Card* n) { cout << "Bus reset" << endl; } //occur only, if my_node is a Card 00066 * void nodeDisabled(const Node* n) { cout << "Node disconnected from bus "<< endl;} 00067 * void nodeEnabled(const Node* n) {cout << "Node is back on bus" << endl;} 00068 * void nodeDestroy(const Node* n) {cout << "Object is deleted " << endl; my_node = NULL;} 00069 * private: 00070 * Node* my_node; 00071 * } 00072 * 00073 * int main(int argc, char* argv[]) 00074 * { 00075 * Session *session = GetSession(); 00076 * Card* card = session->getCard(0); 00077 * MyEventHandle* event_handle = NULL; 00078 * if (card != NULL) 00079 * event_handle = new MyEventHandle(card); //Now you get Information 00080 * 00081 * delete event_handle; 00082 * delete session; 00083 * } 00084 * \endcode 00085 * @author Michael Repplinger 00086 */ 00087 00088 00089 class Node; 00090 class Card; 00091 class EventHandle 00092 { 00093 public: 00094 /*! \name EventHandle constructor 00095 * These functions creates the EventHandle objects. 00096 */ 00097 //@{ 00098 /*! \fn EventHandle() 00099 * \brief Constructor 00100 */ 00101 EventHandle() {}; 00102 00103 /*! \fn ~EventHandle() 00104 * \brief Destructor 00105 */ 00106 virtual ~EventHandle(); 00107 00108 //@} 00109 /** \name Functions that are called by an event 00110 * These functions can be re-implement to handle a certain event. 00111 */ 00112 //@{ 00113 /*! \fn busreset(const Card* node) 00114 * \brief This method handles the BUSRESET event. 00115 * 00116 * Note that this event is only called by a Card object.<BR> 00117 * For a example see tutorial. 00118 * \param node : pointer to the Node object, that call this event. 00119 */ 00120 virtual void busreset(const Card*) {}; 00121 00122 00123 /*! \fn nodeDestroy(const Node* node) 00124 * \brief this method handles the NODE_DESTROY event. 00125 * 00126 * This event is called, if the destructor of a Node is called.<BR> 00127 * For a example see tutorial. 00128 * \param node : pointer to the Node object, that call this event. 00129 */ 00130 virtual void nodeDestroy(const Node* ) {}; 00131 00132 00133 /*! \fn nodeDisabled(const Node* node) 00134 * \brief This method handles the NODE_DISABLED event 00135 * 00136 * This event is called, if a FireWire node is disconnected from bus 00137 * and the L1394 node object is inserted in the inactive_node_list.<BR> 00138 * For example see tutorial. 00139 * \param node : pointer to the Node object, that call this event. 00140 */ 00141 virtual void nodeDisabled(const Node* ) {}; 00142 00143 00144 /*! \fn nodeEnabled(const Node* node) 00145 * \brief This method handles the NODE_ENABLED event 00146 * 00147 * This event is called, if the Node object is removed from the 00148 * inactive_node_list and insert in the active_node_list again.<BR> 00149 * For example see tutorial. 00150 * \param node : pointer to the Node object, that call this event. 00151 */ 00152 virtual void nodeEnabled(const Node* ) {}; 00153 //@} 00154 private: 00155 //disabled copy constructor 00156 EventHandle(const EventHandle&); 00157 }; 00158 } 00159 #endif