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 
52  template <typename ObjType1, typename ObjType2 = void>
53  class NOTMatchExpression : public MatchExpression<ObjType1, ObjType2>
54  {
55 
56  public:
60  typedef std::shared_ptr<NOTMatchExpression> SharedPointer;
61 
67  expression(expr_ptr) {}
68 
79  bool operator()(const ObjType1& query_obj1, const ObjType2& query_obj2, const ObjType1& target_obj1, const ObjType2& target_obj2,
80  const Base::Any& aux_data) const;
81 
94  bool operator()(const ObjType1& query_obj1, const ObjType2& query_obj2, const ObjType1& target_obj1, const ObjType2& target_obj2,
95  const AtomBondMapping& mapping, const Base::Any& aux_data) const;
96 
103  bool requiresAtomBondMapping() const;
104 
105  private:
107  };
108 
116  template <typename ObjType>
117  class NOTMatchExpression<ObjType, void> : public MatchExpression<ObjType, void>
118  {
119 
120  public:
124  typedef std::shared_ptr<NOTMatchExpression> SharedPointer;
125 
131  expression(expr_ptr) {}
132 
141  bool operator()(const ObjType& query_obj, const ObjType& target_obj, const Base::Any& aux_data) const;
142 
153  bool operator()(const ObjType& query_obj, const ObjType& target_obj, const AtomBondMapping& mapping, const Base::Any& aux_data) const;
154 
162 
163  private:
165  };
166  } // namespace Chem
167 } // namespace CDPL
168 
169 
170 // Implementation
171 
172 template <typename ObjType1, typename ObjType2>
173 bool CDPL::Chem::NOTMatchExpression<ObjType1, ObjType2>::operator()(const ObjType1& query_obj1, const ObjType2& query_obj2,
174  const ObjType1& target_obj1, const ObjType2& target_obj2,
175  const Base::Any& data) const
176 {
177  return !this->expression->operator()(query_obj1, query_obj2, target_obj1, target_obj2, data);
178 }
179 
180 template <typename ObjType1, typename ObjType2>
181 bool CDPL::Chem::NOTMatchExpression<ObjType1, ObjType2>::operator()(const ObjType1& query_obj1, const ObjType2& query_obj2,
182  const ObjType1& target_obj1, const ObjType2& target_obj2,
183  const AtomBondMapping& mapping, const Base::Any& data) const
184 {
185  return !this->expression->operator()(query_obj1, query_obj2, target_obj1, target_obj2, mapping, data);
186 }
187 
188 template <typename ObjType1, typename ObjType2>
190 {
191  return this->expression->requiresAtomBondMapping();
192 }
193 
194 
195 template <typename ObjType>
196 bool CDPL::Chem::NOTMatchExpression<ObjType, void>::operator()(const ObjType& query_obj, const ObjType& target_obj,
197  const Base::Any& data) const
198 {
199  return !this->expression->operator()(query_obj, target_obj, data);
200 }
201 
202 template <typename ObjType>
203 bool CDPL::Chem::NOTMatchExpression<ObjType, void>::operator()(const ObjType& query_obj, const ObjType& target_obj,
204  const AtomBondMapping& mapping, const Base::Any& data) const
205 {
206  return !this->expression->operator()(query_obj, target_obj, mapping, data);
207 }
208 
209 template <typename ObjType1>
211 {
212  return this->expression->requiresAtomBondMapping();
213 }
214 
215 #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 a NOTMatchExpressionBase object that wraps the match expression instance specified by expr...
Definition: NOTMatchExpression.hpp:130
std::shared_ptr< NOTMatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated NOTMatchExpression instances.
Definition: NOTMatchExpression.hpp:124
bool requiresAtomBondMapping() const
Tells whether the wrapped match expression requires a reevaluation after a query to target atom/bond ...
Chem::MatchExpression decorator that negates the result of a wrapped Chem::MatchExpression instance.
Definition: NOTMatchExpression.hpp:54
std::shared_ptr< NOTMatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated NOTMatchExpression instances.
Definition: NOTMatchExpression.hpp:60
bool requiresAtomBondMapping() const
Tells whether the wrapped match expression requires a reevaluation after a query to target atom/bond ...
Definition: NOTMatchExpression.hpp:189
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:173
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:66
The namespace of the Chemical Data Processing Library.