40 #ifndef INCLUDED_GLS_METADATA_ATTRIBUTES_H
41 #define INCLUDED_GLS_METADATA_ATTRIBUTES_H
67 #ifdef DISTI_HAS_CPP11
68 # include <functional>
87 *_attribPtr = ( val != 0 );
94 outstr << *_attribPtr;
101 T ConvertToIntOrBool(
int value )
106 inline bool ConvertToIntOrBool(
int value )
112 T ReadValueAsIntOrBool( std::istream& instr )
117 if( strcasecmp( value.c_str(),
"TRUE" ) == 0 )
121 else if( strcasecmp( value.c_str(),
"FALSE" ) == 0 )
128 temp = ConvertToIntOrBool<T>( atoi( value.c_str() ) );
136 *_attribPtr = ReadValueAsIntOrBool<bool>( instr );
147 *_attribPtr = (int)val;
157 *_attribPtr = (short)val;
167 *_attribPtr = (
unsigned short)val;
177 *_attribPtr = (
unsigned char)val;
185 outstr << (int)*_attribPtr;
194 *_attribPtr =
static_cast<unsigned char>( ReadValueAsIntOrBool<int>( instr ) );
203 *_attribPtr = ReadValueAsIntOrBool<int>( instr );
212 *_attribPtr = ReadValueAsIntOrBool<unsigned int>( instr );
224 *_attribPtr = (float)val;
240 virtual GLS_EXPORT
long ValueInt();
241 virtual GLS_EXPORT
void ValueInt(
long val );
243 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
244 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
256 virtual GLS_EXPORT ~DistiAttributeFloatArray();
258 virtual GLS_EXPORT
bool OkToWrite()
const;
260 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
261 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
273 virtual GLS_EXPORT ~DistiAttributeDoubleArray();
275 virtual GLS_EXPORT
bool OkToWrite()
const;
277 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
278 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
290 template<
class containerClass>
294 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
297 using BaseClass::_pairList;
299 typedef void ( containerClass::*SetMethodType )(
const int );
300 typedef int ( containerClass::*GetMethodType )();
305 _pairList = &TextureModeEnumList;
320 template<
class containerClass>
324 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
327 using BaseClass::_pairList;
329 typedef void ( containerClass::*SetMethodType )(
const int );
330 typedef int ( containerClass::*GetMethodType )();
335 _pairList = &TextureFilterEnumList;
349 template<
class containerClass>
353 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
356 using BaseClass::_pairList;
358 typedef void ( containerClass::*SetMethodType )(
const int );
359 typedef int ( containerClass::*GetMethodType )();
364 _pairList = &PolyModeEnumList;
375 template<
class containerClass>
379 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
382 using BaseClass::_pairList;
384 typedef void ( containerClass::*SetMethodType )( int );
385 typedef int ( containerClass::*GetMethodType )();
390 _pairList = &PolyEndEnumList;
401 template<
class containerClass>
405 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
408 using BaseClass::_pairList;
410 typedef void ( containerClass::*SetMethodType )(
const int );
411 typedef int ( containerClass::*GetMethodType )();
416 _pairList = &ShadingEnumList;
421 template<
class containerClass>
425 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
428 using BaseClass::_pairList;
430 typedef void ( containerClass::*SetMethodType )(
const int );
431 typedef int ( containerClass::*GetMethodType )();
445 _pairList = &ColorMaterialModeEnum;
448 virtual GLS_EXPORT
bool OkToWrite()
const {
return false; }
452 template<
class containerClass>
456 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
459 using BaseClass::_pairList;
461 typedef void ( containerClass::*SetMethodType )(
const int );
462 typedef int ( containerClass::*GetMethodType )();
472 _pairList = &ProtectionEnumList;
485 template<
class containerClass>
489 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
492 using BaseClass::_pairList;
494 typedef void ( containerClass::*SetMethodType )(
const int );
495 typedef int ( containerClass::*GetMethodType )();
500 _pairList = &AlphaModeEnumList;
520 virtual GLS_EXPORT ~DistiAttributeString();
523 GLS_EXPORT
char* LocalStorageString();
524 virtual GLS_EXPORT
bool OkToWrite()
const;
526 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
527 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
543 virtual GLS_EXPORT std::string ValueString();
544 virtual GLS_EXPORT
void ValueString(
const std::string& s );
546 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
547 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
561 GLS_EXPORT
bool OkToWrite()
const DISTI_METHOD_OVERRIDE;
565 GLS_EXPORT std::string ValueString() DISTI_METHOD_OVERRIDE;
566 GLS_EXPORT
void ValueString(
const std::string& s ) DISTI_METHOD_OVERRIDE;
568 GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE;
569 GLS_EXPORT std::istream& ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE;
579 virtual GLS_EXPORT ~DistiAttributeFixedString();
581 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
582 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
588 std::string _localStorageString;
596 virtual GLS_EXPORT ~DistiAttributeStdString();
599 GLS_EXPORT std::string* LocalStorageString();
601 virtual GLS_EXPORT
bool OkToWrite()
const;
603 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
604 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
612 virtual GLS_EXPORT ~DistiAttributeLocation();
614 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
615 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
627 virtual GLS_EXPORT
bool OkToWrite()
const;
630 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
631 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
645 virtual GLS_EXPORT
bool OkToWrite()
const;
648 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
649 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
657 template<
class Map_t>
667 , _attribPtr( attribPtr )
673 , _attribPtr(
new Map_t() )
686 return _attribPtr != 0 && _attribPtr->size();
689 static std::string GetEmptyValue() {
return "$$DISTI_EMPTY$$"; }
694 << DistiAttribDict::SpacingString() <<
"{\n";
695 DistiAttribDict::SpacingInc();
699 typename Map_t::iterator i;
700 for( i = _attribPtr->begin(); i != _attribPtr->end(); ++i )
702 std::ostringstream str;
704 const std::string second = str.str();
706 outstr << DistiAttribDict::SpacingString() << i->first <<
" "
707 << ( second.empty() ? GetEmptyValue() : second ) <<
'\n';
711 DistiAttribDict::SpacingDec();
712 outstr << DistiAttribDict::SpacingString() <<
"}\n";
719 instr.ignore( INT_MAX,
'{' );
723 std::stringstream fontStream;
724 instr.get( *fontStream.rdbuf(),
'}' );
728 while( fontStream.good() )
732 std::stringstream::char_type c;
740 }
while( fontStream.good() && isspace( c ) );
742 if( fontStream.good() )
744 fontStream.putback( c );
746 #if _WIN32 && _MSC_VER < 1300 // if _MSC_VER < vc70
748 Map_t::referent_type value;
750 typename Map_t::key_type key;
751 typename Map_t::mapped_type value;
755 std::getline( fontStream >> std::ws, strVal );
757 if( strVal != GetEmptyValue() )
759 std::istringstream str( strVal );
763 ( *_attribPtr )[ key ] = value;
781 unsigned int* _numVertices;
782 unsigned int _numElements;
784 bool _compatabilityMode;
787 void SetCompatabilityMode(
bool mode ) { _compatabilityMode = mode; }
791 , _attribPtr( attribPtr )
792 , _numVertices( numVertices )
794 , _fixedArray(
false )
796 _compatabilityMode =
true;
801 , _attribPtr(
new Tptr( attribPtr ) )
802 , _numVertices( NULL )
803 , _numElements( numElements )
804 , _fixedArray(
true )
806 _compatabilityMode =
true;
811 if( ( _fixedArray || _localStorage ) && _attribPtr )
818 return ( *_attribPtr != NULL );
823 if( *_attribPtr != NULL )
825 unsigned int numVerts = _numElements;
828 outstr << *_numVertices;
829 numVerts = *_numVertices;
831 DistiAttribDict::SpacingInc();
832 for(
unsigned int i = 0; i < numVerts; i++ )
835 outstr << ( *_attribPtr )[ i ];
837 DistiAttribDict::SpacingDec();
843 unsigned int numVerts = _numElements;
848 *_numVertices = numVerts;
851 if( *_attribPtr != NULL )
852 delete[] * _attribPtr;
856 *_attribPtr =
new T[ numVerts ];
861 if( !_compatabilityMode )
865 instr.getline( buf, 1024 );
868 for(
unsigned int i = 0; i < numVerts; i++ )
870 if( !_compatabilityMode )
873 instr.getline( buf, 1024 );
877 std::sscanf( buf,
"%f %f %f",
878 &( ( *_attribPtr )[ i ].x ),
879 &( ( *_attribPtr )[ i ].y ),
880 &( ( *_attribPtr )[ i ].z ) );
882 assert( 3 == count );
887 instr >> ( *_attribPtr )[ i ];
902 if( !( _name == r->
_name ) || _numElements != r->_numElements )
905 for(
unsigned int i = 0u; i < _numElements; ++i )
907 T leftVert = ( *_attribPtr )[ i ];
908 T rightVert = ( *r->_attribPtr )[ i ];
926 unsigned int* _numVertices;
927 unsigned int _numElements;
929 bool _compatabilityMode;
932 void SetCompatabilityMode(
bool mode ) { _compatabilityMode = mode; }
936 , _attribPtr( attribPtr )
937 , _numVertices( numVertices )
939 , _fixedArray(
false )
941 _compatabilityMode =
true;
946 , _attribPtr(
new Tptr( attribPtr ) )
947 , _numVertices( NULL )
948 , _numElements( numElements )
949 , _fixedArray(
true )
951 _compatabilityMode =
true;
956 if( ( _fixedArray || _localStorage ) && _attribPtr )
963 return ( *_attribPtr != NULL );
968 if( *_attribPtr != NULL )
970 unsigned int numVerts = _numElements;
973 outstr << *_numVertices;
974 numVerts = *_numVertices;
976 DistiAttribDict::SpacingInc();
977 for(
unsigned int i = 0; i < numVerts; i++ )
980 outstr << ( *_attribPtr )[ i ];
982 DistiAttribDict::SpacingDec();
988 unsigned int numVerts = _numElements;
993 *_numVertices = numVerts;
996 if( *_attribPtr != NULL )
997 delete[] * _attribPtr;
1000 *_attribPtr =
new Vertex[ numVerts ];
1003 if( !_compatabilityMode )
1007 instr.getline( buf, 1024 );
1010 for(
unsigned int i = 0; i < numVerts; i++ )
1012 if( !_compatabilityMode )
1015 instr.getline( buf, 1024 );
1020 std::sscanf( buf,
"%f %f %f %d %d %d %d",
1021 &( ( *_attribPtr )[ i ].x ),
1022 &( ( *_attribPtr )[ i ].y ),
1023 &( ( *_attribPtr )[ i ].z ),
1026 assert( 7 == count );
1029 ( *_attribPtr )[ i ].color.RGBA( (
unsigned char)r, (
unsigned char)g, (
unsigned char)b, (
unsigned char)a );
1033 instr >> ( *_attribPtr )[ i ];
1048 if( !( _name == r->
_name ) || _numElements != r->_numElements )
1051 for(
unsigned int i = 0u; i < _numElements; ++i )
1053 Vertex leftVert = ( *_attribPtr )[ i ];
1054 Vertex rightVert = ( *r->_attribPtr )[ i ];
1079 unsigned int numVerts = _numElements;
1081 for(
unsigned int i = 0; i < numVerts; i++ )
1084 outstr << ( *_attribPtr )[ i ];
1091 unsigned int numVerts = _numElements;
1093 for(
unsigned int i = 0; i < numVerts; i++ )
1101 std::getline( instr, line );
1103 if( i == 0 && line.length() == 0 )
1104 std::getline( instr, line );
1106 std::stringstream strm( line );
1107 strm >> ( *_attribPtr )[ i ];
1143 , _originalAttribName( originalName )
1144 , _dictionary( dict )
1149 virtual DISTI_EXPORT
bool OkToWrite()
const DISTI_METHOD_OVERRIDE;
1152 virtual DISTI_EXPORT
bool ValueChanged() DISTI_METHOD_OVERRIDE;
1155 virtual DISTI_EXPORT
void ResetValueChanged() DISTI_METHOD_OVERRIDE;
1158 virtual DISTI_EXPORT std::string ValueString() DISTI_METHOD_OVERRIDE;
1161 virtual DISTI_EXPORT
void ValueString(
const std::string& s ) DISTI_METHOD_OVERRIDE;
1164 virtual DISTI_EXPORT
long ValueInt() DISTI_METHOD_OVERRIDE;
1167 virtual DISTI_EXPORT
void ValueInt(
long val ) DISTI_METHOD_OVERRIDE;
1170 virtual DISTI_EXPORT
double ValueFloat() DISTI_METHOD_OVERRIDE;
1173 virtual DISTI_EXPORT
void ValueFloat(
double val ) DISTI_METHOD_OVERRIDE;
1176 virtual DISTI_EXPORT std::ostream& WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE;
1179 virtual DISTI_EXPORT std::istream& ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE;
1187 virtual DISTI_EXPORT
void UnregisterObserver(
CallbackID id ) DISTI_METHOD_OVERRIDE;
1189 virtual DISTI_EXPORT
void NotifyObservers() DISTI_METHOD_OVERRIDE;
1200 template<
class T,
bool showIndex >
1208 , _attribPtr( attribPtr )
1215 , _attribPtr(
new T() )
1228 return ( _attribPtr != NULL && _attribPtr->Capacity() );
1231 std::ostream&
WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE
1233 if( _attribPtr != NULL )
1235 unsigned numEntries = _attribPtr->Count();
1236 outstr << numEntries;
1238 DistiAttribDict::SpacingInc();
1240 for(
unsigned i = 0; i < numEntries; i++ )
1246 outstr << DistiAttribDict::SpacingString() << i <<
" ";
1249 outstr << DistiAttribDict::SpacingString() << ( *_attribPtr )[ i ] <<
" ";
1251 DistiAttribDict::SpacingDec();
1256 std::istream&
ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE
1258 unsigned numEntries = 0;
1259 instr >> numEntries;
1261 _attribPtr->Count( numEntries );
1262 for(
unsigned i = 0; i < numEntries; i++ )
1270 instr >> ( *_attribPtr )[ entry ];
1281 template<
class T,
bool showIndex >
1292 , _attribPtr( attribPtr )
1299 , _attribPtr(
new T() )
1314 return ( _attribPtr != NULL && _attribPtr->size() );
1319 if( _attribPtr != NULL )
1321 const std::size_t numEntries = _attribPtr->size();
1322 outstr << numEntries;
1324 DistiAttribDict::SpacingInc();
1326 for( std::size_t i = 0; i < numEntries; i++ )
1332 outstr << DistiAttribDict::SpacingString() << i <<
" ";
1335 outstr << DistiAttribDict::SpacingString() << ( *_attribPtr )[ i ] <<
" ";
1337 DistiAttribDict::SpacingDec();
1344 if( _attribPtr != NULL )
1347 instr >> numEntries;
1349 _attribPtr->resize( numEntries );
1351 for(
int i = 0; i < numEntries; i++ )
1358 instr >> ( *_attribPtr )[ entry ];
1375 typedef T* ( *CreateItemCb )();
1379 CreateItemCb _createCb;
1386 , _createCb( createCb )
1396 << DistiAttribDict::SpacingString() <<
"{\n";
1397 DistiAttribDict::SpacingInc();
1398 for(
unsigned int i = 0; i < _array->
Count(); i++ )
1400 if( ( *_array )[ i ] )
1402 outstr << DistiAttribDict::SpacingString();
1404 ( ( *_array )[ i ] )->WriteValue( outstr );
1408 DistiAttribDict::SpacingDec();
1409 outstr << DistiAttribDict::SpacingString() <<
"}\n";
1417 while( DistiAttribDict::ScanToken( instr, buf ) )
1427 if( T*
const createdItem = dynamic_cast<T*>( _createCb() ) )
1430 _array->
Back()->ReadValue( instr );
1449 template<
class containerT,
class T,
class SetArgT = const T&,
class GetReturnT = T>
1453 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
1456 typedef void ( containerT::*SetMethodType )( SetArgT );
1457 typedef GetReturnT ( containerT::*GetMethodType )();
1458 typedef GetReturnT ( containerT::*GetMethodConstType )()
const;
1462 containerT* _container;
1463 SetMethodType _setMethod;
1464 GetMethodType _getMethod;
1468 : BaseClass( NULL, name, attribPtr )
1470 , _container( frame )
1471 , _setMethod( setMethod )
1472 , _getMethod( getMethod )
1475 if(
typeid( T ) ==
typeid(
float ) ||
typeid( T ) ==
typeid(
double ) ||
typeid( T ) ==
typeid(
long double ) )
1483 return ( this->_attribPtr || _getMethod );
1488 virtual std::string
ValueString() DISTI_METHOD_OVERRIDE {
return DistiAttributeBase::ValueString(); }
1489 virtual void ValueString(
const std::string& s ) DISTI_METHOD_OVERRIDE { DistiAttributeBase::ValueString( s ); }
1491 virtual long ValueInt() DISTI_METHOD_OVERRIDE {
return DistiAttributeBase::ValueInt(); }
1492 virtual void ValueInt(
long val ) DISTI_METHOD_OVERRIDE { DistiAttributeBase::ValueInt( val ); }
1494 virtual double ValueFloat() DISTI_METHOD_OVERRIDE {
return DistiAttributeBase::ValueFloat(); }
1495 virtual void ValueFloat(
double val ) DISTI_METHOD_OVERRIDE { DistiAttributeBase::ValueFloat( val ); }
1497 virtual std::ostream&
WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE
1499 if( _precision > 0 )
1500 outstr.precision(
int( _precision ) );
1502 if( _getMethod && _container )
1505 T* tempAttribPtr = this->_attribPtr;
1508 T temp( ( _container->*_getMethod )() );
1511 this->_attribPtr = &temp;
1514 BaseClass::WriteValue( outstr );
1517 this->_attribPtr = tempAttribPtr;
1519 else if( this->_attribPtr )
1521 BaseClass::WriteValue( outstr );
1527 virtual std::istream&
ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE
1529 if( _setMethod && _container )
1532 T* tempAttribPtr = this->_attribPtr;
1536 this->_attribPtr = &temp;
1539 BaseClass::ReadValue( instr );
1542 ( _container->*_setMethod )( temp );
1544 this->_attribPtr = tempAttribPtr;
1546 else if( this->_attribPtr )
1548 BaseClass::ReadValue( instr );
1556 if( _getMethod && _container )
1559 return ( _container->*_getMethod )();
1561 else if( this->_attribPtr )
1563 return BaseClass::Value();
1571 virtual void Value(
const T& val ) DISTI_METHOD_OVERRIDE
1573 if( _setMethod && _container )
1575 ( _container->*_setMethod )( val );
1577 else if( this->_attribPtr )
1579 BaseClass::Value( val );
1596 template<
typename Type,
class Class>
1607 template<
typename Type,
class Class>
1619 template<
typename Type,
class Class>
1630 template<
typename Type,
class Class>
1640 template<
typename Type,
class Class>
1651 template<
typename Type,
class Class>
1663 template<
typename GetReturnT,
typename SetArgT,
class Class>
1674 template<
class Class>
1711 template<
class enumType>
1715 enumType* _attribPtr;
1722 , _attribPtr( attribPtr )
1723 , _pairList( pairList )
1728 , _attribPtr(
new enumType( value ) )
1729 , _pairList( pairList )
1735 if( _localStorage && _attribPtr )
1741 virtual void ValueInt(
long val ) { *_attribPtr = (enumType)val; };
1748 *_attribPtr = ( enumType ) * ( ptr->_attribPtr );
1753 return DistiAttributeBase::operator=( oldClass );
1759 bool foundIt =
false;
1761 typename DistiAttributeEnumDefList::iterator item = _pairList->begin();
1762 while( item != _pairList->end() )
1764 if( ( *item )->_enum == *_attribPtr )
1766 outstr << ( *item )->_string;
1775 outstr << (int)*_attribPtr;
1787 bool foundIt =
false;
1788 typename DistiAttributeEnumDefList::iterator item = _pairList->begin();
1791 while( item != _pairList->end() )
1793 if( strcmp( ( *item )->_string, value ) == 0 )
1795 *_attribPtr = ( enumType )( *item )->_enum;
1807 *_attribPtr = (enumType)atoi( value );
1834 #define DISTI_REGISTER_METHOD_CALLBACK( instance, Class, Method ) \
1836 typedef CallbackMethodCallerTemplate<Class, Class> Caller; \
1837 typedef typename Caller::MethodType1 MethodType; \
1838 const MethodType callback = reinterpret_cast<MethodType>( Method ); \
1839 ThisClass::CallbackCaller( new Caller( callback, instance ) ); \
1849 #define DISTI_SET_OBJECT_CALLBACK1( object, method, parent ) \
1850 ( object )->CallbackCaller( \
1851 new CallbackMethodCallerTemplate<DisplayObject, DisplayObject>( \
1852 ( disti::CallbackMethodCallerTemplate<DisplayObject, DisplayObject>::MethodType1 )( method ), ( parent ) ) );
1863 #define DISTI_ADD_ATTRIBUTE( Type, name, memberVarAddr ) \
1865 static const AttributeName attr( name ); \
1866 CallbackAttributeNotifier<ThisClass> cb( this, attr ); \
1867 this->Attributes().Add( new DistiAttribute<Type>( &cb, ( attr ), ( memberVarAddr ) ) ); \
1882 #define DISTI_ADD_ATTRIBUTE_CALLBACK( Type, name, memberVarAddr, callbackFunction ) \
1884 typedef void ( ThisClass::*Method )(); \
1885 static const AttributeName attr( name ); \
1886 CallbackAttributeNotifier<ThisClass> cb( this, attr, reinterpret_cast<Method>( callbackFunction ) ); \
1887 this->Attributes().Add( new DistiAttribute<Type>( &cb, ( attr ), ( memberVarAddr ) ) ); \
1900 #define DISTI_ADD_ATTRIBUTE_SET_GET( Type, name, setter, getter ) \
1902 static const AttributeName attr( name ); \
1903 this->Attributes().Add( CreateDistiAttributeProperty<Type>( attr, this, setter, getter ) ); \
1913 #define DISTI_ADD_ATTRIBUTE_STRING( name, memberVarAddr ) \
1915 static const AttributeName attr( name ); \
1916 CallbackAttributeNotifier<ThisClass> cb( this, attr ); \
1917 this->Attributes().Add( new DistiAttributeEncodedStdString( &cb, attr, memberVarAddr ) ); \
1929 #define DISTI_ADD_ATTRIBUTE_STRING_CALLBACK( name, memberVarAddr, callbackFunction ) \
1931 typedef void ( ThisClass::*Method )(); \
1932 static const AttributeName attr( name ); \
1933 CallbackAttributeNotifier<ThisClass> cb( this, attr, reinterpret_cast<Method>( callbackFunction ) ); \
1934 this->Attributes().Add( new DistiAttributeEncodedStdString( &cb, attr, memberVarAddr ) ); \
1944 #define DISTI_ADD_ATTRIBUTE_ALIAS( aliasName, origName, obj ) \
1946 static const AttributeName aliasAttr( aliasName ); \
1947 static const AttributeName origAttr( origName ); \
1948 DistiAttribDict& attributes = ( obj )->Attributes(); \
1949 this->Attributes().Add( new DistiAttributeAlias( NULL, aliasAttr, origAttr, &attributes ) ); \
1952 #ifdef DISTI_HAS_CPP11
1958 : _func( std::move( func ) )
1974 return !_object.IsNull() && _func;
1978 std::function<void()> _func;
1982 inline AttributeObserver* CreateAttributeFnCallback(
1983 WeakReferenceable*
const obj,
1984 const std::function<
void()>& func )
1986 return new AttributeFnCallback( obj, func );
1990 inline DistiAttributeBase::CallbackID Connect( DisplayObject* obj,
const std::string& resource, WeakReferenceable* funcOwner, std::function<
void()> func )
1992 auto& res = obj->Resource( resource.c_str() );
1993 if( dynamic_cast<disti::DistiEmptyAttribute*>( &res ) )
1995 std::cout <<
"Unknown attribute name: " << resource << std::endl;
1996 return DISTI_INVALID_CALLBACK_ID;
1999 return res.RegisterObserver( CreateAttributeFnCallback( funcOwner, std::move( func ) ) );
2003 template<
class Class>
2004 DistiAttributeBase::CallbackID Connect( DisplayObject* obj,
const std::string& resource, Class*
const methodInstance,
const typename AttributeMethodCallback<Class>::Callback method )
2006 DistiAttributeBase& res = obj->Resource( resource.c_str() );
2007 if( dynamic_cast<disti::DistiEmptyAttribute*>( &res ) )
2009 std::cout <<
"Unknown attribute name: " << resource << std::endl;
2010 return DISTI_INVALID_CALLBACK_ID;
2015 inline void Disconnect( DisplayObject* obj,
const std::string& resource, DistiAttributeBase::CallbackID
id )
2017 DistiAttributeBase& res = obj->Resource( resource.c_str() );
2018 if( !dynamic_cast<disti::DistiEmptyAttribute*>( &res ) &&
id != DISTI_INVALID_CALLBACK_ID )
2020 res.UnregisterObserver(
id );
Definition: display_types.h:75
Definition: gls_metadata_attributes.h:249
Definition: gls_metadata_attributes.h:608
Definition: gls_metadata_attributes.h:266
Definition: display_types.h:100
virtual void ValueString(const std::string &s) override
Definition: gls_metadata_attributes.h:1489
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1393
Definition: display_types.h:73
Definition: gls_metadata_attributes.h:1688
std::ostream & WriteValue(std::ostream &outstr) override
Definition: gls_metadata_attributes.h:1231
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:821
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1077
The disti::Material class.
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
Definition: gls_metadata_attributes.h:586
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:841
Definition: gls_metadata_attributes.h:291
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:966
unsigned Count() const
Definition: dynamic_array.h:204
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1089
Definition: gls_metadata_attributes.h:1954
The disti::DynamicArray class. A templated array of objects capable of dynamically growing...
Definition: gls_metadata_attributes.h:1282
Definition: gls_metadata_attributes.h:232
Definition: gls_metadata_attributes.h:486
Definition: gls_metadata_attributes.h:402
std::istream & ReadValue(std::istream &instr) override
Definition: disti_metadata.h:588
Definition: display_types.h:153
Definition: gls_metadata_attributes.h:533
Definition: gls_metadata_attributes.h:658
virtual long ValueInt()
Definition: gls_metadata_attributes.h:1740
Definition: display_types.h:151
Definition: display_types.h:91
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:684
virtual double ValueFloat() override
Definition: gls_metadata_attributes.h:1494
Definition: display_types.h:103
virtual void ValueFloat(double val) override
Definition: gls_metadata_attributes.h:1495
Definition: gls_metadata_attributes.h:1712
Definition: display_types.h:92
virtual bool operator==(const DistiAttributeBase &rArg)
Definition: gls_metadata_attributes.h:1040
std::ostream & WriteValue(std::ostream &outstr) override
Definition: disti_metadata.h:574
Definition: gls_metadata_attributes.h:1068
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:691
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1342
Definition: display_types.h:102
Definition: display_types.h:110
A file for all GL Studio files to include.
virtual std::string ValueString() override
Definition: gls_metadata_attributes.h:1488
Definition: display_types.h:63
Definition: display_types.h:116
The disti::DisplayObject class and global enumerations.
Definition: gls_metadata_attributes.h:921
unsigned int CallbackID
Type for unique identifiers.
Definition: disti_metadata.h:345
Definition: display_types.h:90
Definition: gls_metadata_attributes.h:1201
Definition: gls_metadata_attributes.h:1372
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1412
Definition: gls_metadata_attributes.h:321
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:448
Definition: weak_reference.h:64
Definition: gls_metadata_attributes.h:1138
Definition: display_types.h:101
Definition: disti_metadata.h:894
bool OkToWrite() const override
Definition: gls_metadata_attributes.h:1226
Definition: display_types.h:123
virtual void ValueInt(long val)
Definition: gls_metadata_attributes.h:1741
The List_c class. Generic linked list.
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1697
bool operator==(const AttributeName &attr1, const AttributeName &attr2)
Definition: disti_metadata.h:144
virtual void Value(const T &val) override
Definition: gls_metadata_attributes.h:1571
Definition: display_types.h:152
Definition: display_types.h:64
Definition: display_types.h:62
Definition: gls_metadata_attributes.h:1119
Definition: disti_metadata.h:491
The disti::Vertex class. A class for manipulating 3D vertices.
Generally useful defines, macros, enumerations and function prototypes.
void Call(DistiAttributeBase &ev)
Definition: gls_metadata_attributes.h:1964
#define GLS_VERIFY(exp)
Definition: disti_assert.h:155
Definition: gls_metadata_attributes.h:1450
Definition: gls_metadata_attributes.h:453
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1757
Definition: disti_metadata.h:186
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:986
Definition: disti_metadata.h:169
Definition: display_types.h:61
Definition: gls_metadata_attributes.h:506
virtual long ValueInt() override
Definition: gls_metadata_attributes.h:1491
Definition: disti_metadata.h:668
DistiAttributeProperty< Class, GetReturnT, SetArgT > * CreateDistiAttributeProperty(const AttributeName &attrName, Class *const obj, const typename DistiAttributeProperty< Class, GetReturnT, SetArgT >::SetMethodType setMethod, const typename DistiAttributeProperty< Class, GetReturnT, SetArgT >::GetMethodType getMethod)
Definition: gls_metadata_attributes.h:1664
Definition: disti_metadata.h:882
Definition: callback_caller_base.h:55
DistiAttributeProperty< Class, Vector, const Vertex &, const Vertex & > * CreateDistiAttributePropertyVertexToVector(const AttributeName &attrName, Class *const obj, const typename DistiAttributeProperty< Class, Vector, const Vertex &, const Vertex & >::SetMethodType setMethod, const typename DistiAttributeProperty< Class, Vector, const Vertex &, const Vertex & >::GetMethodConstType getMethod)
Definition: gls_metadata_attributes.h:1675
Definition: weak_reference.h:91
std::istream & ReadValue(std::istream &instr) override
Definition: gls_metadata_attributes.h:1256
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:1391
T & Back()
Definition: dynamic_array.h:342
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1702
Definition: display_types.h:94
bool Equal(T1 x, T2 y, float precision=0.001f)
Definition: util.h:246
Definition: display_types.h:71
Definition: display_types.h:150
AttributeObserver * CreateAttributeMethodCallback(Class *const obj, const typename AttributeMethodCallback< Class >::Callback method)
Definition: disti_metadata.h:403
virtual std::ostream & WriteValue(std::ostream &outstr) override
Definition: gls_metadata_attributes.h:1497
Definition: gls_metadata_attributes.h:619
AttributeName _name
Definition: disti_metadata.h:193
void Add(DistiAttributeBase *attr)
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:961
Definition: display_types.h:117
virtual void ValueInt(long val) override
Definition: gls_metadata_attributes.h:1492
virtual bool IsValid() const
Definition: gls_metadata_attributes.h:1972
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:717
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1317
Definition: display_types.h:93
Definition: gls_metadata_attributes.h:572
Definition: gls_metadata_attributes.h:776
Definition: display_types.h:74
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
Definition: gls_metadata_attributes.h:1743
Definition: display_types.h:70
unsigned PushBack(const T &object)
Definition: dynamic_array.h:325
Definition: display_types.h:72
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:1131
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1781
Definition: gls_metadata_attributes.h:635
Definition: gls_metadata_attributes.h:422
Definition: gls_metadata_attributes.h:553
Definition: display_types.h:154
Definition: gls_metadata_attributes.h:350
Definition: disti_metadata.h:85
Definition: display_types.h:125
Definition: display_types.h:124
Definition: gls_metadata_attributes.h:376
Definition: bmpimage.h:46
long ValueInt() override
Definition: disti_metadata.h:534
Definition: display_types.h:149
virtual bool OkToWrite() const override
Definition: gls_metadata_attributes.h:1481
virtual std::istream & ReadValue(std::istream &instr) override
Definition: gls_metadata_attributes.h:1527
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:1312
virtual bool operator==(const DistiAttributeBase &rArg)
Definition: gls_metadata_attributes.h:894
Definition: display_types.h:109
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:816
virtual T Value() override
Definition: gls_metadata_attributes.h:1554