[Smtk-developers] Resource Changes
Bob Obara
bob.obara at kitware.com
Mon Aug 21 15:02:04 EDT 2017
Hi All,
This weekend I changed the Resource class and added the ResourceComponent class:
class SMTKCORE_EXPORT Resource : smtkEnableSharedPtr(Resource)
{
friend class ResourceManager;
public:
smtkTypeMacro(Resource);
virtual ~Resource();
std::string location() const;
ResourceManager *manager() const
const UUID& id() const;
// Would like to get rid of the following but ResourceSet needs them
/// Identifies resource type
enum Type
{
ATTRIBUTE = 0,
MODEL,
MESH, // future
NUMBER_OF_TYPES
};
virtual Resource::Type resourceType() const = 0;
virtual ResourceComponentPtr find(const UUID& compId) const = 0;
static std::string type2String(Resource::Type t);
static Resource::Type string2Type(const std::string& s);
protected:
Resource(const UUID &myID, ResourceManager *manager);
Resource(ResourceManager *manager);
void setId(const UUID &myID);
void setLocation(const std::string &url);
private:
UUID m_id;
std::string m_url;
ResourceManager *m_manager;
};
class SMTKCORE_EXPORT ResourceComponent : smtkEnableSharedPtr(ResourceComponent)
{
friend class Resource;
public:
smtkTypeMacro(ResourceComponent);
virtual ~ResourceComponent();
virtual ResourcePtr resource() const = 0;
const UUID& id() const
{return this->m_id;}
protected:
ResourceComponent(const UUID &myID);
ResourceComponent();
void setId(const UUID &myID)
{this->m_id = myID;}
private:
UUID m_id;
};
Now there are two classes that are related to Resources : common/ResourceSet and model/StoredResource. Its ResourceSet that seems to be used the Resource::Type information and StoredResource seems to be tracking stored Model Resources. What I think needs to be done is:
ResourceSet —> Project or ResourceManager
StoredResource —> Resource (meaning we need to move some of its functionality over to Resource)
StoreResource has the following API:
class SMTKCORE_EXPORT StoredResource : public smtk::common::Resource
{
public:
smtkTypeMacro(StoredResource);
smtkCreateMacro(StoredResource);
smtkSharedFromThisMacro(smtk::common::Resource);
virtual ~StoredResource();
std::string url() const;
bool setURL(const std::string& url, bool isModified = false);
void markModified(bool isDirty = true);
bool isModified() const;
int generation() const;
bool exists(const std::string& prefix = "") const;
Resource::Type resourceType() const override { return MODEL; }
smtk::common::ResourceComponentPtr find(const smtk::common::UUID& compId) const override;
bool addEntity(const EntityRef& ent);
bool removeEntity(const EntityRef& ent);
const EntityRefs& entities() const { return this->m_entities; }
SessionRef session() const;
size_t addURLDisposition(const URLDisposition& disposition);
const std::vector<URLDisposition>& dispositions() const { return this->m_dispositions; }
bool clearDispositions();
protected:
StoredResource();
void setGeneration(int gen);
std::string m_url; // The location where this resource is stored.
int m_generation; // The generation number the last time an entity in the resource was modified.
int
m_urlGeneration; // The generation number at the last time the resource was written to/read from disk.
EntityRefs m_entities; // The model entities stored by this resource.
std::vector<URLDisposition>
m_dispositions; // Used to plan a write operation; only valid during writes.
};
The url method is already in Resource (its called location)
isModified() and markModified(..) seem to make sense
generation() - is this like modifiedTime()? Should it be a posix date-time and should it be set when the Resource is saved?
No Clue as to what Dispositions are and why we need them.
Comments?
Bob
Robert M. O'Bara, MEng.
Assistant Director of Scientific Computing
Kitware Inc.
28 Corporate Drive
Suite 101
Clifton Park, NY 12065
Phone: (518) 881- 4931
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/smtk-developers/attachments/20170821/5ad6ab22/attachment.html>
More information about the Smtk-developers
mailing list