MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Attributes | List of all members
mgx::util::PlyFile::Property Class Reference

Class representing a property in an element. More...

#include <PlyFile.hpp>

Public Types

enum  KIND { VALUE, LIST }
 Kind of a property. More...
 

Public Member Functions

 Property (const QString &name, Element *el=0)
 Constructor of a property. More...
 
 ~Property ()
 The destructor takes charge to detach the property from any element that contains it.
 
void allocate (size_t size)
 Allocate the memory for the property, as long as memType is not INVALID_TYPE. More...
 
void deallocate ()
 Free the memory occupied by the property.
 
template<typename T >
std::vector< std::vector< T > > * list ()
 Return a pointer to the list help by the property as long as the property is a list and the type is correct.
 
template<typename T >
std::vector< T > * value ()
 Return a pointer to the values help by the property as long as the property is a value and the type is correct.
 
template<typename T >
const std::vector< std::vector
< T > > * 
list () const
 Return a pointer to the list help by the property as long as the property is a list and the type is correct.
 
template<typename T >
const std::vector< T > * value () const
 Return a pointer to the values help by the property as long as the property is a value and the type is correct.
 
bool error (const QString &str) const
 Print an error on the standard output and return false.
 
const QStringname () const
 Name of the property.
 
TYPE fileType () const
 File type of the property value.
 
TYPE memType () const
 Memory type of the property value.
 
TYPE sizeType () const
 File type of the size of the property list.
 
KIND kind () const
 Kind of the property.
 
size_t size () const
 Size of the property, that is the number of elements stored in it.
 
bool rename (const QString &n)
 Change the name of the property, only if the new name doesn't conflict with one of the other properties in the parent element.
 
void setFileType (TYPE ft)
 Change the file type of the property.
 
void setMemType (TYPE mt)
 Change the memory type of the property. More...
 
void setSizeType (TYPE st)
 Change the file type of the size of the property.
 
void setKind (KIND k)
 Change the kind of the property. More...
 
Elementparent ()
 Get the element containing the property, if any.
 
const Elementparent () const
 Get the element containing the property, if any.
 
bool setParent (Element *parent)
 Change the parent, only if the new parent doesn't already have a property with the same name.
 
void resize (size_t s)
 Resize the property. More...
 

Protected Attributes

QString _name
 
TYPE _fileType
 
TYPE _memType
 
TYPE _sizeType
 
KIND _kind
 
Element_parent
 
void * _content
 
size_t _size
 

Detailed Description

Class representing a property in an element.

Member Enumeration Documentation

Kind of a property.

Enumerator
VALUE 

The property holds a single value per element.

LIST 

The property holds a variable number of values per element.

Constructor & Destructor Documentation

mgx::util::PlyFile::Property::Property ( const QString name,
Element el = 0 
)

Constructor of a property.

Parameters
nameName of the property
elElement containing the property

The name of the property must be unique in the element. If this is not the case, the property won't be attached to the element.

Note
Properties should usually be created using the Element::createValue or Element::createList methods.

Member Function Documentation

void mgx::util::PlyFile::Property::allocate ( size_t  size)

Allocate the memory for the property, as long as memType is not INVALID_TYPE.

All the vectors are initialized with default-constructed values.

void mgx::util::PlyFile::Property::resize ( size_t  s)

Resize the property.

If the property is already allocated, it should leep the min(size,s) first property values.

Warning
You should never call this method if the property is already in an element
void mgx::util::PlyFile::Property::setKind ( KIND  k)

Change the kind of the property.

Warning
If the property has already been allocated, this will erase any data held in it.
void mgx::util::PlyFile::Property::setMemType ( TYPE  mt)

Change the memory type of the property.

If the property is already allocated, the existing values will be converted to the new type.


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