Public Member Functions | Protected Attributes

nitro::ObjectManagerBasic< managing_class > Class Template Reference

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 >.

Collaboration diagram for nitro::ObjectManagerBasic< managing_class >:
Collaboration graph
[legend]

List of all members.

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

Detailed Description

template<class managing_class>
class nitro::ObjectManagerBasic< managing_class >

Class provides routine for storing of various objects.

Author:
Dodonov A.A.

Definition at line 25 of file object_manager.h.


Constructor & Destructor Documentation

template<class managing_class >
nitro::ObjectManagerBasic< managing_class >::~ObjectManagerBasic (  )  [virtual]

Destructor.

Author:
Dodonov A.A.

Definition at line 623 of file object_manager.h.

References nitro::ObjectManagerBasic< managing_class >::Release().

        {
                try
                {
                        Release();
                }
                catch( ... )
                {
                }
        }

Here is the call graph for this function:


Member Function Documentation

template<class managing_class >
managing_class * nitro::ObjectManagerBasic< managing_class >::Back ( void   ) 

Function returns the last object.

Returns:
Pointer on the last object.
Exceptions:
nitro::exception An exception of that type is thrown.
Author:
Dodonov A.A.

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 );
        }

Here is the call graph for this function:

template<class managing_class >
std::size_t nitro::ObjectManagerBasic< managing_class >::Count ( void   )  const

Function returns count of the stored objects.

Returns:
Count of the stored objects.
Exceptions:
nitro::exception An exception of that type is thrown.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

template<class managing_class >
void nitro::ObjectManagerBasic< managing_class >::DeleteObject ( const std::string &  ObjectName  ) 

Function deletes named object.

Parameters:
ObjectName - Name pf the searched object.
Note:
Cursors become invalid after this operation.
Exceptions:
nitro::exception An exception of that type is thrown.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

template<class managing_class >
void nitro::ObjectManagerBasic< managing_class >::DeleteObject ( const char *  ObjectName  ) 

Function deletes named object.

Parameters:
ObjectName - Name pf the searched object.
Note:
Cursors become invalid after this operation.
Exceptions:
nitro::exception An exception of that type is thrown.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

template<class managing_class >
std::size_t nitro::ObjectManagerBasic< managing_class >::GetObjectCursor ( const char *  ObjectName  )  const

Function provides cursor to the named object by it's name.

Parameters:
ObjectName - Name pf the searched object.
Returns:
Cursor of the object.
Exceptions:
nitro::exception An exception of that type is thrown.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

template<class managing_class >
std::size_t nitro::ObjectManagerBasic< managing_class >::GetObjectCursor ( const std::string &  ObjectName  )  const

Function provides cursor to the named object by it's name.

Parameters:
ObjectName - Name pf the searched object.
Returns:
Cursor of the object.
Exceptions:
nitro::exception An exception of that type is thrown.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

template<class managing_class >
bool nitro::ObjectManagerBasic< managing_class >::ObjectExists ( const std::string &  ObjectName  )  const

Function validates object's existance by it's name.

Parameters:
ObjectName - Name of the searched object.
Returns:
true if object exists, false otherwise.
Exceptions:
nitro::exception An exception of that type is thrown.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

template<class managing_class >
bool nitro::ObjectManagerBasic< managing_class >::ObjectExists ( const char *  ObjectName  )  const

Function validates object's existance by it's name.

Parameters:
ObjectName - Name pf the searched object.
Returns:
true if object exists, false otherwise.
Exceptions:
nitro::exception An exception of that type is thrown.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

template<class managing_class >
managing_class * nitro::ObjectManagerBasic< managing_class >::operator[] ( const char *  ObjectName  )  const

Function provides acces for named object.

Parameters:
ObjectName - Name of the requested object.
Returns:
Pointer on stored object.
Exceptions:
nitro::exception An exception of that type is thrown.
Author:
Dodonov A.A.

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 );
        }

Here is the call graph for this function:

template<class managing_class >
managing_class * nitro::ObjectManagerBasic< managing_class >::operator[] ( const std::string &  ObjectName  )  const

Function provides acces for named object.

Parameters:
ObjectName - Name of the requested object.
Returns:
Pointer on stored object.
Exceptions:
nitro::exception An exception of that type is thrown.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

template<class managing_class >
managing_class * nitro::ObjectManagerBasic< managing_class >::operator[] ( const std::size_t  ObjectCursor  )  const

Function provides acces for named object.

Parameters:
ObjectCursor - Cursor of object (has some numeric type).
Returns:
Pointer on stored object.
Exceptions:
nitro::exception An exception of that type is thrown.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

template<class managing_class >
managing_class * nitro::ObjectManagerBasic< managing_class >::operator[] ( const int  ObjectCursor  )  const

Function provides acces for named object.

Parameters:
ObjectCursor - Cursor of object (has some numeric type).
Returns:
Pointer on storedobject.
Exceptions:
nitro::exception An exception of that type is thrown.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:

template<class managing_class >
void nitro::ObjectManagerBasic< managing_class >::Release ( void   )  [virtual]

Function deletes all created objects.

Exceptions:
nitro::exception An exception of that type is thrown.
Author:
Dodonov A.A.

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 ) );
                }
        }

Here is the call graph for this function:


Member Data Documentation

template<class managing_class>
std::vector< std::pair< std::string , managing_class * > > nitro::ObjectManagerBasic< managing_class >::Objects [protected]

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

Generated by  doxygen 1.6.1