Chemical Data Processing Library C++ API - Version 1.4.0
FeatureContainer.hpp
Go to the documentation of this file.
1 /*
2  * FeatureContainer.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_PHARM_FEATURECONTAINER_HPP
30 #define CDPL_PHARM_FEATURECONTAINER_HPP
31 
32 #include <memory>
33 
34 #include "CDPL/Pharm/APIPrefix.hpp"
39 
40 
41 namespace CDPL
42 {
43 
44  namespace Pharm
45  {
46 
47  class Feature;
48 
57  {
58 
59  class ConstFeatureAccessor;
60  class FeatureAccessor;
61 
62  public:
66  typedef std::shared_ptr<FeatureContainer> SharedPointer;
67 
72 
77 
81  virtual ~FeatureContainer() {}
82 
87  virtual std::size_t getNumFeatures() const = 0;
88 
95  virtual const Feature& getFeature(std::size_t idx) const = 0;
96 
103  virtual Feature& getFeature(std::size_t idx) = 0;
104 
111  virtual std::size_t getFeatureIndex(const Feature& feature) const = 0;
112 
118  virtual bool containsFeature(const Feature& feature) const = 0;
119 
125 
131 
137 
143 
149 
155 
161 
167 
172  virtual void orderFeatures(const FeatureCompareFunction& func) = 0;
173 
181  virtual std::size_t getNumEntities() const;
182 
192  virtual const Chem::Entity3D& getEntity(std::size_t idx) const;
193 
203  virtual Chem::Entity3D& getEntity(std::size_t idx);
204 
205  protected:
213 
214  private:
215  class CDPL_PHARM_API ConstFeatureAccessor
216  {
217 
218  public:
219  ConstFeatureAccessor(const FeatureAccessor& accessor):
220  container(accessor.container) {}
221 
222  ConstFeatureAccessor(const FeatureContainer* cntnr):
223  container(cntnr) {}
224 
225  const Feature& operator()(std::size_t idx) const;
226 
227  bool operator==(const ConstFeatureAccessor& accessor) const;
228 
229  ConstFeatureAccessor& operator=(const FeatureAccessor& accessor);
230 
231  private:
232  const FeatureContainer* container;
233  };
234 
235  class CDPL_PHARM_API FeatureAccessor
236  {
237 
238  friend class ConstFeatureAccessor;
239 
240  public:
241  FeatureAccessor(FeatureContainer* cntnr):
242  container(cntnr) {}
243 
244  Feature& operator()(std::size_t idx) const;
245 
246  bool operator==(const FeatureAccessor& accessor) const;
247 
248  private:
249  FeatureContainer* container;
250  };
251  };
252  } // namespace Pharm
253 } // namespace CDPL
254 
255 #endif // CDPL_PHARM_FEATURECONTAINER_HPP
Definition of class CDPL::Chem::Entity3DContainer.
Type declaration of a generic wrapper class for storing user-defined Pharm::Feature compare functions...
Definition of class CDPL::Util::IndexedElementIterator.
Definition of the preprocessor macro CDPL_PHARM_API.
#define CDPL_PHARM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of class CDPL::Base::PropertyContainer.
Base class providing methods for the storage and lookup of object properties.
Definition: PropertyContainer.hpp:75
Common interface for data structures that support a random access to stored Chem::Entity3D instances.
Definition: Entity3DContainer.hpp:53
Base class for objects that have a position in 3D space (e.g. Chem::Atom and Chem::Feature).
Definition: Entity3D.hpp:46
Common interface for data structures that support a random access to stored Pharm::Feature instances.
Definition: FeatureContainer.hpp:57
FeatureIterator end()
Returns a mutable iterator pointing to the end of the stored Pharm::Feature objects.
virtual std::size_t getNumFeatures() const =0
Returns the number of features.
virtual bool containsFeature(const Feature &feature) const =0
Tells whether the specified feature is part of the feature set.
ConstFeatureIterator getFeaturesEnd() const
Returns a constant iterator pointing to the end of the stored const Pharm::Feature objects.
Util::IndexedElementIterator< Feature, FeatureAccessor > FeatureIterator
A mutable random access iterator used to iterate over the stored Pharm::Feature objects.
Definition: FeatureContainer.hpp:76
virtual ~FeatureContainer()
Virtual destructor.
Definition: FeatureContainer.hpp:81
ConstFeatureIterator getFeaturesBegin() const
Returns a constant iterator pointing to the beginning of the stored const Pharm::Feature objects.
FeatureContainer & operator=(const FeatureContainer &cntnr)
Replaces the current set of properties by a copy of the properties of the container cntnr.
virtual Feature & getFeature(std::size_t idx)=0
Returns a non-const reference to the feature at index idx.
FeatureIterator begin()
Returns a mutable iterator pointing to the beginning of the stored Pharm::Feature objects.
virtual std::size_t getFeatureIndex(const Feature &feature) const =0
Returns the index of the specified feature.
ConstFeatureIterator begin() const
Returns a constant iterator pointing to the beginning of the stored const Pharm::Feature objects.
virtual Chem::Entity3D & getEntity(std::size_t idx)
Returns a non-const reference to the entity at index idx.
Util::IndexedElementIterator< const Feature, ConstFeatureAccessor > ConstFeatureIterator
A constant random access iterator used to iterate over the stored const Pharm::Feature objects.
Definition: FeatureContainer.hpp:71
ConstFeatureIterator end() const
Returns a constant iterator pointing to the end of the stored const Pharm::Feature objects.
FeatureIterator getFeaturesBegin()
Returns a mutable iterator pointing to the beginning of the stored Pharm::Feature objects.
std::shared_ptr< FeatureContainer > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated FeatureContainer instances.
Definition: FeatureContainer.hpp:60
virtual const Chem::Entity3D & getEntity(std::size_t idx) const
Returns a const reference to the entity at index idx.
virtual void orderFeatures(const FeatureCompareFunction &func)=0
Orders the features according to criteria implemented by the provided feature comparison function.
FeatureIterator getFeaturesEnd()
Returns a mutable iterator pointing to the end of the stored Pharm::Feature objects.
virtual const Feature & getFeature(std::size_t idx) const =0
Returns a const reference to the feature at index idx.
virtual std::size_t getNumEntities() const
Returns the number of entities.
Abstract base class representing a single pharmacophore feature.
Definition: Feature.hpp:48
STL compatible random access iterator for container elements accessible by index.
Definition: IndexedElementIterator.hpp:125
GridEquality< E1, E2 >::ResultType operator==(const GridExpression< E1 > &e1, const GridExpression< E2 > &e2)
Tells whether the grid expressions e1 and e2 are element-wise equal.
Definition: GridExpression.hpp:677
std::function< bool(const Feature &, const Feature &)> FeatureCompareFunction
Generic wrapper class used to store a user-defined feature compare function.
Definition: FeatureCompareFunction.hpp:41
The namespace of the Chemical Data Processing Library.