Robot Raconteur Core C++ Library
Loading...
Searching...
No Matches
RobotRaconteur::TypeDefinition Class Reference

Class for type definitions. More...

#include <ServiceDefinition.h>

Public Member Functions

 TypeDefinition ()
 Construct a new empty TypeDefinition.
 TypeDefinition (const boost::shared_ptr< MemberDefinition > &member)
 Construct a new empty TypeDefinition.
virtual std::string ToString ()
 Convert property definition to string.
void FromString (boost::string_ref s, const ServiceDefinitionParseInfo *parse_info=NULL)
 Parse a type definition from string.
void Reset ()
 Clear all fields.
void CopyTo (TypeDefinition &def) const
 Copy type definition to def.
boost::shared_ptr< TypeDefinitionClone () const
 Clones the type definition.
void Rename (boost::string_ref name)
 Rename the type definition.
void RemoveContainers ()
 Removes containers from the type.
void RemoveArray ()
 Removes arrays from the type.
void QualifyTypeStringWithUsing ()
 Searches the service definition for a matching using declaration, and replaces type with qualified name.
void UnqualifyTypeStringWithUsing ()
 Searches the service definition for a matching using declaration, and replaces type with unqualified name.
boost::shared_ptr< NamedTypeDefinitionResolveNamedType (const std::vector< boost::shared_ptr< ServiceDefinition > > &other_defs=std::vector< boost::shared_ptr< ServiceDefinition > >(), const boost::shared_ptr< RobotRaconteurNode > &node=boost::shared_ptr< RobotRaconteurNode >(), const boost::shared_ptr< RRObject > &client=boost::shared_ptr< RRObject >())
 Resolve the named type to a NamedTypeDefinition.

Static Public Member Functions

static DataTypes DataTypeFromString (boost::string_ref d)
 Get the DataTypes type code from a string.
static std::string StringFromDataType (DataTypes d)
 Convert a DataTypes type code to a string.

Public Attributes

std::string Name
 The name of the type definition.
DataTypes Type
 The type code of the type definition.
std::string TypeString
 The type name used if Type is DataTypes_namedtype_t.
DataTypes_ArrayTypes ArrayType
 The array type of the type definition.
bool ArrayVarLength
 If true, array is variable length. If false, fixed length.
std::vector< int32_t > ArrayLength
 The array length.
DataTypes_ContainerTypes ContainerType
 The container type of the type definition.
RR_WEAK_PTR< MemberDefinitionmember
 The parent member of the type definition.
ServiceDefinitionParseInfo ParseInfo
 Parsing diagnostic information.

Detailed Description

Class for type definitions.

See service_definitions.md for more information

Constructor & Destructor Documentation

◆ TypeDefinition()

RobotRaconteur::TypeDefinition::TypeDefinition ( const boost::shared_ptr< MemberDefinition > & member)

Construct a new empty TypeDefinition.

Parameters
memberThe parent member definition

Member Function Documentation

◆ Clone()

boost::shared_ptr< TypeDefinition > RobotRaconteur::TypeDefinition::Clone ( ) const

Clones the type definition.

Returns
RR_SHARED_PTR<TypeDefinition> The cloned type definition

◆ CopyTo()

void RobotRaconteur::TypeDefinition::CopyTo ( TypeDefinition & def) const

Copy type definition to def.

Parameters
defThe target type definition

◆ DataTypeFromString()

DataTypes RobotRaconteur::TypeDefinition::DataTypeFromString ( boost::string_ref d)
static

Get the DataTypes type code from a string.

Converts a string name to a type code. Array and containers must be removed from string before use.

All unknown strings return DataTypes_namedtype_t

Parameters
dThe string
Returns
DataTypes The type code

◆ FromString()

void RobotRaconteur::TypeDefinition::FromString ( boost::string_ref s,
const ServiceDefinitionParseInfo * parse_info = NULL )

Parse a type definition from string.

Parameters
sThe type definition as a string
parse_infoParsing diagnostic information

◆ QualifyTypeStringWithUsing()

void RobotRaconteur::TypeDefinition::QualifyTypeStringWithUsing ( )

Searches the service definition for a matching using declaration, and replaces type with qualified name.

member field must be a valid parent member. Service definition must be available by searching the parents of member.

◆ RemoveArray()

void RobotRaconteur::TypeDefinition::RemoveArray ( )

Removes arrays from the type.

Sets ArrayType to DataTypes_ArrayTypes_none

◆ RemoveContainers()

void RobotRaconteur::TypeDefinition::RemoveContainers ( )

Removes containers from the type.

Sets ContainerType to DataTypes_ContainerTypes_none

◆ Rename()

void RobotRaconteur::TypeDefinition::Rename ( boost::string_ref name)

Rename the type definition.

Updates the Name field

Parameters
nameThe new name

◆ ResolveNamedType()

boost::shared_ptr< NamedTypeDefinition > RobotRaconteur::TypeDefinition::ResolveNamedType ( const std::vector< boost::shared_ptr< ServiceDefinition > > & other_defs = std::vector< boost::shared_ptr< ServiceDefinition > >(),
const boost::shared_ptr< RobotRaconteurNode > & node = boost::shared_ptr< RobotRaconteurNode >(),
const boost::shared_ptr< RRObject > & client = boost::shared_ptr< RRObject >() )

Resolve the named type to a NamedTypeDefinition.

Named types are user defined types that are declared in service definition files. Types that are not primitive types are named types. They have the type code DataTypes_namedtype_t when stored in TypeDefinition, and use the TypeString field to store the qualified or unqualified name. ResolveNamedType will search the service definition to find the matching NamedTypeDefinition. This will either have the subclass ServiceEntryDefinition or EnumDefinition.

ResolveNamedType searches the parent tree starting member, the service definitions specified in other_defs, the service types registered by the specified node, or the service types pulled by the specified client, in that order.

Failure will result in a ServiceDefinitionException being thrown.

Parameters
other_defsService definitions to search for type
nodeSearch service types registered in node
clientSearch service types pulled by client
Returns
RR_SHARED_PTR<NamedTypeDefinition> The resolved type definition

◆ StringFromDataType()

std::string RobotRaconteur::TypeDefinition::StringFromDataType ( DataTypes d)
static

Convert a DataTypes type code to a string.

Parameters
dThe type code
Returns
std::string The string type

◆ UnqualifyTypeStringWithUsing()

void RobotRaconteur::TypeDefinition::UnqualifyTypeStringWithUsing ( )

Searches the service definition for a matching using declaration, and replaces type with unqualified name.

member field must be a valid parent member. Service definition must be available by searching the parents of member.

Member Data Documentation

◆ Name

std::string RobotRaconteur::TypeDefinition::Name

The name of the type definition.

Used for parameter names


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