Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

tutorial_4.cpp

Go to the documentation of this file.
00001 /****************************************************************
00002 **
00003 ** L1394 tutorial 4
00004 **
00005 ** This program shows a simple example for the eventhandling.
00006 **
00007 **  begin                : Thu Nov 30 2000
00008 **  copyright            : (C) 2000-2004 by Michael Repplinger
00009 **  email                : repplinger@cs.uni-sb.de
00010 *******************************************************************/
00011 
00012 /***************************************************************************
00013  *                                                                         *
00014  *   This program is free software; you can redistribute it and/or modify  *
00015  *   it under the terms of the GNU General Public License as published by  *
00016  *   the Free Software Foundation; either version 2 of the License, or     *
00017  *   (at your option) any later version.                                   *
00018  *                                                                         *
00019  ***************************************************************************/
00020 
00021 #include <l1394_session.h>
00022 
00023 using namespace L1394;
00024 
00025 class SimpleEventHandle : protected EventHandle {
00026 public: SimpleEventHandle();
00027   virtual ~SimpleEventHandle();
00028 
00029 protected:
00030   virtual void nodeDisabled(const Node*);
00031   virtual void nodeEnabled(const Node*);
00032   virtual void nodeDestroy(const Node*);
00033   virtual void busreset(const Card*);
00034 
00035 };
00036 
00037 
00038 SimpleEventHandle::SimpleEventHandle() {
00039   Session *session = SSession::getInstance();
00040   list<Camera*> camera_list = session->getAllCameras();
00041   for (list<Camera*>::const_iterator it = camera_list.begin(); it != camera_list.end();it++)
00042   {
00043     (*it)->addEventHandle(this);
00044   }
00045   session->addEventHandle(this);
00046 }
00047 
00048 SimpleEventHandle::~SimpleEventHandle() {
00049   Session *session = SSession::getInstance();
00050   list<Camera*> camera_list = session->getAllCameras();
00051   for (list<Camera*>::iterator it = camera_list.begin(); it != camera_list.end(); it++){
00052      (*it)->removeEventHandle(this);
00053   }
00054   session->removeEventHandle(this);
00055 }
00056 
00057 
00058 void SimpleEventHandle::nodeDisabled(const Node* node){
00059   cout << "Node with GUID " << node->getGuid() << " is disconnected" << endl;
00060 }
00061 
00062 void SimpleEventHandle::nodeEnabled(const Node* node){
00063   cout << "Node with GUID " << node->getGuid() << " is reconnect" << endl;
00064 }
00065 
00066 void SimpleEventHandle::nodeDestroy(const Node* /*node*/){
00067   cout << "Node is destroyed" << endl;
00068 }
00069 
00070 void SimpleEventHandle::busreset(const Card* card){
00071   cout << "Busreset on card " << card->getCardID() << endl;
00072 }
00073 
00074 int main()
00075 {
00076     Session *session = SSession::getInstance();
00077     if (!session) {
00078       cerr << "Could not get Session object" << endl;
00079       return 0;
00080     }
00081 
00082     SimpleEventHandle* my_event_handle = new SimpleEventHandle();
00083     char q = 'a';
00084     while (q != 'q')  {
00085         cout << "press 'q' to quit " << endl;
00086         cin >> q;
00087     }
00088     delete my_event_handle;
00089     return 1;
00090 }

Generated on Wed Aug 24 00:36:41 2005 for L1394 by doxygen 1.4.2
L1394 library (NMM) grahics.cs.uni-sb.de/~repplix/l1394_home/