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 
55  {
56 
57  class ConstFeatureAccessor;
58  class FeatureAccessor;
59 
60  public:
64  typedef std::shared_ptr<FeatureContainer> SharedPointer;
65 
70 
75 
79  virtual ~FeatureContainer() {}
80 
85  virtual std::size_t getNumFeatures() const = 0;
86 
93  virtual const Feature& getFeature(std::size_t idx) const = 0;
94 
101  virtual Feature& getFeature(std::size_t idx) = 0;
102 
109  virtual std::size_t getFeatureIndex(const Feature& feature) const = 0;
110 
116  virtual bool containsFeature(const Feature& feature) const = 0;
117 
123 
129 
135 
141 
147 
153 
159 
165 
170  virtual void orderFeatures(const FeatureCompareFunction& func) = 0;
171 
179  virtual std::size_t getNumEntities() const;
180 
190  virtual const Chem::Entity3D& getEntity(std::size_t idx) const;
191 
201  virtual Chem::Entity3D& getEntity(std::size_t idx);
202 
203  protected:
211 
212  private:
213  class CDPL_PHARM_API ConstFeatureAccessor
214  {
215 
216  public:
217  ConstFeatureAccessor(const FeatureAccessor& accessor):
218  container(accessor.container) {}
219 
220  ConstFeatureAccessor(const FeatureContainer* cntnr):
221  container(cntnr) {}
222 
223  const Feature& operator()(std::size_t idx) const;
224 
225  bool operator==(const ConstFeatureAccessor& accessor) const;
226 
227  ConstFeatureAccessor& operator=(const FeatureAccessor& accessor);
228 
229  private:
230  const FeatureContainer* container;
231  };
232 
233  class CDPL_PHARM_API FeatureAccessor
234  {
235 
236  friend class ConstFeatureAccessor;
237 
238  public:
239  FeatureAccessor(FeatureContainer* cntnr):
240  container(cntnr) {}
241 
242  Feature& operator()(std::size_t idx) const;
243 
244  bool operator==(const FeatureAccessor& accessor) const;
245 
246  private:
247  FeatureContainer* container;
248  };
249  };
250  } // namespace Pharm
251 } // namespace CDPL
252 
253 #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
Abstract base class for containers holding a sequence of Pharm::Feature objects with associated prope...
Definition: FeatureContainer.hpp:55
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 contained features.
virtual bool containsFeature(const Feature &feature) const =0
Tells whether the specified feature instance is stored in this pharmacophore.
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:74
virtual ~FeatureContainer()
Virtual destructor.
Definition: FeatureContainer.hpp:79
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 pharmacophore features and properties by a copy of the features and prope...
virtual Feature & getFeature(std::size_t idx)=0
Returns a non-const reference to the pharmacophore 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 Chem::Entity3D 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:69
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:58
virtual const Chem::Entity3D & getEntity(std::size_t idx) const
Returns a const reference to the Chem::Entity3D at index idx.
virtual void orderFeatures(const FeatureCompareFunction &func)=0
Orders the stored features according to criteria implemented by the provided feature comparison funct...
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 stored Chem::Entity3D objects.
Abstract base class representing a single pharmacophore feature within a parent Pharm::Pharmacophore.
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:579
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.