IMP logo
IMP Reference Guide  2.19.0
The Integrative Modeling Platform
distance_pair_score_macros.h
Go to the documentation of this file.
1 /**
2  * \file IMP/score_functor/distance_pair_score_macros.h
3  * \brief Various important macros
4  * for implementing decorators.
5  *
6  * Copyright 2007-2022 IMP Inventors. All rights reserved.
7  *
8  */
9 
10 #ifndef IMPSCORE_FUNCTOR_DISTANCE_PAIR_SCORE_MACROS_H
11 #define IMPSCORE_FUNCTOR_DISTANCE_PAIR_SCORE_MACROS_H
12 
13 #include "DistancePairScore.h"
14 #include <cereal/access.hpp>
15 #include <cereal/types/base_class.hpp>
16 
17 #if defined(SWIG) || defined(IMP_DOXYGEN)
18 /** Use this macro to define PairScores based on the
19  IMP::score_functor::DistancePairScore as it works around various
20  complications caused by SWIG.
21 
22  To use it do something like
23  IMP_FUNCTOR_DISTANCE_PAIR_SCORE(DistancePairScore,
24  score_functor::UnaryFunctionEvaluate,
25  (UnaryFunction *uf, std::string name
26  = "DistancePairScore%1%"), (uf));
27  */
28 #define IMP_FUNCTOR_DISTANCE_PAIR_SCORE(Name, Functor, Args, PassArgs) \
29  class Name : public IMP::PairScore { \
30  typedef IMP::score_functor::DistancePairScore<Functor> P; \
31  \
32  public: \
33  Name Args; \
34  Name() {} \
35  double evaluate_index(Model *m, \
36  const ParticleIndexPair &pip, \
37  DerivativeAccumulator *da) const; \
38  ModelObjectsTemp do_get_inputs( \
39  Model *m, const ParticleIndexes &pis) const; \
40  IMP_OBJECT_METHODS(Name); \
41  }
42 
43 #else
44 #define IMP_FUNCTOR_DISTANCE_PAIR_SCORE(Name, Functor, Args, PassArgs) \
45  class Name : public IMP::score_functor::DistancePairScore<Functor> { \
46  typedef IMP::score_functor::DistancePairScore<Functor> P; \
47  friend class cereal::access; \
48  template<class Archive> void serialize(Archive &ar) { \
49  ar(cereal::base_class< \
50  IMP::score_functor::DistancePairScore<Functor> >(this)); \
51  } \
52  IMP_OBJECT_SERIALIZE_DECL(Name); \
53  \
54  public: \
55  Name Args : P(Functor PassArgs, name) {} \
56  Name() {} \
57  }
58 #endif
59 
60 #endif /* IMPSCORE_FUNCTOR_DISTANCE_PAIR_SCORE_MACROS_H */
A Score on the distance between a pair of particles.