RMF
Decorator.h
Go to the documentation of this file.
1 /**
2  * \file RMF/Decorator.h
3  * \brief Mostly empty base classes for decorators and factories.
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef RMF_DECORATOR_H
10 #define RMF_DECORATOR_H
11 
12 #include "RMF/config.h"
13 #include "infrastructure_macros.h"
14 #include "ID.h"
15 #include "internal/SharedData.h"
16 #include "NodeConstHandle.h"
17 #include "NodeHandle.h"
18 #include <memory>
19 
20 RMF_ENABLE_WARNINGS
21 namespace RMF {
22 
23 //! The base class for decorators.
24 /** Decorators in RMF provide high level routines to manipulate attributes
25  of nodes in the hierarchy. They are created by an associated Factory.
26 
27  See [Decorators and attributes](\ref decoratorsattributes) for more info.
28  */
29 class Decorator {
30  private:
31  NodeID id_;
32  std::shared_ptr<internal::SharedData> data_;
33 
34  protected:
36  : id_(handle.get_id()), data_(handle.get_shared_data()) {};
37 
38  NodeHandle get_node() const { return NodeHandle(id_, data_); }
39 
40  public:
41  RMF_SHOWABLE(Decorator, get_node().get_name());
42 };
43 //! The base class for Factories
44 /** This common base class for all factories is here for organizational
45  * purposes. It doesn't provide any functionality. */
46 class Factory {};
47 
48 } /* namespace RMF */
49 
50 RMF_DISABLE_WARNINGS
51 
52 #endif /* RMF_DECORATOR_H */
Declaration of RMF::ID.
NodeID get_id() const
A handle for a particular node in the hierarchy.
Definition: NodeHandle.h:60
The base class for decorators.
Definition: Decorator.h:29
A handle for a particular node in a read-only hierarchy.
The base class for Factories.
Definition: Decorator.h:46
Declaration of NodeConstHandle.
Declaration of NodeHandle.
Various general useful macros for IMP.