9#ifndef RMF_NODE_CONST_HANDLE_H
10#define RMF_NODE_CONST_HANDLE_H
12#include <boost/any.hpp>
13#include <boost/current_function.hpp>
21#include "RMF/config.h"
24#include "RMF/internal/SharedData.h"
25#include "RMF/internal/errors.h"
28#include "RMF/internal/SharedData.h"
39#define RMF_NODE_CATCH(extra_info) \
40 catch (Exception& e) { \
42 File(get_file_name()) << Node(get_id()) \
43 << Frame(get_current_frame_id()) \
44 << Operation(BOOST_CURRENT_FUNCTION) extra_info, \
48#define RMF_NODE_CATCH_KEY(k, extra_info) \
49 RMF_NODE_CATCH(<< Key(get_name(k)) \
50 << Category(get_category_name(k)) extra_info)
53#define RMF_HDF5_NODE_CONST_KEY_TYPE_METHODS_DECL(Traits, UCName)
55#define RMF_HDF5_NODE_CONST_KEY_TYPE_METHODS_DECL(Traits, UCName) \
57 Nullable<UCName> get_value(UCName##Key k) const; \
58 bool get_has_value(UCName##Key k) const; \
59 Nullable<UCName> get_frame_value(UCName##Key k) const; \
60 Nullable<UCName> get_static_value(UCName##Key k) const;
81class RMFEXPORT NodeConstHandle
87 friend class FileHandle;
88 int compare(
const NodeConstHandle& o)
const {
91 else if (node_ > o.node_)
93 else if (shared_.get() < o.shared_.get())
95 else if (shared_.get() > o.shared_.get())
104 if (shared_->get_loaded_frame() !=
FrameID()) {
106 if (!ret.get_is_null())
return ret;
108 return get_static_value(k);
113 std::shared_ptr<internal::SharedData> shared_;
115 std::string get_file_name()
const;
117 FrameID get_current_frame_id()
const;
119#if !defined(SWIG) && !defined(RMF_DOXYGEN)
121 NodeConstHandle(
NodeID node, std::shared_ptr<internal::SharedData> shared);
125#if !defined(RMF_DOXYGEN) && !defined(SWIG)
126 std::shared_ptr<internal::SharedData> get_shared_data()
const {
131 operator NodeID()
const {
return node_; }
141 std::string
get_name()
const {
return shared_->get_name(node_); }
150 return get_value_impl(k);
153 bool get_has_value(ID<Tag> k)
const {
154 return !get_value(k).get_is_null();
157 Nullable<typename Tag::Type> get_frame_value(ID<Tag> k)
const {
158 RMF_USAGE_CHECK(shared_->get_loaded_frame() !=
FrameID(),
159 "Need to set a current frame before getting frame values.");
160 return shared_->get_loaded_value(node_, k);
163 Nullable<typename Tag::Type> get_static_value(ID<Tag> k)
const {
164 return shared_->get_static_value(node_, k);
186 shared_->set_association(node_, v, overwrite);
189 void set_association(
void* v,
bool overwrite =
false)
const;
195 return boost::any_cast<T>(shared_->get_association(node_));
198 bool get_has_association()
const {
199 return shared_->get_has_association(node_);
207 RMF_SHOWABLE(
NodeConstHandle, get_name() <<
"(" << get_type() <<
", " << node_
A helper class for allowing nice return of possibly null values.
A handle for a read-only RMF file.
A general purpose ID in RMF used, with different tags, to identify things.
A handle for a particular node in a read-only hierarchy.
std::string get_name() const
void set_association(const T &v, bool overwrite=false) const
T get_association() const
Return the associated pointer for this node.
NodeType get_type() const
get the type of this node
Return a possibly null value.
The various enums used in RMF.
Declarations of the various exception types.
Various general useful macros for IMP.
#define RMF_HASHABLE(name, hashret)
Implement a hash function for the class.
#define RMF_COMPARISONS(Name)
Implement comparison in a class using field as the variable to compare.
#define RMF_FOREACH_TYPE(macroname)
Declarations of the various key types.
The namespace for all functionality in the library.
Enum< NodeTypeTag > NodeType
std::vector< NodeConstHandle > NodeConstHandles
Pass a list of them.
std::size_t hash_value(const BufferConstHandle &t)
Produce hash values for boost hash tables.
Handle read/write of Model data from/to files.
Default implementation for types.h.