Chemical Data Processing Library C++ API - Version 1.4.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 
53  template <typename ObjType1, typename ObjType2 = void>
54  class NOTMatchExpression : public MatchExpression<ObjType1, ObjType2>
55  {
56 
57  public:
61  typedef std::shared_ptr<NOTMatchExpression> SharedPointer;
62 
68  expression(expr_ptr) {}
69 
80  bool operator()(const ObjType1& query_obj1, const ObjType2& query_obj2, const ObjType1& target_obj1, const ObjType2& target_obj2,
81  const Base::Any& aux_data) const;
82 
95  bool operator()(const ObjType1& query_obj1, const ObjType2& query_obj2, const ObjType1& target_obj1, const ObjType2& target_obj2,
96  const AtomBondMapping& mapping, const Base::Any& aux_data) const;
97 
104  bool requiresAtomBondMapping() const;
105 
106  private:
108  };
109 
118  template <typename ObjType>
119  class NOTMatchExpression<ObjType, void> : public MatchExpression<ObjType, void>
120  {
121 
122  public:
126  typedef std::shared_ptr<NOTMatchExpression> SharedPointer;
127 
133  expression(expr_ptr) {}
134 
143  bool operator()(const ObjType& query_obj, const ObjType& target_obj, const Base::Any& aux_data) const;
144 
155  bool operator()(const ObjType& query_obj, const ObjType& target_obj, const AtomBondMapping& mapping, const Base::Any& aux_data) const;
156 
164 
165  private:
167  };
168  } // namespace Chem
169 } // namespace CDPL
170 
171 
172 // Implementation
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 Base::Any& data) const
178 {
179  return !this->expression->operator()(query_obj1, query_obj2, target_obj1, target_obj2, data);
180 }
181 
182 template <typename ObjType1, typename ObjType2>
183 bool CDPL::Chem::NOTMatchExpression<ObjType1, ObjType2>::operator()(const ObjType1& query_obj1, const ObjType2& query_obj2,
184  const ObjType1& target_obj1, const ObjType2& target_obj2,
185  const AtomBondMapping& mapping, const Base::Any& data) const
186 {
187  return !this->expression->operator()(query_obj1, query_obj2, target_obj1, target_obj2, mapping, data);
188 }
189 
190 template <typename ObjType1, typename ObjType2>
192 {
193  return this->expression->requiresAtomBondMapping();
194 }
195 
196 
197 template <typename ObjType>
198 bool CDPL::Chem::NOTMatchExpression<ObjType, void>::operator()(const ObjType& query_obj, const ObjType& target_obj,
199  const Base::Any& data) const
200 {
201  return !this->expression->operator()(query_obj, target_obj, data);
202 }
203 
204 template <typename ObjType>
205 bool CDPL::Chem::NOTMatchExpression<ObjType, void>::operator()(const ObjType& query_obj, const ObjType& target_obj,
206  const AtomBondMapping& mapping, const Base::Any& data) const
207 {
208  return !this->expression->operator()(query_obj, target_obj, mapping, data);
209 }
210 
211 template <typename ObjType1>
213 {
214  return this->expression->requiresAtomBondMapping();
215 }
216 
217 #endif // CDPL_CHEM_NOTMATCHEXPRESSION_HPP
Definition of class CDPL::Chem::MatchExpression.
Safe, type checked container for arbitrary data of variable type.
Definition: Any.hpp:60
Data structure for the common storage of related atom to atom and bond to bond mappings.
Definition: AtomBondMapping.hpp:55
Generic boolean expression interface for the implementation of query/target object equivalence tests ...
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 the NOTMatchExpressionBase object that wraps the match expression instance specified by ex...
Definition: NOTMatchExpression.hpp:132
std::shared_ptr< NOTMatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated NOTMatchExpression instances.
Definition: NOTMatchExpression.hpp:126
bool requiresAtomBondMapping() const
Tells whether the wrapped match expression requires a reevaluation after a query to target atom/bond ...
Chem::MatchExpression implementation that negates the evaluation results of a wrapped external expres...
Definition: NOTMatchExpression.hpp:55
std::shared_ptr< NOTMatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated NOTMatchExpression instances.
Definition: NOTMatchExpression.hpp:61
bool requiresAtomBondMapping() const
Tells whether the wrapped match expression requires a reevaluation after a query to target atom/bond ...
Definition: NOTMatchExpression.hpp:191
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:175
NOTMatchExpression(const typename MatchExpression< ObjType1, ObjType2 >::SharedPointer &expr_ptr)
Constructs the NOTMatchExpression object that wraps the match expression instance specified by expr_p...
Definition: NOTMatchExpression.hpp:67
The namespace of the Chemical Data Processing Library.