Chemical Data Processing Library C++ API - Version 1.4.0
DirectAssignmentProxy.hpp
Go to the documentation of this file.
1 /*
2  * DirectAssignmentProxy.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_DIRECTASSIGNMENTPROXY_HPP
28 #define CDPL_MATH_DIRECTASSIGNMENTPROXY_HPP
29 
30 
31 namespace CDPL
32 {
33 
34  namespace Math
35  {
36 
42  template <typename C>
44  {
45 
46  typedef C LValueType;
47  typedef typename C::ClosureType ClosureType;
48 
49  public:
54  explicit DirectAssignmentProxy(LValueType& lval):
55  lvalue(lval) {}
56 
62  lvalue(proxy.lvalue) {}
63 
70  template <typename E>
71  ClosureType& operator=(const E& e)
72  {
73  lvalue.assign(e);
74  return lvalue;
75  }
76 
83  template <typename E>
84  ClosureType& operator+=(const E& e)
85  {
86  lvalue.plusAssign(e);
87  return lvalue;
88  }
89 
96  template <typename E>
97  ClosureType& operator-=(const E& e)
98  {
99  lvalue.minusAssign(e);
100  return lvalue;
101  }
102 
103  private:
105 
106  const DirectAssignmentProxy& operator=(const DirectAssignmentProxy&);
107 
108  ClosureType lvalue;
109  };
110 
117  template <typename C>
119  {
120  return DirectAssignmentProxy<const C>(lvalue);
121  }
122 
129  template <typename C>
131  {
132  return DirectAssignmentProxy<C>(lvalue);
133  }
134  } // namespace Math
135 } // namespace CDPL
136 
137 #endif // CDPL_MATH_DIRECTASSIGNMENTPROXY_HPP
Proxy that converts an assignment to a Math container into the corresponding direct-assignment call o...
Definition: DirectAssignmentProxy.hpp:44
ClosureType & operator-=(const E &e)
Forwards the compound subtraction of e to the wrapped lvalue's direct-minus-assignment method.
Definition: DirectAssignmentProxy.hpp:97
DirectAssignmentProxy(LValueType &lval)
Constructs the proxy wrapping the lvalue lval.
Definition: DirectAssignmentProxy.hpp:54
ClosureType & operator+=(const E &e)
Forwards the compound addition of e to the wrapped lvalue's direct-plus-assignment method.
Definition: DirectAssignmentProxy.hpp:84
ClosureType & operator=(const E &e)
Forwards the assignment of e to the wrapped lvalue's direct-assignment method.
Definition: DirectAssignmentProxy.hpp:71
DirectAssignmentProxy(const DirectAssignmentProxy &proxy)
Copy-constructs the proxy from proxy.
Definition: DirectAssignmentProxy.hpp:61
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
DirectAssignmentProxy< const C > direct(const C &lvalue)
Convenience factory creating a Math::DirectAssignmentProxy for a const lvalue.
Definition: DirectAssignmentProxy.hpp:118
The namespace of the Chemical Data Processing Library.