Chemical Data Processing Library C++ API - Version 1.2.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"
38 
39 
40 namespace CDPL
41 {
42 
43  namespace Pharm
44  {
45 
46  class Feature;
47 
53  {
54 
55  class ConstFeatureAccessor;
56  class FeatureAccessor;
57 
58  public:
62  typedef std::shared_ptr<FeatureContainer> SharedPointer;
63 
68 
73 
77  virtual ~FeatureContainer() {}
78 
83  virtual std::size_t getNumFeatures() const = 0;
84 
91  virtual const Feature& getFeature(std::size_t idx) const = 0;
92 
99  virtual Feature& getFeature(std::size_t idx) = 0;
100 
107  virtual std::size_t getFeatureIndex(const Feature& feature) const = 0;
108 
114  virtual bool containsFeature(const Feature& feature) const = 0;
115 
121 
127 
133 
139 
145 
151 
157 
163 
164  virtual std::size_t getNumEntities() const;
165 
166  virtual const Chem::Entity3D& getEntity(std::size_t idx) const;
167 
168  virtual Chem::Entity3D& getEntity(std::size_t idx);
169 
170  protected:
178 
179  private:
180  class CDPL_PHARM_API ConstFeatureAccessor
181  {
182 
183  public:
184  ConstFeatureAccessor(const FeatureAccessor& accessor):
185  container(accessor.container) {}
186 
187  ConstFeatureAccessor(const FeatureContainer* cntnr):
188  container(cntnr) {}
189 
190  const Feature& operator()(std::size_t idx) const;
191 
192  bool operator==(const ConstFeatureAccessor& accessor) const;
193 
194  ConstFeatureAccessor& operator=(const FeatureAccessor& accessor);
195 
196  private:
197  const FeatureContainer* container;
198  };
199 
200  class CDPL_PHARM_API FeatureAccessor
201  {
202 
203  friend class ConstFeatureAccessor;
204 
205  public:
206  FeatureAccessor(FeatureContainer* cntnr):
207  container(cntnr) {}
208 
209  Feature& operator()(std::size_t idx) const;
210 
211  bool operator==(const FeatureAccessor& accessor) const;
212 
213  private:
214  FeatureContainer* container;
215  };
216  };
217  } // namespace Pharm
218 } // namespace CDPL
219 
220 #endif // CDPL_PHARM_FEATURECONTAINER_HPP
Definition of the class CDPL::Chem::Entity3DContainer.
Definition of the 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 the 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:53
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:72
virtual ~FeatureContainer()
Virtual destructor.
Definition: FeatureContainer.hpp:77
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:67
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:56
virtual const Chem::Entity3D & getEntity(std::size_t idx) const
Returns a const reference to the Chem::Entity3D instance at index idx.
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
The namespace of the Chemical Data Processing Library.