homog2d library
Classes | Functions
h2d::rtp Namespace Reference

Holds pointer-based runtime polymorphism stuff. More...

Classes

class  Root
 Non-templated root class, to achieve dynamic (runtime) polymorphism. More...
 

Functions

std::ostream & operator<< (std::ostream &f, const Root &p)
 Stream operator for Root type. More...
 

Detailed Description

Holds pointer-based runtime polymorphism stuff.

Function Documentation

◆ operator<<()

std::ostream& h2d::rtp::operator<< ( std::ostream &  f,
const Root p 
)
inline

Stream operator for Root type.

Todo:
replace this by a call to a virtual function print() (that needs to be defined in all the child classes as:
void print( std::ostream& f )
{
f << *this;
}
12231 {
12232  f << "type="<< getString( p.type() ) << std::endl;
12233  switch( p.type() )
12234  {
12235  case Type::Circle:
12236  {
12237  const Circle_<double>* p2 = static_cast<const Circle_<double>*>( &p );
12238  f << *p2;
12239  }
12240  break;
12241  case Type::Ellipse:
12242  {
12243  const Ellipse_<double>* p2 = static_cast<const Ellipse_<double>*>( &p );
12244  f << *p2;
12245  }
12246  break;
12247  case Type::FRect:
12248  {
12249  const FRect_<double>* p2 = static_cast<const FRect_<double>*>( &p );
12250  f << *p2;
12251  }
12252  break;
12253  case Type::Line2d:
12254  {
12255  const Line2d_<double>* p2 = static_cast<const Line2d_<double>*>( &p );
12256  f << *p2;
12257  }
12258  break;
12259  case Type::Point2d:
12260  {
12261  const Point2d_<double>* p2 = static_cast<const Point2d_<double>*>( &p );
12262  f << *p2;
12263  }
12264  break;
12265  case Type::Segment:
12266  {
12267  const Segment_<double>* p2 = static_cast<const Segment_<double>*>( &p );
12268  f << *p2;
12269  }
12270  break;
12271  case Type::OSegment:
12272  {
12273  const OSegment_<double>* p2 = static_cast<const OSegment_<double>*>( &p );
12274  f << *p2;
12275  }
12276  break;
12277  case Type::OPolyline:
12278  {
12279  const OPolyline_<double>* p2 = static_cast<const OPolyline_<double>*>( &p );
12280  f << *p2;
12281  }
12282  break;
12283  case Type::CPolyline:
12284  {
12285  const CPolyline_<double>* p2 = static_cast<const CPolyline_<double>*>( &p );
12286  f << *p2;
12287  }
12288  break;
12289  default: assert(0);
12290  }
12291  return f;
12292 }
OPolyline_< HOMOG2D_INUMTYPE > OPolyline
Definition: homog2d.hpp:12403
FRect_< HOMOG2D_INUMTYPE > FRect
Default rectangle type.
Definition: homog2d.hpp:12399
Segment_< HOMOG2D_INUMTYPE > Segment
Default segment type.
Definition: homog2d.hpp:12392
Circle_< HOMOG2D_INUMTYPE > Circle
Default circle type.
Definition: homog2d.hpp:12396
Line2d_< HOMOG2D_INUMTYPE > Line2d
Default line type, uses double as numerical type.
Definition: homog2d.hpp:12380
OSegment_< HOMOG2D_INUMTYPE > OSegment
Definition: homog2d.hpp:12393
Ellipse_< HOMOG2D_INUMTYPE > Ellipse
Default ellipse type.
Definition: homog2d.hpp:12406
const char * getString(PointSide t)
Definition: homog2d.hpp:4836
CPolyline_< HOMOG2D_INUMTYPE > CPolyline
Default polyline type.
Definition: homog2d.hpp:12402
Point2d_< HOMOG2D_INUMTYPE > Point2d
Default point type, uses double as numerical type.
Definition: homog2d.hpp:12383
Here is the call graph for this function: