div class="twikiTopBar">

Chair for Computer Aided Medical Procedures & Augmented Reality
Lehrstuhl für Informatikanwendungen in der Medizin & Augmented Reality

src/services/ubitrack/ErrorVisualizer/ObjrefImporterNeed.h

00001 /* ========================================================================
00002  * Copyright (C) 2000-2004  Technische Universitaet Muenchen
00003  * License: GPL v2 (or later)
00004  *
00005  * For further information please contact the DWARF team at
00006  * <dwarf-gnu@augmentedreality.de>
00007  *
00008  * ObjrefImporterNeed.h
00009  * Daniel Pustka <pustka@in.tum.de> April 2004
00010  * Distributed Wearable Augmented Reality Framework - www.augmentedreality.de
00011  * For documentation and instructions, see the DWARF documentation website at
00012  * http://wwwbruegge.in.tum.de/projects/dwarf/doc/
00013  *
00014  * For further questions about DWARF, please contact us at
00015  * <dwarf@augmentedreality.de>
00016  * For questions about this particular service, contact
00017  * Daniel Pustka <pustka@in.tum.de>
00018  *
00019  * $Id: ObjrefImporterNeed.h,v 1.1 2004/05/05 11:30:49 pustka Exp $
00020  */
00021 
00022 /**
00023  * @file ObjrefImporterNeed.h
00024  * @brief Header file containing the ObjrefImporter helper class
00025  *
00026  * @author Daniel Pustka <pustka@in.tum.de>
00027  */
00028 
00029 #ifndef __ObjrefImporterNeed_H_
00030 #define __ObjrefImporterNeed_H_
00031 
00032 #include <debug.h>
00033 #include <DWARF/Service.h>
00034 
00035 namespace DWARF {
00036 
00037         /**
00038          * An object for importing object references - can be registered for a need
00039          * The template argument gives the CORBA interface name to import
00040          * e.g. DWARF::ServiceManager
00041          * @ingroup ErrorVisualizer
00042          */
00043         template<class CORBAInterface> class ObjrefImporterNeed
00044                 : public POA_DWARF::SvcProtObjrefImporter
00045                 {
00046                 public:
00047                         /** Implement this interface in your parent class if you want to be notified of imports */
00048                         class Processor
00049                                 {
00050                                 public:
00051                                         virtual void onImport( typename CORBAInterface::_ptr_type pInterface,
00052                                                 ObjrefImporterNeed<CORBAInterface>* pImporter ) = 0;
00053                                 };
00054 
00055                 protected:
00056                         typename CORBAInterface::_var_type m_Interface;
00057                         Processor* m_pProcessor;
00058 
00059                 public:
00060                         /** constructor */
00061                         ObjrefImporterNeed( Processor* pProcessor = 0 )
00062                                 : m_pProcessor( pProcessor )
00063                                 {}
00064 
00065                         /** returns true if we have an interface */
00066                         bool hasInterface() const
00067                                 { return !CORBA::is_nil( m_Interface ); }
00068 
00069                         /** returns the imported reference (may be _nil) */
00070                         const typename CORBAInterface::_var_type& getInterface() const
00071                                 { return m_Interface; }
00072 
00073                         /** to change the processor object after contruction */
00074                         void setProcessor( Processor* pProcessor )
00075                                 { m_pProcessor = pProcessor; }
00076 
00077                         // SvcProtObrefImport interface
00078                         /** this is called by the middleware to import new object references */
00079                         void importObjref( CORBA::Object_ptr o )
00080                                 {
00081                                 DEBUGSTREAM( 10, "Got an object reference" );
00082 
00083                                 m_Interface = CORBAInterface::_narrow( o );
00084 
00085                                 if ( !hasInterface() )
00086                                         { DEBUGSTREAM( 2, "Got objref of wrong type or _nil" ); }
00087                                 else
00088                                         if ( m_pProcessor )
00089                                                 m_pProcessor->onImport( m_Interface, this );
00090                                 }
00091 
00092                         // we could overload operator* and operator-> here -- I love C++ :-))
00093 
00094                 };
00095 
00096         }
00097 
00098 #endif //__ObjrefImporterNeed_H_

ObjrefImporterNeed.h Source File | generated on Sun Apr 29 02:01:03 2007 by Doxygen 1.4.1 for DWARF