IMP  2.0.1
The Integrative Modeling Platform
kernel/ConfigurationSet.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/ConfigurationSet.h
3  * \brief Store a set of configurations of the model.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKERNEL_CONFIGURATION_SET_H
10 #define IMPKERNEL_CONFIGURATION_SET_H
11 
12 #include <IMP/kernel/kernel_config.h>
13 #include "Object.h"
14 #include "Pointer.h"
15 #include "Model.h"
16 #include "Configuration.h"
17 #include "internal/OwnerPointer.h"
18 #include "OptimizerState.h"
19 #include "optimizer_state_macros.h"
20 #include "internal/utility.h"
22 
23 IMPKERNEL_BEGIN_NAMESPACE
24 
25 
26 //! A class to store a set of configurations of a model
27 /** The class maintains a set of structures found by a Sampler
28  protocol and allows them to be queried and loaded and saved.
29  \pythonexample{basic_optimization}
30 */
31 class IMPKERNELEXPORT ConfigurationSet: public IMP::base::Object
32 {
33  mutable Pointer<Model> model_;
34  Pointer<Configuration> base_;
35  base::Vector<Pointer<Configuration> > configurations_;
36  public:
37  ConfigurationSet(Model *m, std::string name="ConfigurationSet %1%");
38  //! Save the current configuration of the Model
39  void save_configuration();
40  unsigned int get_number_of_configurations() const;
41  //! Load the ith configuration into the Model
42  /** Passing -1 returns it to the base configuration. */
43  void load_configuration(int i) const;
44  void remove_configuration(unsigned int i);
45  Model *get_model() const {
46  return model_;
47  }
49 };
50 
52 
53 IMP_MODEL_SAVE(SaveToConfigurationSet,
54  (ConfigurationSet *cs, std::string file_name),
55  mutable OwnerPointer<ConfigurationSet> cs_;,
56  cs_=cs;,
57  ,
58  {
59  IMP_LOG_VARIABLE(file_name);
60  IMP_LOG_TERSE( "Saving to configuration set "
61  << file_name << std::endl);
62  cs_->save_configuration();
63  });
64 
65 
66 IMPKERNEL_END_NAMESPACE
67 
68 #endif /* IMPKERNEL_CONFIGURATION_SET_H */