IMP logo
IMP Reference Guide  develop.4eee3cf66f,2026/08/01
The Integrative Modeling Platform
Configuration.h
Go to the documentation of this file.
1 /**
2  * \file IMP/Configuration.h
3  * \brief Store a set of configurations of the model.
4  *
5  * Copyright 2007-2026 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKERNEL_CONFIGURATION_H
10 #define IMPKERNEL_CONFIGURATION_H
11 
12 #include <IMP/kernel_config.h>
13 #include <IMP/Object.h>
14 #include <IMP/Pointer.h>
15 #include "Model.h"
16 #include <cereal/access.hpp>
17 #include <cereal/types/base_class.hpp>
18 
19 IMPKERNEL_BEGIN_NAMESPACE
20 
21 //! A class to store a configuration of a model
22 class IMPKERNELEXPORT Configuration : public IMP::Object {
23  mutable Pointer<Model> model_;
24  Pointer<Object> base_;
25  internal::FloatAttributeTable floats_;
26  internal::FloatsAttributeTable float_lists_;
27  internal::StringAttributeTable strings_;
28  internal::IntAttributeTable ints_;
29  internal::ObjectAttributeTable objects_;
30  internal::WeakObjectAttributeTable weak_objects_;
31  internal::IntsAttributeTable int_lists_;
32  internal::ObjectsAttributeTable object_lists_;
33  internal::ParticleAttributeTable particles_;
34  internal::ParticlesAttributeTable particle_lists_;
35  internal::Vector3DAttributeTable vector3ds_;
36  internal::Vector4DAttributeTable vector4ds_;
37  internal::SparseStringAttributeTable sparse_strings_;
38  internal::SparseIntAttributeTable sparse_ints_;
39  internal::SparseFloatAttributeTable sparse_floats_;
40  internal::SparseParticleAttributeTable sparse_particles_;
41  internal::Vector3DDerivAttributeTable vector3d_derivs_;
42  internal::Vector4DDerivAttributeTable vector4d_derivs_;
43 
44  friend class cereal::access;
45  template<class Archive> void serialize(Archive &ar) {
46  ar(cereal::base_class<Object>(this));
47  if (std::is_base_of<cereal::detail::OutputArchiveBase, Archive>::value) {
48  uint32_t model_id = get_model_id();
49  ar(model_id);
50  } else {
51  uint32_t model_id;
52  ar(model_id);
53  set_model_from_id(model_id);
54  }
55  ar(base_, floats_, float_lists_, strings_, ints_, objects_, weak_objects_,
56  int_lists_, object_lists_, particles_, particle_lists_, vector3ds_,
57  vector4ds_, sparse_strings_, sparse_ints_, sparse_floats_,
58  sparse_particles_, vector3d_derivs_, vector4d_derivs_);
59  }
60  void set_model_from_id(uint32_t model_id);
61  uint32_t get_model_id() const;
62 
63  public:
64  Configuration(Model *m, std::string name = "Configuration %1%");
65  //! Only store parts of the configuration that have changed from base
66  /** At the moment, this does not play well with adding and removing
67  attributes.*/
69  std::string name = "Configuration %1%");
70 
71  Configuration() : Object("") {}
72 
73  void load_configuration() const;
74  //! Swap the current configuration with that in the Model
75  /** This should be faster than loading (or at least not slower).
76  */
77  void swap_configuration();
79 };
80 
82 
83 IMPKERNEL_END_NAMESPACE
84 
85 #endif /* IMPKERNEL_CONFIGURATION_H */
A class to store a configuration of a model.
Definition: Configuration.h:22
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Storage of a model, its restraints, constraints and particles.
A more IMP-like version of the std::vector.
Definition: Vector.h:50
A smart pointer to a reference counted object.
Definition: Pointer.h:87
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Common base class for heavy weight IMP objects.
Definition: Object.h:111
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Definition: object_macros.h:44
A nullptr-initialized pointer to an IMP Object.
A shared base class to help in debugging and things.
Object(std::string name)
Construct an object with the given name.