Chemical Data Processing Library C++ API - Version 1.1.1
MatchExpression.hpp
Go to the documentation of this file.
1 /*
2  * MatchExpression.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_MATCHEXPRESSION_HPP
30 #define CDPL_CHEM_MATCHEXPRESSION_HPP
31 
32 #include <memory>
33 
34 
35 namespace CDPL
36 {
37 
38  namespace Base
39  {
40 
41  class Any;
42  }
43 
44  namespace Chem
45  {
46 
47  class AtomBondMapping;
48 
73  template <typename ObjType1, typename ObjType2 = void>
75  {
76 
77  public:
81  typedef std::shared_ptr<MatchExpression> SharedPointer;
82 
86  virtual ~MatchExpression() {}
87 
99  virtual bool operator()(const ObjType1& query_obj1, const ObjType2& query_obj2, const ObjType1& target_obj1, const ObjType2& target_obj2,
100  const Base::Any& aux_data) const;
101 
114  virtual bool operator()(const ObjType1& query_obj1, const ObjType2& query_obj2, const ObjType1& target_obj1, const ObjType2& target_obj2,
115  const AtomBondMapping& mapping, const Base::Any& aux_data) const;
116 
123  virtual bool requiresAtomBondMapping() const;
124  };
125 
148  template <typename ObjType>
149  class MatchExpression<ObjType, void>
150  {
151 
152  public:
156  typedef std::shared_ptr<MatchExpression> SharedPointer;
157 
161  virtual ~MatchExpression() {}
162 
172  virtual bool operator()(const ObjType& query_obj, const ObjType& target_obj, const Base::Any& aux_data) const;
173 
184  virtual bool operator()(const ObjType& query_obj, const ObjType& target_obj, const AtomBondMapping& mapping, const Base::Any& aux_data) const;
185 
192  virtual bool requiresAtomBondMapping() const;
193  };
194  } // namespace Chem
195 } // namespace CDPL
196 
197 
198 // Implementation
199 
200 template <typename ObjType1, typename ObjType2>
202  const ObjType1&, const ObjType2&,
203  const Base::Any&) const
204 {
205  return true;
206 }
207 
208 template <typename ObjType1, typename ObjType2>
209 bool CDPL::Chem::MatchExpression<ObjType1, ObjType2>::operator()(const ObjType1& query_obj1, const ObjType2& query_obj2,
210  const ObjType1& target_obj1, const ObjType2& target_obj2,
211  const AtomBondMapping&, const Base::Any& data) const
212 {
213  return operator()(query_obj1, query_obj2, target_obj1, target_obj2, data);
214 }
215 
216 template <typename ObjType1, typename ObjType2>
218 {
219  return false;
220 }
221 
222 
223 template <typename ObjType>
224 bool CDPL::Chem::MatchExpression<ObjType, void>::operator()(const ObjType&, const ObjType&,
225  const Base::Any&) const
226 {
227  return true;
228 }
229 
230 template <typename ObjType>
231 bool CDPL::Chem::MatchExpression<ObjType, void>::operator()(const ObjType& query_obj, const ObjType& target_obj,
232  const AtomBondMapping&, const Base::Any& data) const
233 {
234  return operator()(query_obj, target_obj, data);
235 }
236 
237 template <typename ObjType1>
239 {
240  return false;
241 }
242 
243 #endif // CDPL_CHEM_MATCHEXPRESSION_HPP
CDPL::Chem::MatchExpression::operator()
virtual 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 expression for the given query and target objects.
Definition: MatchExpression.hpp:201
CDPL::Chem::SybylAtomType::Any
const unsigned int Any
Specifies any atom.
Definition: SybylAtomType.hpp:198
CDPL::Chem::MatchExpression::requiresAtomBondMapping
virtual bool requiresAtomBondMapping() const
Tells whether the expression must be reevaluated after a query to target atom/bond mapping candidate ...
Definition: MatchExpression.hpp:217
CDPL::Base::Any
A safe, type checked container for arbitrary data of variable type.
Definition: Any.hpp:59
CDPL::Chem::MatchExpression< ObjType, void >::SharedPointer
std::shared_ptr< MatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MatchExpression instances.
Definition: MatchExpression.hpp:156
CDPL::Chem::MatchExpression< ObjType, void >::~MatchExpression
virtual ~MatchExpression()
Virtual Destructor.
Definition: MatchExpression.hpp:161
CDPL::Chem::MatchExpression::SharedPointer
std::shared_ptr< MatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MatchExpression instances.
Definition: MatchExpression.hpp:81
CDPL::Chem::MatchExpression< ObjType, void >::requiresAtomBondMapping
virtual bool requiresAtomBondMapping() const
Tells whether the expression must be reevaluated after a query to target atom/bond mapping candidate ...
CDPL::Chem::MatchExpression
A generic boolean expression interface for the implementation of query/target object equivalence test...
Definition: MatchExpression.hpp:75
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Chem::MatchExpression::operator()
virtual bool operator()(const ObjType1 &query_obj1, const ObjType2 &query_obj2, const ObjType1 &target_obj1, const ObjType2 &target_obj2, const AtomBondMapping &mapping, const Base::Any &aux_data) const
Performs an evaluation of the expression for the given query and target objects under consideration o...
Definition: MatchExpression.hpp:209
CDPL::Chem::MatchExpression::~MatchExpression
virtual ~MatchExpression()
Virtual Destructor.
Definition: MatchExpression.hpp:86
CDPL::Chem::AtomBondMapping
A data structure for the common storage of related atom to atom and bond to bond mappings.
Definition: AtomBondMapping.hpp:55