40 #ifndef INCLUDED_GLS_METADATA_ATTRIBUTES_H
41 #define INCLUDED_GLS_METADATA_ATTRIBUTES_H
66 #ifdef DISTI_HAS_CPP11
67 # include <functional>
85 *_attribPtr = ( val != 0 );
92 outstr << *_attribPtr;
99 T ConvertToIntOrBool(
int value )
104 inline bool ConvertToIntOrBool(
int value )
110 T ReadValueAsIntOrBool( std::istream& instr )
115 if( strcasecmp( value.c_str(),
"TRUE" ) == 0 )
119 else if( strcasecmp( value.c_str(),
"FALSE" ) == 0 )
126 temp = ConvertToIntOrBool<T>( atoi( value.c_str() ) );
134 *_attribPtr = ReadValueAsIntOrBool<bool>( instr );
145 *_attribPtr = (int)val;
155 *_attribPtr = (short)val;
165 *_attribPtr = (
unsigned short)val;
175 *_attribPtr = (
unsigned char)val;
183 outstr << (int)*_attribPtr;
192 *_attribPtr =
static_cast<unsigned char>( ReadValueAsIntOrBool<int>( instr ) );
201 *_attribPtr = ReadValueAsIntOrBool<int>( instr );
210 *_attribPtr = ReadValueAsIntOrBool<unsigned int>( instr );
222 *_attribPtr = (float)val;
238 virtual GLS_EXPORT
long ValueInt();
239 virtual GLS_EXPORT
void ValueInt(
long val );
241 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
242 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
254 virtual GLS_EXPORT ~DistiAttributeFloatArray();
256 virtual GLS_EXPORT
bool OkToWrite()
const;
258 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
259 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
271 virtual GLS_EXPORT ~DistiAttributeDoubleArray();
273 virtual GLS_EXPORT
bool OkToWrite()
const;
275 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
276 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
288 template<
class containerClass>
292 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
295 using BaseClass::_pairList;
297 typedef void ( containerClass::*SetMethodType )(
const int );
298 typedef int ( containerClass::*GetMethodType )();
303 _pairList = &TextureModeEnumList;
318 template<
class containerClass>
322 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
325 using BaseClass::_pairList;
327 typedef void ( containerClass::*SetMethodType )(
const int );
328 typedef int ( containerClass::*GetMethodType )();
333 _pairList = &TextureFilterEnumList;
347 template<
class containerClass>
351 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
354 using BaseClass::_pairList;
356 typedef void ( containerClass::*SetMethodType )(
const int );
357 typedef int ( containerClass::*GetMethodType )();
362 _pairList = &PolyModeEnumList;
373 template<
class containerClass>
377 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
380 using BaseClass::_pairList;
382 typedef void ( containerClass::*SetMethodType )( int );
383 typedef int ( containerClass::*GetMethodType )();
388 _pairList = &PolyEndEnumList;
399 template<
class containerClass>
403 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
406 using BaseClass::_pairList;
408 typedef void ( containerClass::*SetMethodType )(
const int );
409 typedef int ( containerClass::*GetMethodType )();
414 _pairList = &ShadingEnumList;
419 template<
class containerClass>
423 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
426 using BaseClass::_pairList;
428 typedef void ( containerClass::*SetMethodType )(
const int );
429 typedef int ( containerClass::*GetMethodType )();
443 _pairList = &ColorMaterialModeEnum;
446 virtual GLS_EXPORT
bool OkToWrite()
const {
return false; }
450 template<
class containerClass>
454 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
457 using BaseClass::_pairList;
459 typedef void ( containerClass::*SetMethodType )(
const int );
460 typedef int ( containerClass::*GetMethodType )();
470 _pairList = &ProtectionEnumList;
483 template<
class containerClass>
487 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
490 using BaseClass::_pairList;
492 typedef void ( containerClass::*SetMethodType )(
const int );
493 typedef int ( containerClass::*GetMethodType )();
498 _pairList = &AlphaModeEnumList;
518 virtual GLS_EXPORT ~DistiAttributeString();
521 GLS_EXPORT
char* LocalStorageString();
522 virtual GLS_EXPORT
bool OkToWrite()
const;
524 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
525 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
541 virtual GLS_EXPORT std::string ValueString();
542 virtual GLS_EXPORT
void ValueString(
const std::string& s );
544 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
545 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
559 GLS_EXPORT
bool OkToWrite()
const DISTI_METHOD_OVERRIDE;
563 GLS_EXPORT std::string ValueString() DISTI_METHOD_OVERRIDE;
564 GLS_EXPORT
void ValueString(
const std::string& s ) DISTI_METHOD_OVERRIDE;
566 GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE;
567 GLS_EXPORT std::istream& ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE;
577 virtual GLS_EXPORT ~DistiAttributeFixedString();
579 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
580 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
586 std::string _localStorageString;
594 virtual GLS_EXPORT ~DistiAttributeStdString();
597 GLS_EXPORT std::string* LocalStorageString();
599 virtual GLS_EXPORT
bool OkToWrite()
const;
601 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
602 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
610 virtual GLS_EXPORT ~DistiAttributeLocation();
612 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
613 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
625 virtual GLS_EXPORT
bool OkToWrite()
const;
628 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
629 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
643 virtual GLS_EXPORT
bool OkToWrite()
const;
646 virtual GLS_EXPORT std::ostream& WriteValue( std::ostream& outstr );
647 virtual GLS_EXPORT std::istream& ReadValue( std::istream& instr );
655 template<
class Map_t>
665 , _attribPtr( attribPtr )
671 , _attribPtr(
new Map_t() )
684 return _attribPtr != 0 && _attribPtr->size();
687 static std::string GetEmptyValue() {
return "$$DISTI_EMPTY$$"; }
692 << DistiAttribDict::SpacingString() <<
"{\n";
693 DistiAttribDict::SpacingInc();
697 typename Map_t::iterator i;
698 for( i = _attribPtr->begin(); i != _attribPtr->end(); ++i )
700 std::ostringstream str;
702 const std::string second = str.str();
704 outstr << DistiAttribDict::SpacingString() << i->first <<
" "
705 << ( second.empty() ? GetEmptyValue() : second ) <<
'\n';
709 DistiAttribDict::SpacingDec();
710 outstr << DistiAttribDict::SpacingString() <<
"}\n";
717 instr.ignore( INT_MAX,
'{' );
721 std::stringstream fontStream;
722 instr.get( *fontStream.rdbuf(),
'}' );
726 while( fontStream.good() )
730 std::stringstream::char_type c;
739 }
while( fontStream.good() && std::isspace( c, std::locale(
".UTF-8" ) ) );
741 }
while( fontStream.good() && isspace( c ) );
744 if( fontStream.good() )
746 fontStream.putback( c );
748 #if _WIN32 && _MSC_VER < 1300 // if _MSC_VER < vc70
750 Map_t::referent_type value;
752 typename Map_t::key_type key;
753 typename Map_t::mapped_type value;
757 std::getline( fontStream >> std::ws, strVal );
759 if( strVal != GetEmptyValue() )
761 std::istringstream str( strVal );
765 ( *_attribPtr )[ key ] = value;
783 unsigned int* _numVertices;
784 unsigned int _numElements;
786 bool _compatabilityMode;
789 void SetCompatabilityMode(
bool mode ) { _compatabilityMode = mode; }
793 , _attribPtr( attribPtr )
794 , _numVertices( numVertices )
796 , _fixedArray(
false )
798 _compatabilityMode =
true;
803 , _attribPtr(
new Tptr( attribPtr ) )
804 , _numVertices( NULL )
805 , _numElements( numElements )
806 , _fixedArray(
true )
808 _compatabilityMode =
true;
813 if( ( _fixedArray || _localStorage ) && _attribPtr )
820 return ( *_attribPtr != NULL );
825 if( *_attribPtr != NULL )
827 unsigned int numVerts = _numElements;
830 outstr << *_numVertices;
831 numVerts = *_numVertices;
833 DistiAttribDict::SpacingInc();
834 for(
unsigned int i = 0; i < numVerts; i++ )
837 outstr << ( *_attribPtr )[ i ];
839 DistiAttribDict::SpacingDec();
845 unsigned int numVerts = _numElements;
850 *_numVertices = numVerts;
853 if( *_attribPtr != NULL )
854 delete[] * _attribPtr;
858 *_attribPtr =
new T[ numVerts ];
863 if( !_compatabilityMode )
867 instr.getline( buf, 1024 );
870 for(
unsigned int i = 0; i < numVerts; i++ )
872 if( !_compatabilityMode )
875 instr.getline( buf, 1024 );
879 std::sscanf( buf,
"%f %f %f",
880 &( ( *_attribPtr )[ i ].x ),
881 &( ( *_attribPtr )[ i ].y ),
882 &( ( *_attribPtr )[ i ].z ) );
884 assert( 3 == count );
889 instr >> ( *_attribPtr )[ i ];
904 if( !( _name == r->
_name ) || _numElements != r->_numElements )
907 for(
unsigned int i = 0u; i < _numElements; ++i )
909 T leftVert = ( *_attribPtr )[ i ];
910 T rightVert = ( *r->_attribPtr )[ i ];
928 unsigned int* _numVertices;
929 unsigned int _numElements;
931 bool _compatabilityMode;
934 void SetCompatabilityMode(
bool mode ) { _compatabilityMode = mode; }
938 , _attribPtr( attribPtr )
939 , _numVertices( numVertices )
941 , _fixedArray(
false )
943 _compatabilityMode =
true;
948 , _attribPtr(
new Tptr( attribPtr ) )
949 , _numVertices( NULL )
950 , _numElements( numElements )
951 , _fixedArray(
true )
953 _compatabilityMode =
true;
958 if( ( _fixedArray || _localStorage ) && _attribPtr )
965 return ( *_attribPtr != NULL );
970 if( *_attribPtr != NULL )
972 unsigned int numVerts = _numElements;
975 outstr << *_numVertices;
976 numVerts = *_numVertices;
978 DistiAttribDict::SpacingInc();
979 for(
unsigned int i = 0; i < numVerts; i++ )
982 outstr << ( *_attribPtr )[ i ];
984 DistiAttribDict::SpacingDec();
990 unsigned int numVerts = _numElements;
995 *_numVertices = numVerts;
998 if( *_attribPtr != NULL )
999 delete[] * _attribPtr;
1002 *_attribPtr =
new Vertex[ numVerts ];
1005 if( !_compatabilityMode )
1009 instr.getline( buf, 1024 );
1012 for(
unsigned int i = 0; i < numVerts; i++ )
1014 if( !_compatabilityMode )
1017 instr.getline( buf, 1024 );
1022 std::sscanf( buf,
"%f %f %f %d %d %d %d",
1023 &( ( *_attribPtr )[ i ].x ),
1024 &( ( *_attribPtr )[ i ].y ),
1025 &( ( *_attribPtr )[ i ].z ),
1028 assert( 7 == count );
1031 ( *_attribPtr )[ i ].color.RGBA( (
unsigned char)r, (
unsigned char)g, (
unsigned char)b, (
unsigned char)a );
1035 instr >> ( *_attribPtr )[ i ];
1050 if( !( _name == r->
_name ) || _numElements != r->_numElements )
1053 for(
unsigned int i = 0u; i < _numElements; ++i )
1055 Vertex leftVert = ( *_attribPtr )[ i ];
1056 Vertex rightVert = ( *r->_attribPtr )[ i ];
1081 unsigned int numVerts = _numElements;
1083 for(
unsigned int i = 0; i < numVerts; i++ )
1086 outstr << ( *_attribPtr )[ i ];
1093 unsigned int numVerts = _numElements;
1095 for(
unsigned int i = 0; i < numVerts; i++ )
1103 std::getline( instr, line );
1105 if( i == 0 && line.length() == 0 )
1106 std::getline( instr, line );
1108 std::stringstream strm( line );
1109 strm >> ( *_attribPtr )[ i ];
1145 , _originalAttribName( originalName )
1146 , _dictionary( dict )
1151 virtual DISTI_EXPORT
bool OkToWrite()
const DISTI_METHOD_OVERRIDE;
1154 virtual DISTI_EXPORT
bool ValueChanged() DISTI_METHOD_OVERRIDE;
1157 virtual DISTI_EXPORT
void ResetValueChanged() DISTI_METHOD_OVERRIDE;
1160 virtual DISTI_EXPORT std::string ValueString() DISTI_METHOD_OVERRIDE;
1163 virtual DISTI_EXPORT
void ValueString(
const std::string& s ) DISTI_METHOD_OVERRIDE;
1166 virtual DISTI_EXPORT
long ValueInt() DISTI_METHOD_OVERRIDE;
1169 virtual DISTI_EXPORT
void ValueInt(
long val ) DISTI_METHOD_OVERRIDE;
1172 virtual DISTI_EXPORT
double ValueFloat() DISTI_METHOD_OVERRIDE;
1175 virtual DISTI_EXPORT
void ValueFloat(
double val ) DISTI_METHOD_OVERRIDE;
1178 virtual DISTI_EXPORT std::ostream& WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE;
1181 virtual DISTI_EXPORT std::istream& ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE;
1189 virtual DISTI_EXPORT
void UnregisterObserver(
CallbackID id ) DISTI_METHOD_OVERRIDE;
1191 virtual DISTI_EXPORT
void NotifyObservers() DISTI_METHOD_OVERRIDE;
1202 template<
class T,
bool showIndex >
1210 , _attribPtr( attribPtr )
1217 , _attribPtr(
new T() )
1230 return ( _attribPtr != NULL && _attribPtr->Capacity() );
1233 std::ostream&
WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE
1235 if( _attribPtr != NULL )
1237 unsigned numEntries = _attribPtr->Count();
1238 outstr << numEntries;
1240 DistiAttribDict::SpacingInc();
1242 for(
unsigned i = 0; i < numEntries; i++ )
1248 outstr << DistiAttribDict::SpacingString() << i <<
" ";
1251 outstr << DistiAttribDict::SpacingString() << ( *_attribPtr )[ i ] <<
" ";
1253 DistiAttribDict::SpacingDec();
1258 std::istream&
ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE
1260 unsigned numEntries = 0;
1261 instr >> numEntries;
1263 _attribPtr->Count( numEntries );
1264 for(
unsigned i = 0; i < numEntries; i++ )
1272 instr >> ( *_attribPtr )[ entry ];
1283 template<
class T,
bool showIndex >
1294 , _attribPtr( attribPtr )
1301 , _attribPtr(
new T() )
1316 return ( _attribPtr != NULL && _attribPtr->size() );
1321 if( _attribPtr != NULL )
1323 const std::size_t numEntries = _attribPtr->size();
1324 outstr << numEntries;
1326 DistiAttribDict::SpacingInc();
1328 for( std::size_t i = 0; i < numEntries; i++ )
1334 outstr << DistiAttribDict::SpacingString() << i <<
" ";
1337 outstr << DistiAttribDict::SpacingString() << ( *_attribPtr )[ i ] <<
" ";
1339 DistiAttribDict::SpacingDec();
1346 if( _attribPtr != NULL )
1349 instr >> numEntries;
1351 _attribPtr->resize( numEntries );
1353 for(
int i = 0; i < numEntries; i++ )
1360 instr >> ( *_attribPtr )[ entry ];
1377 typedef T* ( *CreateItemCb )();
1381 CreateItemCb _createCb;
1388 , _createCb( createCb )
1398 << DistiAttribDict::SpacingString() <<
"{\n";
1399 DistiAttribDict::SpacingInc();
1400 for(
unsigned int i = 0; i < _array->
Count(); i++ )
1402 if( ( *_array )[ i ] )
1404 outstr << DistiAttribDict::SpacingString();
1406 ( ( *_array )[ i ] )->WriteValue( outstr );
1410 DistiAttribDict::SpacingDec();
1411 outstr << DistiAttribDict::SpacingString() <<
"}\n";
1419 while( DistiAttribDict::ScanToken( instr, buf ) )
1429 if( T*
const createdItem = dynamic_cast<T*>( _createCb() ) )
1432 _array->
Back()->ReadValue( instr );
1451 template<
class containerT,
class T,
class SetArgT = const T&,
class GetReturnT = T>
1455 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
1458 typedef void ( containerT::*SetMethodType )( SetArgT );
1459 typedef GetReturnT ( containerT::*GetMethodType )();
1460 typedef GetReturnT ( containerT::*GetMethodConstType )()
const;
1464 containerT* _container;
1465 SetMethodType _setMethod;
1466 GetMethodType _getMethod;
1470 : BaseClass( NULL, name, attribPtr )
1472 , _container( frame )
1473 , _setMethod( setMethod )
1474 , _getMethod( getMethod )
1477 if(
typeid( T ) ==
typeid(
float ) ||
typeid( T ) ==
typeid(
double ) ||
typeid( T ) ==
typeid(
long double ) )
1485 return ( this->_attribPtr || _getMethod );
1490 virtual std::string
ValueString() DISTI_METHOD_OVERRIDE {
return DistiAttributeBase::ValueString(); }
1491 virtual void ValueString(
const std::string& s ) DISTI_METHOD_OVERRIDE { DistiAttributeBase::ValueString( s ); }
1493 virtual long ValueInt() DISTI_METHOD_OVERRIDE {
return DistiAttributeBase::ValueInt(); }
1494 virtual void ValueInt(
long val ) DISTI_METHOD_OVERRIDE { DistiAttributeBase::ValueInt( val ); }
1496 virtual double ValueFloat() DISTI_METHOD_OVERRIDE {
return DistiAttributeBase::ValueFloat(); }
1497 virtual void ValueFloat(
double val ) DISTI_METHOD_OVERRIDE { DistiAttributeBase::ValueFloat( val ); }
1499 virtual std::ostream&
WriteValue( std::ostream& outstr ) DISTI_METHOD_OVERRIDE
1501 if( _precision > 0 )
1502 outstr.precision(
int( _precision ) );
1504 if( _getMethod && _container )
1507 T* tempAttribPtr = this->_attribPtr;
1510 T temp( ( _container->*_getMethod )() );
1513 this->_attribPtr = &temp;
1516 BaseClass::WriteValue( outstr );
1519 this->_attribPtr = tempAttribPtr;
1521 else if( this->_attribPtr )
1523 BaseClass::WriteValue( outstr );
1529 virtual std::istream&
ReadValue( std::istream& instr ) DISTI_METHOD_OVERRIDE
1531 if( _setMethod && _container )
1534 T* tempAttribPtr = this->_attribPtr;
1538 this->_attribPtr = &temp;
1541 BaseClass::ReadValue( instr );
1544 ( _container->*_setMethod )( temp );
1546 this->_attribPtr = tempAttribPtr;
1548 else if( this->_attribPtr )
1550 BaseClass::ReadValue( instr );
1558 if( _getMethod && _container )
1561 return ( _container->*_getMethod )();
1563 else if( this->_attribPtr )
1565 return BaseClass::Value();
1573 virtual void Value(
const T& val ) DISTI_METHOD_OVERRIDE
1575 if( _setMethod && _container )
1577 ( _container->*_setMethod )( val );
1579 else if( this->_attribPtr )
1581 BaseClass::Value( val );
1598 template<
typename Type,
class Class>
1609 template<
typename Type,
class Class>
1621 template<
typename Type,
class Class>
1632 template<
typename Type,
class Class>
1642 template<
typename Type,
class Class>
1653 template<
typename Type,
class Class>
1665 template<
typename GetReturnT,
typename SetArgT,
class Class>
1676 template<
class Class>
1713 template<
class enumType>
1717 enumType* _attribPtr;
1724 , _attribPtr( attribPtr )
1725 , _pairList( pairList )
1730 , _attribPtr(
new enumType( value ) )
1731 , _pairList( pairList )
1737 if( _localStorage && _attribPtr )
1743 virtual void ValueInt(
long val ) { *_attribPtr = (enumType)val; };
1750 *_attribPtr = ( enumType ) * ( ptr->_attribPtr );
1755 return DistiAttributeBase::operator=( oldClass );
1761 bool foundIt =
false;
1763 typename DistiAttributeEnumDefList::iterator item = _pairList->begin();
1764 while( item != _pairList->end() )
1766 if( ( *item )->_enum == *_attribPtr )
1768 outstr << ( *item )->_string;
1777 outstr << (int)*_attribPtr;
1789 bool foundIt =
false;
1790 typename DistiAttributeEnumDefList::iterator item = _pairList->begin();
1793 while( item != _pairList->end() )
1795 if( strcmp( ( *item )->_string, value ) == 0 )
1797 *_attribPtr = (enumType)( *item )->_enum;
1809 *_attribPtr = (enumType)atoi( value );
1836 #define DISTI_REGISTER_METHOD_CALLBACK( instance, Class, Method ) \
1838 typedef CallbackMethodCallerTemplate<Class, Class> Caller; \
1839 typedef typename Caller::MethodType1 MethodType; \
1840 const MethodType callback = reinterpret_cast<MethodType>( Method ); \
1841 ThisClass::CallbackCaller( new Caller( callback, instance ) ); \
1851 #define DISTI_SET_OBJECT_CALLBACK1( object, method, parent ) \
1852 ( object )->CallbackCaller( \
1853 new CallbackMethodCallerTemplate<DisplayObject, DisplayObject>( \
1854 (disti::CallbackMethodCallerTemplate<DisplayObject, DisplayObject>::MethodType1)( method ), ( parent ) ) );
1865 #define DISTI_ADD_ATTRIBUTE( Type, name, memberVarAddr ) \
1867 static const AttributeName attr( name ); \
1868 CallbackAttributeNotifier<ThisClass> cb( this, attr ); \
1869 this->Attributes().Add( new DistiAttribute<Type>( &cb, ( attr ), ( memberVarAddr ) ) ); \
1884 #define DISTI_ADD_ATTRIBUTE_CALLBACK( Type, name, memberVarAddr, callbackFunction ) \
1886 typedef void ( ThisClass::*Method )(); \
1887 static const AttributeName attr( name ); \
1888 CallbackAttributeNotifier<ThisClass> cb( this, attr, reinterpret_cast<Method>( callbackFunction ) ); \
1889 this->Attributes().Add( new DistiAttribute<Type>( &cb, ( attr ), ( memberVarAddr ) ) ); \
1902 #define DISTI_ADD_ATTRIBUTE_SET_GET( Type, name, setter, getter ) \
1904 static const AttributeName attr( name ); \
1905 this->Attributes().Add( CreateDistiAttributeProperty<Type>( attr, this, setter, getter ) ); \
1915 #define DISTI_ADD_ATTRIBUTE_STRING( name, memberVarAddr ) \
1917 static const AttributeName attr( name ); \
1918 CallbackAttributeNotifier<ThisClass> cb( this, attr ); \
1919 this->Attributes().Add( new DistiAttributeEncodedStdString( &cb, attr, memberVarAddr ) ); \
1931 #define DISTI_ADD_ATTRIBUTE_STRING_CALLBACK( name, memberVarAddr, callbackFunction ) \
1933 typedef void ( ThisClass::*Method )(); \
1934 static const AttributeName attr( name ); \
1935 CallbackAttributeNotifier<ThisClass> cb( this, attr, reinterpret_cast<Method>( callbackFunction ) ); \
1936 this->Attributes().Add( new DistiAttributeEncodedStdString( &cb, attr, memberVarAddr ) ); \
1946 #define DISTI_ADD_ATTRIBUTE_ALIAS( aliasName, origName, obj ) \
1948 static const AttributeName aliasAttr( aliasName ); \
1949 static const AttributeName origAttr( origName ); \
1950 DistiAttribDict& attributes = ( obj )->Attributes(); \
1951 this->Attributes().Add( new DistiAttributeAlias( NULL, aliasAttr, origAttr, &attributes ) ); \
1954 #ifdef DISTI_HAS_CPP11
1960 : _func( std::move( func ) )
1976 return !_object.IsNull() && _func;
1980 std::function<void()> _func;
1984 inline AttributeObserver* CreateAttributeFnCallback(
1985 WeakReferenceable*
const obj,
1986 const std::function<
void()>& func )
1988 return new AttributeFnCallback( obj, func );
1991 inline DistiAttributeBase::CallbackID Connect( DisplayObject* obj,
const std::string& resource, WeakReferenceable* funcOwner, std::function<
void()> func )
1993 auto& res = obj->Resource( resource.c_str() );
1994 if( dynamic_cast<disti::DistiEmptyAttribute*>( &res ) )
1996 std::cout <<
"Unknown attribute name: " << resource << std::endl;
1997 return DISTI_INVALID_CALLBACK_ID;
2000 return res.RegisterObserver( CreateAttributeFnCallback( funcOwner, std::move( func ) ) );
2004 template<
class Class>
2005 DistiAttributeBase::CallbackID Connect( DisplayObject* obj,
const std::string& resource, Class*
const methodInstance,
const typename AttributeMethodCallback<Class>::Callback method )
2007 DistiAttributeBase& res = obj->Resource( resource.c_str() );
2008 if( dynamic_cast<disti::DistiEmptyAttribute*>( &res ) )
2010 std::cout <<
"Unknown attribute name: " << resource << std::endl;
2011 return DISTI_INVALID_CALLBACK_ID;
2016 inline void Disconnect( DisplayObject* obj,
const std::string& resource, DistiAttributeBase::CallbackID
id )
2018 DistiAttributeBase& res = obj->Resource( resource.c_str() );
2019 if( !dynamic_cast<disti::DistiEmptyAttribute*>( &res ) &&
id != DISTI_INVALID_CALLBACK_ID )
2021 res.UnregisterObserver(
id );
Definition: display_types.h:69
Definition: gls_metadata_attributes.h:247
Definition: gls_metadata_attributes.h:606
Definition: gls_metadata_attributes.h:264
Definition: display_types.h:94
virtual void ValueString(const std::string &s) override
Definition: gls_metadata_attributes.h:1491
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1395
Definition: display_types.h:67
Definition: gls_metadata_attributes.h:1690
std::ostream & WriteValue(std::ostream &outstr) override
Definition: gls_metadata_attributes.h:1233
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:823
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1079
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:584
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:843
Definition: gls_metadata_attributes.h:289
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:968
unsigned Count() const
Definition: dynamic_array.h:204
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1091
Definition: gls_metadata_attributes.h:1956
The disti::DynamicArray class. A templated array of objects capable of dynamically growing...
Definition: gls_metadata_attributes.h:1284
Definition: gls_metadata_attributes.h:230
Definition: gls_metadata_attributes.h:484
Definition: gls_metadata_attributes.h:400
std::istream & ReadValue(std::istream &instr) override
Definition: disti_metadata.h:588
Definition: display_types.h:147
Definition: gls_metadata_attributes.h:531
Definition: gls_metadata_attributes.h:656
virtual long ValueInt()
Definition: gls_metadata_attributes.h:1742
Definition: display_types.h:145
Definition: display_types.h:85
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:682
virtual double ValueFloat() override
Definition: gls_metadata_attributes.h:1496
Definition: display_types.h:97
virtual void ValueFloat(double val) override
Definition: gls_metadata_attributes.h:1497
Definition: gls_metadata_attributes.h:1714
Definition: display_types.h:86
virtual bool operator==(const DistiAttributeBase &rArg)
Definition: gls_metadata_attributes.h:1042
std::ostream & WriteValue(std::ostream &outstr) override
Definition: disti_metadata.h:574
Definition: gls_metadata_attributes.h:1070
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:689
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1344
Definition: display_types.h:96
Definition: display_types.h:104
A file for all GL Studio files to include.
virtual std::string ValueString() override
Definition: gls_metadata_attributes.h:1490
Definition: display_types.h:57
Definition: display_types.h:110
The disti::DisplayObject class and global enumerations.
Definition: gls_metadata_attributes.h:923
unsigned int CallbackID
Type for unique identifiers.
Definition: disti_metadata.h:345
Definition: display_types.h:84
Definition: gls_metadata_attributes.h:1203
Definition: gls_metadata_attributes.h:1374
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1414
Definition: gls_metadata_attributes.h:319
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:446
Definition: weak_reference.h:64
Definition: gls_metadata_attributes.h:1140
Definition: display_types.h:95
Definition: disti_metadata.h:894
bool OkToWrite() const override
Definition: gls_metadata_attributes.h:1228
Definition: display_types.h:117
virtual void ValueInt(long val)
Definition: gls_metadata_attributes.h:1743
The List_c class. Generic linked list.
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1699
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:1573
Definition: display_types.h:146
Definition: display_types.h:58
Definition: display_types.h:56
Definition: gls_metadata_attributes.h:1121
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:1966
#define GLS_VERIFY(exp)
Definition: disti_assert.h:155
Definition: gls_metadata_attributes.h:1452
Definition: gls_metadata_attributes.h:451
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1759
Definition: disti_metadata.h:186
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:988
Definition: disti_metadata.h:169
Definition: display_types.h:55
Definition: gls_metadata_attributes.h:504
virtual long ValueInt() override
Definition: gls_metadata_attributes.h:1493
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:1666
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:1677
Definition: weak_reference.h:91
std::istream & ReadValue(std::istream &instr) override
Definition: gls_metadata_attributes.h:1258
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:1393
T & Back()
Definition: dynamic_array.h:342
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1704
Definition: display_types.h:88
bool Equal(T1 x, T2 y, float precision=0.001f)
Definition: util.h:423
Definition: display_types.h:65
Definition: display_types.h:144
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:1499
Definition: gls_metadata_attributes.h:617
AttributeName _name
Definition: disti_metadata.h:193
void Add(DistiAttributeBase *attr)
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:963
Definition: display_types.h:111
virtual void ValueInt(long val) override
Definition: gls_metadata_attributes.h:1494
virtual bool IsValid() const
Definition: gls_metadata_attributes.h:1974
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:715
virtual std::ostream & WriteValue(std::ostream &outstr)
Definition: gls_metadata_attributes.h:1319
Definition: display_types.h:87
Definition: gls_metadata_attributes.h:570
Definition: gls_metadata_attributes.h:778
Definition: display_types.h:68
virtual DistiAttributeBase & operator=(const DistiAttributeBase &oldClass)
Definition: gls_metadata_attributes.h:1745
Definition: display_types.h:64
unsigned PushBack(const T &object)
Definition: dynamic_array.h:325
Definition: display_types.h:66
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:1133
virtual std::istream & ReadValue(std::istream &instr)
Definition: gls_metadata_attributes.h:1783
Definition: gls_metadata_attributes.h:633
Definition: gls_metadata_attributes.h:420
Definition: gls_metadata_attributes.h:551
Definition: display_types.h:148
Definition: gls_metadata_attributes.h:348
Definition: disti_metadata.h:85
Definition: display_types.h:119
Definition: display_types.h:118
Definition: gls_metadata_attributes.h:374
Definition: bmpimage.h:46
long ValueInt() override
Definition: disti_metadata.h:534
Definition: display_types.h:143
virtual bool OkToWrite() const override
Definition: gls_metadata_attributes.h:1483
virtual std::istream & ReadValue(std::istream &instr) override
Definition: gls_metadata_attributes.h:1529
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:1314
virtual bool operator==(const DistiAttributeBase &rArg)
Definition: gls_metadata_attributes.h:896
Definition: display_types.h:103
virtual bool OkToWrite() const
Definition: gls_metadata_attributes.h:818
virtual T Value() override
Definition: gls_metadata_attributes.h:1556