SurgSim::Serialize::ShapesFactory Class Reference

A factory implementation for shapes. More...

`#include <SurgSim/Serialize/ShapesFactory.h>`

## Public Member Functions

| ShapesFactory ()
| Constructor. More...
virtual | ~ShapesFactory ()
| Destructor. More...
template<class Derived >
void | registerShape (const std::string &className)
| Template version to register a shape into the internal directory. More...
std::shared_ptr< SurgSim::Math::Shape > | createShape (const std::string &className)
| Create an instance of derived rigid shape based on the specific class name. More...

## Private Types

typedef boost::function< std::shared_ptr< SurgSim::Math::Shape >)> | ShapesFactoryFunction
| A wrapper of function object. More...

## Private Attributes

std::map< std::string, ShapesFactoryFunction > | m_registerDirectory
| Look up table for shapes factory. More...

## Detailed Description

A factory implementation for shapes.

## Member Typedef Documentation

## ShapesFactoryFunction

typedef boost::function<std::shared_ptr<SurgSim::Math::Shape>)> SurgSim::Serialize::ShapesFactory::ShapesFactoryFunction

private

A wrapper of function object.

## Constructor & Destructor Documentation

## ShapesFactory()

SurgSim::Serialize::ShapesFactory::ShapesFactory | ( |  | ) |

Constructor.

## ~ShapesFactory()

SurgSim::Serialize::ShapesFactory::~ShapesFactory | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## createShape()

std::shared_ptr< SurgSim::Math::Shape > SurgSim::Serialize::ShapesFactory::createShape | ( | const std::string & | className | ) |

Create an instance of derived rigid shape based on the specific class name.

Parameters

  className | The identifier name to be used.

Returns
  a pointer to the object of derived rigid shape, or nullptr otherwise.

Return a nullptr if the class name has not been registered before.

## registerShape()

template<class Derived >

void SurgSim::Serialize::ShapesFactory::registerShape | ( | const std::string & | className | ) |

Template version to register a shape into the internal directory.

Template Parameters

  T | The specific type of the shape to be registered.

Parameters

  className | The identifier name to be used.

## Member Data Documentation

## m_registerDirectory

std::map<std::string, ShapesFactoryFunction> SurgSim::Serialize::ShapesFactory::m_registerDirectory

private

Look up table for shapes factory.

The documentation for this class was generated from the following files:

- SurgSim/Serialize/ShapesFactory.h
- SurgSim/Serialize/ShapesFactory-inl.h
- SurgSim/Serialize/ShapesFactory.cpp