ESLA

Embeddable Scriting LAnguage

frantz@pangea.stanford.edu

Stanford University, Rock Fracture Project research group

© 2003

action_factory.h

Go to the documentation of this file.
00001 /*************************************************************************
00002  *              ESLA: Embeddable Scripting LAnguage
00003  *                  Copyright (C) 2003 Frantz Maerten
00004  *
00005  *   This  program  is  free  software;  you  can  redistribute it and/or
00006  *   modify  it  under  the  terms  of  the GNU General Public License as
00007  *   published  by  the Free Software Foundation; either version 2 of the
00008  *   License, or (at your option) any later version.
00009  *
00010  *   If  you modify this software, you should contact the author, include
00011  *   a  notice giving the name of the person performing the modification,
00012  *   the date of modification, and the reason for such modification.
00013  *
00014  *   Note   that   the   GNU  General  Public  License  does  not  permit
00015  *   incorporating the Software into proprietary programs.
00016  *
00017  *  Contact: Frantz Maerten
00018  *     frantz@pangea.stanford.edu
00019  *
00020  *     Dept. of Geological & Environmental Sciences
00021  *     Stanford University 
00022  *     Stanford, CA 94305-2115
00023  *     USA
00024  *************************************************************************/
00025 
00026 
00027 #ifndef ACTION_FACTORY_
00028 #define ACTION_FACTORY_
00029 
00030 #include "../esla_namespace.h"
00031 #include "common.h"
00032 #include "../utils/generic_factory.h"
00033 #include "../utils/gen_object.h"
00034 #include "../utils/name.h"
00035 #include <typeinfo>
00036 #include <string>
00037 #include <vector>
00038 
00039 //------------------------------------------------------
00040 BEGIN_LIB_NAMESPACE 
00041 
00042 class NamingContext ;
00043 class Factory ;
00044 class GenAction ;
00045 
00046 class ActionsFactory {
00047 public:
00048   // Bind a new factory 'factory' with a context name 'context_name'
00049   // Return true if sucessfull, false otherwise
00050   static bool bind(const std::string& context_name, Factory* factory) ;
00051   static GenAction* resolve(const std::string& complete_name) ;
00052   static void binded(std::vector<std::string>& list) ;
00053   static void unbind_all() ;
00054   // Retrun the context name of the binded object
00055   static std::string context_name(GenObject* object) ;
00056 
00057 protected:
00058   static void initialize(const std::string& the_factory_name) ;
00059   static void terminate(const std::string& the_factory_name) ;
00060   static void binded_list(NamingContext* ctxt, Name& full_path, std::vector<std::string>& list) ;
00061   friend class P3DTools_p3dactions_libinit ;
00062   
00063 } ;
00064 
00065 
00066 END_LIB_NAMESPACE
00067 
00068 // --------------------------------------------------
00069 
00070 #define BIND_ACTION_CONTEXT(CONTEXT, OBJECT) \
00071   ActionsFactory::bind(CONTEXT, new GenericFactory<OBJECT> ) ;
00072 
00073 #define __BIND_ACTION__(obj,OBJECT) \
00074 ActionsFactory::bind(  \
00075   (obj->name_space()==""? \
00076     (obj->command_name()): \
00077     (obj->name_space()+ Name::separator() + obj->command_name()) \
00078   ) , \
00079   new GenericFactory<OBJECT> ) ;
00080 
00081 #define BIND_ACTION(OBJECT) \
00082   __BIND_ACTION__((new OBJECT),OBJECT)
00083 
00084 #endif
00085 

Generated on Wed May 14 11:42:30 2003 for Esla-lib by doxygen1.3-rc1