This is Unofficial EPICS BASE Doxygen Site
epics::pvData::FieldBuilder Class Reference

Interface for in-line creating of introspection interfaces. More...

#include "pvIntrospect.h"

+ Inheritance diagram for epics::pvData::FieldBuilder:
+ Collaboration diagram for epics::pvData::FieldBuilder:

Public Member Functions

FieldBuilderPtr setId (std::string const &id)
 
FieldBuilderPtr add (std::string const &name, ScalarType scalarType)
 
FieldBuilderPtr addBoundedString (std::string const &name, std::size_t maxLength) PVD_DEPRECATED_52
 
FieldBuilderPtr add (std::string const &name, FieldConstPtr const &field)
 
FieldBuilderPtr addArray (std::string const &name, ScalarType scalarType)
 
FieldBuilderPtr addFixedArray (std::string const &name, ScalarType scalarType, std::size_t size) PVD_DEPRECATED_52
 
FieldBuilderPtr addBoundedArray (std::string const &name, ScalarType scalarType, std::size_t bound) PVD_DEPRECATED_52
 
FieldBuilderPtr addArray (std::string const &name, FieldConstPtr const &element)
 
StructureConstPtr createStructure ()
 
UnionConstPtr createUnion ()
 
FieldBuilderPtr addNestedStructure (std::string const &name)
 
FieldBuilderPtr addNestedUnion (std::string const &name)
 
FieldBuilderPtr addNestedStructureArray (std::string const &name)
 
FieldBuilderPtr addNestedUnionArray (std::string const &name)
 
FieldBuilderPtr endNested ()
 

Static Public Member Functions

static FieldBuilderPtr begin ()
 
static FieldBuilderPtr begin (StructureConstPtr S)
 Create a new instance of in-line Field builder pre-initialized with and existing Structure. More...
 

Friends

class FieldCreate
 

Detailed Description

Interface for in-line creating of introspection interfaces.

One instance can be used to create multiple Field instances. An instance of this object must not be used concurrently (an object has a state).

Author
mse

Definition at line 1072 of file pvIntrospect.h.

Member Function Documentation

FieldBuilderPtr epics::pvData::FieldBuilder::add ( std::string const &  name,
ScalarType  scalarType 
)

Add a Scalar.

Parameters
namename of the array.
scalarTypetype of a scalar to add.
Returns
this instance of a FieldBuilder.
FieldBuilderPtr epics::pvData::FieldBuilder::add ( std::string const &  name,
FieldConstPtr const &  field 
)

Add a Field (e.g. Structure, Union).

Parameters
namename of the array.
fielda field to add.
Returns
this instance of a FieldBuilder.
FieldBuilderPtr epics::pvData::FieldBuilder::addArray ( std::string const &  name,
ScalarType  scalarType 
)

Add variable size array of Scalar elements.

Parameters
namename of the array.
scalarTypetype of a scalar element.
Returns
this instance of a FieldBuilder.
FieldBuilderPtr epics::pvData::FieldBuilder::addArray ( std::string const &  name,
FieldConstPtr const &  element 
)

Add array of Field elements.

Parameters
namename of the array.
elementa type of an array element.
Returns
this instance of a FieldBuilder.
FieldBuilderPtr epics::pvData::FieldBuilder::addBoundedArray ( std::string const &  name,
ScalarType  scalarType,
std::size_t  bound 
)

Add bounded-size array of Scalar elements.

Parameters
namename of the array.
scalarTypetype of a scalar element.
boundArray maximum capacity (size).
Returns
this instance of a FieldBuilder.

Definition at line 1039 of file FieldCreateFactory.cpp.

1040 {
1041  return add(name, fieldCreate->createBoundedScalarArray(scalarType, size));
1042 }
FieldBuilderPtr add(std::string const &name, ScalarType scalarType)
FieldBuilderPtr epics::pvData::FieldBuilder::addBoundedString ( std::string const &  name,
std::size_t  maxLength 
)

Add a BoundedString.

Parameters
namename of the array.
maxLengtha string maximum length.
Returns
this instance of a FieldBuilder.

Definition at line 1013 of file FieldCreateFactory.cpp.

1014 {
1015  return add(name, fieldCreate->createBoundedString(maxLength));
1016 }
FieldBuilderPtr add(std::string const &name, ScalarType scalarType)
FieldBuilderPtr epics::pvData::FieldBuilder::addFixedArray ( std::string const &  name,
ScalarType  scalarType,
std::size_t  size 
)

Add fixed-size array of Scalar elements.

Parameters
namename of the array.
scalarTypetype of a scalar element.
sizeArray fixed size.
Returns
this instance of a FieldBuilder.

Definition at line 1034 of file FieldCreateFactory.cpp.

1035 {
1036  return add(name, fieldCreate->createFixedScalarArray(scalarType, size));
1037 }
FieldBuilderPtr add(std::string const &name, ScalarType scalarType)
FieldBuilderPtr epics::pvData::FieldBuilder::addNestedStructure ( std::string const &  name)

Add new nested Structure. endNested() method must be called to complete creation of the nested Structure.

Parameters
namenested structure name.
Returns
a new instance of a FieldBuilder is returned.
See also
endNested()

Definition at line 1135 of file FieldCreateFactory.cpp.

1136 {
1137  const Field *cur = findField(name, structure);
1138  if(cur) {
1139  return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name,
1140  static_cast<const Structure*>(cur)));
1141  }
1142  return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name, structure, false));
1143 }
std::tr1::shared_ptr< FieldBuilder > FieldBuilderPtr
FieldBuilderPtr epics::pvData::FieldBuilder::addNestedStructureArray ( std::string const &  name)

Add new nested Structure[]. endNested() method must be called to complete creation of the nested Structure.

Parameters
namenested structure name.
Returns
a new instance of a FieldBuilder is returned.
See also
endNested()

Definition at line 1157 of file FieldCreateFactory.cpp.

1158 {
1159  const Field *cur = findField(name, structureArray);
1160  if(cur) {
1161  return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name,
1162  static_cast<const StructureArray*>(cur)));
1163  }
1164  return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name, structure, true));
1165 }
std::tr1::shared_ptr< FieldBuilder > FieldBuilderPtr
FieldBuilderPtr epics::pvData::FieldBuilder::addNestedUnion ( std::string const &  name)

Add new nested Union. endNested() method must be called to complete creation of the nested Union.

Parameters
namenested union name.
Returns
a new instance of a FieldBuilder is returned.
See also
endNested()

Definition at line 1146 of file FieldCreateFactory.cpp.

1147 {
1148  const Field *cur = findField(name, union_);
1149  if(cur) {
1150  return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name,
1151  static_cast<const Union*>(cur)));
1152  }
1153  return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name, union_, false));
1154 }
std::tr1::shared_ptr< FieldBuilder > FieldBuilderPtr
FieldBuilderPtr epics::pvData::FieldBuilder::addNestedUnionArray ( std::string const &  name)

Add new nested Union[]. endNested() method must be called to complete creation of the nested Union.

Parameters
namenested union name.
Returns
a new instance of a FieldBuilder is returned.
See also
endNested()

Definition at line 1167 of file FieldCreateFactory.cpp.

1168 {
1169  const Field *cur = findField(name, unionArray);
1170  if(cur) {
1171  return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name,
1172  static_cast<const UnionArray*>(cur)));
1173  }
1174  return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name, union_, true));
1175 }
std::tr1::shared_ptr< FieldBuilder > FieldBuilderPtr
FieldBuilderPtr epics::pvData::FieldBuilder::begin ( )
static

Create a new instance of in-line Field builder.

Version
Added after 7.0.0

Definition at line 988 of file FieldCreateFactory.cpp.

989 {
990  FieldBuilderPtr ret(new FieldBuilder);
991  return ret;
992 }
std::tr1::shared_ptr< FieldBuilder > FieldBuilderPtr
FieldBuilderPtr epics::pvData::FieldBuilder::begin ( StructureConstPtr  S)
static

Create a new instance of in-line Field builder pre-initialized with and existing Structure.

Definition at line 994 of file FieldCreateFactory.cpp.

995 {
996  FieldBuilderPtr ret(new FieldBuilder(S.get()));
997  return ret;
998 }
std::tr1::shared_ptr< FieldBuilder > FieldBuilderPtr
StructureConstPtr epics::pvData::FieldBuilder::createStructure ( )

Create a Structure. This resets this instance state and allows new Field instance to be created.

Returns
a new instance of a Structure.

Definition at line 1099 of file FieldCreateFactory.cpp.

1100 {
1101  if (parentBuilder.get())
1102  THROW_EXCEPTION2(std::runtime_error, "createStructure() called in nested FieldBuilder");
1103 
1104  StructureConstPtr field(static_pointer_cast<const Structure>(createFieldInternal(structure)));
1105  reset();
1106  return field;
1107 }
#define THROW_EXCEPTION2(TYPE, MSG)
std::tr1::shared_ptr< const Structure > StructureConstPtr
Definition: pvIntrospect.h:162
UnionConstPtr epics::pvData::FieldBuilder::createUnion ( )

Create an Union. This resets this instance state and allows new Field instance to be created.

Returns
a new instance of an Union.

Definition at line 1109 of file FieldCreateFactory.cpp.

1110 {
1111  if (parentBuilder.get())
1112  THROW_EXCEPTION2(std::runtime_error, "createUnion() called in nested FieldBuilder");
1113 
1114  UnionConstPtr field(static_pointer_cast<const Union>(createFieldInternal(union_)));
1115  reset();
1116  return field;
1117 }
#define THROW_EXCEPTION2(TYPE, MSG)
std::tr1::shared_ptr< const Union > UnionConstPtr
Definition: pvIntrospect.h:170
FieldBuilderPtr epics::pvData::FieldBuilder::endNested ( )

Complete the creation of a nested object.

See also
addNestedStructure(std::string const & name)
addNestedUnion(std::string const & name)
Returns
a previous (parent) FieldBuilder.

Definition at line 1177 of file FieldCreateFactory.cpp.

1178 {
1179  if (!parentBuilder)
1180  THROW_EXCEPTION2(std::runtime_error, "FieldBuilder::endNested() can only be called to create nested fields");
1181 
1182  FieldConstPtr nestedField = createFieldInternal(nestedClassToBuild);
1183 
1184  if(createNested) {
1185  if (nestedArray)
1186  parentBuilder->addArray(nestedName, nestedField);
1187  else
1188  parentBuilder->add(nestedName, nestedField);
1189  return parentBuilder;
1190  } else {
1191  for(size_t i=0, N = parentBuilder->fieldNames.size(); i<N; i++)
1192  {
1193  if(nestedName!=parentBuilder->fieldNames[i])
1194  continue;
1195 
1196  if(nestedArray) {
1197  if(nestedClassToBuild==structure)
1198  parentBuilder->fields[i] = fieldCreate->createStructureArray(std::tr1::static_pointer_cast<const Structure>(nestedField));
1199  else if(nestedClassToBuild==union_)
1200  parentBuilder->fields[i] = fieldCreate->createUnionArray(std::tr1::static_pointer_cast<const Union>(nestedField));
1201  else
1202  throw std::logic_error("bad nested class");
1203  } else {
1204  parentBuilder->fields[i] = nestedField;
1205  }
1206  return parentBuilder;
1207  }
1208  // this only reached if bug in ctor
1209  THROW_EXCEPTION2(std::logic_error, "no nested field field?");
1210  }
1211 }
#define THROW_EXCEPTION2(TYPE, MSG)
int i
Definition: scan.c:967
std::tr1::shared_ptr< const Field > FieldConstPtr
Definition: pvIntrospect.h:137
FieldBuilderPtr epics::pvData::FieldBuilder::setId ( std::string const &  id)

Set ID of an object to be created.

Parameters
idid to be set.
Returns
this instance of a FieldBuilder.

Definition at line 1001 of file FieldCreateFactory.cpp.

1002 {
1003  this->id = id;
1004  idSet = true;
1005  return shared_from_this();
1006 }

Friends And Related Function Documentation

friend class FieldCreate
friend

Definition at line 1225 of file pvIntrospect.h.


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