SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
ResourceLinks.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_ResourceLinks_h
12 #define smtk_resource_ResourceLinks_h
13 
14 #include "smtk/CoreExports.h"
15 #include "smtk/PublicPointerDefs.h"
16 
17 #include "smtk/common/Links.h"
18 #include "smtk/common/UUID.h"
19 
20 #include "smtk/resource/ComponentLinks.h"
21 #include "smtk/resource/Surrogate.h"
22 
23 #include "smtk/resource/Links.h"
24 
25 #include <set>
26 
27 namespace smtk
28 {
29 namespace resource
30 {
31 class Resource;
32 
33 namespace detail
34 {
36  : public Surrogate
37  , public ComponentLinks::Data
38 {
39 public:
40  ResourceLinkBase(const ResourceLinkBase&) = default;
42 
44  const std::size_t& index,
45  const std::string& typeName,
46  const smtk::common::UUID& id,
47  const std::string& location)
48  : Surrogate(index, typeName, id, location)
49  {
50  }
51 
54  {
55  }
56 
57  ResourceLinkBase(Surrogate&& surrogate)
58  : Surrogate(surrogate)
59  {
60  }
61 
62  ~ResourceLinkBase() override = default;
63 };
64 
71 class SMTKCORE_EXPORT ResourceLinks : public Links
72 {
75 
76 public:
77  friend class smtk::resource::Resource;
78 
79  typedef smtk::common::
80  Links<smtk::common::UUID, smtk::common::UUID, smtk::common::UUID, int, ResourceLinkBase>
82 
83  typedef ResourceLinkData::Link Link;
84 
85  ~ResourceLinks();
86 
88  ResourceLinkData& data() { return m_data; }
89  const ResourceLinkData& data() const { return m_data; }
90 
93  bool resolve(const ResourcePtr&) const;
94 
97  bool removeAllLinksTo(const ResourcePtr&);
98 
99 private:
100  ResourceLinks(Resource*);
101 
102  Resource* leftHandSideResource() override;
103  const Resource* leftHandSideResource() const override;
104 
105  Resource* m_resource;
106  ResourceLinkData m_data;
107 };
108 } // namespace detail
109 } // namespace resource
110 } // namespace smtk
111 
112 #endif // smtk_resource_ResourceLinks_h
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
PublicPointerDefs.h
smtk::resource::Surrogate
A resource Surrogate is a stand-in for an actual resource.
Definition: Surrogate.h:33
smtk::resource::Surrogate::resource
ResourcePtr resource() const
Return the resource for which the instance is a surrogate.
Definition: Surrogate.cxx:65
smtk::common::UUID
Definition: UUID.h:38
smtk::resource::detail::ResourceLinkBase
Definition: ResourceLinks.h:35
smtk::resource::Resource
An abstract base class for SMTK resources.
Definition: Resource.h:59
smtk::resource::Surrogate::Surrogate
Surrogate(const Index &, const std::string &, const smtk::common::UUID &, const std::string &)
Constructor for unresolved resource.
Definition: Surrogate.cxx:26
smtk::resource::ResourcePtr
smtk::shared_ptr< smtk::resource::Resource > ResourcePtr
Definition: PublicPointerDefs.h:295