|
#ifndef ___obj_managers_h__
#define ___obj_managers_h__
/*
Generic object manager
Traits for the managed objects the object
*/
template< class T >
struct _object_manager
{
// Managed type
typedef T managed_type;
// Function name : init_object
// Description : Init the managed object
// Return type : void
// Argument : managed_type& a
void init_object( managed_type& a )
{
}
// Function name : delete_object
// Description : Destroys the managed object
// Return type : void
// Argument : managed_type& a
void delete_object( managed_type& a )
{
}
};
/*
Pointer manager
*/
template< class T >
struct _pointer_manager :
public _object_manager< T >
{
// Function name : init_object
// Description : Init the managed object
// Return type : void
// Argument : managed_type& a
void init_object( managed_type& a )
{
a = NULL;
}
// Function name : delete_object
// Description : Deletes the pointer
// Return type : void
// Argument : managed_type& a
void delete_object( managed_type& a )
{
if( a != NULL )
{
delete a;
a = NULL;
}
}
};
/*
Array manager
*/
template< class T >
struct _array_manager :
public _object_manager< T >
{
// Function name : init_object
// Description : Init the managed object
// Return type : void
// Argument : managed_type& a
void init_object( managed_type& a )
{
a = NULL;
}
// Function name : delete_object
// Description : Deletes the array
// Return type : void
// Argument : managed_type& a
void delete_object( managed_type& a )
{
if( a != NULL )
{
delete[] a;
a = NULL;
}
}
};
#endif // ___obj_managers_h__
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.