D
DomoChan
I have a component which basically stores objects shared across other
parts of the application. the function accepts a pointer to an
interface. to make things a bit more clear...
// StorageComponent.h
.....
map< string, INode* > m_resources;
// StorageComponent.cpp
....
StorageComponent::AddResource( string key, INode* resource, int
resourceSize )
{
// I need to 'new' the sourceObject here so that the memory is
moved to this class
// but, I only have an interface to work with
void* copy = new char[ resourceSize ];
memcopy( copy, resource, resourceSize );
m_resources[ key ] = (INode*) copy;
}
Does anyone know of a better way to do this? is the way this is done
post any problems. I do use stl, and to my surprise, the object can
be cast back to its derived type and everything translates ok.
Thanks very much for any assistance!
-Velik
parts of the application. the function accepts a pointer to an
interface. to make things a bit more clear...
// StorageComponent.h
.....
map< string, INode* > m_resources;
// StorageComponent.cpp
....
StorageComponent::AddResource( string key, INode* resource, int
resourceSize )
{
// I need to 'new' the sourceObject here so that the memory is
moved to this class
// but, I only have an interface to work with
void* copy = new char[ resourceSize ];
memcopy( copy, resource, resourceSize );
m_resources[ key ] = (INode*) copy;
}
Does anyone know of a better way to do this? is the way this is done
post any problems. I do use stl, and to my surprise, the object can
be cast back to its derived type and everything translates ok.
Thanks very much for any assistance!
-Velik