MorphoGraphX  2.0-1-227
Public Member Functions | Protected Attributes | List of all members
mgx::PlyFile::Element Class Reference

#include <PlyFile.hpp>

Public Member Functions

 Element (const QString &name, PlyFile *parent=0)
 Element constructor. More...
 
 ~Element ()
 The destructor takes care of detaching the element from the PLY file that contains it. More...
 
void allocate ()
 Allocate the memory for all the properties attached to the element. More...
 
void clear ()
 Remove any property attached to this element. More...
 
size_t nbProperties () const
 Number of properties in the element. More...
 
size_t size () const
 Number of items in the element. More...
 
void resize (size_t n)
 Change the number of items in the element. More...
 
QStringList properties () const
 Get the list of property names. More...
 
Propertyproperty (size_t pos)
 Access a property by index number. More...
 
const Propertyproperty (size_t pos) const
 Access a property by index number. More...
 
Propertyproperty (const QString &name)
 Access a property by name. More...
 
const Propertyproperty (const QString &name) const
 Access a property by name. More...
 
PropertycreateValue (const QString &name, TYPE file, TYPE mem=INVALID_TYPE)
 Create a new value property if the name doesn't already exist. More...
 
PropertycreateList (const QString &name, TYPE size, TYPE file, TYPE mem=INVALID_TYPE)
 Create a new value property if the name doesn't already exist. More...
 
bool error (const QString &str) const
 Write the error in the standard out and return false. More...
 
bool hasProperty (const QString &name) const
 Returns true if the element has a property names name. More...
 
bool attach (Property *prop)
 Attach a property to the element. More...
 
bool detach (Property *prop)
 Remove a property from the element. More...
 
Propertydetach (const QString &name)
 Remove a property from the element, and return the removed property. More...
 
const QString & name () const
 Name of the element. More...
 
bool rename (const QString &n)
 Rename the element, only if the containing PLY file doesn't already contain an element with the new name. More...
 
bool allocated () const
 Return true if the element has been allocated. More...
 
bool setParent (PlyFile *p)
 Change the parent of the element, only if the new parent doesn't have an element with the same name. More...
 
PlyFileparent ()
 Get the parent of the element. More...
 
const PlyFileparent () const
 Get the parent of the element. More...
 
void _rename_prop (Property *prop, const QString &new_name)
 
void _attach (Property *prop)
 
void _detach (Property *prop)
 

Protected Attributes

QString _name
 
size_t _nbElements
 
QList< Property * > _properties
 
QHash< QString, int > _property_map
 
PlyFile_parent
 
bool _allocated
 

Detailed Description

Class representing an element

Definition at line 332 of file PlyFile.hpp.

Constructor & Destructor Documentation

◆ Element()

mgx::PlyFile::Element::Element ( const QString &  name,
PlyFile parent = 0 
)

Element constructor.

Parameters
nameName of the lement
parentPLY file holding the element

The name must be unique in the PLY file. If this is not the case, the element won't be attached to the PLY file and the parent won't be set.

Note
An element should be created using the PlyFile::createElement method.

◆ ~Element()

mgx::PlyFile::Element::~Element ( )

The destructor takes care of detaching the element from the PLY file that contains it.

Member Function Documentation

◆ _attach()

void mgx::PlyFile::Element::_attach ( Property prop)

◆ _detach()

void mgx::PlyFile::Element::_detach ( Property prop)

◆ _rename_prop()

void mgx::PlyFile::Element::_rename_prop ( Property prop,
const QString &  new_name 
)

◆ allocate()

void mgx::PlyFile::Element::allocate ( )

Allocate the memory for all the properties attached to the element.

◆ allocated()

bool mgx::PlyFile::Element::allocated ( ) const
inline

Return true if the element has been allocated.

Definition at line 465 of file PlyFile.hpp.

◆ attach()

bool mgx::PlyFile::Element::attach ( Property prop)

Attach a property to the element.

◆ clear()

void mgx::PlyFile::Element::clear ( )

Remove any property attached to this element.

The properties will be deleted.

◆ createList()

Property* mgx::PlyFile::Element::createList ( const QString &  name,
TYPE  size,
TYPE  file,
TYPE  mem = INVALID_TYPE 
)

Create a new value property if the name doesn't already exist.

Parameters
nameName of the new property
sizeFile type for the size of the list
fileFile type of the property
memMemory type. If INVALID_TYPE is specified here, the memory type will be equal to the file type

◆ createValue()

Property* mgx::PlyFile::Element::createValue ( const QString &  name,
TYPE  file,
TYPE  mem = INVALID_TYPE 
)

Create a new value property if the name doesn't already exist.

Parameters
nameName of the new property
fileFile type of the property
memMemory type. If INVALID_TYPE is specified here, the memory type will be equal to the file type

◆ detach() [1/2]

Property* mgx::PlyFile::Element::detach ( const QString &  name)

Remove a property from the element, and return the removed property.

◆ detach() [2/2]

bool mgx::PlyFile::Element::detach ( Property prop)

Remove a property from the element.

◆ error()

bool mgx::PlyFile::Element::error ( const QString &  str) const

Write the error in the standard out and return false.

◆ hasProperty()

bool mgx::PlyFile::Element::hasProperty ( const QString &  name) const

Returns true if the element has a property names name.

◆ name()

const QString& mgx::PlyFile::Element::name ( ) const
inline

Name of the element.

Definition at line 453 of file PlyFile.hpp.

◆ nbProperties()

size_t mgx::PlyFile::Element::nbProperties ( ) const
inline

Number of properties in the element.

Definition at line 367 of file PlyFile.hpp.

◆ parent() [1/2]

PlyFile* mgx::PlyFile::Element::parent ( )
inline

Get the parent of the element.

Definition at line 476 of file PlyFile.hpp.

◆ parent() [2/2]

const PlyFile* mgx::PlyFile::Element::parent ( ) const
inline

Get the parent of the element.

Definition at line 482 of file PlyFile.hpp.

◆ properties()

QStringList mgx::PlyFile::Element::properties ( ) const

Get the list of property names.

◆ property() [1/4]

Property* mgx::PlyFile::Element::property ( const QString &  name)

Access a property by name.

◆ property() [2/4]

const Property* mgx::PlyFile::Element::property ( const QString &  name) const

Access a property by name.

◆ property() [3/4]

Property* mgx::PlyFile::Element::property ( size_t  pos)

Access a property by index number.

◆ property() [4/4]

const Property* mgx::PlyFile::Element::property ( size_t  pos) const

Access a property by index number.

◆ rename()

bool mgx::PlyFile::Element::rename ( const QString &  n)

Rename the element, only if the containing PLY file doesn't already contain an element with the new name.

◆ resize()

void mgx::PlyFile::Element::resize ( size_t  n)

Change the number of items in the element.

This will call Property::resize on all the properties of the element.

◆ setParent()

bool mgx::PlyFile::Element::setParent ( PlyFile p)

Change the parent of the element, only if the new parent doesn't have an element with the same name.

◆ size()

size_t mgx::PlyFile::Element::size ( ) const
inline

Number of items in the element.

Definition at line 374 of file PlyFile.hpp.

Member Data Documentation

◆ _allocated

bool mgx::PlyFile::Element::_allocated
protected

Definition at line 508 of file PlyFile.hpp.

◆ _name

QString mgx::PlyFile::Element::_name
protected

Definition at line 503 of file PlyFile.hpp.

◆ _nbElements

size_t mgx::PlyFile::Element::_nbElements
protected

Definition at line 504 of file PlyFile.hpp.

◆ _parent

PlyFile* mgx::PlyFile::Element::_parent
protected

Definition at line 507 of file PlyFile.hpp.

◆ _properties

QList<Property*> mgx::PlyFile::Element::_properties
protected

Definition at line 505 of file PlyFile.hpp.

◆ _property_map

QHash<QString, int> mgx::PlyFile::Element::_property_map
protected

Definition at line 506 of file PlyFile.hpp.


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