Chemical Data Processing Library C++ API - Version 1.2.0
NOTMatchExpression.hpp
Go to the documentation of this file.
1 /*
2  * NOTMatchExpression.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_CHEM_NOTMATCHEXPRESSION_HPP
30 #define CDPL_CHEM_NOTMATCHEXPRESSION_HPP
31 
32 #include <memory>
33 
35 
36 
37 namespace CDPL
38 {
39 
40  namespace Chem
41  {
42 
49  template <typename ObjType1, typename ObjType2 = void>
50  class NOTMatchExpression : public MatchExpression<ObjType1, ObjType2>
51  {
52 
53  public:
57  typedef std::shared_ptr<NOTMatchExpression> SharedPointer;
58 
64  expression(expr_ptr) {}
65 
76  bool operator()(const ObjType1& query_obj1, const ObjType2& query_obj2, const ObjType1& target_obj1, const ObjType2& target_obj2,
77  const Base::Any& aux_data) const;
78 
91  bool operator()(const ObjType1& query_obj1, const ObjType2& query_obj2, const ObjType1& target_obj1, const ObjType2& target_obj2,
92  const AtomBondMapping& mapping, const Base::Any& aux_data) const;
93 
100  bool requiresAtomBondMapping() const;
101 
102  private:
104  };
105 
110  template <typename ObjType>
111  class NOTMatchExpression<ObjType, void> : public MatchExpression<ObjType, void>
112  {
113 
114  public:
118  typedef std::shared_ptr<NOTMatchExpression> SharedPointer;
119 
125  expression(expr_ptr) {}
126 
135  bool operator()(const ObjType& query_obj, const ObjType& target_obj, const Base::Any& aux_data) const;
136 
147  bool operator()(const ObjType& query_obj, const ObjType& target_obj, const AtomBondMapping& mapping, const Base::Any& aux_data) const;
148 
156 
157  private:
159  };
160  } // namespace Chem
161 } // namespace CDPL
162 
163 
164 // Implementation
165 
166 template <typename ObjType1, typename ObjType2>
167 bool CDPL::Chem::NOTMatchExpression<ObjType1, ObjType2>::operator()(const ObjType1& query_obj1, const ObjType2& query_obj2,
168  const ObjType1& target_obj1, const ObjType2& target_obj2,
169  const Base::Any& data) const
170 {
171  return !this->expression->operator()(query_obj1, query_obj2, target_obj1, target_obj2, data);
172 }
173 
174 template <typename ObjType1, typename ObjType2>
175 bool CDPL::Chem::NOTMatchExpression<ObjType1, ObjType2>::operator()(const ObjType1& query_obj1, const ObjType2& query_obj2,
176  const ObjType1& target_obj1, const ObjType2& target_obj2,
177  const AtomBondMapping& mapping, const Base::Any& data) const
178 {
179  return !this->expression->operator()(query_obj1, query_obj2, target_obj1, target_obj2, mapping, data);
180 }
181 
182 template <typename ObjType1, typename ObjType2>
184 {
185  return this->expression->requiresAtomBondMapping();
186 }
187 
188 
189 template <typename ObjType>
190 bool CDPL::Chem::NOTMatchExpression<ObjType, void>::operator()(const ObjType& query_obj, const ObjType& target_obj,
191  const Base::Any& data) const
192 {
193  return !this->expression->operator()(query_obj, target_obj, data);
194 }
195 
196 template <typename ObjType>
197 bool CDPL::Chem::NOTMatchExpression<ObjType, void>::operator()(const ObjType& query_obj, const ObjType& target_obj,
198  const AtomBondMapping& mapping, const Base::Any& data) const
199 {
200  return !this->expression->operator()(query_obj, target_obj, mapping, data);
201 }
202 
203 template <typename ObjType1>
205 {
206  return this->expression->requiresAtomBondMapping();
207 }
208 
209 #endif // CDPL_CHEM_NOTMATCHEXPRESSION_HPP
Definition of the class CDPL::Chem::MatchExpression.
A safe, type checked container for arbitrary data of variable type.
Definition: Any.hpp:59
A data structure for the common storage of related atom to atom and bond to bond mappings.
Definition: AtomBondMapping.hpp:55
A generic boolean expression interface for the implementation of query/target object equivalence test...
Definition: MatchExpression.hpp:75
std::shared_ptr< MatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MatchExpression instances.
Definition: MatchExpression.hpp:81
NOTMatchExpression(const typename MatchExpression< ObjType, void >::SharedPointer &expr_ptr)
Constructs a NOTMatchExpressionBase object that wraps the match expression instance specified by expr...
Definition: NOTMatchExpression.hpp:124
std::shared_ptr< NOTMatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated NOTMatchExpression instances.
Definition: NOTMatchExpression.hpp:118
bool requiresAtomBondMapping() const
Tells whether the wrapped match expression requires a reevaluation after a query to target atom/bond ...
NOTMatchExpression.
Definition: NOTMatchExpression.hpp:51
std::shared_ptr< NOTMatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated NOTMatchExpression instances.
Definition: NOTMatchExpression.hpp:57
bool requiresAtomBondMapping() const
Tells whether the wrapped match expression requires a reevaluation after a query to target atom/bond ...
Definition: NOTMatchExpression.hpp:183
bool operator()(const ObjType1 &query_obj1, const ObjType2 &query_obj2, const ObjType1 &target_obj1, const ObjType2 &target_obj2, const Base::Any &aux_data) const
Performs an evaluation of the wrapped match expression for the given query and target objects and ret...
Definition: NOTMatchExpression.hpp:167
NOTMatchExpression(const typename MatchExpression< ObjType1, ObjType2 >::SharedPointer &expr_ptr)
Constructs a NOTMatchExpression object that wraps the match expression instance specified by expr_ptr...
Definition: NOTMatchExpression.hpp:63
The namespace of the Chemical Data Processing Library.