IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
ExampleSingletonModifier.h
Go to the documentation of this file.
1/**
2 * \file IMP/example/ExampleSingletonModifier.h
3 * \brief A singleton modifier which wraps an attribute into a
4 * given range.
5 *
6 * Copyright 2007-2026 IMP Inventors. All rights reserved.
7 */
8
9#ifndef IMPEXAMPLE_EXAMPLE_SINGLETON_MODIFIER_H
10#define IMPEXAMPLE_EXAMPLE_SINGLETON_MODIFIER_H
11
12#include <IMP/example/example_config.h>
16#include <cereal/access.hpp>
17#include <cereal/types/base_class.hpp>
18
19IMPEXAMPLE_BEGIN_NAMESPACE
20
21//! An example singleton modifier
22/** A simple singleton modifier which ensures the x,y,z coordinates
23 stay in a box by wrapping them.
24
25 Such a class could be coupled with an IMP::core::SingletonConstraint
26 or IMP::container::SingletonsConstraint to keep a set of particles
27 in a box.
28
29 \include range_restriction.py
30
31 The source code is as follows:
32 \include ExampleSingletonModifier.h
33 \include ExampleSingletonModifier.cpp
34 */
35class IMPEXAMPLEEXPORT ExampleSingletonModifier : public SingletonModifier {
37
38 friend class cereal::access;
39 template<class Archive> void serialize(Archive &ar) {
40 ar(cereal::base_class<SingletonModifier>(this), bb_);
41 }
42 IMP_OBJECT_SERIALIZE_DECL(ExampleSingletonModifier);
43
44 public:
45 ExampleSingletonModifier(const algebra::BoundingBoxD<3> &bb);
46 ExampleSingletonModifier() {}
47
48 algebra::BoundingBoxD<3> get_bounding_box() const { return bb_; }
49
50 // note, Doxygen wants a semicolon at the end of macro lines
51 virtual void apply_index(Model *m, ParticleIndex p) const
52 override;
54 Model *m, const ParticleIndexes &pis) const override;
56 Model *m, const ParticleIndexes &pis) const override;
57 IMP_SINGLETON_MODIFIER_METHODS(ExampleSingletonModifier);
58 IMP_OBJECT_METHODS(ExampleSingletonModifier);
59};
60
61IMPEXAMPLE_END_NAMESPACE
62
63#endif /* IMPEXAMPLE_EXAMPLE_SINGLETON_MODIFIER_H */
A bounding box in D dimensions.
A Modifier on ParticlesTemp.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
An axis-aligned bounding box.
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const override
Overload this method to specify the inputs.
virtual void apply_index(Model *m, ParticleIndex p) const override
virtual ModelObjectsTemp do_get_outputs(Model *m, const ParticleIndexes &pis) const override
Overload this method to specify the outputs.
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
Definition base_types.h:199
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition base_types.h:122
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Macros for various classes.
#define IMP_SINGLETON_MODIFIER_METHODS(Name)