, , ( ) . , IResource , resource-ish, , . , . IResource. , isLoaded, - . .
, :
class IResource
{
public:
virtual SomeCommonResourceBehavior(...) = 0;
virtual ~IResource() {}
};
class IResourceFactory
{
public:
virtual std::unique_ptr<IResource> CreateFromFile(...) = 0;
virtual std::unique_ptr<IResource> CreateFromMemory(...) = 0;
virtual ~IResourceFactory() {}
};
Thus, when you see a reference or non-zero pointer to IResourceanywhere in your code, you know that it has already been created.
Also, if you cannot identify SomeCommonResourceBehaviorin IResource, then you probably thought a little wrong about your design.
EDIT: If you live on the land of pre-C ++ 0x, then this boost::unique_ptr<>is an alternative in the factory. If boost is not an alternative, std::auto_ptr<>better than the original pointer.
source
share