IMP logo
IMP Reference Guide  2.10.1
The Integrative Modeling Platform
RestraintInfo.h
Go to the documentation of this file.
1 /**
2  * \file IMP/RestraintInfo.h
3  * \brief Report key:value information on restraints
4  *
5  * Copyright 2007-2018 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKERNEL_RESTRAINT_INFO_H
10 #define IMPKERNEL_RESTRAINT_INFO_H
11 
12 #include <IMP/kernel_config.h>
13 #include <IMP/Object.h>
14 #include <IMP/types.h>
15 
16 IMPKERNEL_BEGIN_NAMESPACE
17 
18 //! Report key:value information on restraints
19 /** These objects are typically returned by Restraint::get_static_info()
20  or Restraint::get_dynamic_info() and are used to report information
21  about a Restraint instance as a set of key:value pairs. The primary
22  purpose is to allow restraints to be written to files, such as RMF.
23  */
24 class IMPKERNELEXPORT RestraintInfo : public Object {
25 public:
26  RestraintInfo(std::string name = "RestraintInfo %1%") : Object(name) {}
27 
28  //! Add an int value referenced by the given key
29  void add_int(std::string key, int value);
30 
31  //! Get the number of int that have been added
32  unsigned get_number_of_int() const { return int_.size(); }
33 
34  //! Get the key for the ith int mapping
35  std::string get_int_key(unsigned i) const { return int_[i].first; }
36 
37  //! Get the value for the ith int mapping
38  int get_int_value(unsigned i) const {
39  return int_[i].second;
40  }
41 
42  //! Add a float value referenced by the given key
43  void add_float(std::string key, double value);
44 
45  //! Get the number of float that have been added
46  unsigned get_number_of_float() const { return float_.size(); }
47 
48  //! Get the key for the ith float mapping
49  std::string get_float_key(unsigned i) const { return float_[i].first; }
50 
51  //! Get the value for the ith float mapping
52  double get_float_value(unsigned i) const {
53  return float_[i].second;
54  }
55 
56  //! Add a string value referenced by the given key
57  void add_string(std::string key, std::string value);
58 
59  //! Get the number of string that have been added
60  unsigned get_number_of_string() const { return string_.size(); }
61 
62  //! Get the key for the ith string mapping
63  std::string get_string_key(unsigned i) const { return string_[i].first; }
64 
65  //! Get the value for the ith string mapping
66  std::string get_string_value(unsigned i) const {
67  return string_[i].second;
68  }
69 
70  //! Add a filename value referenced by the given key
71  /** Filenames are treated similarly to strings but the caller is expected
72  to make them absolute paths before adding them here. When written to
73  file they may be converted to paths relative to the file.
74  */
75  void add_filename(std::string key, std::string value);
76 
77  //! Get the number of filename that have been added
78  unsigned get_number_of_filename() const { return filename_.size(); }
79 
80  //! Get the key for the ith filename mapping
81  std::string get_filename_key(unsigned i) const { return filename_[i].first; }
82 
83  //! Get the value for the ith filename mapping
84  std::string get_filename_value(unsigned i) const {
85  return filename_[i].second;
86  }
87 
88  //! Add a list of Float values referenced by the given key
89  void add_floats(std::string key, Floats value);
90 
91  //! Get the number of Floats that have been added
92  unsigned get_number_of_floats() const { return floats_.size(); }
93 
94  //! Get the key for the ith Floats mapping
95  std::string get_floats_key(unsigned i) const { return floats_[i].first; }
96 
97  //! Get the value for the ith Floats mapping
98  Floats get_floats_value(unsigned i) const {
99  return floats_[i].second;
100  }
101 
102  //! Add a list of filename values referenced by the given key
103  /** Filenames are treated similarly to strings but the caller is expected
104  to make them absolute paths before adding them here. When written to
105  file they may be converted to paths relative to the file.
106  */
107  void add_filenames(std::string key, Strings value);
108 
109  //! Get the number of filenames that have been added
110  unsigned get_number_of_filenames() const { return filenames_.size(); }
111 
112  //! Get the key for the ith filenames mapping
113  std::string get_filenames_key(unsigned i) const {
114  return filenames_[i].first;
115  }
116 
117  //! Get the value for the ith filenames mapping
118  Strings get_filenames_value(unsigned i) const {
119  return filenames_[i].second;
120  }
121 
123 
124 private:
125  typedef std::pair<std::string, int> IntData;
126  std::vector<IntData> int_;
127 
128  typedef std::pair<std::string, double> FloatData;
129  std::vector<FloatData> float_;
130 
131  typedef std::pair<std::string, std::string> StringData;
132  std::vector<StringData> string_, filename_;
133 
134  typedef std::pair<std::string, Floats> FloatsData;
135  std::vector<FloatsData> floats_;
136 
137  typedef std::pair<std::string, Strings> StringsData;
138  std::vector<StringsData> filenames_;
139 };
140 
141 IMPKERNEL_END_NAMESPACE
142 
143 #endif /* IMPKERNEL_RESTRAINT_INFO_H */
Basic types used by IMP.
unsigned get_number_of_filenames() const
Get the number of filenames that have been added.
std::string get_string_value(unsigned i) const
Get the value for the ith string mapping.
Definition: RestraintInfo.h:66
double get_float_value(unsigned i) const
Get the value for the ith float mapping.
Definition: RestraintInfo.h:52
unsigned get_number_of_filename() const
Get the number of filename that have been added.
Definition: RestraintInfo.h:78
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
std::string get_filename_key(unsigned i) const
Get the key for the ith filename mapping.
Definition: RestraintInfo.h:81
int get_int_value(unsigned i) const
Get the value for the ith int mapping.
Definition: RestraintInfo.h:38
std::string get_float_key(unsigned i) const
Get the key for the ith float mapping.
Definition: RestraintInfo.h:49
Floats get_floats_value(unsigned i) const
Get the value for the ith Floats mapping.
Definition: RestraintInfo.h:98
std::string get_filename_value(unsigned i) const
Get the value for the ith filename mapping.
Definition: RestraintInfo.h:84
std::string get_filenames_key(unsigned i) const
Get the key for the ith filenames mapping.
Common base class for heavy weight IMP objects.
Definition: Object.h:106
std::string get_floats_key(unsigned i) const
Get the key for the ith Floats mapping.
Definition: RestraintInfo.h:95
unsigned get_number_of_float() const
Get the number of float that have been added.
Definition: RestraintInfo.h:46
unsigned get_number_of_string() const
Get the number of string that have been added.
Definition: RestraintInfo.h:60
Report key:value information on restraints.
Definition: RestraintInfo.h:24
std::string get_int_key(unsigned i) const
Get the key for the ith int mapping.
Definition: RestraintInfo.h:35
unsigned get_number_of_int() const
Get the number of int that have been added.
Definition: RestraintInfo.h:32
A shared base class to help in debugging and things.
Object(std::string name)
Construct an object with the given name.
std::string get_string_key(unsigned i) const
Get the key for the ith string mapping.
Definition: RestraintInfo.h:63
unsigned get_number_of_floats() const
Get the number of Floats that have been added.
Definition: RestraintInfo.h:92
Strings get_filenames_value(unsigned i) const
Get the value for the ith filenames mapping.