IMP  2.0.1
The Integrative Modeling Platform
links.h
Go to the documentation of this file.
1 /**
2  * \file IMP/rmf/links.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_LINKS_H
10 #define IMPRMF_LINKS_H
11 
12 #include <IMP/rmf/rmf_config.h>
13 #include <RMF/NodeHandle.h>
14 #include <RMF/FileHandle.h>
15 #include <IMP/base/Object.h>
16 #include <IMP/base/Pointer.h>
17 #include <IMP/base/object_macros.h>
18 #include <IMP/base/log_macros.h>
19 
20 IMPRMF_BEGIN_NAMESPACE
21 
22 
23 #ifndef IMP_DOXYGEN
24 IMPRMFEXPORT
25 unsigned int get_load_linker_index(std::string st);
26 IMPRMFEXPORT
27 unsigned int get_save_linker_index(std::string st);
28 #endif
29 
30 class SaveLink;
31 class LoadLink;
33 
35 
36 /** Manage a link between an \imp object and a part
37  of the RMF file. This allows conformations to be
38  loaded flexibly.
39 
40  LoadLinks must not save any handles to RMF objects.
41 */
42 class IMPRMFEXPORT LoadLink: public base::Object {
43  bool frame_loaded_;
44  IMP_PROTECTED_METHOD(virtual void, do_load,
45  (RMF::FileConstHandle fh),,=0);
46  IMP_PROTECTED_CONSTRUCTOR(LoadLink,(std::string name),);
47  public:
48  void load(RMF::FileConstHandle fh) {
50  set_was_used(true);
51  do_load(fh);
52  frame_loaded_=true;
53  }
55 };
56 /** Manage a link between an \imp object and a part
57  of the RMF file. This allows conformations to be
58  saved flexibly.
59 
60  SaveLinks must not save any handles to RMF objects.
61 */
62 class IMPRMFEXPORT SaveLink: public base::Object {
63  bool frame_saved_;
64  IMP_PROTECTED_METHOD(virtual void,
65  do_save, (RMF::FileHandle hf),,=0);
66  IMP_PROTECTED_CONSTRUCTOR(SaveLink, (std::string name),);
67 public:
68  void save(RMF::FileHandle fh) {
70  set_was_used(true);
71  do_save(fh);
72  frame_saved_=true;
73  }
75 };
76 
77 
78 IMPRMF_END_NAMESPACE
79 
80 #endif /* IMPRMF_LINKS_H */