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