Class documentation of Concepts

Loading...
Searching...
No Matches
elementFormulaRCP_boost.hh
Go to the documentation of this file.
1
8#ifndef elementformulaRCP_hh
9#define elementformulaRCP_hh
10
12#include "elementFormula.hh"
13#include "formula.hh"
14#include "constFormula.hh"
15
16#define ElemFormRCPClone_D 0
17#define ElemFormRCPValue_D 0
18#define FormRCPClone_D 0
19#define FormRCPValue_D 0
20
21namespace concepts {
22
23
24 // ***************************************** RCP<const ElementFormula<F,G> > **
25
26 template<class F, typename G>
27 class RCP<const ElementFormula<F,G> >
28 : public boost::shared_ptr<const ElementFormula<F,G> >
29 {
30 public:
38 explicit RCP(const F x)
39 : boost::shared_ptr<const ElementFormula<F,G> >
40 (new const ConstFormula<F>(x)) {}
41
43 RCP() : boost::shared_ptr<const ElementFormula<F,G> >() {}
44
45 // this conversion operator is already implemented for shared_ptr
46 #if 0
47 // implicit conversion ops.
48 template<class OldF, class OldG>
50 : boost::shared_ptr<const ElementFormula<F,G> >( old )
51 {
52 }
53 #endif
54
67 explicit RCP(const ElementFormula<F,G>* x)
68 : boost::shared_ptr<const ElementFormula<F,G> >(x) {}
69
71 RCP(boost::shared_ptr<const ElementFormula<F,G> >& x)
72 : boost::shared_ptr<const ElementFormula<F,G> >(x) {}
73
76 template<class H>
77 RCP(const boost::shared_ptr<H>& x)
78 : boost::shared_ptr<const ElementFormula<F,G> >(x) {}
79
81 template<class H, class I>
82 RCP(H x, I y) : boost::shared_ptr<const ElementFormula<F,G> >(x, y) {}
83
88 // but more importantly it is severely prone to errors.
90 // this functions tells C++ to convert any const
91 // reference to ElementFormulas AUTOMATICALLY into
92 // RCP<ElementFormula>. In particular this strip of code
93 // equates EF-References with EF-SmartPointer, so it equates
94 // references with pointers. I do not know which side effects
95 // this strip of code can create, but expect severe ones!
96 //explicit RCP(const ElementFormula<F,G>& x)
98 : boost::shared_ptr<const ElementFormula<F,G> >(x.clone())
99 {
100 DEBUGL(ElemFormRCPClone_D, "Cloned " << **this << " = *" << *this);
101 }
102
104 operator=(const RCP<const ElementFormula<F,G> >& x)
105 {
107 return *this;
108 }
109
110 template<class H>
112 operator=(const RCP<H>& x)
113 {
115 return *this;
116 }
117
118#if ElemFormRCPValue_D
119 // for debugging in case of zero pointers: output of pointer
120 const ElementFormula<F,G>& operator* () const // never throws
121 {
122 DEBUGL(1, *this);
123 return boost::shared_ptr<const ElementFormula<F,G> >(*this).operator*();
124 }
125#endif
126 };
127
128
129 // ************************************************ RCP<const Formula<F,G> > **
130
131 template<class F>
132 class RCP<const Formula<F> > : public boost::shared_ptr<const Formula<F> >
133 {
134 public:
142 explicit RCP(const F x)
143 : boost::shared_ptr<const Formula<F> >(new const ConstFormula<F>(x)) {}
144
146 RCP() : boost::shared_ptr<const Formula<F> >() {}
147
160 explicit RCP(const Formula<F>* x)
161 : boost::shared_ptr<const Formula<F> >(x) {}
162
163 RCP(boost::shared_ptr<const Formula<F> >& x)
164 : boost::shared_ptr<const Formula<F> >(x) {}
165
166 template<class H>
167 RCP(const boost::shared_ptr<H>& x)
168 : boost::shared_ptr<const Formula<F> >(x) {}
169
171 template<class H, class I>
172 RCP(H x, I y) : boost::shared_ptr<const Formula<F> >(x, y) {}
173
178 // but more importantly it is severely prone to errors.
180 // this functions tells C++ to convert any const
181 // reference to ElementFormulas AUTOMATICALLY into
182 // RCP<ElementFormula>. In particular this strip of code
183 // equates EF-References with EF-SmartPointer, so it equates
184 // references with pointers. I do not know which side effects
185 // this strip of code can create, but expect severe ones!
186 explicit RCP(const Formula<F>& x) : boost::shared_ptr<const Formula<F> >(x.clone())
187 {
188 DEBUGL(FormRCPClone_D, "Cloned " << **this << " = *" << *this);
189 }
190
192 operator=(const RCP<const Formula<F> >& x)
193 {
194 RCP<const Formula<F> >(x).swap(*this);
195 return *this;
196 }
197
198 template<class H>
200 operator=(const RCP<H>& x)
201 {
202 RCP<const Formula<F> >(x).swap(*this);
203 return *this;
204 }
205
206#if FormRCPValue_D
207 // for debugging in case of zero pointers: output of pointer
208 const Formula<F>& operator* () const // never throws
209 {
210 DEBUGL(1, *this);
211 return boost::shared_ptr<const Formula<F> >(*this).operator*();
212 }
213#endif
214
215 };
216
217
218} // namespace concepts
219
220
221#endif // elementformulaRCP_hh
RCP(H x, I y)
Constructor with any two parameters, I is a deleter function.
RCP(boost::shared_ptr< const ElementFormula< F, G > > &x)
conversion constructor from boost::shared_ptr
RCP(const ElementFormula< F, G > &x)
@obsolete: try to write code which does NOT depend on this function,
RCP()
Default constructor, creates an RCP to a NULL-pointer.
RCP(H x, I y)
Constructor with any two parameters.
RCP(const Formula< F > &x)
@obsolete: try to write code which does NOT depend on this function,
RCP()
Default constructor.
#define DEBUGL(doit, msg)
Definition debug.hh:40
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320