Public Member Functions | Private Member Functions | Private Attributes

nitro::MVC Class Reference

#include <utilities/mvc/mvc_core.h>

Collaboration diagram for nitro::MVC:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MVC (void)
 MVC (nitro::XMLTag &ManifestPart, MVC *theRootMVC=NULL)
void AddModel (const char *ModelName, nitro::ModelInterface *Model)
void AddView (const char *ViewName, ViewInterface *View)
void AddController (const char *ControllerName, nitro::ControllerInterface *Controller)
nitro::ModelInterfaceGetModel (const char *ModelName)
nitro::ViewInterfaceGetView (const char *ViewName)
nitro::ControllerInterfaceGetController (const char *ControllerName)
nitro::ModelInterfaceGetModel (const std::string &ModelName)
nitro::ViewInterfaceGetView (const std::string &ViewName)
nitro::ControllerInterfaceGetController (const std::string &ControllerName)
bool ExecuteCommand (const char *Command, const void *Param1=NULL, const void *Param2=NULL)
void LoadModules (const char *Path, const nitro::XMLTag &ManifestPart)
void LoadModule (const char *Path, const nitro::XMLTag &ManifestPart)
void LoadModules (const std::string &Path, const nitro::XMLTag &ManifestPart)
void Create (const char *Path=NULL, MVC *theRootMVC=NULL)
void Create (const std::string &Path, MVC *theRootMVC=NULL)
void Create (nitro::XMLTag &ManifestPart, MVC *theRootMVC=NULL)
int Entry (MAIN_FUNC_PARAMS_LIST)
const char * GetStartupViewName (void) const
const char * GetStartupControllerName (void) const
const char * GetStartupControllerCommand (void) const
virtual ~MVC ()

Private Member Functions

void LoadModules (const std::vector< std::string > &ModulePaths, const nitro::XMLTag &ManifestPart)

Private Attributes

nitro::ObjectManager
< nitro::ModelInterface
Models
nitro::ObjectManager
< nitro::ViewInterface
Views
nitro::ObjectManager
< nitro::ControllerInterface
Controllers
nitro::ObjectManager< nitro::MVCMVCObjects
nitro::DynamicLibManager Modules
MVCRootMVC
std::string StartupViewName
std::string StartupControllerName
std::string StartupControllerCommand

Detailed Description

This class unites model, view and controller.

Author:
Dodonov A.A.

Definition at line 65 of file mvc_core.h.


Constructor & Destructor Documentation

nitro::MVC::MVC ( void   ) 

Contructor.

Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 20 of file mvc_core.cpp.

References nitro::exception::code(), RootMVC, StartupControllerCommand, StartupControllerName, StartupViewName, and nitro::exception::what().

Referenced by Create().

        {
                try
                {
                        RootMVC = NULL;
                        StartupViewName = "";
                        StartupControllerName = "";
                        StartupControllerCommand = "startup";
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::MVC( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::MVC( void )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

nitro::MVC::MVC ( nitro::XMLTag ManifestPart,
MVC theRootMVC = NULL 
)

Contructor.

Parameters:
ManifestPart - Part of the manifest.
theRootMVC - Root MVC.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 39 of file mvc_core.cpp.

References nitro::exception::code(), Create(), RootMVC, StartupControllerCommand, StartupControllerName, StartupViewName, and nitro::exception::what().

        {
                try
                {
                        RootMVC = theRootMVC;

                        StartupViewName = "";
                        StartupControllerName = "";
                        StartupControllerCommand = "startup";

                        Create( ManifestPart );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::MVC( nitro::XMLTag & ManifestPart )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::MVC( nitro::XMLTag & ManifestPart )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

nitro::MVC::~MVC (  )  [virtual]

Destructor.

Author:
Dodonov A.A.

Definition at line 485 of file mvc_core.cpp.

        {
                try
                {
                }
                catch( ... )
                {
                }
        }


Member Function Documentation

void nitro::MVC::AddController ( const char *  ControllerName,
nitro::ControllerInterface Controller 
)

Function adds controller.

Parameters:
ControllerName - Controller's name.
Controller - Controller.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 93 of file mvc_core.cpp.

References nitro::ObjectManager< managing_class >::AddObject(), nitro::exception::code(), Controllers, and nitro::exception::what().

Referenced by LoadModules().

        {
                try
                {
                        Controllers.AddObject( ControllerName , Controller );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::AddController( const char * ControllerName , nitro::ControllerInterface * Controller )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::AddController( const char * ControllerName , nitro::ControllerInterface * Controller )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

void nitro::MVC::AddModel ( const char *  ModelName,
nitro::ModelInterface Model 
)

Function adds model.

Parameters:
ModelName - Model's name.
Model - Model.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 61 of file mvc_core.cpp.

References nitro::ObjectManager< managing_class >::AddObject(), nitro::exception::code(), Models, and nitro::exception::what().

Referenced by LoadModules().

        {
                try
                {
                        Models.AddObject( ModelName , Model );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::AddModel( const char * ModelName , nitro::ModelInterface * Model )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::AddModel( const char * ModelName , nitro::ModelInterface * Model )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

void nitro::MVC::AddView ( const char *  ViewName,
nitro::ViewInterface View 
)

Function adds view.

Parameters:
ViewName - View's name.
View - View.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 77 of file mvc_core.cpp.

References nitro::ObjectManager< managing_class >::AddObject(), nitro::exception::code(), Views, and nitro::exception::what().

Referenced by LoadModules(), and nitro::Application::OnInit().

        {
                try
                {
                        Views.AddObject( ViewName , View );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::AddView( const char * ViewName , nitro::ViewInterface * View )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::AddView( const char * ViewName , nitro::ViewInterface * View )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

void nitro::MVC::Create ( nitro::XMLTag ManifestPart,
MVC theRootMVC = NULL 
)

Function creates object by it's manifest.

Parameters:
ManifestPart - Part of the manifest.
theRootMVC - Root MVC.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 353 of file mvc_core.cpp.

References nitro::ObjectManager< managing_class >::AddObject(), nitro::exception::code(), nitro::XMLTag::CountOfChildTags(), nitro::XMLTag::GetAttribute_string(), LoadModule(), LoadModules(), MVC(), MVCObjects, RootMVC, StartupControllerCommand, StartupControllerName, StartupViewName, and nitro::exception::what().

        {
                try
                {
                        RootMVC = theRootMVC;
                        for( std::size_t i( 0 ) ; i < ManifestPart.CountOfChildTags() ; i++ )
                        {
                                if( ManifestPart[ i ].Name == "setlocale" )
                                {
                                        setlocale( LC_ALL , ManifestPart[ i ].GetAttribute_string( "locale" ) );
                                        continue;
                                }

                                if( ManifestPart[ i ].Name == "dll" )
                                {
                                        LoadModule( ManifestPart[ i ].GetAttribute_string( "value" ) , ManifestPart[ i ] );
                                        continue;
                                }

                                if( ManifestPart[ i ].Name == "dlls" )
                                {
                                        LoadModules( ManifestPart[ i ].GetAttribute_string( "value" ) , ManifestPart[ i ] );
                                        continue;
                                }
                                
                                if( ManifestPart[ i ].Name == "mvc" )
                                {
                                        if( ManifestPart[ i ].AttributeExists( "path" ) )
                                        {
                                                nitro::XMLFile                  MVCManifest( ManifestPart[ i ].GetAttribute_string( "path" ) );
                                                MVCObjects.AddObject( ManifestPart[ i ].GetAttribute_string( "name" ) , new MVC( MVCManifest[ 0 ] , this ) );
                                        }
                                        
                                        MVCObjects.AddObject( ManifestPart[ i ].GetAttribute_string( "name" ) , new MVC( ManifestPart[ i ] , this ) );
                                        continue;
                                }

                                if( ManifestPart[ i ].Name == "main" )
                                {
                                        if( ManifestPart[ i ].AttributeExists( "startup_view" ) )
                                        {
                                                StartupViewName = ManifestPart[ i ].GetAttribute_string( "startup_view" );
                                        }

                                        if( ManifestPart[ i ].AttributeExists( "startup_controller" ) )
                                        {
                                                StartupControllerName = ManifestPart[ i ].GetAttribute_string( "startup_controller" );
                                        }

                                        if( ManifestPart[ i ].AttributeExists( "startup_controller_command" ) )
                                        {
                                                StartupControllerCommand = ManifestPart[ i ].GetAttribute_string( "startup_controller_command" );
                                        }

                                        continue;
                                }
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::Create( nitro::XMLTag & ManifestPart , MVC * theRootMVC /* = NULL */ )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::Create( nitro::XMLTag & ManifestPart , MVC * theRootMVC /* = NULL */ )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

void nitro::MVC::Create ( const char *  Path = NULL,
MVC theRootMVC = NULL 
)

Function creates object by it's manifest.

Parameters:
Path - Path to the manifest.
theRootMVC - Root MVC.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 305 of file mvc_core.cpp.

References nitro::exception::code(), nitro::File::FileExists(), nitro::XMLFile::GetRoot(), LoadModules(), nitro::XMLFile::LoadXML(), and nitro::exception::what().

Referenced by Create(), and MVC().

        {
                try
                {
                        std::string                     ManifestPath( "./conf/mvc_config.xml" );
                        if( Path != NULL && strlen( Path ) != 0 )
                        {
                                ManifestPath = Path;
                        }
                        
                        nitro::XMLFile          Manifest;

                        if( nitro::File::FileExists( ManifestPath ) )
                        {
                                Manifest.LoadXML( ManifestPath );
                                Create( Manifest.GetRoot() , theRootMVC );
                        }
                        else
                        {
                                this->LoadModules( std::string( "./bin" ) , Manifest );
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::Create( const char * Path /* = NULL */ , MVC * theRootMVC /* = NULL */ )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::Create( const char * Path /* = NULL */ , MVC * theRootMVC /* = NULL */ )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

void nitro::MVC::Create ( const std::string &  Path,
MVC theRootMVC = NULL 
)

Function creates object by it's manifest.

Parameters:
Path - Path to the manifest.
theRootMVC - Root MVC.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 337 of file mvc_core.cpp.

References nitro::exception::code(), Create(), and nitro::exception::what().

        {
                try
                {
                        Create( Path.c_str() , theRootMVC );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::Create( const std::string & Path , MVC * theRootMVC /* = NULL */ )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::Create( const std::string & Path , MVC * theRootMVC /* = NULL */ )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

int nitro::MVC::Entry ( MAIN_FUNC_PARAMS_LIST   ) 

Program's entry point.

Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 421 of file mvc_core.cpp.

References nitro::exception::code(), and nitro::exception::what().

        {
                try
                {
                        return( wxEntry( MAIN_FUNC_VALUES_LIST ) );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::Entry( MAIN_FUNC_PARAMS_LIST )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::Entry( MAIN_FUNC_PARAMS_LIST )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

bool nitro::MVC::ExecuteCommand ( const char *  Command,
const void *  Param1 = NULL,
const void *  Param2 = NULL 
)

Function can be used to control MVC.

Parameters:
Command - Command's name.
Param1 - First parameter.
Param2 - parameter.
Returns:
- false if the command was processed.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 205 of file mvc_core.cpp.

References nitro::exception::code(), Controllers, nitro::ObjectManagerBasic< managing_class >::Count(), Views, and nitro::exception::what().

        {
                try
                {
                        for( std::size_t i( 0 ) ; i < Controllers.Count() ; i++ )
                        {
                                if( Controllers[ i ]->ExecuteCommand( Command , Param1 , Param2 ) == false )
                                {
                                        return( false );
                                }
                        }

                        for( std::size_t i( 0 ) ; i < Views.Count() ; i++ )
                        {
                                if( Views[ i ]->ExecuteCommand( Command , Param1 , Param2 ) == false )
                                {
                                        return( false );
                                }
                        }

                        return( true );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::ExecuteCommand( const char * Command , const void * Param1 , const void * Param2  )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::ExecuteCommand( const char * Command , const void * Param1 , const void * Param2 )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

nitro::ControllerInterface * nitro::MVC::GetController ( const std::string &  ControllerName  ) 

Function returns controller.

Parameters:
ControllerName - Controller's name.
Returns:
Controller.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 189 of file mvc_core.cpp.

References nitro::exception::code(), Controllers, and nitro::exception::what().

        {
                try
                {
                        return( Controllers[ ControllerName ] );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::GetController( const std::string & ControllerName )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::GetController( const std::string & ControllerName )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

nitro::ControllerInterface * nitro::MVC::GetController ( const char *  ControllerName  ) 

Function returns controller.

Parameters:
ControllerName - Controller's name.
Returns:
Controller.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 141 of file mvc_core.cpp.

References nitro::exception::code(), Controllers, and nitro::exception::what().

Referenced by LoadModules(), and nitro::Application::OnInit().

        {
                try
                {
                        return( Controllers[ ControllerName ] );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::GetController( const char * ControllerName )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::GetController( const char * ControllerName )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

nitro::ModelInterface * nitro::MVC::GetModel ( const char *  ModelName  ) 

Function returns model.

Parameters:
ModelName - Models's name.
Returns:
Model.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 109 of file mvc_core.cpp.

References nitro::exception::code(), Models, and nitro::exception::what().

Referenced by LoadModules().

        {
                try
                {
                        return( Models[ ModelName ] );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::GetModel( const char * ModelName )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::GetModel( const char * ModelName )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

nitro::ModelInterface * nitro::MVC::GetModel ( const std::string &  ModelName  ) 

Function returns model.

Parameters:
ModelName - Models's name.
Returns:
Model.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 157 of file mvc_core.cpp.

References nitro::exception::code(), Models, and nitro::exception::what().

        {
                try
                {
                        return( Models[ ModelName ] );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::GetModel( const char * ModelName )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::GetModel( const std::string & ModelName )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

const char * nitro::MVC::GetStartupControllerCommand ( void   )  const

Getting startup controller's command.

Returns:
Startup controller's command.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 469 of file mvc_core.cpp.

References nitro::exception::code(), StartupControllerCommand, and nitro::exception::what().

        {
                try
                {
                        return( StartupControllerCommand.c_str() );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::GetStartupControllerCommand( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::GetStartupControllerCommand( void )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

const char * nitro::MVC::GetStartupControllerName ( void   )  const

Getting startup controller's name.

Returns:
Startup controller's name.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 453 of file mvc_core.cpp.

References nitro::exception::code(), StartupControllerName, and nitro::exception::what().

        {
                try
                {
                        return( StartupControllerName.c_str() );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::GetStartupControllerName( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::GetStartupControllerName( void )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

const char * nitro::MVC::GetStartupViewName ( void   )  const

Getting startup view's name.

Returns:
Startup view's name.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 437 of file mvc_core.cpp.

References nitro::exception::code(), StartupViewName, and nitro::exception::what().

        {
                try
                {
                        return( StartupViewName.c_str() );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::GetStartupViewName( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::GetStartupViewName( void )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

nitro::ViewInterface * nitro::MVC::GetView ( const std::string &  ViewName  ) 

Function returns view.

Parameters:
ViewName - View's name.
Returns:
View.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 173 of file mvc_core.cpp.

References nitro::exception::code(), Views, and nitro::exception::what().

        {
                try
                {
                        return( Views[ ViewName ] );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::GetView( const std::string & ViewName )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::GetView( const std::string & ViewName )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

nitro::ViewInterface * nitro::MVC::GetView ( const char *  ViewName  ) 

Function returns view.

Parameters:
ViewName - View's name.
Returns:
View.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 125 of file mvc_core.cpp.

References nitro::exception::code(), Views, and nitro::exception::what().

Referenced by LoadModules(), and nitro::Application::OnInit().

        {
                try
                {
                        return( Views[ ViewName ] );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::GetView( const char * ViewName )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::GetView( const char * ViewName )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

void nitro::MVC::LoadModule ( const char *  Path,
const nitro::XMLTag ManifestPart 
)

Function loads module.

Parameters:
Path Path to the plugin.
ManifestPart - Part of the manifest.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 264 of file mvc_core.cpp.

References nitro::exception::code(), nitro::File::FileExists(), LoadModules(), and nitro::exception::what().

Referenced by Create().

        {
                try
                {
                        if( nitro::File::FileExists( Path ) == false )
                        {
                                throw( nitro::exception( std::string( "Module " ) + Path + " does not exists" , 1 ) );
                        }

                        std::vector< std::string >      ModulePaths;

                        ModulePaths.push_back( std::string( Path ) );

                        LoadModules( ModulePaths , ManifestPart );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::LoadModule( const char * Path , const nitro::XMLTag & ManifestPart )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::LoadModule( const char * Path , const nitro::XMLTag & ManifestPart )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

void nitro::MVC::LoadModules ( const std::string &  Path,
const nitro::XMLTag ManifestPart 
)

Function loads modules.

Parameters:
Path - Path to the plugin directory (path to the directory or to the exact module).
ManifestPart - Part of the manifest.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 289 of file mvc_core.cpp.

References nitro::exception::code(), LoadModules(), and nitro::exception::what().

        {
                try
                {
                        LoadModules( Path.c_str() , ManifestPart );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::LoadModules( const std::string & Path , const nitro::XMLTag & ManifestPart )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::LoadModules( const std::string & Path , const nitro::XMLTag & ManifestPart )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

void nitro::MVC::LoadModules ( const char *  Path,
const nitro::XMLTag ManifestPart 
)

Function loads modules.

Parameters:
Path Path to the plugin directory (path to the directory or to the exact module).
ManifestPart - Part of the manifest.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 237 of file mvc_core.cpp.

References nitro::exception::code(), nitro::CollectFilesFromDirectory(), and nitro::exception::what().

Referenced by Create(), LoadModule(), and LoadModules().

        {
                try
                {
                        std::vector< std::string >      ModulePaths;

                        std::string                             PluginPath( "./bin/mvc/" );
                        if( Path != NULL && strlen( Path ) != 0 )
                        {
                                PluginPath = Path;
                        }
                        
                        // загрузка модулей
                        nitro::CollectFilesFromDirectory( PluginPath , ModulePaths );

                        LoadModules( ModulePaths , ManifestPart );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::LoadModules( const char * Path , const nitro::XMLTag & ManifestPart )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::LoadModules( const char * Path , const nitro::XMLTag & ManifestPart )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:

void nitro::MVC::LoadModules ( const std::vector< std::string > &  ModulePaths,
const nitro::XMLTag ManifestPart 
) [private]

Function loads modules.

Parameters:
ModulePaths - Paths to the plugin directory.
ManifestPart - Part of the manifest.
Exceptions:
nitro::exception - An exception of this type is thrown if the error occured.
Author:
Dodonov A.A.

Definition at line 495 of file mvc_core.cpp.

References AddController(), AddModel(), AddView(), nitro::exception::code(), DEFINE_DYNAMIC_ARRAY, nitro::Parsers::EndsWith(), GetController(), GetModel(), GetView(), nitro::DynamicLibManager::LoadLibrary(), Modules, and nitro::exception::what().

        {
                try
                {
                        for( std::size_t i( 0 ) ; i < ModulePaths.size() ; i++ )
                        {
                                if( nitro::Parsers::EndsWith( ModulePaths[ i ] , std::string( ".dll" ) ) )
                                {
                                        Modules.LoadLibrary( ModulePaths[ i ] );

                                        if( Modules[ ModulePaths[ i ].c_str() ]->ResourceExists( "GetModel" ) )
                                        {
                                                DEFINE_DYNAMIC_ARRAY( char , Name , 128 );
                                                nitro::ModelInterface *                 Interface;

                                                void                                                    ( * GetModel )( char * , nitro::ModelInterface * & , const nitro::XMLTag & );
                                                GetModel = ( void ( * )( char * , nitro::ModelInterface * & , const nitro::XMLTag & ) )Modules[ ModulePaths[ i ].c_str() ]->GetResource( "GetModel" );

                                                GetModel( Name , Interface , ManifestPart );

                                                AddModel( Name , Interface );
                                        }

                                        if( Modules[ ModulePaths[ i ].c_str() ]->ResourceExists( "GetView" ) )
                                        {
                                                DEFINE_DYNAMIC_ARRAY( char , Name , 128 );
                                                nitro::ViewInterface *                  Interface;

                                                void                                                    ( * GetView )( char * , nitro::ViewInterface * & , const nitro::XMLTag & );
                                                GetView = ( void ( * )( char * , nitro::ViewInterface * & , const nitro::XMLTag & ) )Modules[ ModulePaths[ i ].c_str() ]->GetResource( "GetView" );

                                                GetView( Name , Interface , ManifestPart );

                                                AddView( Name , Interface );
                                        }

                                        if( Modules[ ModulePaths[ i ].c_str() ]->ResourceExists( "GetController" ) )
                                        {
                                                DEFINE_DYNAMIC_ARRAY( char , Name , 128 );
                                                nitro::ControllerInterface *    Interface;

                                                void                                                    ( * GetController )( char * , nitro::ControllerInterface * & , const nitro::XMLTag & );
                                                GetController = ( void ( * )( char * , nitro::ControllerInterface * & , const nitro::XMLTag & ) )Modules[ ModulePaths[ i ].c_str() ]->GetResource( "GetController" );

                                                GetController( Name , Interface , ManifestPart );

                                                AddController( Name , Interface );
                                        }
                                }
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "MVC::LoadModules( const std::vector< std::string > & ModulePaths , const nitro::XMLTag & ManifestPart )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( "MVC::LoadModules( const std::vector< std::string > & ModulePaths , const nitro::XMLTag & ManifestPart )::An error occured" , 1 ) );
                }
        }

Here is the call graph for this function:


Member Data Documentation

Controllers.

Author:
Dodonov A.A.

Definition at line 624 of file mvc_core.h.

Referenced by AddController(), ExecuteCommand(), and GetController().

Models.

Author:
Dodonov A.A.

Definition at line 600 of file mvc_core.h.

Referenced by AddModel(), and GetModel().

Loaded modules.

Author:
Dodonov A.A.

Definition at line 648 of file mvc_core.h.

Referenced by LoadModules().

MVC objects.

Author:
Dodonov A.A.

Definition at line 636 of file mvc_core.h.

Referenced by Create().

Root MVC.

Author:
Dodonov A.A.

Definition at line 660 of file mvc_core.h.

Referenced by Create(), and MVC().

std::string nitro::MVC::StartupControllerCommand [private]

Startup controller.

Author:
Dodonov A.A.

Definition at line 696 of file mvc_core.h.

Referenced by Create(), GetStartupControllerCommand(), and MVC().

std::string nitro::MVC::StartupControllerName [private]

Startup controller.

Author:
Dodonov A.A.

Definition at line 684 of file mvc_core.h.

Referenced by Create(), GetStartupControllerName(), and MVC().

std::string nitro::MVC::StartupViewName [private]

Startup view.

Author:
Dodonov A.A.

Definition at line 672 of file mvc_core.h.

Referenced by Create(), GetStartupViewName(), and MVC().

Views.

Author:
Dodonov A.A.

Definition at line 612 of file mvc_core.h.

Referenced by AddView(), ExecuteCommand(), and GetView().


The documentation for this class was generated from the following files:

Generated by  doxygen 1.6.1