8#ifndef IMPKERNEL_DECORATOR_H
9#define IMPKERNEL_DECORATOR_H
11#include <IMP/kernel_config.h>
19#include "internal/utility.h"
23#include <cereal/access.hpp>
25IMPKERNEL_BEGIN_NAMESPACE
119class IMPKERNELEXPORT Decorator :
public Value {
125 friend class cereal::access;
126 template<
class Archive>
void serialize(Archive &ar) {
129 if (std::is_base_of<cereal::detail::OutputArchiveBase, Archive>::value) {
130 uint32_t model_id = get_model_id();
135 set_model_from_id(model_id);
141 void set_model_from_id(uint32_t model_id);
142 uint32_t get_model_id()
const;
144 int compare(
Object* o)
const {
155 : model_(m), pi_(pi), is_valid_(
true) {}
156 Decorator() : is_valid_(
false) {}
168 bool __eq__(
Object* o)
const {
return operator==(o); }
169 bool __ne__(
Object* o)
const {
return operator!=(o); }
170 bool __lt__(
Object* o)
const {
return operator<(o); }
171 bool __gt__(
Object* o)
const {
return operator>(o); }
172 bool __ge__(
Object* o)
const {
return operator>=(o); }
173 bool __le__(
Object* o)
const {
return operator<=(o); }
175 bool operator==(Decorator d)
const {
return (compare(d) == 0); }
177 bool operator==(
Object* o)
const {
return (compare(o) == 0); }
178 bool operator!=(
Object* o)
const {
return (compare(o) != 0); }
179 bool operator<(
Object* o)
const {
return (compare(o) < 0); }
180 bool operator>(
Object* o)
const {
return (compare(o) > 0); }
181 bool operator>=(
Object* o)
const {
return !(compare(o) < 0); }
182 bool operator<=(
Object* o)
const {
return !(compare(o) > 0); }
184 bool operator==(
Particle* o)
const {
return (compare(o) == 0); }
185 bool operator!=(
Particle* o)
const {
return (compare(o) != 0); }
186 bool operator<(
Particle* o)
const {
return (compare(o) < 0); }
187 bool operator>(
Particle* o)
const {
return (compare(o) > 0); }
188 bool operator>=(
Particle* o)
const {
return !(compare(o) < 0); }
189 bool operator<=(
Particle* o)
const {
return !(compare(o) > 0); }
199 "Particle " << pi_ <<
" is no longer part of the model.");
200 return model_->get_particle(pi_);
205 operator Particle*()
const {
return get_particle(); }
206 Particle* operator->()
const {
return get_particle(); }
207 operator ParticleIndex()
const {
return get_particle_index(); }
227#if !defined(IMP_DOXYGEN) && !defined(SWIG)
228 typedef std::false_type DecoratorHasTraits;
234IMPKERNELEXPORT
void check_particle(Model *m, ParticleIndex pi);
237IMPKERNEL_END_NAMESPACE
A base class for constraints.
Storage of a model, its restraints, constraints and particles.
A shared base class to help in debugging and things.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
Base class for a simple primitive-like type.
A class for storing lists of IMP items.
A weak pointer to an Object or RefCountedObject.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Interface to specialized Particle types (e.g. atoms).
bool get_is_valid() const
Returns true if constructed with a non-default constructor.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Model * get_model() const
Returns the Model containing the particle.
Particle * get_particle() const
Returns the particle decorated by this decorator.
Class for storing model, its restraints, constraints, and particles.
Common base class for heavy weight IMP objects.
Class to handle individual particles of a Model object.
#define IMP_HASHABLE_INLINE(name, hashret)
Index< ParticleIndexTag > ParticleIndex
Smart pointer to Object-derived classes that does not refcount.
Various general useful functions for IMP.
Various general useful macros for IMP.