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 
54  {
55 
56  class ConstFeatureAccessor;
57  class FeatureAccessor;
58 
59  public:
63  typedef std::shared_ptr<FeatureContainer> SharedPointer;
64 
69 
74 
78  virtual ~FeatureContainer() {}
79 
84  virtual std::size_t getNumFeatures() const = 0;
85 
92  virtual const Feature& getFeature(std::size_t idx) const = 0;
93 
100  virtual Feature& getFeature(std::size_t idx) = 0;
101 
108  virtual std::size_t getFeatureIndex(const Feature& feature) const = 0;
109 
115  virtual bool containsFeature(const Feature& feature) const = 0;
116 
122 
128 
134 
140 
146 
152 
158 
164 
169  virtual void orderFeatures(const FeatureCompareFunction& func) = 0;
170 
171  virtual std::size_t getNumEntities() const;
172 
173  virtual const Chem::Entity3D& getEntity(std::size_t idx) const;
174 
175  virtual Chem::Entity3D& getEntity(std::size_t idx);
176 
177  protected:
185 
186  private:
187  class CDPL_PHARM_API ConstFeatureAccessor
188  {
189 
190  public:
191  ConstFeatureAccessor(const FeatureAccessor& accessor):
192  container(accessor.container) {}
193 
194  ConstFeatureAccessor(const FeatureContainer* cntnr):
195  container(cntnr) {}
196 
197  const Feature& operator()(std::size_t idx) const;
198 
199  bool operator==(const ConstFeatureAccessor& accessor) const;
200 
201  ConstFeatureAccessor& operator=(const FeatureAccessor& accessor);
202 
203  private:
204  const FeatureContainer* container;
205  };
206 
207  class CDPL_PHARM_API FeatureAccessor
208  {
209 
210  friend class ConstFeatureAccessor;
211 
212  public:
213  FeatureAccessor(FeatureContainer* cntnr):
214  container(cntnr) {}
215 
216  Feature& operator()(std::size_t idx) const;
217 
218  bool operator==(const FeatureAccessor& accessor) const;
219 
220  private:
221  FeatureContainer* container;
222  };
223  };
224  } // namespace Pharm
225 } // namespace CDPL
226 
227 #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.
A class providing methods for the storage and lookup of object properties.
Definition: PropertyContainer.hpp:75
A common interface for data-structures that support a random access to stored Chem::Entity3D instance...
Definition: Entity3DContainer.hpp:53
Entity3D.
Definition: Entity3D.hpp:46
FeatureContainer.
Definition: FeatureContainer.hpp:54
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:73
virtual ~FeatureContainer()
Virtual destructor.
Definition: FeatureContainer.hpp:78
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 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:68
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:57
virtual const Chem::Entity3D & getEntity(std::size_t idx) const
Returns a const reference to the Chem::Entity3D instance 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.
Feature.
Definition: Feature.hpp:48
A 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)
Definition: GridExpression.hpp:339
std::function< bool(const Feature &, const Feature &)> FeatureCompareFunction
A generic wrapper class used to store a user-defined feature compare function.
Definition: FeatureCompareFunction.hpp:41
The namespace of the Chemical Data Processing Library.