Chemical Data Processing Library C++ API - Version 1.1.1
FeatureSet.hpp
Go to the documentation of this file.
1 /*
2  * FeatureSet.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_FEATURESET_HPP
30 #define CDPL_PHARM_FEATURESET_HPP
31 
32 #include <vector>
33 #include <unordered_map>
34 #include <memory>
35 
36 #include <boost/iterator/indirect_iterator.hpp>
37 
38 #include "CDPL/Pharm/APIPrefix.hpp"
40 
41 
42 namespace CDPL
43 {
44 
45  namespace Pharm
46  {
47 
52  {
53 
54  typedef std::vector<Feature*> FeatureList;
55 
56  public:
60  typedef std::shared_ptr<FeatureSet> SharedPointer;
61 
65  typedef boost::indirect_iterator<FeatureList::const_iterator, const Feature> ConstFeatureIterator;
66 
70  typedef boost::indirect_iterator<FeatureList::iterator, Feature> FeatureIterator;
71 
76 
81  FeatureSet(const FeatureSet& ftr_set);
82 
87  explicit FeatureSet(const FeatureContainer& cntnr);
88 
95 
100  std::size_t getNumFeatures() const;
101 
107  bool containsFeature(const Feature& ftr) const;
108 
115  std::size_t getFeatureIndex(const Feature& ftr) const;
116 
122 
128 
134 
140 
147  const Feature& getFeature(std::size_t idx) const;
148 
155  Feature& getFeature(std::size_t idx);
156 
162  bool addFeature(const Feature& ftr);
163 
169  void removeFeature(std::size_t idx);
170 
179 
185  bool removeFeature(const Feature& ftr);
186 
190  void clear();
191 
198  FeatureSet& operator=(const FeatureSet& ftr_set);
199 
207 
215 
223 
224  private:
225  typedef std::unordered_map<const Feature*, std::size_t> FeatureIndexMap;
226 
227  FeatureList features;
228  FeatureIndexMap featureIndices;
229  };
230  } // namespace Pharm
231 } // namespace CDPL
232 
233 #endif // CDPL_PHARM_FEATURESET_HPP
APIPrefix.hpp
Definition of the preprocessor macro CDPL_PHARM_API.
CDPL::Pharm::FeatureSet::getFeature
Feature & getFeature(std::size_t idx)
Returns a non-const reference to the feature at index idx.
CDPL::Pharm::FeatureSet::removeFeature
FeatureIterator removeFeature(const FeatureIterator &it)
Removes the feature specified by the iterator it.
CDPL_PHARM_API
#define CDPL_PHARM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
CDPL::Pharm::FeatureSet::getNumFeatures
std::size_t getNumFeatures() const
Returns the number of features.
CDPL::Pharm::FeatureSet::clear
void clear()
Removes all features and properties.
CDPL::Pharm::FeatureSet::FeatureSet
FeatureSet()
Constructs an empty FeatureSet instance.
CDPL::Pharm::FeatureSet::FeatureIterator
boost::indirect_iterator< FeatureList::iterator, Feature > FeatureIterator
A mutable random access iterator used to iterate over the stored const Pharm::Feature objects.
Definition: FeatureSet.hpp:70
CDPL::Pharm::FeatureSet::containsFeature
bool containsFeature(const Feature &ftr) const
Tells whether the specified feature is part of this feature set.
CDPL::Pharm::FeatureSet::ConstFeatureIterator
boost::indirect_iterator< FeatureList::const_iterator, const Feature > ConstFeatureIterator
A constant random access iterator used to iterate over the stored const Pharm::Feature objects.
Definition: FeatureSet.hpp:65
FeatureContainer.hpp
Definition of the class CDPL::Pharm::FeatureContainer.
CDPL::Pharm::FeatureSet::FeatureSet
FeatureSet(const FeatureSet &ftr_set)
Constructs a copy of the FeatureSet instance ftr_set.
CDPL::Util::IndexedElementIterator
A STL compatible random access iterator for container elements accessible by index.
Definition: IndexedElementIterator.hpp:125
CDPL::Pharm::FeatureSet::operator=
FeatureSet & operator=(const FeatureContainer &cntnr)
Replaces the current set of features and properties by the features and properties of the feature con...
CDPL::Pharm::FeatureSet::removeFeature
void removeFeature(std::size_t idx)
Removes the feature at the specified index.
CDPL::Pharm::FeatureSet::FeatureSet
FeatureSet(const FeatureContainer &cntnr)
Constructs a FeatureSet instance storing the features and properties of the feature container cntnr.
CDPL::Pharm::FeatureSet::~FeatureSet
~FeatureSet()
Destructor.
CDPL::Pharm::FeatureContainer
FeatureContainer.
Definition: FeatureContainer.hpp:53
CDPL::Pharm::FeatureSet::getFeaturesBegin
FeatureIterator getFeaturesBegin()
Returns a mutable iterator pointing to the beginning of the stored const Pharm::Feature objects.
CDPL::Pharm::FeatureSet::removeFeature
bool removeFeature(const Feature &ftr)
Removes the specified feature.
CDPL::Pharm::FeatureSet::getFeaturesEnd
FeatureIterator getFeaturesEnd()
Returns a mutable iterator pointing to the end of the stored const Pharm::Feature objects.
CDPL::Pharm::FeatureSet::getFeature
const Feature & getFeature(std::size_t idx) const
Returns a const reference to the feature at index idx.
CDPL::Pharm::FeatureSet::SharedPointer
std::shared_ptr< FeatureSet > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated FeatureSet instances.
Definition: FeatureSet.hpp:60
CDPL::Pharm::FeatureSet
FeatureSet.
Definition: FeatureSet.hpp:52
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Pharm::FeatureSet::operator-=
FeatureSet & operator-=(const FeatureContainer &cntnr)
Removes the pharmacophore features referenced by the feature container cntnr from this FeatureSet ins...
CDPL::Pharm::FeatureSet::operator=
FeatureSet & operator=(const FeatureSet &ftr_set)
Replaces the current set of features and properties by the features and properties of the feature set...
CDPL::Pharm::FeatureSet::getFeatureIndex
std::size_t getFeatureIndex(const Feature &ftr) const
Returns the index of the specified feature.
CDPL::Pharm::FeatureSet::getFeaturesBegin
ConstFeatureIterator getFeaturesBegin() const
Returns a constant iterator pointing to the beginning of the stored const Pharm::Feature objects.
CDPL::Pharm::FeatureSet::operator+=
FeatureSet & operator+=(const FeatureContainer &cntnr)
Extends the current set of features by the features in the feature container cntnr.
CDPL::Pharm::FeatureSet::getFeaturesEnd
ConstFeatureIterator getFeaturesEnd() const
Returns a constant iterator pointing to the end of the stored const Pharm::Feature objects.
CDPL::Pharm::Feature
Feature.
Definition: Feature.hpp:48
CDPL::Pharm::FeatureSet::addFeature
bool addFeature(const Feature &ftr)
Extends the feature set by the specified feature.