9 #ifndef RMF_DECORATOR_REPRESENTATION_H
10 #define RMF_DECORATOR_REPRESENTATION_H
12 #include <RMF/config.h>
19 #include <RMF/internal/paths.h>
21 #include <boost/lexical_cast.hpp>
34 std::vector<T> get_it(
const Ints &in)
const {
37 ret.push_back(get_node().get_file().get_node(
NodeID(i)));
43 :
Decorator(nh), representation_(representation) {}
48 return get_it<NodeConstHandle>(get_node().get_value(representation_));
50 RMF_DECORATOR_CATCH();
54 return get_it<NodeConstHandle>(
55 get_node().get_frame_value(representation_));
57 RMF_DECORATOR_CATCH();
61 return get_it<NodeConstHandle>(
62 get_node().get_static_value(representation_));
64 RMF_DECORATOR_CATCH();
67 static std::string get_decorator_type_name() {
return "RepresentationConst"; }
77 Ints set_it(
const std::vector<T> &in)
const {
79 ret.reserve(in.size());
80 for(T n : in) { ret.push_back(n.get_id().get_index()); }
85 ret.reserve(in.size());
86 for(
NodeID n : in) { ret.push_back(n.get_index()); }
91 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
92 void set_representation(
Ints v) {
96 RMF_DECORATOR_CATCH();
98 void set_frame_representation(
Ints v) {
102 RMF_DECORATOR_CATCH();
104 void set_static_representation(
Ints v) {
108 RMF_DECORATOR_CATCH();
113 set_representation(set_it(v));
115 RMF_DECORATOR_CATCH();
119 set_frame_representation(set_it(v));
121 RMF_DECORATOR_CATCH();
125 set_static_representation(set_it(v));
127 RMF_DECORATOR_CATCH();
131 set_representation(set_it(v));
133 RMF_DECORATOR_CATCH();
135 void set_frame_representation(
const NodeHandles &v) {
137 set_frame_representation(set_it(v));
139 RMF_DECORATOR_CATCH();
141 void set_static_representation(
const NodeHandles &v) {
143 set_static_representation(set_it(v));
145 RMF_DECORATOR_CATCH();
148 void set_representation(
const NodeIDs &v) {
150 set_representation(set_it(v));
152 RMF_DECORATOR_CATCH();
154 void set_frame_representation(
const NodeIDs &v) {
156 set_frame_representation(set_it(v));
158 RMF_DECORATOR_CATCH();
160 void set_static_representation(
const NodeIDs &v) {
162 set_static_representation(set_it(v));
164 RMF_DECORATOR_CATCH();
169 return get_it<NodeHandle>(get_node().get_value(representation_));
171 RMF_DECORATOR_CATCH();
175 return get_it<NodeHandle>(get_node().get_frame_value(representation_));
177 RMF_DECORATOR_CATCH();
181 return get_it<NodeHandle>(get_node().get_static_value(representation_));
183 RMF_DECORATOR_CATCH();
186 static std::string get_decorator_type_name() {
return "Representation"; }
197 : cat_(fh.get_category(
"feature")),
198 representation_(fh.
get_key<IntsTag>(cat_,
"representation")) {}
200 : cat_(fh.get_category(
"feature")),
201 representation_(fh.
get_key<IntsTag>(cat_,
"representation")) {}
205 std::string(
"Bad node type. Got \"") +
206 boost::lexical_cast<std::string>(nh.get_type()) +
207 "\" in decorator type Representation");
213 std::string(
"Bad node type. Got \"") +
214 boost::lexical_cast<std::string>(nh.get_type()) +
215 "\" in decorator type Representation");
222 !nh.get_value(representation_).get_is_null();
226 !nh.get_static_value(representation_).get_is_null();
230 struct RepresentationConstFactory :
public RepresentationFactory {
231 RepresentationConstFactory(FileConstHandle fh) : RepresentationFactory(fh) {}
232 RepresentationConstFactory(FileHandle fh) : RepresentationFactory(fh) {}
Mostly empty base classes for decorators and factories.
const NodeType FEATURE
Store information about some feature of the system.
A handle for a particular node in the hierarchy.
The base class for decorators.
NodeType get_type() const
get the type of this node
A handle for a particular node in a read-only hierarchy.
std::vector< NodeHandle > NodeHandles
Pass a list of them.
A handle for a read-only RMF file.
void set_value(ID< Tag > k, typename Tag::ArgumentType v) const
A handle for an RMF file.
The base class for Factories.
Declaration for RMF::FileHandle.
Declaration of NodeHandle.
void set_static_value(ID< Tag > k, typename Tag::ArgumentType v) const
set the value of the attribute k for all frames.
std::vector< NodeConstHandle > NodeConstHandles
Pass a list of them.
ID< Tag > get_key(Category category, std::string name) const
bool get_is(NodeConstHandle nh) const
Various general useful macros for IMP.
std::vector< NodeID > NodeIDs
void set_frame_value(ID< Tag > k, typename Tag::ArgumentType v) const
set the value of the attribute k for this node on the current frame.