Files
cgal/Classification/include/CGAL/Classification/Feature_base.h
T
2017-03-16 14:16:44 +01:00

97 lines
2.4 KiB
C++

// Copyright (c) 2017 GeometryFactory Sarl (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
// Author(s) : Simon Giraudot
#ifndef CGAL_CLASSIFICATION_FEATURE_BASE_H
#define CGAL_CLASSIFICATION_FEATURE_BASE_H
#include <boost/shared_ptr.hpp>
#include <vector>
namespace CGAL {
namespace Classification {
/*!
\ingroup PkgClassification
\brief Abstract class describing a classification feature that
associates a scalar value to each item of the classification input.
User-defined features must inherit this class. Feature objects are
generated by `CGAL::Classifier` objects by the method
`CGAL::Classifier::add_feature()`. For this method to work, the
first argument of the feature's constructors must be of type
`ItemRange&` (where `ItemRange` is the first template argument of
`CGAL::Classifier`).
*/
class Feature_base
{
std::string m_name;
public:
/// \cond SKIP_IN_MANUAL
Feature_base() : m_name ("abstract_feature") { }
virtual ~Feature_base() { }
/// \endcond
/*!
\brief Returns the name of the feature (initialized to
`abstract_feature` for `Feature_base`).
*/
const std::string& name() const { return m_name; }
/*!
\brief Changes the name of the feature.
*/
void set_name (const std::string& name) { m_name = name; }
/*!
\brief Returns the value taken by the feature for at the item at
position `index`. This method must be implemented by inherited
classes.
*/
virtual double value (std::size_t index) = 0;
};
#ifdef DOXYGEN_RUNNING
/*!
\ingroup PkgClassification
\brief %Handle to an `Feature_base`.
\cgalModels Handle
*/
class Feature_handle { };
#else
typedef boost::shared_ptr<Feature_base> Feature_handle;
#endif
} // namespace Classification
} // namespace CGAL
#endif // CGAL_CLASSIFICATION_FEATURE_BASE_H