Chemical Data Processing Library C++ API - Version 1.1.1
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 
37  template <typename C>
39  {
40 
41  typedef C LValueType;
42  typedef typename C::ClosureType ClosureType;
43 
44  public:
45  explicit DirectAssignmentProxy(LValueType& lval):
46  lvalue(lval) {}
47 
49  lvalue(proxy.lvalue) {}
50 
51  template <typename E>
52  ClosureType& operator=(const E& e)
53  {
54  lvalue.assign(e);
55  return lvalue;
56  }
57 
58  template <typename E>
59  ClosureType& operator+=(const E& e)
60  {
61  lvalue.plusAssign(e);
62  return lvalue;
63  }
64 
65  template <typename E>
66  ClosureType& operator-=(const E& e)
67  {
68  lvalue.minusAssign(e);
69  return lvalue;
70  }
71 
72  private:
74 
75  const DirectAssignmentProxy& operator=(const DirectAssignmentProxy&);
76 
77  ClosureType lvalue;
78  };
79 
80  template <typename C>
82  {
83  return DirectAssignmentProxy<const C>(lvalue);
84  }
85 
86  template <typename C>
88  {
89  return DirectAssignmentProxy<C>(lvalue);
90  }
91  } // namespace Math
92 } // namespace CDPL
93 
94 #endif // CDPL_MATH_DIRECTASSIGNMENTPROXY_HPP
CDPL::Chem::CIPDescriptor::E
const unsigned int E
Specifies that the stereocenter has E configuration.
Definition: CIPDescriptor.hpp:96
CDPL::Math::DirectAssignmentProxy::operator+=
ClosureType & operator+=(const E &e)
Definition: DirectAssignmentProxy.hpp:59
CDPL::Math::DirectAssignmentProxy
Definition: DirectAssignmentProxy.hpp:39
CDPL::Math::DirectAssignmentProxy::DirectAssignmentProxy
DirectAssignmentProxy(LValueType &lval)
Definition: DirectAssignmentProxy.hpp:45
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Math::DirectAssignmentProxy::DirectAssignmentProxy
DirectAssignmentProxy(const DirectAssignmentProxy &proxy)
Definition: DirectAssignmentProxy.hpp:48
CDPL::Math::DirectAssignmentProxy::operator-=
ClosureType & operator-=(const E &e)
Definition: DirectAssignmentProxy.hpp:66
CDPL::Math::DirectAssignmentProxy::operator=
ClosureType & operator=(const E &e)
Definition: DirectAssignmentProxy.hpp:52
CDPL::Chem::AtomType::C
const unsigned int C
Specifies Carbon.
Definition: AtomType.hpp:92
CDPL::Math::direct
DirectAssignmentProxy< const C > direct(const C &lvalue)
Definition: DirectAssignmentProxy.hpp:81