/
links.h
79 lines (63 loc) · 1.68 KB
/
links.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* \file IMP/rmf/links.h
* \brief Manage links between \imp objects and a part of the RMF file.
*
* Copyright 2007-2022 IMP Inventors. All rights reserved.
*
*/
#ifndef IMPRMF_LINKS_H
#define IMPRMF_LINKS_H
#include <IMP/rmf/rmf_config.h>
#include <RMF/NodeHandle.h>
#include <RMF/FileHandle.h>
#include <IMP/Object.h>
#include <IMP/Pointer.h>
#include <IMP/object_macros.h>
#include <IMP/log_macros.h>
IMPRMF_BEGIN_NAMESPACE
class SaveLink;
class LoadLink;
IMP_OBJECTS(SaveLink, SaveLinks);
IMP_OBJECTS(LoadLink, LoadLinks);
/** Manage a link between an \imp object and a part
of the RMF file. This allows conformations to be
loaded flexibly.
LoadLinks must not save any handles to RMF objects.
\unstable{LoadLink}
*/
class IMPRMFEXPORT LoadLink : public Object {
bool frame_loaded_;
protected:
virtual void do_load(RMF::FileConstHandle fh) = 0;
LoadLink(std::string name);
public:
void load(RMF::FileConstHandle fh) {
IMP_OBJECT_LOG;
set_was_used(true);
do_load(fh);
frame_loaded_ = true;
}
IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR(LoadLink);
};
/** Manage a link between an \imp object and a part
of the RMF file. This allows conformations to be
saved flexibly.
SaveLinks must not save any handles to RMF objects.
\unstable{SaveLink}
*/
class IMPRMFEXPORT SaveLink : public Object {
bool frame_saved_;
protected:
virtual void do_save(RMF::FileHandle hf) = 0;
SaveLink(std::string name);
public:
void save(RMF::FileHandle fh) {
IMP_OBJECT_LOG;
set_was_used(true);
do_save(fh);
frame_saved_ = true;
}
IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR(SaveLink);
};
IMPRMF_END_NAMESPACE
#endif /* IMPRMF_LINKS_H */