SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Component.h
1 //=========================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //=========================================================================
10 
11 #ifndef smtk_resource_Component_h
12 #define smtk_resource_Component_h
13 
14 #include "smtk/resource/ComponentLinks.h"
15 #include "smtk/resource/PersistentObject.h"
16 #include "smtk/resource/Properties.h"
17 
18 #include <string>
19 
20 namespace smtk
21 {
22 namespace resource
23 {
24 class Resource;
25 
43 class SMTKCORE_EXPORT Component : public PersistentObject
44 {
45  friend class Resource;
46 
47 public:
48  typedef std::function<void(const ComponentPtr&)> Visitor;
51 
55 
56  ~Component() override;
57 
63  virtual const ResourcePtr resource() const = 0;
64 
72  virtual Resource* parentResource() const { return this->resource().get(); }
73 
75  Links& links() override { return m_links; }
76  const Links& links() const override { return m_links; }
77 
79  Properties& properties() override { return m_properties; }
80  const Properties& properties() const override { return m_properties; }
81 
82 protected:
83  Component();
84 
85 private:
86  Links m_links;
87  Properties m_properties;
88 };
89 } // namespace resource
90 } // namespace smtk
91 
92 #endif // smtk_resource_Component_h
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
smtk::resource::Component::properties
Properties & properties() override
Return properties defined on this component.
Definition: Component.h:79
smtk::resource::Component::links
Links & links() override
Return the links that connect this component to external resources/components.
Definition: Component.h:75
smtkSharedFromThisMacro
#define smtkSharedFromThisMacro(...)
A macro to help with derived classes whose bases enable shared_from_this().
Definition: SharedFromThis.h:190
smtkTypeMacro
#define smtkTypeMacro(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:51
smtk::resource::detail::ComponentProperties
This specialization of smtk::resource::Properties completes aforementioned class's implementation by ...
Definition: Properties.h:461
smtkSuperclassMacro
#define smtkSuperclassMacro(...)
Add a typedef to the superclass of this class.
Definition: SharedFromThis.h:87
smtk::resource::Resource
An abstract base class for SMTK resources.
Definition: Resource.h:60
smtk::resource::Properties
Resource/Component properties store data as maps from UUIDs to values and present data as key/value p...
Definition: Properties.h:331
smtk::resource::Component
Component is the base class for records stored in an smtk::resource::Resource.
Definition: Component.h:43
smtk::resource::PersistentObject
An abstract base class for SMTK resources and their components.
Definition: PersistentObject.h:39
smtk::resource::ComponentPtr
smtk::shared_ptr< smtk::resource::Component > ComponentPtr
Definition: PublicPointerDefs.h:297
smtk::resource::Component::parentResource
virtual Resource * parentResource() const
Return a raw (not shared) pointer to the resource that owns this component.
Definition: Component.h:72
smtk::resource::ResourcePtr
smtk::shared_ptr< smtk::resource::Resource > ResourcePtr
Definition: PublicPointerDefs.h:295