IMP
2.0.1
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
kernel/SingletonPredicate.h
Go to the documentation of this file.
1
/**
2
* \file IMP/kernel/SingletonPredicate.h
3
* \brief Define SingletonPredicate.
4
*
5
* WARNING This file was generated from SingletonPredicate.h
6
* in /tmp/nightly-build-36540/imp-2.0.1/tools/build/container_templates/kernel
7
* by tools/maintenance/setup_containers.py.
8
*
9
* Copyright 2007-2013 IMP Inventors. All rights reserved.
10
*/
11
12
#ifndef IMPKERNEL_SINGLETON_PREDICATE_H
13
#define IMPKERNEL_SINGLETON_PREDICATE_H
14
15
#include <IMP/kernel/kernel_config.h>
16
#include "
base_types.h
"
17
#include "
ParticleTuple.h
"
18
#include "
DerivativeAccumulator.h
"
19
#include "internal/container_helpers.h"
20
#include "
input_output_macros.h
"
21
22
IMPKERNEL_BEGIN_NAMESPACE
23
24
//! Abstract predicate function
25
/** A predicate is a function which returns one of a discrete set of
26
values (eg -1, 0, 1 depending on whether a value is negative, zero
27
or positive). SingletonPredicates will evaluate the predicate for the passed
28
particles.
29
30
Implementers should check out IMP_SINGLETON_PREDICATE().
31
*/
32
class
IMPKERNELEXPORT
SingletonPredicate
:
public
base::Object
33
{
34
public
:
35
typedef
Particle
*
Argument
;
36
typedef
ParticleIndex
IndexArgument
;
37
SingletonPredicate
(std::string name=
"SingletonPredicate %1%"
);
38
//! Compute the predicate.
39
virtual
int
get_value(
Particle
* vt)
const
=0;
40
41
/** Implementations
42
for these are provided by the IMP_SINGLETON_PREDICATE()
43
macro.
44
*/
45
virtual
Ints
get_value
(
const
ParticlesTemp
&o)
const
{
46
Ints
ret(o.size());
47
for
(
unsigned
int
i=0; i< o.size(); ++i) {
48
ret[i]+= get_value(o[i]);
49
}
50
return
ret;
51
}
52
53
#if !defined(IMP_DOXYGEN) && !defined(SWIG)
54
virtual
void
remove_if_equal(
Model
*m,
55
ParticleIndexes
& ps,
int
v)
const
;
56
virtual
void
remove_if_not_equal(
Model
*m,
57
ParticleIndexes
& ps,
int
v)
const
;
58
#endif
59
60
//! Compute the predicate and the derivative if needed.
61
virtual
int
get_value_index
(
Model
*m,
ParticleIndex
vt)
const
{
62
return
get_value(internal::get_particle(m, vt));
63
}
64
65
//! Enable them to be use as functors
66
/** But beware of slicing.
67
*/
68
int
operator()
(
Model
*m,
ParticleIndex
vt)
const
{
69
return
get_value_index(m, vt);
70
}
71
72
/** Implementations
73
for these are provided by the IMP_SINGLETON_PREDICATE()
74
macro.
75
*/
76
virtual
Ints
get_value_index(
Model
*m,
77
const
ParticleIndexes
&o)
const
{
78
Ints
ret(o.size());
79
for
(
unsigned
int
i=0; i< o.size(); ++i) {
80
ret[i]+= get_value_index(m, o[i]);
81
}
82
return
ret;
83
}
84
85
IMP_INPUTS_DECL
(
SingletonPredicate
);
86
87
IMP_REF_COUNTED_DESTRUCTOR
(
SingletonPredicate
);
88
};
89
90
91
IMPKERNEL_END_NAMESPACE
92
93
#endif
/* IMPKERNEL_SINGLETON_PREDICATE_H */