00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "l1394_event.h"
00019 #include "l1394_node.h"
00020
00021
00022 namespace L1394{
00023
00024 Event::Event(const L1394::Node* parent, const L1394::Card* card){
00025 message = internal::SMessage::getInstance();
00026 this->parent = parent;
00027 this->card = card;
00028 }
00029 Event::~Event(){
00030
00031 }
00032
00033 void Event::call(const EVENT event)
00034 {
00035 list<EventHandle*>::const_iterator it;
00036 switch(event)
00037 {
00038 case BUSRESET:
00039 if (card == 0)
00040 break;
00041 for (it = busreset_list.begin(); it != busreset_list.end(); it++)
00042 (*it)->busreset(card);
00043
00044 break;
00045
00046 case NODE_DESTROY:
00047 for (it = node_destroy_list.begin(); it != node_destroy_list.end(); it++)
00048 (*it)->nodeDestroy(parent);
00049
00050 break;
00051
00052 case NODE_DISABLED:
00053 for (it = node_disabled_list.begin(); it != node_disabled_list.end(); it++)
00054 (*it)->nodeDisabled(parent);
00055
00056 break;
00057
00058 case NODE_ENABLED:
00059 for (it = node_disabled_list.begin(); it != node_disabled_list.end(); it++)
00060 (*it)->nodeEnabled(parent);
00061
00062 break;
00063 default:
00064 message->errorStream() << "L1394_Event > Unhandled event" << endl;
00065 break;
00066 }
00067 }
00068
00069
00070 void Event::addEventHandle(EventHandle* event_handle, const EVENT event)
00071 {
00072 switch(event)
00073 {
00074 case BUSRESET:
00075 busreset_list.insert(busreset_list.end(), event_handle);
00076 break;
00077
00078 case NODE_DESTROY:
00079 node_destroy_list.insert(node_destroy_list.end(), event_handle);
00080 break;
00081
00082 case NODE_DISABLED:
00083 node_disabled_list.insert(node_disabled_list.end(), event_handle);
00084 break;
00085
00086 case NODE_ENABLED:
00087 node_disabled_list.insert(node_disabled_list.end(), event_handle);
00088 break;
00089
00090 default:
00091 message->errorStream() << "L1394_Event > Unhandled event " << endl;
00092 break;
00093 }
00094 }
00095
00096
00097 void Event::addEventHandle(EventHandle* event_handle)
00098 {
00099 busreset_list.insert(busreset_list.end(), event_handle);
00100 node_destroy_list.insert(node_destroy_list.end(), event_handle);
00101 node_disabled_list.insert(node_disabled_list.end(), event_handle);
00102 }
00103
00104
00105 void Event::removeEventHandle(EventHandle* event_handle)
00106 {
00107 busreset_list.remove(event_handle);
00108 node_destroy_list.remove(event_handle);
00109 node_disabled_list.remove(event_handle);
00110 }
00111
00112
00113 void Event::removeEventHandle(EventHandle* event_handle, const EVENT event)
00114 {
00115 switch(event)
00116 {
00117 case BUSRESET:
00118 busreset_list.remove(event_handle);
00119 break;
00120
00121 case NODE_DESTROY:
00122 node_destroy_list.remove(event_handle);
00123 break;
00124
00125 default:
00126 message->errorStream() << "L1394_Event > Unhandled event " << endl;
00127 break;
00128 }
00129 }
00130
00131
00132 }