00001 /* 00002 * Copyright 2006 Sony Computer Entertainment Inc. 00003 * 00004 * Licensed under the MIT Open Source License, for details please see license.txt or the website 00005 * http://www.opensource.org/licenses/mit-license.php 00006 * 00007 */ 00008 00009 #ifndef __DAE_META_ATTRIBUTE_H__ 00010 #define __DAE_META_ATTRIBUTE_H__ 00011 00012 #include <string> 00013 #include <sstream> 00014 #include <dae/daeTypes.h> 00015 #include <dae/daeStringRef.h> 00016 #include <dae/daeAtomicType.h> 00017 #include <dae/daeElement.h> 00018 #include <dae/daeArray.h> 00019 00020 class daeElement; 00021 class daeMetaElement; 00022 class daeMetaAttribute; 00023 class daeMetaElementAttribute; 00024 00041 class DLLSPEC daeMetaAttribute : public daeRefCountedObj 00042 { 00043 protected: 00044 daeStringRef _name; 00045 daeInt _offset; 00046 daeAtomicType* _type; 00047 daeMetaElement* _container; 00048 std::string _defaultString; 00049 daeMemoryRef _defaultValue; 00050 daeBool _isRequired; 00051 00052 public: 00056 daeMetaAttribute(); 00057 00061 virtual ~daeMetaAttribute(); 00062 public: 00067 daeBool getIsRequired() {return _isRequired; } 00073 void setIsRequired(daeBool isRequired) {_isRequired = isRequired;} 00079 void setOffset(daeInt offset) { _offset = offset; } 00080 00086 daeInt getOffset() { return _offset; } 00087 00093 void setName(daeString name) { _name = name; } 00094 00099 daeStringRef getName() { return _name; } 00100 00106 void setType(daeAtomicType* type) { _type = type; } 00107 00113 daeAtomicType* getType() { return _type; } 00114 00119 virtual void setDefaultString(daeString defaultVal); 00120 00125 virtual void setDefaultValue(daeMemoryRef defaultVal); 00126 00131 daeString getDefaultString(); 00132 00137 daeMemoryRef getDefaultValue(); 00138 00143 void setContainer(daeMetaElement* container) { _container = container; } 00144 00149 daeMetaElement* getContainer() { return _container; } 00150 00154 virtual void setDocument(daeElement* e, daeDocument* doc); 00155 00159 virtual void memoryToString(daeElement* e, std::ostringstream& buffer); 00160 00164 virtual void stringToMemory(daeElement* e, daeString s); 00165 00171 virtual daeMemoryRef get(daeElement* e); 00172 00177 virtual daeBool isArrayAttribute() { return false; } 00178 00179 public: 00185 virtual daeInt getSize(); 00186 00191 virtual daeInt getAlignment(); 00192 00198 virtual void copy(daeElement* toElement, daeElement* fromElement); 00199 00204 virtual void copyDefault(daeElement* element); 00205 00213 virtual daeInt compare(daeElement* elt1, daeElement* elt2); 00214 00222 virtual daeInt compareToDefault(daeElement* e); 00223 00224 public: 00225 // These methods are deprecated. 00226 virtual daeChar* getWritableMemory(daeElement* e); // Use get instead. 00227 virtual void set(daeElement* element, daeString s); // Use stringToMemory instead. 00228 }; 00229 00230 00238 class DLLSPEC daeMetaArrayAttribute : public daeMetaAttribute 00239 { 00240 public: 00241 virtual ~daeMetaArrayAttribute(); 00242 00248 virtual void copy(daeElement* toElement, daeElement* fromElement); 00249 00254 virtual void copyDefault(daeElement* element); 00255 00263 virtual daeInt compare(daeElement* elt1, daeElement* elt2); 00264 00272 virtual daeInt compareToDefault(daeElement* e); 00273 00277 virtual void memoryToString(daeElement* e, std::ostringstream& buffer); 00278 00282 virtual void stringToMemory(daeElement* e, daeString s); 00283 00288 virtual void setDefaultString(daeString defaultVal); 00289 00294 virtual void setDefaultValue(daeMemoryRef defaultVal); 00295 00300 virtual daeBool isArrayAttribute() { return true; } 00301 00305 virtual void setDocument(daeElement* e, daeDocument* doc); 00306 }; 00307 00308 00309 typedef daeSmartRef<daeMetaAttribute> daeMetaAttributeRef; 00310 00311 typedef daeTArray<daeMetaAttributeRef> daeMetaAttributeRefArray; 00312 typedef daeTArray<daeMetaAttribute*> daeMetaAttributePtrArray; 00313 00314 #endif //__DAE_META_ATTRIBUTE_H__ 00315 00316 00317 00318 00319 00320