OpenTracker

An Open Architecture for Reconfigurable Tracking based on XML | Contact

OpenTracker.cxx

Go to the documentation of this file.
00001 /* ========================================================================
00002  * Copyright (c) 2006,
00003  * Institute for Computer Graphics and Vision
00004  * Graz University of Technology
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions are
00009  * met:
00010  *
00011  * Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the following disclaimer.
00013  *
00014  * Redistributions in binary form must reproduce the above copyright
00015  * notice, this list of conditions and the following disclaimer in the
00016  * documentation and/or other materials provided with the distribution.
00017  *
00018  * Neither the name of the Graz University of Technology nor the names of
00019  * its contributors may be used to endorse or promote products derived from
00020  * this software without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00023  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00024  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00025  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00026  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00027  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00028  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00029  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00030  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00031  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  * ========================================================================
00034  * PROJECT: OpenTracker
00035  * ======================================================================== */
00043 /* ======================================================================= */
00044 
00045 // a trick to avoid warnings when ace includes the STL headers
00046 #ifdef WIN32
00047 #pragma warning(disable:4786)
00048 #endif
00049 #include <stdlib.h>
00050 #include <string>
00051 
00052 #include <ace/ACE.h>
00053 
00054 #include "../dllinclude.h"
00055 
00056 #include "../core/Event.h"
00057 #include "../core/Context.h"
00058 #include "../common/CommonNodeFactory.h"
00059 #include "../core/TestModule.h"
00060 
00061 // the following modules are not supported under Windows CE
00062 #ifndef _WIN32_WCE
00063 #include "../common/ConsoleModule.h"
00064 #ifndef DARWIN
00065 #include "../input/InterSenseModule.h"
00066 #include "../input/ParButtonModule.h"
00067 #endif //DARWIN
00068 #include "../input/XSensModule.h"
00069 #include "../input/DynaSightModule.h"
00070 #include "../input/FastTrakModule.h"
00071 #include "../input/FOBModule.h"
00072 #include "../input/ARTDataTrackerModule.h"
00073 #endif //_WIN32_WCE
00074 
00075 #include "../network/NetworkSinkModule.h"
00076 #include "../network/NetworkSourceModule.h"
00077 #include "../common/TimeModule.h"
00078 #include "../common/FileModule.h"
00079 #include "../network/TCPModule.h"
00080 
00081 #include "../input/UltraTrakModule.h"
00082 #include "../common/GroupGateModule.h"
00083 #include "../common/InterpolatorModule.h"
00084 #include "../common/ButtonHoldFilterModule.h"
00085 #include "../input/GPSModule.h"
00086 #include "../input/MagicYModule.h"
00087 #include "../common/CallbackModule.h"
00088 #include "../common/LogModule.h"
00089 
00090 // these modules depend on compile options
00091 #include "../input/ARToolKitModule.h"
00092 #include "../input/ARToolKitPlusModule.h"
00093 #include "../input/CyberMouseModule.h"
00094 #include "../input/TargusModule.h"
00095 #include "../input/LinmouseModule.h"
00096 #include "../input/WacomGraphireModule.h"
00097 #include "../input/JoystickModule.h"
00098 #include "../input/SpaceMouseModule.h"
00099 #include "../input/SpeechModule.h"
00100 #include "../input/P5GloveModule.h"
00101 #include "../input/MulticastInputModule.h"
00102 #include "../input/UbisenseModule.h"
00103 #include "../input/OpenVideoModule.h"
00104 #include "../network/DwarfModule.h"
00105 #include "../network/VRPNModule.h"
00106 #include "../network/CORBAModule.h"
00107 
00108 // DLL main function
00109 
00110 #ifdef WIN32
00111 
00112 #ifndef OPENTRACKER_STATIC
00113 BOOL APIENTRY DllMain( HANDLE hModule, 
00114                DWORD  ul_reason_for_call, 
00115                LPVOID lpReserved
00116                )
00117 {
00118     switch( ul_reason_for_call )
00119     {
00120         case DLL_PROCESS_ATTACH:        
00121             ACE::init();
00122             break;
00123         case DLL_THREAD_ATTACH:
00124             break;
00125         case DLL_THREAD_DETACH:     
00126             break;
00127         case DLL_PROCESS_DETACH:        
00128             ACE::fini();
00129             break;  
00130     }
00131     return TRUE;
00132 }
00133 #endif //OPENTRACKER_STATIC
00134 
00135 #endif //WIN32
00136 
00137 // initializes context
00138 
00139 namespace ot {
00140 
00141     void OPENTRACKER_API initializeContext( Context & context )
00142     {
00143         // register the creator functions and generic names of all known types
00144         Event::registerAllKnownTypes();
00145 
00146         // Instance the default modules and add to factory and parser
00147         CommonNodeFactory * common = new CommonNodeFactory;
00148         context.addFactory( *common );
00149 
00150         LogModule * log = new LogModule;
00151         context.addModule( "LogConfig", *log );
00152 
00153 #ifndef OT_NO_TESTMODULE_SUPPORT
00154         TestModule * test = new TestModule;
00155         context.addFactory( *test );
00156         // actually it doesn't have a configuration element
00157         context.addModule( "TestConfig", *test );
00158 #endif
00159 
00160 #ifndef OT_NO_NETWORK_SUPPORT
00161         NetworkSinkModule * networksink = new NetworkSinkModule;
00162         context.addFactory( *networksink );
00163         context.addModule( "NetworkSinkConfig", *networksink );
00164 #endif
00165 
00166 
00167 #ifndef _WIN32_WCE
00168 #ifndef OT_NO_CONSOLE_SUPPORT
00169         ConsoleModule * console = new ConsoleModule ;
00170         context.addFactory( *console );
00171         context.addModule( "ConsoleConfig", *console );
00172 #endif
00173 
00174 #ifndef OT_NO_NETWORK_SUPPORT
00175         NetworkSourceModule * network = new NetworkSourceModule;
00176         context.addFactory( * network );
00177         context.addModule( "NetworkSourceConfig", *network );    
00178 #endif
00179 #endif //_WIN32_WCE
00180 
00181 #ifdef USE_ARTOOLKIT
00182         ARToolKitModule * artool = new ARToolKitModule;
00183         context.addFactory( * artool );
00184         context.addModule( "ARToolKitConfig", *artool );
00185 #endif
00186 
00187 #ifdef USE_ARTOOLKITPLUS
00188         // Create an ARToolKitPlusModule instance
00189         ARToolKitPlusModule *artoolplus = new ARToolKitPlusModule;
00190         context.addFactory( * artoolplus );
00191         context.addModule( "ARToolKitPlusConfig", *artoolplus );
00192         context.registerVideoUser(artoolplus);
00193 #endif
00194 
00195 #ifdef USE_OPENVIDEO
00196         OpenVideoModule * ovModule = new OpenVideoModule(&context);
00197         context.addModule( "OpenVideoConfig", *ovModule );
00198 #endif
00199 
00200 #ifdef USE_WACOMGRAPHIRE
00201         WacomGraphireModule * wacom = new WacomGraphireModule;
00202         context.addFactory( * wacom );
00203         context.addModule( "WacomGraphireConfig", * wacom );
00204 #endif
00205 
00206 #ifdef USE_CYBERMOUSE
00207         CyberMouseModule * cmouse = new CyberMouseModule;
00208         context.addFactory( * cmouse );
00209         context.addModule( "CyberMouseConfig", * cmouse );
00210 #endif  
00211 
00212 #ifdef USE_LINMOUSEMODULE
00213         LinmouseModule * linmousemodule = new LinmouseModule;
00214         context.addFactory( * linmousemodule );
00215         context.addModule( "LinmouseConfig", * linmousemodule );
00216 #endif  
00217 
00218 #ifdef USE_TARGUSMODULE
00219         TargusModule * targusmodule = new TargusModule;
00220         context.addFactory( * targusmodule );
00221         context.addModule( "TargusConfig", * targusmodule );
00222 #endif  
00223 
00224 #ifdef USE_JOYSTICK
00225         JoystickModule * joy = new JoystickModule();
00226         context.addFactory( *joy );
00227         context.addModule( "JoystickConfig", *joy );
00228 #endif
00229 
00230 #ifdef USE_SPACEMOUSE
00231         SpaceMouseModule * smouse = new SpaceMouseModule;
00232         context.addFactory( * smouse );
00233         context.addModule( "SpaceMouseConfig", * smouse );
00234 #endif  
00235 
00236 #ifndef OT_NO_NETWORK_SUPPORT
00237         MulticastInputModule *mcinput = new MulticastInputModule;
00238         context.addFactory( * mcinput );
00239         context.addModule( "MulticastInputConfig", * mcinput );
00240 #endif
00241 
00242 #ifndef _WIN32_WCE
00243 #ifndef DARWIN
00244 #ifndef OT_NO_INTERSENSE_SUPPORT
00245         InterSenseModule * intersense = new InterSenseModule;
00246         context.addFactory( * intersense );
00247         context.addModule( "InterSenseConfig", * intersense );
00248 #endif
00249 #endif //DARWIN
00250 #endif //_WIN32_WCE
00251 
00252 #ifndef OT_NO_TIMEMODULE_SUPPORT
00253         TimeModule * time = new TimeModule();
00254         context.addModule( "TimeConfig", * time );
00255 #endif
00256 
00257 #ifndef OT_NO_FILEMODULE_SUPPORT
00258         FileModule * file = new FileModule();
00259         context.addFactory( * file );
00260         context.addModule( "FileConfig", * file );
00261 #endif
00262 
00263 #ifndef _WIN32_WCE
00264 #ifndef DARWIN
00265 #ifndef OT_NO_PARBUTTON_SUPPORT
00266         ParButtonModule * parbutton = new ParButtonModule();
00267         context.addFactory( *parbutton );
00268         context.addModule( "ParButtonConfig", *parbutton );
00269 #endif
00270 #endif //DARWIN
00271 #endif //_WIN32_WCE
00272 
00273 #ifndef OT_NO_NETWORK_SUPPORT
00274         TCPModule * tcp = new TCPModule();
00275         context.addFactory( *tcp );
00276         context.addModule( "TCPConfig", *tcp );
00277 #endif
00278 
00279 #ifndef _WIN32_WCE
00280 #ifndef OT_NO_FOB_SUPPORT
00281         FOBModule * fob = new FOBModule();
00282         context.addFactory( *fob );
00283         context.addModule( "FOBConfig", *fob );
00284 #endif
00285 #endif //_WIN32_WCE
00286 
00287 #ifndef _WIN32_WCE
00288 #ifndef OT_NO_FASTTRACK_SUPPORT
00289         FastTrakModule * ftrak = new FastTrakModule();
00290         context.addFactory( *ftrak );
00291         context.addModule( "FastTrakConfig", *ftrak );
00292 #endif
00293 #endif //_WIN32_WCE
00294 
00295 #ifndef _WIN32_WCE
00296 #ifndef OT_NO_ARTDATATRACKER_SUPPORT
00297         ARTDataTrackerModule * dtrak = new ARTDataTrackerModule();
00298         context.addFactory( *dtrak );
00299         context.addModule( "ARTDataTrackerConfig", *dtrak );
00300 #endif
00301 #endif //_WIN32_WCE
00302 
00303 #ifndef OT_NO_ULTRATRACK_SUPPORT
00304         UltraTrakModule * ultra = new UltraTrakModule;
00305         context.addFactory( * ultra );
00306         context.addModule( "UltraTrakConfig", *ultra );
00307 #endif
00308 
00309 #ifndef OT_NO_GROUPGATE_SUPPORT
00310         GroupGateModule * groupgate = new GroupGateModule();
00311         context.addFactory( * groupgate );
00312         context.addModule( "GroupGateConfig", *groupgate ); 
00313 #endif
00314     
00315 #ifndef OT_NO_SPEECH_SUPPORT
00316         SpeechModule *speechmodule = new SpeechModule;
00317         context.addFactory( *speechmodule );
00318         context.addModule( "SpeechRecoConfig", *speechmodule );
00319 #endif
00320 
00321 #ifndef OT_NO_INTERPORLATORMODULE_SUPPORT
00322         InterpolatorModule * ipol = new InterpolatorModule;
00323         context.addFactory( *ipol );
00324         // actually it doesn't have a configuration element
00325         context.addModule( "InterpolatorConfig", *ipol );
00326 #endif
00327 
00328 #ifndef OT_NO_BUTTON_SUPPORT
00329         ButtonHoldFilterModule * buttonHoldFiler = new ButtonHoldFilterModule;
00330         context.addFactory( *buttonHoldFiler );
00331         // actually it doesn't have a configuration element
00332         context.addModule( "ButtonHoldFilterConfig", *buttonHoldFiler );
00333 #endif
00334 
00335 #ifdef USE_P5GLOVE
00336         P5GloveModule *p5glovemodule = new P5GloveModule;
00337         context.addFactory( *p5glovemodule );
00338         context.addModule( "P5GloveConfig", *p5glovemodule );
00339 #endif
00340 
00341 #ifndef OT_NO_GPS_SUPPORT
00342         GPSModule * gps = new GPSModule;
00343         context.addFactory( * gps );
00344         context.addModule( "GPSConfig", * gps );
00345 #endif
00346 
00347 #ifndef _WIN32_WCE
00348 #ifndef OT_NO_DYNASIGHT_SUPPORT
00349         DynaSightModule * dynasight = new DynaSightModule;
00350         context.addFactory( * dynasight );
00351         context.addModule( "DynaSightConfig", *dynasight );
00352 #endif
00353 #endif //_WIN32_WCE
00354 
00355 #ifndef OT_NO_MAGICY_SUPPORT
00356         MagicYModule * magicY = new MagicYModule;
00357         context.addFactory( * magicY );
00358         context.addModule( "MagicYConfig", *magicY );
00359 #endif
00360     
00361 #ifndef OT_NO_CALLBACKMODULE_SUPPORT
00362     CallbackModule  * cbModule = new CallbackModule;
00363         context.addFactory( *cbModule );
00364         context.addModule( "CallbackConfig", *cbModule );
00365 #endif
00366 
00367 #ifdef USE_DWARF
00368         DwarfModule * dwarf = new DwarfModule;
00369         context.addFactory( *dwarf);
00370         context.addModule( "DwarfConfig", *dwarf );
00371 #endif
00372 
00373 #ifdef USE_CORBA
00374         CORBAModule * corba = new CORBAModule;
00375         context.addFactory( *corba);
00376         context.addModule( "CORBAConfig", *corba );
00377 #endif
00378 
00379 #ifdef USE_VRPN
00380         VRPNModule * vrpn = new VRPNModule;
00381         context.addFactory( *vrpn );
00382         context.addModule( "VRPNConfig", *vrpn );
00383 #endif
00384 
00385 #ifndef _WIN32_WCE
00386 #ifndef OT_NO_XSENS_SUPPORT
00387         XSensModule * xsens = new XSensModule;
00388         context.addFactory( *xsens );
00389         context.addModule( "XSensConfig", *xsens );
00390 #endif
00391 #endif //_WIN32_WCE
00392 
00393 #ifdef USE_UBISENSE
00394         UbisenseModule * ubisense = new UbisenseModule;
00395         context.addFactory( * ubisense );
00396         context.addModule( "UbisenseConfig", *ubisense );
00397 #endif
00398     }
00399 
00400 } // namespace ot
00401 
00402 /* 
00403  * ------------------------------------------------------------
00404  *   End of OpenTracker.cxx
00405  * ------------------------------------------------------------
00406  *   Automatic Emacs configuration follows.
00407  *   Local Variables:
00408  *   mode:c++
00409  *   c-basic-offset: 4
00410  *   eval: (c-set-offset 'substatement-open 0)
00411  *   eval: (c-set-offset 'case-label '+)
00412  *   eval: (c-set-offset 'statement 'c-lineup-runin-statements)
00413  *   eval: (setq indent-tabs-mode nil)
00414  *   End:
00415  * ------------------------------------------------------------ 
00416  */

copyright (c) 2006 Graz University of Technology