IMP logo
IMP Reference Guide  2.15.0
The Integrative Modeling Platform
associations.h
Go to the documentation of this file.
1 /**
2  * \file IMP/rmf/associations.h
3  * \brief Track associations between an RMF file and native objects.
4  *
5  * Copyright 2007-2021 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/Object.h>
15 #include <IMP/Pointer.h>
16 #include <IMP/object_macros.h>
17 #include <IMP/log_macros.h>
18 #include <RMF/names.h>
19 
20 IMPRMF_BEGIN_NAMESPACE
21 
22 typedef Object *AssociationType;
23 
24 IMPRMFEXPORT void set_association(RMF::NodeConstHandle nh, 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  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 and native objects.
37  In the \imp case these are IMP::Object and we provide some special
38  methods to aid in this process.
39  @{
40 */
41 IMPRMFEXPORT RMF::NodeConstHandle get_node_from_association(
42  RMF::FileConstHandle nh, Object *oi);
43 
44 IMPRMFEXPORT RMF::NodeHandle get_node_from_association(RMF::FileHandle nh,
45  Object *oi);
46 IMPRMFEXPORT bool get_has_associated_node(RMF::FileConstHandle nh,
47  Object *oi);
48 
49 /** @} */
50 
51 IMPRMF_END_NAMESPACE
52 
53 #endif /* IMPRMF_ASSOCIATIONS_H */
Helper macros for implementing IMP Objects.
Logging and error reporting support.
A nullptr-initialized pointer to an IMP Object.
A shared base class to help in debugging and things.