IMP  2.0.1
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 Model data from/to files.
4  *
5  * Copyright 2007-2013 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 
22 
24 class SaveLink;
26 class LoadLink;
28 
29 IMPRMFEXPORT
30 void set_association(RMF::NodeConstHandle nh,
31  base::Object *o, bool overwrite=false);
32 
33 template <class T>
34 inline T* get_association(RMF::NodeConstHandle nh) {
36  = nh.get_association<AssociationType >();
37  base::Object *op= o;
38  return dynamic_cast<T*>(op);
39 }
40 
41 
42 /** \name Associations
43  RMF supports tracking associations between an RMF file an native objects.
44  In the \imp case these are IMP::base::Object and we provide some special
45  methods aid in this process.
46  @{
47 */
48 IMPRMFEXPORT RMF::NodeConstHandle
49 get_node_from_association(RMF::FileConstHandle nh,
50  base::Object *oi);
51 
52 IMPRMFEXPORT RMF::NodeHandle get_node_from_association(RMF::FileHandle nh,
53  base::Object *oi);
54 IMPRMFEXPORT
55 bool get_has_associated_node(RMF::FileConstHandle nh,
56  base::Object*oi);
57 
58 /** @} */
59 
60 IMPRMFEXPORT bool get_has_linker(RMF::FileConstHandle nh,
61  unsigned int id);
62 
63 #ifndef SWIG
64 IMPRMFEXPORT void set_linker(RMF::FileConstHandle nh,
65  unsigned int id,
66  SaveLinkAssociationType l);
67 
68 IMPRMFEXPORT void set_linker(RMF::FileConstHandle nh,
69  unsigned int id,
70  LoadLinkAssociationType l);
71 
72 IMPRMFEXPORT SaveLinkAssociationType get_save_linker(RMF::FileConstHandle nh,
73  unsigned int id);
74 
75 IMPRMFEXPORT LoadLinkAssociationType get_load_linker(RMF::FileConstHandle nh,
76  unsigned int id);
77 #endif
78 
79 IMPRMF_END_NAMESPACE
80 
81 #endif /* IMPRMF_ASSOCIATIONS_H */