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

#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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
bool error (const QString &str) const
 Print an error on the standard output and return false. More...
 
const QString & name () const
 Name of the property. More...
 
TYPE fileType () const
 File type of the property value. More...
 
TYPE memType () const
 Memory type of the property value. More...
 
TYPE sizeType () const
 File type of the size of the property list. More...
 
KIND kind () const
 Kind of the property. More...
 
size_t size () const
 Size of the property, that is the number of elements stored in it. More...
 
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. More...
 
void setFileType (TYPE ft)
 Change the file type of the property. More...
 
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. More...
 
void setKind (KIND k)
 Change the kind of the property. More...
 
Elementparent ()
 Get the element containing the property, if any. More...
 
const Elementparent () const
 Get the element containing the property, if any. More...
 
bool setParent (Element *parent)
 Change the parent, only if the new parent doesn't already have a property with the same name. More...
 
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

Definition at line 118 of file PlyFile.hpp.

Member Enumeration Documentation

◆ KIND

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.

Definition at line 122 of file PlyFile.hpp.

Constructor & Destructor Documentation

◆ Property()

mgx::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.

◆ ~Property()

mgx::PlyFile::Property::~Property ( )

The destructor takes charge to detach the property from any element that contains it.

Member Function Documentation

◆ allocate()

void mgx::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.

◆ deallocate()

void mgx::PlyFile::Property::deallocate ( )

Free the memory occupied by the property.

◆ error()

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

Print an error on the standard output and return false.

◆ fileType()

TYPE mgx::PlyFile::Property::fileType ( ) const
inline

File type of the property value.

Definition at line 221 of file PlyFile.hpp.

◆ kind()

KIND mgx::PlyFile::Property::kind ( ) const
inline

Kind of the property.

Definition at line 242 of file PlyFile.hpp.

◆ list() [1/2]

template<typename T >
std::vector<std::vector<T> >* mgx::PlyFile::Property::list ( )
inline

Return a pointer to the list help by the property as long as the property is a list and the type is correct.

Definition at line 159 of file PlyFile.hpp.

◆ list() [2/2]

template<typename T >
const std::vector<std::vector<T> >* mgx::PlyFile::Property::list ( ) const
inline

Return a pointer to the list help by the property as long as the property is a list and the type is correct.

Definition at line 184 of file PlyFile.hpp.

◆ memType()

TYPE mgx::PlyFile::Property::memType ( ) const
inline

Memory type of the property value.

Definition at line 228 of file PlyFile.hpp.

◆ name()

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

Name of the property.

Definition at line 214 of file PlyFile.hpp.

◆ parent() [1/2]

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

Get the element containing the property, if any.

Definition at line 291 of file PlyFile.hpp.

◆ parent() [2/2]

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

Get the element containing the property, if any.

Definition at line 298 of file PlyFile.hpp.

◆ rename()

bool mgx::PlyFile::Property::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.

◆ resize()

void mgx::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

◆ setFileType()

void mgx::PlyFile::Property::setFileType ( TYPE  ft)
inline

Change the file type of the property.

Definition at line 263 of file PlyFile.hpp.

◆ setKind()

void mgx::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.

◆ setMemType()

void mgx::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.

◆ setParent()

bool mgx::PlyFile::Property::setParent ( Element parent)

Change the parent, only if the new parent doesn't already have a property with the same name.

◆ setSizeType()

void mgx::PlyFile::Property::setSizeType ( TYPE  st)
inline

Change the file type of the size of the property.

Definition at line 277 of file PlyFile.hpp.

◆ size()

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

Size of the property, that is the number of elements stored in it.

Definition at line 249 of file PlyFile.hpp.

◆ sizeType()

TYPE mgx::PlyFile::Property::sizeType ( ) const
inline

File type of the size of the property list.

Definition at line 235 of file PlyFile.hpp.

◆ value() [1/2]

template<typename T >
std::vector<T>* mgx::PlyFile::Property::value ( )
inline

Return a pointer to the values help by the property as long as the property is a value and the type is correct.

Definition at line 172 of file PlyFile.hpp.

◆ value() [2/2]

template<typename T >
const std::vector<T>* mgx::PlyFile::Property::value ( ) const
inline

Return a pointer to the values help by the property as long as the property is a value and the type is correct.

Definition at line 197 of file PlyFile.hpp.

Member Data Documentation

◆ _content

void* mgx::PlyFile::Property::_content
protected

Definition at line 323 of file PlyFile.hpp.

◆ _fileType

TYPE mgx::PlyFile::Property::_fileType
protected

Definition at line 318 of file PlyFile.hpp.

◆ _kind

KIND mgx::PlyFile::Property::_kind
protected

Definition at line 321 of file PlyFile.hpp.

◆ _memType

TYPE mgx::PlyFile::Property::_memType
protected

Definition at line 319 of file PlyFile.hpp.

◆ _name

QString mgx::PlyFile::Property::_name
protected

Definition at line 317 of file PlyFile.hpp.

◆ _parent

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

Definition at line 322 of file PlyFile.hpp.

◆ _size

size_t mgx::PlyFile::Property::_size
protected

Definition at line 324 of file PlyFile.hpp.

◆ _sizeType

TYPE mgx::PlyFile::Property::_sizeType
protected

Definition at line 320 of file PlyFile.hpp.


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