ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Pincushion.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Pincushion.h
1 #ifndef SEAMSTRESS_PINCUSHION_H
2 #define SEAMSTRESS_PINCUSHION_H
3 
4 #include "Seamstress.h"
5 #include "Needle.h"
6 
7 namespace SeamStress
8 {
9  template <class TClass>
10  class Pincushion : public Needle
11  {
12  public:
13  Pincushion<TClass>(TClass *glove, std::vector<Seamstress*> *ss)
14  {
15  hand = glove;
16  seamstresses = ss;
17  }
18  virtual ~Pincushion<TClass>(){}
19 
20 
21  void operator()(void *thread)
22  {
23  (hand->*pattern)(thread);
24  }
25 
26 
27  void sew(void (TClass::*design)(void*), std::vector<void*> threads)
28  {
29  pattern = design;
30  unsigned long int ntot = threads.size();
31  if(seamstresses->size() < ntot){ntot = seamstresses->size();}
32  for(unsigned long int i=0;i<ntot;i++)
33  {
34  (*seamstresses)[i]->needle = this;
35  (*seamstresses)[i]->thread = threads[i];
36  (*seamstresses)[i]->sew();
37  }
38  for(unsigned long int i=0;i<ntot;i++)
39  {
40  (*seamstresses)[i]->rest();
41  }
42  }
43 
44 
45  void sewSoftly(void (TClass::*design)(void*))
46  {
47  pattern = design;
48  for(unsigned long int i=0;i<seamstresses->size();i++)
49  {
50  (*seamstresses)[i]->needle = this;
51  (*seamstresses)[i]->thread = NULL;
52  (*seamstresses)[i]->sew();
53  }
54  for(unsigned long int i=0;i<seamstresses->size();i++)
55  {
56  (*seamstresses)[i]->rest();
57  }
58  }
59 
60 
61  void sewSoftly(void (TClass::*design)(void*), unsigned long int N)
62  {
63  pattern = design;
64  for(unsigned long int i=0;i<N;i++)
65  {
66  (*seamstresses)[i]->needle = this;
67  (*seamstresses)[i]->thread = NULL;
68  (*seamstresses)[i]->sew();
69  }
70  for(unsigned long int i=0;i<N;i++)
71  {
72  (*seamstresses)[i]->rest();
73  }
74  }
75 
76 
77  void sewStraight(void (TClass::*design)(void*))
78  {
79  pattern = design;
80  std::vector<unsigned long int> quilt;
81  for(unsigned long int i=0;i<seamstresses->size();i++){quilt.push_back(i);}
82  for(unsigned long int i=0;i<seamstresses->size();i++)
83  {
84  (*seamstresses)[i]->needle = this;
85  (*seamstresses)[i]->thread = &(quilt[i]);
86  (*seamstresses)[i]->sew();
87  }
88  for(unsigned long int i=0;i<seamstresses->size();i++)
89  {
90  (*seamstresses)[i]->rest();
91  }
92  }
93 
94 
95  void sewStraight(void (TClass::*design)(void*), unsigned long int N)
96  {
97  pattern = design;
98  std::vector<unsigned long int> quilt;
99  for(unsigned long int i=0;i<N;i++){quilt.push_back(i);}
100  for(unsigned long int i=0;i<N;i++)
101  {
102  (*seamstresses)[i]->needle = this;
103  (*seamstresses)[i]->thread = &(quilt[i]);
104  (*seamstresses)[i]->sew();
105  }
106  for(unsigned long int i=0;i<N;i++)
107  {
108  (*seamstresses)[i]->rest();
109  }
110  }
111 
112 
113  void sewOpenlyStraight(void (TClass::*design)(void*))
114  {
115  pattern = design;
116  std::vector<unsigned long int> quilt;
117  for(unsigned long int i=0;i<seamstresses->size();i++){quilt.push_back(i);}
118  for(unsigned long int i=0;i<seamstresses->size();i++)
119  {
120  (*seamstresses)[i]->needle = this;
121  (*seamstresses)[i]->thread = &(quilt[i]);
122  (*seamstresses)[i]->sew();
123  }
124  }
125 
126 
127  void sewOpenlyStraight(void (TClass::*design)(void*), unsigned long int N)
128  {
129  pattern = design;
130  std::vector<unsigned long int> quilt;
131  for(unsigned long int i=0;i<N;i++){quilt.push_back(i);}
132  for(unsigned long int i=0;i<N;i++)
133  {
134  (*seamstresses)[i]->needle = this;
135  (*seamstresses)[i]->thread = &(quilt[i]);
136  (*seamstresses)[i]->sew();
137  }
138  }
139 
140 
141  void sewOpenlySoft(void (TClass::*design)(void*))
142  {
143  pattern = design;
144  for(unsigned long int i=0;i<seamstresses->size();i++)
145  {
146  (*seamstresses)[i]->needle = this;
147  (*seamstresses)[i]->thread = NULL;
148  (*seamstresses)[i]->sew();
149  }
150  }
151 
152 
153  void sewOpenlySoft(void (TClass::*design)(void*), unsigned long int N)
154  {
155  pattern = design;
156  for(unsigned long int i=0;i<N;i++)
157  {
158  (*seamstresses)[i]->needle = this;
159  (*seamstresses)[i]->thread = NULL;
160  (*seamstresses)[i]->sew();
161  }
162  }
163 
164 
165  void tieOff()
166  {
167  for(unsigned long int i=0;i<seamstresses->size();i++)
168  {
169  (*seamstresses)[i]->rest();
170  }
171  }
172 
173 
174  void tieOff(unsigned long int N)
175  {
176  for(unsigned long int i=0;i<N;i++)
177  {
178  (*seamstresses)[i]->rest();
179  }
180  }
181 
182 
183  std::vector<Seamstress*> *seamstresses;
184  TClass *hand;
185  void (TClass::*pattern)(void*);
186  };
187 }
188 
189 
190 #endif