A potentially large change I am considering is to add a class into the resource hierarchy to represent artifacts (i.e., persistent objects that are files but do not contain components – things that have non-native (i.e., non-SMTK) data in them). Use cases we design for include
- simulation results (typically produced “offline” or in a long-running asynchronous operation and are read-only as far as SMTK is concerned),
- meshes (typically produced by a long-running asynchronous operation and may have some edits made by SMTK operations), and
- CAD models (may be produced offline or by interactive operations in SMTK, often edited by SMTK operations).
@johnt calls these “assets,” but that is a word I want to reserve for the information tasks exchange (“artifact” is used more frequently in the context of files than “asset,” which may refer to information more generally).
The current hierarchy is
smtk::resource::PersistentObject
+-- smtk::resource::Component
+-- smtk::resource::Resource
+-- smtk::geometry::Resource (*)
+-- smtk::attribute::Resource (*)
... + others ...
(* = via DerivedFrom)
Alternative 1 (Preferred)
If we insert a class between PersistentObject and Resource, we get a new branch point:
smtk::resource::PersistentObject
+-- smtk::resource::Artifact
+-- smtk::resource::Resource
+-- smtk::geometry::Resource (*)
+-- smtk::attribute::Resource (*)
+-- smtk::model::Resource (*)
+-- smtk::session::polygon::Resource (*)
... + others ...
+-- smtk::mesh::Resource (*)
+-- smtk::resource::Component
(* = via DerivedFrom)
Since artifacts would not be SMTK-formatted JSON files,
-
Artifact
would not have properties or links but could have queries associated with them (i.e., bounding box, filesystem size/SHA, etc.). They would have names and locations (URLs). -
Resource
would inherit its name, location, and queries fromArtifact
but add API for links, properties, and components (find/visit/filter).
We could use Artifact without further inheritance, but in all likelihood we would derive SimulationArtifact, MeshArtifact, ModelArtifact, etc. since we may wish to provide import/export operations and (especially for model resources) have a native SMTK resource own a non-native artifact (e.g., a STEP or IGES file owned by an smtk::session::opencascade::Resource
).
We might also introduce the concept of “remote-ness” (i.e., resources held on remote computers) to Artifact or a subclass. I don’t think that an object being remote should require it being an instance of a separate class – so I’m not sure it makes a difference to this change – but it’s worth bringing up.
The ramifications of this inheritance hierarchy are:
- Artifacts can be held by the
resource::Manager
, loaded in/out of memory as needed, indexed withresource::Metadata
, observed, locked-for/consumed-by operations, handled by qtReferenceItem, marked clean/dirty, and easily added to projects. - Significant API changes would be required since the resource manager and observers would provide pointers to Artifacts rather than Resources (requiring type casting). Some function names would be deprecated (e.g.,
Manager::registerResource
,Manager::unregisterResource
). Some changes we might get around by providing function overloads (i.e., accepting visitor functions that only visit resources, not artifacts).
Alternative 2
Another option is to treat artifacts as components (i.e., subclass Component).
smtk::resource::PersistentObject
+-- smtk::resource::Component
+-- smtk::resource::Artifact
+-- smtk::resource::Resource
+-- smtk::geometry::Resource (*)
+-- smtk::attribute::Resource (*)
+-- smtk::model::Resource (*)
+-- smtk::session::polygon::Resource (*)
... + others ...
+-- smtk::mesh::Resource (*)
(* = via DerivedFrom)
The ramifications of this are:
- non-native artifacts would be owned by native SMTK resources (and/or projects, since it inherits Resource).
- Operations could produce artifacts, but there would be no read/write locking (which means if two resources owned artifacts that point to the same file, there would be no blocking to prevent simultaneous modification).
- Artifacts would not be visible/queryable in the resource manager same way as other files; a new manager would be needed if this type of query was to be handled. This might cause trouble for the use case of meshes – because we don’t always want all large meshes loaded into memory but do want them managed.
Alternative 3
smtk::resource::PersistentObject
+-- smtk::resource::Artifact
+-- smtk::resource::Component
+-- smtk::resource::Resource
+-- smtk::geometry::Resource (*)
+-- smtk::attribute::Resource (*)
+-- smtk::model::Resource (*)
+-- smtk::session::polygon::Resource (*)
... + others ...
+-- smtk::mesh::Resource (*)
(* = via DerivedFrom)
We could have Artifact inherit from PersistentObject
, but not have Resource
inherit Artifact
. The ramifications of this are
- Artifacts would not be managed by the resource manager.
- Read and write locking would not apply to artifacts or would force operations to have lots of redundant code for locking both resources and artifacts.
- Passing artifacts to operations might require a new
smtk::attribute::ItemDefinition
type and/or UI element. - New observers would be required for tasks or UI elements that wish to be notified when artifacts are added-to/removed-from an application.
- Projects would have to explicitly consume artifacts, which could be awkward for model and mesh resources (since they should not need to be aware of project but need some way to declare that they own artifacts).