CORBASink.h

Go to the documentation of this file.
00001 /* ======================================================================== 
00002  * Copyright (C) 2006  Graz University of Technology
00003  *
00004  * This framework is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This framework is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this framework; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  * For further information please contact 
00019  * Dieter Schmalstieg
00020  * <schmalstieg@icg.tu-graz.ac.at>
00021  * Graz University of Technology, 
00022  * Institut for Computer Graphics and Vision,
00023  * Inffeldgasse 16a, 8010 Graz, Austria.
00024  * ========================================================================
00025  * PROJECT: OpenTracker
00026  * ======================================================================== */
00033  /* ======================================================================= */
00034 
00049 #ifndef _CORBASINK_H
00050 #define _CORBASINK_H
00051 
00052 #include <OpenTracker/OpenTracker.h>
00053 #include <OpenTracker/tool/OT_ACE_Log.h>
00054 #include <OpenTracker/skeletons/OT_CORBA.hh>
00055 #include <OpenTracker/network/CORBAUtils.h>
00064 namespace ot {
00065 
00066 class CORBAModule;
00067 
00068 class OPENTRACKER_API CORBASink : public Node
00069 {
00070 // Members
00071 public:
00073   OT_CORBA::Node_var corba_sink;
00075     int frequency;
00076     int cycle;
00077     
00078 
00079 // Methods
00080 protected:
00081     CORBASink() :
00082       frequency( 1 ),
00083       cycle( 0 ) 
00084         {
00085           // empty default constructor
00086         };
00087 
00091     CORBASink( OT_CORBA::Node_var corba_sink_, int frequency_) :
00092         Node(), 
00093         corba_sink( corba_sink_ ),
00094         frequency( frequency_ ),
00095         cycle ( 0 )
00096     {}
00097         virtual ~CORBASink() {
00098       // CORBASink destructor
00099           std::cout << "CORBASink destructor" << std::endl;
00100         }
00101 
00102 public:
00106     virtual int isEventGenerator()
00107     {
00108       return 1;
00109       //return 0;
00110     }
00111     
00121     virtual void onEventGenerated( Event& event, Node& generator)
00122     {
00123       //logPrintI("CORBASink::onEventGenerated %d %d\n", cycle, frequency);
00124       if ((cycle++ % frequency) == 0) {
00125         OT_CORBA::Event corba_event = event.getCORBAEvent();
00126         //CORBAUtils::convertToCORBAEvent(event, corba_event);
00127         try {
00128           corba_sink->setEvent(corba_event);
00129         }
00130         catch (CORBA::COMM_FAILURE) {
00131           std::cerr << "Caught CORBA::COMM_FAILURE" << std::endl;
00132         }
00133         catch (CORBA::TRANSIENT) {
00134           std::cerr << "Caught CORBA::TRANSIENT" << std::endl;
00135         }
00136         updateObservers( event );
00137       }
00138     }
00139     
00140     friend class CORBAModule;
00141 };
00142 
00143 }
00144 
00145 #endif

Generated on Wed Feb 28 15:18:50 2007 for NaviTrack by  doxygen 1.4.6