dime  0.9.1
Portable DXF file library
Loading...
Searching...
No Matches
dimeRecordHolder Class Reference

The dimeRecordHolder class is a superclass for objects that store records. More...

#include <dime/RecordHolder.h>

Inheritance diagram for dimeRecordHolder:
dimeBase dimeClass dimeEntity dimeObject dimeTableEntry dimeUnknownClass dimeBlock dimeExtrusionEntity dimeFaceEntity dimeInsert dimeSpline dimeUnknownEntity dimeVertex dimeUnknownObject dimeLayerTable dimeUCSTable dimeUnknownTable

Public Member Functions

 dimeRecordHolder (const int separator)
 
virtual ~dimeRecordHolder ()
 
virtual int countRecords () const
 
dimeRecordfindRecord (const int groupcode, const int index=0)
 
int getNumRecordsInRecordHolder (void) const
 
virtual bool getRecord (const int groupcode, dimeParam &param, const int index=0) const
 
dimeRecordgetRecordInRecordHolder (const int idx) const
 
virtual bool isOfType (const int thetypeid) const
 
virtual bool read (dimeInput *const in)
 
void setIndexedRecord (const int groupcode, const dimeParam &value, const int index, dimeMemHandler *const memhandler=NULL)
 
void setRecord (const int groupcode, const dimeParam &value, dimeMemHandler *const memhandler=NULL)
 
void setRecords (const int *const groupcodes, const dimeParam *const params, const int numrecords, dimeMemHandler *const memhandler=NULL)
 
virtual bool write (dimeOutput *const out)
 
- Public Member Functions inherited from dimeBase
 dimeBase (void)
 
virtual ~dimeBase ()
 
void operator delete (void *ptr)
 
void * operator new (size_t size, dimeMemHandler *memhandler=NULL, const int alignment=4)
 
virtual int typeId () const =0
 

Protected Member Functions

bool copyRecords (dimeRecordHolder *const rh, dimeMemHandler *const memhandler) const
 
virtual bool handleRecord (const int groupcode, const dimeParam &param, dimeMemHandler *const memhandler)
 
virtual bool shouldWriteRecord (const int groupcode) const
 

Protected Attributes

int numRecords
 
dimeRecord ** records
 

Additional Inherited Members

- Public Types inherited from dimeBase
enum  {
  dimeBaseType = 1 , dimeRecordType , dimeStringRecordType , dimeFloatRecordType ,
  dimeDoubleRecordType , dimeInt8RecordType , dimeInt16RecordType , dimeInt32RecordType ,
  dimeHexRecordType , dimeRecordHolderType , dimeClassType , dimeUnknownClassType ,
  dimeObjectType , dimeUnknownObjectType , dimeEntityType , dimeUnknownEntityType ,
  dimePolylineType , dimeVertexType , dimeFaceEntityType , dimeExtrusionEntityType ,
  dime3DFaceType , dimeSolidType , dimeTraceType , dimeLineType ,
  dimeTextType , dimePointType , dimeBlockType , dimeInsertType ,
  dimeCircleType , dimeArcType , dimeLWPolylineType , dimeEllipseType ,
  dimeSplineType , dimeSectionType , dimeUnknownSectionType , dimeEntitiesSectionType ,
  dimeBlocksSectionType , dimeTablesSectionType , dimeHeaderSectionType , dimeClassesSectionType ,
  dimeObjectsSectionType , dimeTableType , dimeTableEntryType , dimeUnknownTableType ,
  dimeUCSTableType , dimeLayerTableType , dimeLastTypeTag
}
 

Detailed Description

The dimeRecordHolder class is a superclass for objects that store records.

This class makes it very easy to add new classes to dime, as it handles all of the reading, error checking and storing of records of no use to the subclass. Subclasses will only need to implement the dimeRecordHolder::handleRecord() and dimeRecordHolder::getRecord() methods.

Constructor & Destructor Documentation

◆ dimeRecordHolder()

dimeRecordHolder::dimeRecordHolder ( const int sep)

Constructor. separator is the group code that will separate objects, to enable the record holder to stop reading the object at the correct time. For instance, entities are separated by group code 0 (a group code 0 signals a new entity is about to start).

◆ ~dimeRecordHolder()

dimeRecordHolder::~dimeRecordHolder ( )
virtual

Destructor.

Member Function Documentation

◆ copyRecords()

bool dimeRecordHolder::copyRecords ( dimeRecordHolder *const rh,
dimeMemHandler *const memh ) const
protected

Copies the stored records into rh.

◆ countRecords()

int dimeRecordHolder::countRecords ( ) const
virtual

Returns the number of records in the record holder. Should be overloaded by subclasses which should count their records, and then call the parent's method. This method is used to precalculate the number of records to be written. Very useful when progress information is needed during write().

Reimplemented in dimeClass, dimeUnknownClass, dime3DFace, dimeArc, dimeBlock, dimeCircle, dimeEllipse, dimeEntity, dimeExtrusionEntity, dimeFaceEntity, dimeInsert, dimeLine, dimeLWPolyline, dimePoint, dimePolyline, dimeSolid, dimeSpline, dimeText, dimeTrace, dimeUnknownEntity, dimeVertex, dimeObject, dimeUnknownObject, dimeLayerTable, dimeTableEntry, dimeUCSTable, and dimeUnknownTable.

◆ findRecord()

dimeRecord * dimeRecordHolder::findRecord ( const int groupcode,
const int index = 0 )

Returns the record with group code groupcode. If index > 0, the index'th record with group code groupcode will be returned. Returns NULL if the record is not found or index is out of bounds.

◆ getNumRecordsInRecordHolder()

int dimeRecordHolder::getNumRecordsInRecordHolder ( void ) const

Returns the number of records stored in this record holder.

◆ getRecord()

bool dimeRecordHolder::getRecord ( const int groupcode,
dimeParam & param,
const int index = 0 ) const
virtual

Will return the value of the record with group code groupcode. false is returned if the record could not be found. Subclasses should overload this method if one or several records are stored in the class. If the group code queried is not stored internally, the subclass should call its parent's method.

Reimplemented in dimeLWPolyline, dimeSpline, dime3DFace, dimeArc, dimeBlock, dimeCircle, dimeEllipse, dimeEntity, dimeExtrusionEntity, dimeFaceEntity, dimeInsert, dimeLine, dimePoint, dimePolyline, dimeSolid, dimeText, dimeTrace, and dimeVertex.

◆ getRecordInRecordHolder()

dimeRecord * dimeRecordHolder::getRecordInRecordHolder ( const int idx) const

Returns the idx'th record in the record holder.

See also
getNumRecordsInRecordHolder().

◆ handleRecord()

bool dimeRecordHolder::handleRecord ( const int groupcode,
const dimeParam & param,
dimeMemHandler *const memhandler )
protectedvirtual

Must be overloaded by entities that directly support a record type. During dimeRecordHolder::read(), dimeRecordHolder::setRecord and dimeRecordHolder::setRecords, this function is called for every record found, and it is up to the subclass if the record should be stored internally, or if a generic record should be created and stored in this superclass. A subclass should return true when it will handle the record, false otherwise. Default function does nothing, and returns false.

For entities, records with group codes 8 (layer name) and 62 (color number) are automatically handled by the dimeEntity class.

See also
dimeRecordHolder::read()
dimeRecordHolder::setRecord()

Reimplemented in dimeClass, dime3DFace, dimeArc, dimeBlock, dimeCircle, dimeEllipse, dimeEntity, dimeExtrusionEntity, dimeFaceEntity, dimeInsert, dimeLine, dimeLWPolyline, dimePoint, dimePolyline, dimeSolid, dimeSpline, dimeText, dimeTrace, dimeVertex, dimeObject, dimeLayerTable, dimeTableEntry, and dimeUCSTable.

◆ isOfType()

bool dimeRecordHolder::isOfType ( const int thetypeid) const
virtual

Returns true if the object is of type typeid or is inherited from it. Function in base class checks whether thetypeid equals the virtual dimeBase::typeId() value or equals dimeBaseType. Must be implemented by all subclasses that are superclasses of other classes, and should check if thetypeid equals its typeId, and then call its parent's isOfType function. Leaf-classes do not have to implement this method.

Reimplemented from dimeBase.

Reimplemented in dimeClass, dimeEntity, dimeFaceEntity, dimeObject, dimeTableEntry, and dimeExtrusionEntity.

◆ read()

bool dimeRecordHolder::read ( dimeInput *const file)
virtual

Reads records from in until the separator group code (specified in constructor) is found. Can be overloaded by subclasses, but in most cases this will not be necessary as dimeRecordHolder::handleRecord() is called for each record found in the stream.

See also
dimeEntity::handleRecord().

Reimplemented in dimeClass, dimeBlock, dimeEntity, dimeInsert, dimePolyline, dimeObject, dimeLayerTable, and dimeTableEntry.

◆ setIndexedRecord()

void dimeRecordHolder::setIndexedRecord ( const int groupcode,
const dimeParam & value,
const int index,
dimeMemHandler *const memhandler = NULL )

Basically the same function as setRecord(), but also allows you to specify an index for the record. This is useful if you're going to set several records with the same group code.

See also
dimeRecordHolder::setRecord()

◆ setRecord()

void dimeRecordHolder::setRecord ( const int groupcode,
const dimeParam & value,
dimeMemHandler *const memhandler = NULL )

Sets the data for the record with group code groupcode. If the record already exists, its value will simply be overwritten, otherwise a new record will be created. If the record is handled by a subclass, param will be passed on to the subclass (using dimeRecordHolder::handleRecord()), and will be ignored by dimeRecordHolder.

For entities, you cannot use this method to set the layer name. Use dimeEntity::setLayer() to do that. Also, you should not use this function to set the block name for a dimeInsert entity, use dimeInsert::setBlock() instead.

See also
dimeRecordHolder::handleRecord()
dimeRecordHolder::getRecord()
dimeRecordHolder::setRecords()

◆ setRecords()

void dimeRecordHolder::setRecords ( const int *const groupcodes,
const dimeParam *const params,
const int numrecords,
dimeMemHandler *const memhandler = NULL )

Sets an array of entities. It is much more efficient to use this than using dimeRecordHolder::setRecord() several times if you are going to set the value of more than one record. Otherwise behaves exactly as dimeRecordHolder::setRecord().

◆ shouldWriteRecord()

bool dimeRecordHolder::shouldWriteRecord ( const int groupcode) const
protectedvirtual

Can be overloaded by subclasses that want the record holder to store a record, but handle writing themselves. Default method returns true for all group codes.

Reimplemented in dimeEntity.

◆ write()


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