IMP  2.2.0
The Integrative Modeling Platform
associations.h
Go to the documentation of this file.
1 /**
2  * \file IMP/rmf/associations.h
3  * \brief Handle read/write of kernel::Model data from/to files.
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPRMF_ASSOCIATIONS_H
10 #define IMPRMF_ASSOCIATIONS_H
11 
12 #include <IMP/rmf/rmf_config.h>
13 #include "links.h"
14 #include <IMP/base/Object.h>
15 #include <IMP/base/Pointer.h>
16 #include <IMP/base/object_macros.h>
17 #include <IMP/base/log_macros.h>
18 #include <RMF/names.h>
19 
20 IMPRMF_BEGIN_NAMESPACE
21 
23 
24 IMPRMFEXPORT void set_association(RMF::NodeConstHandle nh, base::Object *o,
25  bool overwrite = false);
26 
27 template <class T>
28 inline T *get_association(RMF::NodeConstHandle nh) {
29  AssociationType o = nh.get_association<AssociationType>();
30  base::Object *op = o;
31  if (!op) return nullptr;
32  return dynamic_cast<T *>(op);
33 }
34 
35 /** \name Associations
36  RMF supports tracking associations between an RMF file an native objects.
37  In the \imp case these are IMP::base::Object and we provide some special
38  methods aid in this process.
39  @{
40 */
41 IMPRMFEXPORT RMF::NodeConstHandle get_node_from_association(
42  RMF::FileConstHandle nh, base::Object *oi);
43 
44 IMPRMFEXPORT RMF::NodeHandle get_node_from_association(RMF::FileHandle nh,
45  base::Object *oi);
46 IMPRMFEXPORT bool get_has_associated_node(RMF::FileConstHandle nh,
47  base::Object *oi);
48 
49 /** @} */
50 
51 IMPRMF_END_NAMESPACE
52 
53 #endif /* IMPRMF_ASSOCIATIONS_H */
A nullptr-initialized pointer to an IMP Object.
Logging and error reporting support.
Common base class for heavy weight IMP objects.
Definition: base/Object.h:106
Various general useful macros for IMP.
A shared base class to help in debugging and things.