1 #ifndef FAIF_POINT_HPP_ 2 #define FAIF_POINT_HPP_ 10 #include <boost/bind.hpp> 12 #include <boost/serialization/serialization.hpp> 13 #include <boost/serialization/list.hpp> 14 #include <boost/serialization/nvp.hpp> 15 #include <boost/serialization/vector.hpp> 22 template<
typename Val>
class Point :
public std::vector<typename Val::DomainType::ValueId> {
27 template<
class Archive>
29 ar & boost::serialization::make_nvp(
"PointVect",
30 boost::serialization::base_object< std::vector<typename Val::DomainType::ValueId> >(*
this) );
35 template<
typename Val>
36 std::ostream& operator<<(std::ostream& os, const Point<Val>& p) {
37 for(
typename std::vector<typename Val::DomainType::ValueId>::const_iterator i = p.begin(); i != p.end(); ++i) {
47 static Feature init() {
56 template<
typename Value,
typename Feature,
68 feature_ = right.feature_;
71 Feature getFeature()
const {
return feature_; }
74 template<
class Archive>
76 ar & boost::serialization::make_nvp(
"Point", boost::serialization::base_object<
Point<Value> >(*
this) );
77 ar & boost::serialization::make_nvp(
"Feature", feature_ );
85 template <
typename Value,
typename Feature,
template <
typename>
class FeatureInit >
86 std::ostream& operator<<(std::ostream& os, const PointAndFeature<Value, Feature, FeatureInit>& pf) {
87 os << static_cast<const Point<Value>&>(pf) <<
": " << pf.getFeature();
92 template<
typename Domain>
class Space :
public std::list<Domain> {
95 typedef typename Domain::Value Value;
100 template<
typename It>
103 typename Space::const_iterator j = this->begin();
104 for(It i = begin_range; i != end_range && j != this->end(); ++i, ++j) {
105 point.push_back( j->find(*i) );
112 typedef std::pair<std::string, typename Value::Value> AttrValPair;
113 typedef std::vector<AttrValPair> VecAttrValPair;
116 for(
typename Space::const_iterator j = this->begin(); j != this->end(); ++j ) {
117 const typename Value::DomainType& d = *j;
118 typename VecAttrValPair::const_iterator k = std::find_if(collection.begin(), collection.end(),
119 boost::bind(&AttrValPair::first, _1) == boost::bind(&Domain::getId, d) );
121 typename Domain::ValueId
id = Domain::getUnknownId();
122 if( k != collection.end() ) {
124 id = d.find( k->second );
136 typedef std::pair<std::string, typename Value::Value> AttrValPair;
137 typedef std::vector<AttrValPair> VecAttrValPair;
140 for(
typename Space::const_iterator j = this->begin(); j != this->end(); ++j ) {
141 const typename Value::DomainType& d = *j;
142 typename VecAttrValPair::const_iterator k = std::find_if(collection.begin(), collection.end(),
143 boost::bind(&AttrValPair::first, _1) == boost::bind(&Domain::getId, d) );
144 if( k == collection.end() )
146 point.push_back( d.find( k->second ) );
156 #endif //FAIF_POINT_HPP_
the domain concept
Definition: Value.hpp:140
point and some feature
Definition: Point.hpp:58
feature init policy - use default constructor
Definition: Point.hpp:46
Space n-dimensional, each domain of the same type.
Definition: Point.hpp:92
Point< Value > createPoint(const std::vector< std::pair< std::string, typename Value::Value > > &collection) const
create the test example from collection of pairs: attribute(domain) identifier and attribute value ...
Definition: Point.hpp:111
Point in n-space, each component of the same type.
Definition: Point.hpp:22
void serialize(Archive &ar, const unsigned int)
serialization using boost::serialization
Definition: Point.hpp:28
the value concept
Definition: Value.hpp:41
Point< Value > createPoint(It begin_range, It end_range) const
create the test example from iterator range or C-like table of values
Definition: Point.hpp:101
Point< Value > createPointStrict(const std::vector< std::pair< std::string, typename Value::Value > > &collection) const
create the test example from collection of pairs: attribute(domain) identifier and attribute value ...
Definition: Point.hpp:135
void serialize(Archive &ar, const unsigned int)
serialization using boost::serialization
Definition: Point.hpp:75
the exception thrown when the value for given attribute is not found
Definition: ExceptionsFaif.hpp:32