IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
Copy.h
Go to the documentation of this file.
1/**
2 * \file IMP/atom/Copy.h
3 * \brief A decorator for keeping track of copies of a molecule.
4 *
5 * Copyright 2007-2022 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef IMPATOM_COPY_H
10#define IMPATOM_COPY_H
11
12#include <IMP/atom/atom_config.h>
13#include <IMP/macros.h>
14
15#include "Molecule.h"
16#include <IMP/Decorator.h>
17#include <vector>
18#include <limits>
19
20IMPATOM_BEGIN_NAMESPACE
21
22//! A decorator for keeping track of copies of a molecule.
23/** This decorator is for differentiating and keeping track
24 of identity when there are multiple copies of a
25 molecule in the system. It should only be applied to
26 Molecule particles.
27 */
28class IMPATOMEXPORT Copy : public Molecule {
29 static void do_setup_particle(Model *m, ParticleIndex pi,
30 int number) {
31 m->add_attribute(get_copy_index_key(), pi, number);
32 if (!Molecule::get_is_setup(m, pi)) {
34 }
35 }
36
37 public:
38 static IntKey get_copy_index_key();
39
40 IMP_DECORATOR_METHODS(Copy, Molecule);
41 //! Create a decorator for the numberth copy.
42 IMP_DECORATOR_SETUP_1(Copy, Int, number);
43
44 static bool get_is_setup(Model *m, ParticleIndex pi) {
45 return m->get_has_attribute(get_copy_index_key(), pi);
46 }
47
48 int get_copy_index() const {
49 return get_particle()->get_value(get_copy_index_key());
50 }
51};
52
53IMP_DECORATORS(Copy, Copies, ParticlesTemp);
54
55//! Walk up the hierarchy to find the current copy index.
56/** \return the copy index, or -1 if there is none.
57 */
58IMPATOMEXPORT int get_copy_index(Hierarchy h);
59
60IMPATOM_END_NAMESPACE
61
62#endif /* IMPATOM_COPY_H */
The base class for decorators.
A decorator for Molecules.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
The standard decorator for manipulating molecular structures.
static Molecule setup_particle(Model *m, ParticleIndex pi)
Definition Molecule.h:37
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
#define IMP_DECORATOR_METHODS(Name, Parent)
Various general useful macros for IMP.
int get_copy_index(Hierarchy h)
Walk up the hierarchy to find the current copy index.
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
int Int
Basic integer value.
Definition types.h:34
Key< 1 > IntKey
The type used to identify int attributes in the Particles.
Definition base_types.h:36