Chemical Data Processing Library C++ API - Version 1.2.0
Expression.hpp
Go to the documentation of this file.
1 /*
2  * Expression.hpp
3  *
4  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
27 #ifndef CDPL_MATH_EXPRESSION_HPP
28 #define CDPL_MATH_EXPRESSION_HPP
29 
30 
31 namespace CDPL
32 {
33 
34  namespace Math
35  {
36 
37  template <typename E>
38  class Expression
39  {
40 
41  public:
42  typedef E ExpressionType;
43 
44  protected:
47 
48  private:
49  const Expression& operator=(const Expression&);
50  };
51 
52  template <typename E>
53  class VectorExpression : public Expression<E>
54  {
55 
56  public:
57  typedef E ExpressionType;
58 
59  const ExpressionType& operator()() const
60  {
61  return *static_cast<const ExpressionType*>(this);
62  }
63 
65  {
66  return *static_cast<ExpressionType*>(this);
67  }
68 
69  protected:
72  };
73 
74  template <typename E>
75  class MatrixExpression : public Expression<E>
76  {
77 
78  public:
79  typedef E ExpressionType;
80 
81  const ExpressionType& operator()() const
82  {
83  return *static_cast<const ExpressionType*>(this);
84  }
85 
87  {
88  return *static_cast<ExpressionType*>(this);
89  }
90 
91  protected:
94  };
95 
96  template <typename E>
97  class QuaternionExpression : public Expression<E>
98  {
99 
100  public:
101  typedef E ExpressionType;
102 
103  const ExpressionType& operator()() const
104  {
105  return *static_cast<const ExpressionType*>(this);
106  }
107 
109  {
110  return *static_cast<ExpressionType*>(this);
111  }
112 
113  protected:
116  };
117 
118  template <typename E>
119  class GridExpression : public Expression<E>
120  {
121 
122  public:
123  typedef E ExpressionType;
124 
125  const ExpressionType& operator()() const
126  {
127  return *static_cast<const ExpressionType*>(this);
128  }
129 
131  {
132  return *static_cast<ExpressionType*>(this);
133  }
134 
135  protected:
138  };
139 
140  template <typename C>
142  {
143 
144  public:
145  typedef C ContainerType;
146 
147  const ContainerType& operator()() const
148  {
149  return *static_cast<const ContainerType*>(this);
150  }
151 
153  {
154  return *static_cast<ContainerType*>(this);
155  }
156 
157  protected:
160  };
161 
162  template <typename C>
164  {
165 
166  public:
167  typedef C ContainerType;
168 
169  const ContainerType& operator()() const
170  {
171  return *static_cast<const ContainerType*>(this);
172  }
173 
175  {
176  return *static_cast<ContainerType*>(this);
177  }
178 
179  protected:
182  };
183 
184  template <typename C>
186  {
187 
188  public:
189  typedef C ContainerType;
190 
191  const ContainerType& operator()() const
192  {
193  return *static_cast<const ContainerType*>(this);
194  }
195 
197  {
198  return *static_cast<ContainerType*>(this);
199  }
200 
201  protected:
204  };
205 
206  template <typename C>
207  class GridContainer : public GridExpression<C>
208  {
209 
210  public:
211  typedef C ContainerType;
212 
213  const ContainerType& operator()() const
214  {
215  return *static_cast<const ContainerType*>(this);
216  }
217 
219  {
220  return *static_cast<ContainerType*>(this);
221  }
222 
223  protected:
226  };
227  } // namespace Math
228 } // namespace CDPL
229 
230 #endif // CDPL_MATH_EXPRESSION_HPP
Definition: Expression.hpp:39
E ExpressionType
Definition: Expression.hpp:42
~Expression()
Definition: Expression.hpp:46
Expression()
Definition: Expression.hpp:45
Definition: Expression.hpp:208
ContainerType & operator()()
Definition: Expression.hpp:218
~GridContainer()
Definition: Expression.hpp:225
const ContainerType & operator()() const
Definition: Expression.hpp:213
C ContainerType
Definition: Expression.hpp:211
GridContainer()
Definition: Expression.hpp:224
Definition: Expression.hpp:120
E ExpressionType
Definition: Expression.hpp:123
ExpressionType & operator()()
Definition: Expression.hpp:130
GridExpression()
Definition: Expression.hpp:136
~GridExpression()
Definition: Expression.hpp:137
const ExpressionType & operator()() const
Definition: Expression.hpp:125
Definition: Expression.hpp:164
const ContainerType & operator()() const
Definition: Expression.hpp:169
MatrixContainer()
Definition: Expression.hpp:180
C ContainerType
Definition: Expression.hpp:167
~MatrixContainer()
Definition: Expression.hpp:181
ContainerType & operator()()
Definition: Expression.hpp:174
Definition: Expression.hpp:76
E ExpressionType
Definition: Expression.hpp:79
const ExpressionType & operator()() const
Definition: Expression.hpp:81
MatrixExpression()
Definition: Expression.hpp:92
ExpressionType & operator()()
Definition: Expression.hpp:86
~MatrixExpression()
Definition: Expression.hpp:93
Definition: Expression.hpp:186
ContainerType & operator()()
Definition: Expression.hpp:196
const ContainerType & operator()() const
Definition: Expression.hpp:191
QuaternionContainer()
Definition: Expression.hpp:202
C ContainerType
Definition: Expression.hpp:189
~QuaternionContainer()
Definition: Expression.hpp:203
Definition: Expression.hpp:98
QuaternionExpression()
Definition: Expression.hpp:114
ExpressionType & operator()()
Definition: Expression.hpp:108
~QuaternionExpression()
Definition: Expression.hpp:115
const ExpressionType & operator()() const
Definition: Expression.hpp:103
E ExpressionType
Definition: Expression.hpp:101
Definition: Expression.hpp:142
~VectorContainer()
Definition: Expression.hpp:159
C ContainerType
Definition: Expression.hpp:145
ContainerType & operator()()
Definition: Expression.hpp:152
const ContainerType & operator()() const
Definition: Expression.hpp:147
VectorContainer()
Definition: Expression.hpp:158
Definition: Expression.hpp:54
const ExpressionType & operator()() const
Definition: Expression.hpp:59
~VectorExpression()
Definition: Expression.hpp:71
ExpressionType & operator()()
Definition: Expression.hpp:64
E ExpressionType
Definition: Expression.hpp:57
VectorExpression()
Definition: Expression.hpp:70
constexpr unsigned int C
Specifies Carbon.
Definition: AtomType.hpp:92
constexpr unsigned int E
Specifies that the stereocenter has E configuration.
Definition: CIPDescriptor.hpp:96
The namespace of the Chemical Data Processing Library.