Configurator.h

Go to the documentation of this file.
00001 
00002 /* ========================================================================
00003  * Copyright (c) 2006,
00004  * Institute for Computer Graphics and Vision
00005  * Graz University of Technology
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are
00010  * met:
00011  *
00012  * Redistributions of source code must retain the above copyright notice,
00013  * this list of conditions and the following disclaimer.
00014  *
00015  * Redistributions in binary form must reproduce the above copyright
00016  * notice, this list of conditions and the following disclaimer in the
00017  * documentation and/or other materials provided with the distribution.
00018  *
00019  * Neither the name of the Graz University of Technology nor the names of
00020  * its contributors may be used to endorse or promote products derived from
00021  * this software without specific prior written permission.
00022  *
00023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00024  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00025  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00026  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00027  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00028  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00029  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00030  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00031  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00032  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00033  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034  * ========================================================================
00035  * PROJECT: OpenTracker
00036  * ======================================================================== */
00043 /* ======================================================================= */
00044 
00045 #ifndef CONFIGURATOR_HH
00046 #define CONFIGURATOR_HH
00047 #include <string>
00048 #include "../dllinclude.h"
00049 
00050 namespace ot 
00051 {
00052 
00053     class Context;
00054     class ThreadContext;
00055     class ConfigurationThread;
00056     enum ContextType {
00057         NORMAL = 0,
00058         THREAD = 1
00059     };
00060 
00061     class OPENTRACKER_API Configurator {
00062     public:
00063         typedef void (*ModuleInitFunc) (Context *, void * data);
00064          
00065     protected:
00066         struct MIFunctor{
00067             ModuleInitFunc function;
00068             void * data;
00069             //MIFunctor(ModuleInitFunc f, void * d):function(f), data(d){};
00070         };
00071     public:
00072         typedef std::map<std::string, MIFunctor> Registry;
00073     protected:
00074         static Registry initFunctions;
00075         static Configurator * self;
00076         Context * ctx;
00077         bool isDefaultContext;
00078 
00079         ConfigurationThread * thread;
00080 
00081         static void doInitialization(Context & newctx);
00082       
00083         Configurator(int ctx_type = NORMAL);
00084     public:
00085         
00086 
00087         static Configurator * instance(int ctx_type = NORMAL);
00088         virtual ~Configurator();
00089 
00090         Context * getContext();
00091         
00092         void parseConfigurationString(std::string configString);
00093         void changeConfiguration(std::string configString);
00094         void changeConfigurationFile(const char* xmlstring);
00095         void changeConfigurationString(const char* xmlstring);
00096 
00097         void runConfigurationThread(const char * filename);
00098 
00099         static void addModuleInit(const char * name, ModuleInitFunc func, void * data);
00100         static void loadModule(Context & newctx, const char * module);
00101         friend OPENTRACKER_API void initializeContext(Context *, void *);
00102     };
00103 
00104 }
00105 
00106 
00107 #endif //CONFIGURATOR_HH
00108 
00109 
00110 
00111 /* 
00112  * ------------------------------------------------------------
00113  *   End of Configurator.h
00114  * ------------------------------------------------------------
00115  *   Automatic Emacs configuration follows.
00116  *   Local Variables:
00117  *   mode:c++
00118  *   c-basic-offset: 4
00119  *   eval: (c-set-offset 'substatement-open 0)
00120  *   eval: (c-set-offset 'case-label '+)
00121  *   eval: (c-set-offset 'statement 'c-lineup-runin-statements)
00122  *   eval: (setq indent-tabs-mode nil)
00123  *   End:
00124  * ------------------------------------------------------------ 
00125  */

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