YAP
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DataAccessor.h
Go to the documentation of this file.
1 /* YAP - Yet another PWA toolkit
2  Copyright 2015, Technische Universitaet Muenchen,
3  Authors: Daniel Greenwald, Johannes Rauch
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
20 
21 #ifndef yap_DataAccessor_h
22 #define yap_DataAccessor_h
23 
24 #include "fwd/DataAccessor.h"
25 
26 #include "fwd/CachedValue.h"
27 #include "fwd/DataPoint.h"
28 #include "fwd/Model.h"
29 #include "fwd/ParticleCombination.h"
30 
31 #include <memory>
32 
33 namespace yap {
34 
39 {
40 public:
41 
44  DataAccessor(const ParticleCombinationEqualTo& equal);
45 
47  const ParticleCombinationEqualTo& equal() const
48  { return Equal_; }
49 
51  int index() const
52  { return Index_; }
53 
55  unsigned symmetrizationIndex(const std::shared_ptr<ParticleCombination>& c) const
56  { return SymmetrizationIndices_.at(c); }
57 
59  const ParticleCombinationMap<unsigned>& symmetrizationIndices() const
60  { return SymmetrizationIndices_; }
61 
63  const unsigned nSymmetrizationIndices() const
64  { return NIndices_; }
65 
67  void printParticleCombinations() const;
68 
70  const CachedValueSet& CachedValues() const
71  { return CachedValues_; }
72 
74  const unsigned size() const
75  { return Size_; }
76 
78  const bool requiresStorage() const
79  { return size() > 0 and nSymmetrizationIndices() > 0; }
80 
82  bool consistent() const;
83 
85  virtual const Model* model() const = 0;
86 
88  friend Model;
89 
91  friend CachedValue;
92 
93 protected:
94 
96  void virtual registerWithModel();
97 
99  void addCachedValue(std::shared_ptr<CachedValue> c);
100 
102  virtual void addParticleCombination(std::shared_ptr<ParticleCombination> pc);
103 
105  virtual void pruneSymmetrizationIndices();
106 
108  void setIndex(size_t i)
109  { Index_ = i; }
110 
111 private:
112 
115  void increaseSize(unsigned n)
116  { Size_ += n; }
117 
119  ParticleCombinationEqualTo Equal_;
120 
122  ParticleCombinationMap<unsigned> SymmetrizationIndices_;
123 
125  unsigned NIndices_;
126 
128  CachedValueSet CachedValues_;
129 
131  unsigned Size_;
132 
134  int Index_;
135 
136 };
137 
139 void remove_expired(DataAccessorSet& S);
140 
141 }
142 
143 #endif
virtual void addParticleCombination(std::shared_ptr< ParticleCombination > pc)
add ParticleCombination to SymmetrizationIndices_
Definition: DataAccessor.cxx:46
CachedValueSet CachedValues_
Set of CachedValues that have this DataAccessor as an owner.
Definition: DataAccessor.h:128
unsigned NIndices_
Number of independent indices stored in SymmetrizationIndices_.
Definition: DataAccessor.h:125
const ParticleCombinationEqualTo & equal() const
Definition: DataAccessor.h:47
friend Model
grant friend status to Model to access CachedValues_
Definition: DataAccessor.h:88
DataAccessor(const ParticleCombinationEqualTo &equal)
Definition: DataAccessor.cxx:15
void printParticleCombinations() const
print ParticleCombination map
Definition: DataAccessor.cxx:24
ParticleCombinationMap< unsigned > SymmetrizationIndices_
Map of indices for each used symmetrization stored with key = shared_ptr<ParticleCombination> ...
Definition: DataAccessor.h:122
void setIndex(size_t i)
set storage index used in DataPoint. Must be unique.
Definition: DataAccessor.h:108
bool consistent() const
Check consistency of object.
Definition: DataAccessor.cxx:31
const ParticleCombinationMap< unsigned > & symmetrizationIndices() const
Definition: DataAccessor.h:59
void increaseSize(unsigned n)
Definition: DataAccessor.h:115
unsigned Size_
number of real values stored per symm. index
Definition: DataAccessor.h:131
const bool requiresStorage() const
Definition: DataAccessor.h:78
Class implementing a PWA model.
Definition: Model.h:56
unsigned symmetrizationIndex(const std::shared_ptr< ParticleCombination > &c) const
Definition: DataAccessor.h:55
void remove_expired(DataAccessorSet &S)
remove expired elements of set
Definition: DataAccessor.cxx:180
const unsigned size() const
Definition: DataAccessor.h:74
virtual void pruneSymmetrizationIndices()
prune SymmetrizationIndices_ to only contain ParticleCombination's tracing back up the ISP ...
Definition: DataAccessor.cxx:73
void addCachedValue(std::shared_ptr< CachedValue > c)
add CachedValue
Definition: DataAccessor.cxx:159
const unsigned nSymmetrizationIndices() const
Definition: DataAccessor.h:63
Abstract base class for all objects accessing DataPoint's.
Definition: DataAccessor.h:38
ParticleCombinationEqualTo Equal_
Object to check equality of symmetrizations for determining storage indices.
Definition: DataAccessor.h:119
virtual void registerWithModel()
register with Model
Definition: DataAccessor.cxx:125
virtual const Model * model() const =0
get raw pointer to Model (const)
const CachedValueSet & CachedValues() const
Definition: DataAccessor.h:70
int index() const
Definition: DataAccessor.h:51
int Index_
storage index used in DataPoint. Must be unique.
Definition: DataAccessor.h:134
friend CachedValue
grant friend status to CachedValue to call addCachedValue
Definition: DataAccessor.h:91