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;
}
12227 {
12228  f << "type="<< getString( p.type() ) << std::endl;
12229  switch( p.type() )
12230  {
12231  case Type::Circle:
12232  {
12233  const Circle_<double>* p2 = static_cast<const Circle_<double>*>( &p );
12234  f << *p2;
12235  }
12236  break;
12237  case Type::Ellipse:
12238  {
12239  const Ellipse_<double>* p2 = static_cast<const Ellipse_<double>*>( &p );
12240  f << *p2;
12241  }
12242  break;
12243  case Type::FRect:
12244  {
12245  const FRect_<double>* p2 = static_cast<const FRect_<double>*>( &p );
12246  f << *p2;
12247  }
12248  break;
12249  case Type::Line2d:
12250  {
12251  const Line2d_<double>* p2 = static_cast<const Line2d_<double>*>( &p );
12252  f << *p2;
12253  }
12254  break;
12255  case Type::Point2d:
12256  {
12257  const Point2d_<double>* p2 = static_cast<const Point2d_<double>*>( &p );
12258  f << *p2;
12259  }
12260  break;
12261  case Type::Segment:
12262  {
12263  const Segment_<double>* p2 = static_cast<const Segment_<double>*>( &p );
12264  f << *p2;
12265  }
12266  break;
12267  case Type::OSegment:
12268  {
12269  const OSegment_<double>* p2 = static_cast<const OSegment_<double>*>( &p );
12270  f << *p2;
12271  }
12272  break;
12273  case Type::OPolyline:
12274  {
12275  const OPolyline_<double>* p2 = static_cast<const OPolyline_<double>*>( &p );
12276  f << *p2;
12277  }
12278  break;
12279  case Type::CPolyline:
12280  {
12281  const CPolyline_<double>* p2 = static_cast<const CPolyline_<double>*>( &p );
12282  f << *p2;
12283  }
12284  break;
12285  default: assert(0);
12286  }
12287  return f;
12288 }
OPolyline_< HOMOG2D_INUMTYPE > OPolyline
Definition: homog2d.hpp:12399
FRect_< HOMOG2D_INUMTYPE > FRect
Default rectangle type.
Definition: homog2d.hpp:12395
Segment_< HOMOG2D_INUMTYPE > Segment
Default segment type.
Definition: homog2d.hpp:12388
Circle_< HOMOG2D_INUMTYPE > Circle
Default circle type.
Definition: homog2d.hpp:12392
Line2d_< HOMOG2D_INUMTYPE > Line2d
Default line type, uses double as numerical type.
Definition: homog2d.hpp:12376
OSegment_< HOMOG2D_INUMTYPE > OSegment
Definition: homog2d.hpp:12389
Ellipse_< HOMOG2D_INUMTYPE > Ellipse
Default ellipse type.
Definition: homog2d.hpp:12402
const char * getString(PointSide t)
Definition: homog2d.hpp:4832
CPolyline_< HOMOG2D_INUMTYPE > CPolyline
Default polyline type.
Definition: homog2d.hpp:12398
Point2d_< HOMOG2D_INUMTYPE > Point2d
Default point type, uses double as numerical type.
Definition: homog2d.hpp:12379
Here is the call graph for this function: