Class provides routine for storing of various objects. More...
#include <managers/object_manager.h>
Inherited by nitro::LocalObjectManager< managing_class >, and nitro::ObjectManager< managing_class >.
Public Member Functions | |
managing_class * | operator[] (const int ObjectCursor) const |
managing_class * | operator[] (const std::size_t ObjectCursor) const |
managing_class * | operator[] (const char *ObjectName) const |
managing_class * | operator[] (const std::string &ObjectName) const |
managing_class * | Back (void) |
virtual void | Release (void) |
std::size_t | GetObjectCursor (const std::string &ObjectName) const |
std::size_t | GetObjectCursor (const char *ObjectName) const |
bool | ObjectExists (const std::string &ObjectName) const |
bool | ObjectExists (const char *ObjectName) const |
void | DeleteObject (const std::string &ObjectName) |
void | DeleteObject (const char *ObjectName) |
std::size_t | Count (void) const |
virtual | ~ObjectManagerBasic () |
Protected Attributes | |
std::vector< std::pair < std::string, managing_class * > > | Objects |
Class provides routine for storing of various objects.
Definition at line 25 of file object_manager.h.
nitro::ObjectManagerBasic< managing_class >::~ObjectManagerBasic | ( | ) | [virtual] |
Destructor.
Definition at line 623 of file object_manager.h.
References nitro::ObjectManagerBasic< managing_class >::Release().
{ try { Release(); } catch( ... ) { } }
managing_class * nitro::ObjectManagerBasic< managing_class >::Back | ( | void | ) |
Function returns the last object.
nitro::exception | An exception of that type is thrown. |
Definition at line 437 of file object_manager.h.
References nitro::exception::code(), nitro::ObjectManagerBasic< managing_class >::Objects, and nitro::exception::what().
{ try { if( Objects.size() == 0 ) { throw( nitro::exception( std::string( "There are no objects in the manager" ) , 1 ) ); } return( Objects.back() ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::operator[]( const str_type ObjectName )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::operator[]( const str_type ObjectName )::An error occured" ) , 1 ) ); } // типа чтобы ворнинг задавить, хотя на самом деле сюда никогда управление не передастся return( ( managing_class * )NULL ); }
std::size_t nitro::ObjectManagerBasic< managing_class >::Count | ( | void | ) | const |
Function returns count of the stored objects.
nitro::exception | An exception of that type is thrown. |
Definition at line 607 of file object_manager.h.
References nitro::exception::code(), nitro::ObjectManagerBasic< managing_class >::Objects, and nitro::exception::what().
Referenced by nitro::MVC::ExecuteCommand().
{ try { return( Objects.size() ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::Count( void )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::Count( void )::An error occured" ) , 1 ) ); } }
void nitro::ObjectManagerBasic< managing_class >::DeleteObject | ( | const std::string & | ObjectName | ) |
Function deletes named object.
ObjectName | - Name pf the searched object. |
nitro::exception | An exception of that type is thrown. |
Definition at line 565 of file object_manager.h.
References nitro::exception::code(), and nitro::exception::what().
{ try { DeleteObject( ObjectName.c_str() ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::DeleteObject( const str_type & ObjectName )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::DeleteObject( const str_type & ObjectName )::An error occured" ) , 1 ) ); } }
void nitro::ObjectManagerBasic< managing_class >::DeleteObject | ( | const char * | ObjectName | ) |
Function deletes named object.
ObjectName | - Name pf the searched object. |
nitro::exception | An exception of that type is thrown. |
Definition at line 581 of file object_manager.h.
References nitro::exception::code(), nitro::ObjectManagerBasic< managing_class >::GetObjectCursor(), nitro::ObjectManagerBasic< managing_class >::ObjectExists(), nitro::ObjectManagerBasic< managing_class >::Objects, and nitro::exception::what().
{ try { if( ObjectExists( ObjectName ) == false ) { throw( std::string( "Object \"" ) + ObjectName + "\" does not exist" ); } else { // удаляем элемент массива Objects.erase( Objects.begin() + GetObjectCursor( ObjectName ) ); // после этого все курсоры становятся невалидными } } catch( nitro::exception e ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::DeleteObject( const char * ObjectName )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::DeleteObject( const char * ObjectName )::An error occured" ) , 1 ) ); } }
std::size_t nitro::ObjectManagerBasic< managing_class >::GetObjectCursor | ( | const char * | ObjectName | ) | const |
Function provides cursor to the named object by it's name.
ObjectName | - Name pf the searched object. |
nitro::exception | An exception of that type is thrown. |
Definition at line 501 of file object_manager.h.
References nitro::exception::code(), nitro::ObjectManagerBasic< managing_class >::Objects, and nitro::exception::what().
{ try { for( std::size_t i( 0 ) ; i < Objects.size() ; i++ ) { if( Objects[ i ].first == ObjectName ) { return( i ); } } throw( nitro::exception( std::string( "Object \"" ) + ObjectName + "\" was not found" , 1 ) ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::GetObjectCursor( const char * ObjectName )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::GetObjectCursor( const char * ObjectName )::An error occured" ) , 1 ) ); } }
std::size_t nitro::ObjectManagerBasic< managing_class >::GetObjectCursor | ( | const std::string & | ObjectName | ) | const |
Function provides cursor to the named object by it's name.
ObjectName | - Name pf the searched object. |
nitro::exception | An exception of that type is thrown. |
Definition at line 477 of file object_manager.h.
References nitro::exception::code(), nitro::ObjectManagerBasic< managing_class >::Objects, and nitro::exception::what().
Referenced by nitro::ObjectManagerBasic< managing_class >::DeleteObject().
{ try { for( std::size_t i( 0 ) ; i < Objects.size() ; i++ ) { if( Objects[ i ].first == ObjectName ) { return( i ); } } throw( nitro::exception( std::string( "Object \"" ) + ObjectName + "\" was not found" , 1 ) ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::GetObjectCursor( const std::string & ObjectName )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::GetObjectCursor( const std::string & ObjectName )::An error occured" ) , 1 ) ); } }
bool nitro::ObjectManagerBasic< managing_class >::ObjectExists | ( | const std::string & | ObjectName | ) | const |
Function validates object's existance by it's name.
ObjectName | - Name of the searched object. |
nitro::exception | An exception of that type is thrown. |
Definition at line 525 of file object_manager.h.
References nitro::exception::code(), and nitro::exception::what().
Referenced by nitro::ObjectManagerBasic< managing_class >::DeleteObject().
{ try { return( ObjectExists( ObjectName.c_str() ) ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::ObjectExists( const std::string & ObjectName )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::ObjectExists( const std::string & ObjectName )::An error occured" ) , 1 ) ); } }
bool nitro::ObjectManagerBasic< managing_class >::ObjectExists | ( | const char * | ObjectName | ) | const |
Function validates object's existance by it's name.
ObjectName | - Name pf the searched object. |
nitro::exception | An exception of that type is thrown. |
Definition at line 541 of file object_manager.h.
References nitro::exception::code(), nitro::ObjectManagerBasic< managing_class >::Objects, and nitro::exception::what().
{ try { for( std::size_t i( 0 ) ; i < Objects.size() ; i++ ) { if( Objects[ i ].first == ObjectName ) { return( true ); } } return( false ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::GetObjectCursor( const char * ObjectName )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::GetObjectCursor( const char * ObjectName )::An error occured" ) , 1 ) ); } }
managing_class * nitro::ObjectManagerBasic< managing_class >::operator[] | ( | const char * | ObjectName | ) | const |
Function provides acces for named object.
ObjectName | - Name of the requested object. |
nitro::exception | An exception of that type is thrown. |
Definition at line 394 of file object_manager.h.
References nitro::exception::code(), nitro::ObjectManagerBasic< managing_class >::Objects, and nitro::exception::what().
{ try { for( typename std::vector< std::pair< std::string , managing_class * > >::const_iterator i( Objects.begin() ) ; i != Objects.end() ; i++ ) { if( i->first == ObjectName ) { return( i->second ); } } throw( nitro::exception( std::string( "An error occured while getting object \"" ) + ObjectName + "\"" , 1 ) ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::operator[]( const char * ObjectName )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::operator[]( const char * ObjectName )::An error occured" ) , 1 ) ); } // типа чтобы ворнинг задавить, хотя на самом деле сюда никогда управление не передастся return( ( managing_class * )NULL ); }
managing_class * nitro::ObjectManagerBasic< managing_class >::operator[] | ( | const std::string & | ObjectName | ) | const |
Function provides acces for named object.
ObjectName | - Name of the requested object. |
nitro::exception | An exception of that type is thrown. |
Definition at line 421 of file object_manager.h.
References nitro::exception::code(), and nitro::exception::what().
{ try { return( ( * this )[ ObjectName.c_str() ] ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::operator[]( const std::string & ObjectName )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::operator[]( const std::string & ObjectName )::An error occured" ) , 1 ) ); } }
managing_class * nitro::ObjectManagerBasic< managing_class >::operator[] | ( | const std::size_t | ObjectCursor | ) | const |
Function provides acces for named object.
ObjectCursor | - Cursor of object (has some numeric type). |
nitro::exception | An exception of that type is thrown. |
Definition at line 373 of file object_manager.h.
References nitro::exception::code(), nitro::ObjectManagerBasic< managing_class >::Objects, and nitro::exception::what().
{ try { if( ( std::size_t )ObjectCursor >= Objects.size() ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::operator[]( const std::size_t ObjectCursor )::An error occured while getting object by cursor" ) , 1 ) ); } return( Objects[ ObjectCursor ].second ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::operator[]( const std::size_t ObjectCursor )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::operator[]( const std::size_t ObjectCursor )::An error occured" ) , 1 ) ); } }
managing_class * nitro::ObjectManagerBasic< managing_class >::operator[] | ( | const int | ObjectCursor | ) | const |
Function provides acces for named object.
ObjectCursor | - Cursor of object (has some numeric type). |
nitro::exception | An exception of that type is thrown. |
Definition at line 352 of file object_manager.h.
References nitro::exception::code(), and nitro::exception::what().
{ try { if( ObjectCursor <= 0 ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::operator[]( const int ObjectCursor )::Negative cursors are illegal" ) , 1 ) ); } return( ( * this )[ ( std::size_t )ObjectCursor ] ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::operator[]( const int ObjectCursor )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::operator[]( const int ObjectCursor )::An error occured" ) , 1 ) ); } }
void nitro::ObjectManagerBasic< managing_class >::Release | ( | void | ) | [virtual] |
Function deletes all created objects.
nitro::exception | An exception of that type is thrown. |
Reimplemented in nitro::LocalObjectManager< managing_class >.
Definition at line 461 of file object_manager.h.
References nitro::exception::code(), nitro::ObjectManagerBasic< managing_class >::Objects, and nitro::exception::what().
Referenced by nitro::ObjectManager< managing_class >::~ObjectManager(), and nitro::ObjectManagerBasic< managing_class >::~ObjectManagerBasic().
{ try { Objects.erase( Objects.begin(), Objects.end() ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::Release( void )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "ObjectManagerBasic< managing_class >::Release( void )::An error occured" ) , 1 ) ); } }
std::vector< std::pair< std::string , managing_class * > > nitro::ObjectManagerBasic< managing_class >::Objects [protected] |
List of named objects.
Definition at line 349 of file object_manager.h.
Referenced by nitro::ObjectManagerBasic< managing_class >::Back(), nitro::ObjectManagerBasic< managing_class >::Count(), nitro::ObjectManagerBasic< managing_class >::DeleteObject(), nitro::ObjectManagerBasic< managing_class >::GetObjectCursor(), nitro::ObjectManagerBasic< managing_class >::ObjectExists(), nitro::ObjectManagerBasic< managing_class >::operator[](), and nitro::ObjectManagerBasic< managing_class >::Release().