Go to the documentation of this file.00001 #ifndef __MVC_CORE_H__
00002 #define __MVC_CORE_H__
00003
00004 #include <memory>
00005 #include <vector>
00006
00007 #include <loaders/xml.h>
00008 #include <managers/dynamic_lib_manager.h>
00009 #include <managers/object_manager.h>
00010 #include <utilities/mvc/mvc_defines.h>
00011 #include <utilities/mvc/mvc_interfaces.h>
00012 #include <utilities/shared_pointer.h>
00013
00014 #if !defined( WIN32_PLATFORM ) && !defined( NIX_PLATFORM ) && !defined( MINGW_PLATFORM ) && !defined( CYGWIN_PLATFORM )
00015 #define WIN32_PLATFORM
00016 #endif
00017
00018 namespace nitro
00019 {
00020
00021 #define BEGIN_EXTRACTION_SECTION()\
00022 std::vector< nitro::SharedPointer< nitro::ModelInterface > > StoredModels;\
00023 std::vector< nitro::SharedPointer< nitro::ViewInterface > > StoredViews;\
00024 std::vector< nitro::SharedPointer< nitro::ControllerInterface > > StoredControllers;
00025
00026 #define DECLARE_MODEL_EXTRACTOR( TYPE_NAME , MODEL_NAME )\
00027 EXTERN_C NITRO_EXPORTING void GetModel( char * ModelName , nitro::ModelInterface * & Model , const nitro::XMLTag & ManifestPart )\
00028 {\
00029 ModelName[ 0 ] = '\0';\
00030 StoredModels.push_back( nitro::SharedPointer< nitro::ModelInterface >( ( nitro::ModelInterface * )new TYPE_NAME( ManifestPart ) ) );\
00031 Model = StoredModels.back().GetData();;\
00032 strcpy( ModelName , MODEL_NAME );\
00033 }
00034
00035 #define DECLARE_CONTROLLER_EXTRACTOR( TYPE_NAME , CONTROLLER_NAME )\
00036 EXTERN_C NITRO_EXPORTING void GetController( char * ControllerName , nitro::ControllerInterface * & Controller , const nitro::XMLTag & ManifestPart )\
00037 {\
00038 ControllerName[ 0 ] = '\0';\
00039 StoredControllers.push_back( nitro::SharedPointer< nitro::ControllerInterface >( ( nitro::ControllerInterface * )new TYPE_NAME( ManifestPart ) ) );\
00040 Controller = StoredControllers.back().GetData();;\
00041 strcpy( ControllerName , CONTROLLER_NAME );\
00042 }
00043
00044 #define DECLARE_VIEW_EXTRACTOR( TYPE_NAME , VIEW_NAME )\
00045 EXTERN_C NITRO_EXPORTING void GetView( char * ViewName , nitro::ViewInterface * & View , const nitro::XMLTag & ManifestPart )\
00046 {\
00047 ViewName[ 0 ] = '\0';\
00048 StoredViews.push_back( nitro::SharedPointer< nitro::ViewInterface >( ( nitro::ViewInterface * )new TYPE_NAME( ManifestPart ) ) );\
00049 View = StoredViews.back().GetData();\
00050 strcpy( ViewName , VIEW_NAME );\
00051 }
00052
00053 #define END_EXTRACTION_SECTION()
00054
00065 class MVC_DLL_ENTITY MVC{
00066 public:
00067
00082 MVC( void );
00083
00106 MVC( nitro::XMLTag & ManifestPart , MVC * theRootMVC = NULL );
00107
00130 void AddModel( const char * ModelName , nitro::ModelInterface * Model );
00131
00154 void AddView( const char * ViewName , ViewInterface * View );
00155
00178 void AddController( const char * ControllerName , nitro::ControllerInterface * Controller );
00179
00202 nitro::ModelInterface * GetModel( const char * ModelName );
00203
00226 nitro::ViewInterface * GetView( const char * ViewName );
00227
00250 nitro::ControllerInterface * GetController( const char * ControllerName );
00251
00274 nitro::ModelInterface * GetModel( const std::string & ModelName );
00275
00298 nitro::ViewInterface * GetView( const std::string & ViewName );
00299
00322 nitro::ControllerInterface * GetController( const std::string & ControllerName );
00323
00354 bool ExecuteCommand( const char * Command , const void * Param1 = NULL , const void * Param2 = NULL );
00355
00378 void LoadModules( const char * Path , const nitro::XMLTag & ManifestPart );
00379
00402 void LoadModule( const char * Path , const nitro::XMLTag & ManifestPart );
00403
00426 void LoadModules( const std::string & Path , const nitro::XMLTag & ManifestPart );
00427
00450 void Create( const char * Path = NULL , MVC * theRootMVC = NULL );
00451
00474 void Create( const std::string & Path , MVC * theRootMVC = NULL );
00475
00498 void Create( nitro::XMLTag & ManifestPart , MVC * theRootMVC = NULL );
00499
00514 int Entry( MAIN_FUNC_PARAMS_LIST );
00515
00534 const char * GetStartupViewName( void ) const;
00535
00554 const char * GetStartupControllerName( void ) const;
00555
00574 const char * GetStartupControllerCommand( void ) const;
00575
00586 virtual ~MVC();
00587
00588 private:
00589
00600 nitro::ObjectManager< nitro::ModelInterface > Models;
00601
00612 nitro::ObjectManager< nitro::ViewInterface > Views;
00613
00624 nitro::ObjectManager< nitro::ControllerInterface > Controllers;
00625
00636 nitro::ObjectManager< nitro::MVC > MVCObjects;
00637
00648 nitro::DynamicLibManager Modules;
00649
00660 MVC * RootMVC;
00661
00672 std::string StartupViewName;
00673
00684 std::string StartupControllerName;
00685
00696 std::string StartupControllerCommand;
00697
00720 void LoadModules( const std::vector< std::string > & ModulePaths , const nitro::XMLTag & ManifestPart );
00721
00722 };
00723
00742 MVC_DLL_ENTITY MVC * GetMainMVCObject( void );
00743
00744 };
00745
00746 #endif