updated COLLADA-DOM to the latest bleeding-edge (1.4.1) SVN version of today
This commit is contained in:
@@ -130,6 +130,13 @@ public:
|
||||
for(size_t i=0;i<_count;i++)
|
||||
set( i, cpy[i] );
|
||||
}
|
||||
/**
|
||||
* Constructor that takes one element and turns into an array
|
||||
*/
|
||||
daeTArray( const T &el ) : daeArray() {
|
||||
_elementSize = sizeof(T);
|
||||
append( el );
|
||||
}
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
@@ -177,10 +184,10 @@ public:
|
||||
{
|
||||
// If the array shrank, destruct the elements
|
||||
size_t i;
|
||||
for(i=_count-1; i>= nElements; i--)
|
||||
for(i=_count; i>nElements; i--)
|
||||
{
|
||||
((T*)_data + i)->~T();
|
||||
memset(_data+i*_elementSize,0,_elementSize);
|
||||
((T*)_data + (i-1))->~T();
|
||||
memset(_data+(i-1)*_elementSize,0,_elementSize);
|
||||
}
|
||||
}
|
||||
_count = nElements;
|
||||
@@ -239,11 +246,14 @@ public:
|
||||
* objects in two places, the class member and the <i> @c _contents </i> array, when you remove something from the
|
||||
* do, you must remove it from both places.
|
||||
*/
|
||||
inline daeInt remove(const T& value)
|
||||
inline daeInt remove(const T& value, size_t *idx = NULL )
|
||||
{
|
||||
size_t index;
|
||||
if(find(value,index) == DAE_OK)
|
||||
{
|
||||
if ( idx != NULL ) {
|
||||
*idx = index;
|
||||
}
|
||||
return(removeIndex( index ));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -73,14 +73,14 @@ public:
|
||||
* @note This function is called internally and not meant to be called by the client application.
|
||||
* Calling this function from the client application may result in unexpected behavior.
|
||||
*/
|
||||
void insertElement( daeElementRef element ) { insertedElements.append( element ); }
|
||||
void insertElement( daeElementRef element );
|
||||
/**
|
||||
* This function is used to track how a document gets modified. It gets called internally.
|
||||
* @param element The element that was removed from this document.
|
||||
* @note This function is called internally and not meant to be called by the client application.
|
||||
* Calling this function from the client application may result in unexpected behavior.
|
||||
*/
|
||||
void removeElement( daeElementRef element ) { removedElements.append( element ); }
|
||||
void removeElement( daeElementRef element );
|
||||
|
||||
/**
|
||||
* This function is used to track how a document gets modified. It gets called internally.
|
||||
|
||||
@@ -54,6 +54,7 @@ private:
|
||||
protected:
|
||||
daeMetaElement* _meta;
|
||||
daeString _elementName;
|
||||
daeBoolArray _validAttributeArray;
|
||||
|
||||
public:
|
||||
/** An enum that describes the state of user integration with this object */
|
||||
@@ -210,6 +211,30 @@ public:
|
||||
*/
|
||||
virtual daeBool setAttribute(daeString attrName, daeString attrValue);
|
||||
|
||||
/**
|
||||
* Checks if an attribute has been set either by being loaded from the COLLADA document or set
|
||||
* programmatically.
|
||||
* @param attrName The name of the attribute to check.
|
||||
* @return Returns true if the attribute has been set. False if the attribute hasn't been set
|
||||
* or doesn't exist for this element.
|
||||
*/
|
||||
daeBool isAttributeSet( daeString attrName );
|
||||
|
||||
/**
|
||||
* Checks if this element can have the attribute specified.
|
||||
* @param attrName The name of the attribute to look for.
|
||||
* @return Returns true is this element can have an attribute with the name specified. False otherwise.
|
||||
*/
|
||||
daeBool hasAttribute( daeString attrName );
|
||||
|
||||
/**
|
||||
* Gets a pointer to the value of the attribute specified.
|
||||
* @param attrName The name of the attribute to look for.
|
||||
* @return Returns a daeMemoryRef (char *) to the value of the attribute. The return value will need
|
||||
* to be typecast to the appropriate type. Returns NULL if the attribute does not exist.
|
||||
*/
|
||||
daeMemoryRef getAttributeValue( daeString attrName );
|
||||
|
||||
/**
|
||||
* Finds the database document associated with @c this element.
|
||||
* @return Returns the @c daeDocument representing the containing file or database
|
||||
@@ -255,7 +280,6 @@ public:
|
||||
*/
|
||||
daeElement* createAndPlace(daeString className);
|
||||
|
||||
//!!!ACL
|
||||
/**
|
||||
* Create a sub-element via #createElement and place it via #placeElementAt
|
||||
* This also automatically inserts the new element at the specified index in the _contents of it's
|
||||
@@ -272,7 +296,18 @@ public:
|
||||
* If @c createAndPlace() was used to create the element, its parent is the the caller of @c createAndPlace().
|
||||
* @return Returns the parent element, if @c this is not the top level element.
|
||||
*/
|
||||
daeElement* getParentElement() { return _parent;}
|
||||
/**
|
||||
* Deprecated. Use getParentElement()
|
||||
* @deprecated
|
||||
*/
|
||||
daeElement* getXMLParentElement() { return _parent;}
|
||||
/**
|
||||
* Sets the parent element for this element.
|
||||
* @param newParent The element which is the new parent element for this element.
|
||||
* @note This function is called internally and not meant to be called form the client application.
|
||||
*/
|
||||
void setParentElement( daeElement *parent ) { _parent = parent; }
|
||||
|
||||
/**
|
||||
* Gets the associated Meta information for this element. This
|
||||
@@ -321,7 +356,6 @@ public:
|
||||
*/
|
||||
daeString getID() const;
|
||||
|
||||
//!!! ACL
|
||||
/**
|
||||
* Gets the children/sub-elements of this element.
|
||||
* This is a helper function used to easily access an element's children without the use of the
|
||||
|
||||
@@ -191,6 +191,11 @@ public:
|
||||
* Initializes the @c daeIDREf, setting <tt><i>id, element,</i></tt> and <tt><i>container</i></tt> to NULL.
|
||||
*/
|
||||
void initialize();
|
||||
|
||||
//Backwards Compatibility
|
||||
daeIDRef &get( daeUInt idx ) { (void)idx; return *this; }
|
||||
size_t getCount() const { return 1; }
|
||||
daeIDRef& operator[](size_t index) { (void)index; return *this; }
|
||||
};
|
||||
|
||||
class daeIDRefResolver;
|
||||
|
||||
@@ -35,8 +35,8 @@ public:
|
||||
virtual ~daeIntegrationObject() {}
|
||||
|
||||
public:
|
||||
/** A smartRef to the element associated with this integration object. */
|
||||
daeElementRef _element;
|
||||
/** A pointer to the element associated with this integration object. */
|
||||
daeElement *_element;
|
||||
/** A pointer at which to store the user object associated with this element. */
|
||||
void* _object;
|
||||
/** An enum describing the state of the conversion from COLLADA. */
|
||||
|
||||
44
Extras/COLLADA_DOM/include/dae/daeMetaAny.h
Normal file
44
Extras/COLLADA_DOM/include/dae/daeMetaAny.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2006 Sony Computer Entertainment Inc.
|
||||
*
|
||||
* Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at:
|
||||
* http://research.scea.com/scea_shared_source_license.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
|
||||
#ifndef __DAE_META_ANY_H__
|
||||
#define __DAE_META_ANY_H__
|
||||
|
||||
#include <dae/daeMetaCMPolicy.h>
|
||||
|
||||
/**
|
||||
* The daeMetaAny class defines the behavior of an xs:any content model in the COLLADA Schema.
|
||||
*/
|
||||
class daeMetaAny : public daeMetaCMPolicy
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* @param container The daeMetaElement that this policy object belongs to.
|
||||
* @param parent The daeMetaCMPolicy parent of this policy object.
|
||||
* @param odinal The ordinal value offset of this specific policy object. Used for maintaining the
|
||||
* correct order of child elements.
|
||||
* @param minO The minimum number of times this CMPolicy object must appear. This value comes from the COLLADA schema.
|
||||
* @param maxO The maximum number of times this CMPolicy object may appear. This value comes from the COLLADA schema.
|
||||
*/
|
||||
daeMetaAny( daeMetaElement *container, daeMetaCMPolicy *parent = NULL, daeUInt ordinal = 0, daeInt minO = 1, daeInt maxO = 1 );
|
||||
~daeMetaAny();
|
||||
|
||||
daeElement *placeElement( daeElement *parent, daeElement *child, daeUInt &ordinal, daeInt offset = 0, daeElement* before = NULL, daeElement *after = NULL );
|
||||
daeBool removeElement(daeElement* parent, daeElement* child);
|
||||
daeMetaElement *findChild( daeString elementName );
|
||||
void getChildren( daeElement* parent, daeElementRefArray &array );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,14 +25,6 @@ class daeMetaElement;
|
||||
class daeMetaAttribute;
|
||||
class daeMetaElementAttribute;
|
||||
|
||||
typedef daeSmartRef<daeMetaElementAttribute> daeMetaElementAttributeRef;
|
||||
typedef daeSmartRef<daeMetaElement> daeMetaElementRef;
|
||||
typedef daeSmartRef<daeMetaAttribute> daeMetaAttributeRef;
|
||||
|
||||
typedef daeTArray<daeMetaAttributeRef> daeMetaAttributeRefArray;
|
||||
typedef daeTArray<daeMetaAttribute*> daeMetaAttributePtrArray;
|
||||
typedef daeTArray<daeMetaElementAttributeRef> daeMetaElementAttributeRefArray;
|
||||
|
||||
/**
|
||||
* The @c daeMetaAttribute class describes one attribute in a C++ COLLADA dom element.
|
||||
*
|
||||
@@ -57,7 +49,6 @@ protected:
|
||||
daeAtomicType* _type;
|
||||
daeMetaElement* _container;
|
||||
daeString _default;
|
||||
daeBool _isValid;
|
||||
daeBool _isRequired;
|
||||
|
||||
public:
|
||||
@@ -71,21 +62,6 @@ public:
|
||||
*/
|
||||
~daeMetaAttribute() {}
|
||||
public:
|
||||
/**
|
||||
* Determines if the value of this attribute was ever set.
|
||||
* This will be the case if @c setDefault() was
|
||||
* called or if the attribute was assigned a value by the input file. If you set the value yourself,
|
||||
* you need to call @c setIsValid() to set this flag.
|
||||
* @return Returns true if the value in this attribute is valid.
|
||||
*/
|
||||
daeBool getIsValid() {return _isValid; }
|
||||
/**
|
||||
* Sets the value that indicates if this attribute contains a valid value.
|
||||
* If you don't set this on an optional
|
||||
* attribute, that attribute will not be written.
|
||||
* @param isValid Indicates if the value in this attribute valid, true if it is, false if not.
|
||||
*/
|
||||
void setIsValid(daeBool isValid) {_isValid = isValid;}
|
||||
/**
|
||||
* Determines if the schema indicates that this is a required attribute.
|
||||
* @return Returns true if this is a required attribute, false if not.
|
||||
@@ -182,35 +158,14 @@ public:
|
||||
* @return Returns the associated particle out of parent element e, based on index, if necessary.
|
||||
*/
|
||||
virtual daeMemoryRef get(daeElement* e, daeInt index);
|
||||
|
||||
/**
|
||||
* Gets if this attribute is an array attribute.
|
||||
* @return Returns true if this attribute is an array type.
|
||||
*/
|
||||
virtual daeBool isArrayAttribute() { return false; }
|
||||
|
||||
public: // STATIC MEMBERS
|
||||
/**
|
||||
* Lists the type names that can be created by factories and indicates which _FactoryTemplates to use for each type.
|
||||
*/
|
||||
static daeStringRefArrayArray _NameBindings;
|
||||
/**
|
||||
* Points to the factory objects used to construct various types of attributes, _NameBindings specifies which type names are bound to which factories.
|
||||
*/
|
||||
static daeMetaAttributeRefArray _FactoryTemplates;
|
||||
|
||||
public: //STATIC INTERFACE
|
||||
/**
|
||||
* Obsolete
|
||||
*/
|
||||
static daeMetaAttributeRef Factory(daeStringRef xmlTypeName);
|
||||
/**
|
||||
* Obsolete
|
||||
*/
|
||||
static void InitializeKnownTypes();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Clones the @c daeMetaAttribute.
|
||||
* @return Returns a duplicate of this @c daeMetaAttribute.
|
||||
* @note Not Implemented.
|
||||
*/
|
||||
virtual daeMetaAttributeRef clone();
|
||||
|
||||
/**
|
||||
* Resolves a reference (if there is one) in the attribute type;
|
||||
* only useful for reference types.
|
||||
@@ -261,171 +216,7 @@ public:
|
||||
daeChar* getWritableMemory(daeElement* e) {
|
||||
return (daeChar*)e+_offset; }
|
||||
};
|
||||
/**
|
||||
* The @c daeMetaElementAttribute class represents a single attribute whose value is an element.
|
||||
*/
|
||||
class daeMetaElementAttribute : public daeMetaAttribute
|
||||
{
|
||||
public:
|
||||
/** Minimum number of times this meta element can occur. */
|
||||
daeInt _minOccurs;
|
||||
/** Maximum number of times this meta element can occur. */
|
||||
daeInt _maxOccurs;
|
||||
/** If this element is found in a choice group in the schema */
|
||||
daeBool _isInChoice;
|
||||
/** If this element is found in a sequence group in the schema */
|
||||
daeBool _isInSequence;
|
||||
|
||||
/** The element found before this one in the sequence group in the schema */
|
||||
daeMetaElement* _previousInSequence;
|
||||
/** The metaElement that describes the element type of this attribute */
|
||||
daeMetaElement* _elementType;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
daeMetaElementAttribute();
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~daeMetaElementAttribute() {}
|
||||
public:
|
||||
/**
|
||||
* Sets the element type for the element that this attribute points to.
|
||||
* @param elementType @c daeMetaElement representing the type.
|
||||
*/
|
||||
void setElementType(daeMetaElement *elementType) {
|
||||
_elementType = elementType; }
|
||||
|
||||
/**
|
||||
* Gets the element type for the element that this attribute points to.
|
||||
* @return Returns the @c daeMetaElement representing the type.
|
||||
*/
|
||||
daeMetaElement* getElementType() { return _elementType; }
|
||||
|
||||
/**
|
||||
* Defines the override version of base method.
|
||||
* @see daeMetaAttribute::clone()
|
||||
*/
|
||||
virtual daeMetaAttributeRef clone();
|
||||
|
||||
/**
|
||||
* Places element <tt><i>child</i></tt> in element <tt><i>parent</i></tt> using @c this element attribute.
|
||||
* @param parent The Element in which to place child.
|
||||
* @param child The Element to place in parent.
|
||||
*/
|
||||
virtual void placeElement(daeElement* parent, daeElement* child);
|
||||
/**
|
||||
* Removes element <tt><i>child</i></tt> from element <tt><i>parent</i></tt> using @c this element attribute.
|
||||
* @param parent The Element in which to remove child.
|
||||
* @param child The Element to remove from parent.
|
||||
*/
|
||||
virtual void removeElement(daeElement* parent, daeElement* child);
|
||||
/**
|
||||
* Sets the database document associated with this element.
|
||||
* @param parent The daeElement to set the document.
|
||||
* @param c The @c daeDocument to associate with this element.
|
||||
*/
|
||||
virtual void setDocument(daeElement *parent, daeDocument* c );
|
||||
inline void setCollection(daeElement *parent, daeDocument* c ) {
|
||||
setDocument( parent, c );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of elements associated with this attribute in instance <tt><i>e.</i></tt>
|
||||
* @param e Containing element to run the operation on.
|
||||
* @return Returns the number of elements associated with this attribute
|
||||
* in instance <tt><i>e.</i></tt>
|
||||
*/
|
||||
virtual daeInt getCount(daeElement* e);
|
||||
|
||||
/**
|
||||
* Gets an element from containing element <tt><i>e</i></tt> based on <tt><i>index.</i></tt>
|
||||
* @param e Containing element from which to get the element.
|
||||
* @param index Index of the element to retrieve if indeed
|
||||
* there is an array of elements rather than a singleton.
|
||||
* @return Returns the associated element out of parent element e, based on index, if necessary.
|
||||
*/
|
||||
virtual daeMemoryRef get(daeElement* e, daeInt index);
|
||||
|
||||
/**
|
||||
* Defines the override version of base method.
|
||||
* @param element Element on which to set this attribute.
|
||||
* @param s String containing the value to be converted via the
|
||||
* atomic type system.
|
||||
*/
|
||||
virtual void set(daeElement* element, daeString s);
|
||||
/**
|
||||
* Defines the override version of base method.
|
||||
* @param toElement Pointer to a @c daeElement to copy this attribute to.
|
||||
* @param fromElement Pointer to a @c daeElement to copy this attribute from.
|
||||
*/
|
||||
virtual void copy(daeElement* toElement, daeElement* fromElement);
|
||||
};
|
||||
typedef daeSmartRef<daeMetaElementAttribute> daeMetaElementAttributeRef;
|
||||
typedef daeTArray<daeMetaElementAttributeRef> daeMetaElementAttributeArray;
|
||||
|
||||
|
||||
/**
|
||||
* The @c daeMetaElementArrayAttribute class is similar to daeMetaElementAttribute
|
||||
* except that this meta attribute
|
||||
* describes an array of elements rather than a singleton.
|
||||
*/
|
||||
class daeMetaElementArrayAttribute : public daeMetaElementAttribute
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
daeMetaElementArrayAttribute();
|
||||
public:
|
||||
/**
|
||||
* Defines the override version of this method from @c daeMetaElement.
|
||||
* @return Returns a duplicate of this @c daeMetaAttribute.
|
||||
* @note Not Implemented.
|
||||
*/
|
||||
virtual daeMetaAttributeRef clone();
|
||||
/**
|
||||
* Defines the override version of this method from @c daeMetaElement.
|
||||
*/
|
||||
virtual void placeElement(daeElement* parent, daeElement* child);
|
||||
/**
|
||||
* Defines the override version of this method from @c daeMetaElement.
|
||||
*/
|
||||
virtual void removeElement(daeElement* parent, daeElement* child);
|
||||
/**
|
||||
* Sets the database document associated with this element.
|
||||
* @param c The @c daeDocument to associate with this element.
|
||||
*/
|
||||
virtual void setDocument(daeElement *parent, daeDocument* c );
|
||||
inline void setCollection(daeElement *parent, daeDocument* c ) {
|
||||
setDocument( parent, c );
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the override version of this method from @c daeMetaElement.
|
||||
* @param e Containing element to run the operation on.
|
||||
* @return Returns the number of particles associated with this attribute
|
||||
* in instance <tt><i>e.</i></tt>
|
||||
*/
|
||||
virtual daeInt getCount(daeElement* e);
|
||||
/**
|
||||
* Defines the override version of this method from @c daeMetaElement.
|
||||
* @param e Containing element from which to get the element.
|
||||
* @param index Index of the particle to retrieve if indeed
|
||||
* there is an array of elements rather than a singleton.
|
||||
* @return Returns the associated particle out of parent element e, based on index, if necessary.
|
||||
*/
|
||||
virtual daeMemoryRef get(daeElement* e, daeInt index);
|
||||
/**
|
||||
* Defines the override version of this method from @c daeMetaElement.
|
||||
* @param toElement Pointer to a @c daeElement to copy this attribute to.
|
||||
* @param fromElement Pointer to a @c daeElement to copy this attribute from.
|
||||
*/
|
||||
virtual void copy(daeElement* toElement, daeElement* fromElement);
|
||||
};
|
||||
typedef daeSmartRef<daeMetaElementArrayAttribute> daeMetaElementArrayAttributeRef;
|
||||
typedef daeTArray<daeMetaElementArrayAttributeRef> daeMetaElementArrayAttributeArray;
|
||||
|
||||
/**
|
||||
* The @c daeMetaArrayAttribute class is simple a wrapper that implements
|
||||
@@ -436,14 +227,7 @@ typedef daeTArray<daeMetaElementArrayAttributeRef> daeMetaElementArrayAttributeA
|
||||
*/
|
||||
class daeMetaArrayAttribute : public daeMetaAttribute
|
||||
{
|
||||
daeMetaAttributeRef arrayType;
|
||||
public:
|
||||
/**
|
||||
* Defines the override version of this method from @c daeMetaAttribute.
|
||||
* @return Returns a duplicate of this @c daeMetaAttribute.
|
||||
* @note Not Implemented.
|
||||
*/
|
||||
virtual daeMetaAttributeRef clone();
|
||||
/**
|
||||
* Defines the override version of this method from @c daeMetaAttribute.
|
||||
* @param element Element on which to set this attribute.
|
||||
@@ -472,8 +256,20 @@ public:
|
||||
* @return Returns the associated particle out of parent element e, based on index, if necessary.
|
||||
*/
|
||||
virtual daeMemoryRef get(daeElement* e, daeInt index);
|
||||
|
||||
/**
|
||||
* Gets if this attribute is an array attribute.
|
||||
* @return Returns true if this attribute is an array type.
|
||||
*/
|
||||
virtual daeBool isArrayAttribute() { return true; }
|
||||
};
|
||||
|
||||
|
||||
typedef daeSmartRef<daeMetaAttribute> daeMetaAttributeRef;
|
||||
|
||||
typedef daeTArray<daeMetaAttributeRef> daeMetaAttributeRefArray;
|
||||
typedef daeTArray<daeMetaAttribute*> daeMetaAttributePtrArray;
|
||||
|
||||
#endif //__DAE_META_ATTRIBUTE_H__
|
||||
|
||||
|
||||
|
||||
118
Extras/COLLADA_DOM/include/dae/daeMetaCMPolicy.h
Normal file
118
Extras/COLLADA_DOM/include/dae/daeMetaCMPolicy.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2006 Sony Computer Entertainment Inc.
|
||||
*
|
||||
* Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at:
|
||||
* http://research.scea.com/scea_shared_source_license.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
|
||||
#ifndef __DAE_META_CM_POLICY_H__
|
||||
#define __DAE_META_CM_POLICY_H__
|
||||
|
||||
#include <dae/daeTypes.h>
|
||||
#include <dae/daeElement.h>
|
||||
//class daeElement;
|
||||
class daeMetaElement;
|
||||
|
||||
/**
|
||||
* The daeMetaCMPolicy class is the base class for the content model policy classes which are used to
|
||||
* describe the availability and ordering of an element's children.
|
||||
*/
|
||||
class daeMetaCMPolicy
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Places an element into the parent element based on this content model policy object.
|
||||
* @param parent The parent element for which the child element will be placed.
|
||||
* @param child The new child element.
|
||||
* @param ordinal A reference to a daeUInt which holds the ordinal return value for a placed child. Used
|
||||
* to maintain proper ording of child elements.
|
||||
* @param offset The offset to used when attempting to place this element. Affects comparison against
|
||||
* minOccurs and maxOccurs.
|
||||
* @param before The element that the child should appear before. Optional.
|
||||
* @param after The element that the child should appear after. Optional.
|
||||
* @return Returns The child element that was placed within this content model object or any of its
|
||||
* children. NULL if placement failed.
|
||||
*/
|
||||
virtual daeElement *placeElement( daeElement *parent, daeElement *child, daeUInt &ordinal, daeInt offset = 0, daeElement* before = NULL, daeElement *after = NULL ) = 0;
|
||||
/**
|
||||
* Removes an element from the parent based on this content model object.
|
||||
* @param parent The parent element for which child you want to remove.
|
||||
* @param child The child that will be removed from the parent.
|
||||
* @return Returns true if the child was successfully removed from this content model object or any of
|
||||
* its children. False otherwise.
|
||||
*/
|
||||
virtual daeBool removeElement(daeElement* parent, daeElement* child ) = 0;
|
||||
/**
|
||||
* Gets the daeMetaElement of an acceptable child of this content model object.
|
||||
* @param elementName The name of the element whos metaElement information you are interested in.
|
||||
* @return Returns a pointer to a daeMetaElement class that describes the element interested in.
|
||||
* Returns NULL if the element is not valid in this content model.
|
||||
*/
|
||||
virtual daeMetaElement *findChild( daeString elementName ) = 0;
|
||||
/**
|
||||
* Populates an array with the children of parent based on this content model object.
|
||||
* @param parent The parent element whos children you want.
|
||||
* @param array The array where you the children will be appended to.
|
||||
*/
|
||||
virtual void getChildren( daeElement* parent, daeElementRefArray &array ) = 0;
|
||||
|
||||
/**
|
||||
* Adds a child to this content model object.
|
||||
* @param p The child content model policy object.
|
||||
*/
|
||||
void appendChild( daeMetaCMPolicy *p ) { _children.append( p ); }
|
||||
|
||||
/**
|
||||
* Gets the parent of this content model policy object.
|
||||
* @return Returns a pointer to the parent node.
|
||||
*/
|
||||
daeMetaCMPolicy *getParent() { return _parent; }
|
||||
|
||||
/**
|
||||
* Sets the maximum ordinal value of this policy objects children. Used to keep proper ording for
|
||||
* cm objects that may appear multiple times.
|
||||
* @param ord The maximum ordinal value for this content model object.
|
||||
*/
|
||||
void setMaxOrdinal( daeUInt ord ) { _maxOrdinal = ord; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Constructor.
|
||||
* @param container The daeMetaElement that this policy object belongs to.
|
||||
* @param parent The daeMetaCMPolicy parent of this policy object.
|
||||
* @param odinal The ordinal value offset of this specific policy object. Used for maintaining the
|
||||
* correct order of child elements.
|
||||
* @param minO The minimum number of times this CMPolicy object must appear. This value comes from the COLLADA schema.
|
||||
* @param maxO The maximum number of times this CMPolicy object may appear. This value comes from the COLLADA schema.
|
||||
*/
|
||||
daeMetaCMPolicy( daeMetaElement *container ,daeMetaCMPolicy *parent, daeUInt ordinal,
|
||||
daeInt minO, daeInt maxO ) : _container( container ), _parent( parent ), _minOccurs( minO ),
|
||||
_maxOccurs( maxO ), _maxOrdinal( 0 ), _ordinalOffset( ordinal ) {}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~daeMetaCMPolicy();
|
||||
|
||||
daeMetaElement * _container;
|
||||
daeMetaCMPolicy * _parent;
|
||||
daeTArray<daeMetaCMPolicy*> _children;
|
||||
|
||||
/** Minimum number of times this meta element can occur. */
|
||||
daeInt _minOccurs;
|
||||
/** Maximum number of times this meta element can occur. -1 for unbounded */
|
||||
daeInt _maxOccurs;
|
||||
|
||||
daeUInt _maxOrdinal;
|
||||
daeUInt _ordinalOffset;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
44
Extras/COLLADA_DOM/include/dae/daeMetaChoice.h
Normal file
44
Extras/COLLADA_DOM/include/dae/daeMetaChoice.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2006 Sony Computer Entertainment Inc.
|
||||
*
|
||||
* Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at:
|
||||
* http://research.scea.com/scea_shared_source_license.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
|
||||
#ifndef __DAE_META_CHOICE_H__
|
||||
#define __DAE_META_CHOICE_H__
|
||||
|
||||
#include <dae/daeMetaCMPolicy.h>
|
||||
|
||||
/**
|
||||
* The daeMetaChoice class defines the behavior of an xs:choice content model in the COLLADA Schema.
|
||||
*/
|
||||
class daeMetaChoice : public daeMetaCMPolicy
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* @param container The daeMetaElement that this policy object belongs to.
|
||||
* @param parent The daeMetaCMPolicy parent of this policy object.
|
||||
* @param odinal The ordinal value offset of this specific policy object. Used for maintaining the
|
||||
* correct order of child elements.
|
||||
* @param minO The minimum number of times this CMPolicy object must appear. This value comes from the COLLADA schema.
|
||||
* @param maxO The maximum number of times this CMPolicy object may appear. This value comes from the COLLADA schema.
|
||||
*/
|
||||
daeMetaChoice( daeMetaElement *container, daeMetaCMPolicy *parent = NULL, daeUInt ordinal = 0, daeInt minO = 1, daeInt maxO = 1 );
|
||||
~daeMetaChoice();
|
||||
|
||||
daeElement *placeElement( daeElement *parent, daeElement *child, daeUInt &ordinal, daeInt offset = 0, daeElement* before = NULL, daeElement *after = NULL );
|
||||
daeBool removeElement(daeElement* parent, daeElement* child);
|
||||
daeMetaElement *findChild( daeString elementName );
|
||||
void getChildren( daeElement* parent, daeElementRefArray &array );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
#include <dae/daeElement.h>
|
||||
#include <dae/daeMetaAttribute.h>
|
||||
|
||||
class daeMetaCMPolicy;
|
||||
class daeMetaElementArrayAttribute;
|
||||
|
||||
typedef daeElementRef (*daeElementConstructFunctionPtr)(daeInt bytes);
|
||||
class daeMetaElement;
|
||||
typedef daeSmartRef<daeMetaElement> daeMetaElementRef;
|
||||
typedef daeTArray<daeMetaElementRef> daeMetaElementRefArray;
|
||||
|
||||
/**
|
||||
* Each instance of the @c daeMetaElement class describes a C++ COLLADA dom
|
||||
@@ -45,43 +45,33 @@ typedef daeTArray<daeMetaElementRef> daeMetaElementRefArray;
|
||||
class daeMetaElement : public daeElement
|
||||
{
|
||||
protected:
|
||||
daeStringRef _name;
|
||||
daeStringRef _name;
|
||||
|
||||
daeElementConstructFunctionPtr _createFunc;
|
||||
daeInt _minOccurs;
|
||||
daeInt _maxOccurs;
|
||||
daeStringRef _ref;
|
||||
daeBool _isSequence;
|
||||
daeBool _isChoice;
|
||||
daeBool _needsResolve;
|
||||
daeInt _elementSize;
|
||||
daeElementConstructFunctionPtr _createFunc;
|
||||
daeBool _needsResolve;
|
||||
daeInt _elementSize;
|
||||
|
||||
daeMetaElementAttributeArray _metaElements;
|
||||
daeMetaAttributeRefArray _metaAttributes;
|
||||
daeMetaAttributeRef _metaValue;
|
||||
daeMetaElementArrayAttribute* _metaContents;
|
||||
daeMetaArrayAttribute* _metaContentsOrder;
|
||||
|
||||
daeMetaElement * _metaIntegration;
|
||||
daeMetaAttributeRef _metaID;
|
||||
|
||||
daeMetaElement* _parent;
|
||||
|
||||
daeMetaElement** _staticPointerAddress;
|
||||
|
||||
daeMetaAttributePtrArray _resolvers;
|
||||
|
||||
daeBool _isTrackableForQueries;
|
||||
daeBool _usesStringContents;
|
||||
|
||||
daeBool _isTransparent;
|
||||
daeBool _isAbstract;
|
||||
daeBool _allowsAny;
|
||||
daeBool _isTransparent;
|
||||
daeBool _isAbstract;
|
||||
daeBool _allowsAny;
|
||||
daeBool _innerClass;
|
||||
|
||||
static daeMetaElementRefArray _metas;
|
||||
static daeTArray<daeSmartRef<daeMetaElement> > _metas;
|
||||
|
||||
daeStringArray _otherChildren;
|
||||
daeStringArray _otherChildrenTypes;
|
||||
daeTArray<daeMetaElementAttribute*> _otherChildrenContainer;
|
||||
|
||||
daeMetaCMPolicy * _contentModel;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -95,31 +85,17 @@ public:
|
||||
~daeMetaElement();
|
||||
|
||||
public: // public accessors
|
||||
|
||||
/**
|
||||
* Gets the number of possible children of elements of this type that don't actually
|
||||
* belong to this type.
|
||||
* @return Returns the number of other possible children.
|
||||
* Determines if elements of this type is an inner class.
|
||||
* @return Returns true if this element type is an inner class.
|
||||
*/
|
||||
size_t getPossibleChildrenCount() { return _otherChildren.getCount(); }
|
||||
daeBool getIsInnerClass() { return _innerClass; }
|
||||
/**
|
||||
* Gets the name of the possible child specified.
|
||||
* @param index Index into the _otherChildren array.
|
||||
* @return Returns the name of the possible child specified.
|
||||
* Sets if elements of this type are inner classes.
|
||||
* @param abstract True if this type is an inner class.
|
||||
*/
|
||||
daeString getPossibleChildName(daeInt index) { return _otherChildren.get(index); }
|
||||
/**
|
||||
* Gets the containing element for the possible child specified.
|
||||
* @param index Index into the _otherChildrenContainer array.
|
||||
* @return Returns the containing element for the possible child specified.
|
||||
*/
|
||||
daeMetaElementAttribute* getPossibleChildContainer(daeInt index) { return _otherChildrenContainer.get(index); }
|
||||
/**
|
||||
* Gets the type of the possible child specified.
|
||||
* @param index Index into the _otherChildren array.
|
||||
* @return Returns a string of the type of the possible child specified.
|
||||
*/
|
||||
daeString getPossibleChildType(daeInt index) { return _otherChildrenTypes.get(index); }
|
||||
|
||||
void setIsInnerClass( daeBool ic ) { _innerClass = ic; }
|
||||
/**
|
||||
* Determines if elements of this type can be placed in the object model.
|
||||
* @return Returns true if this element type is abstract, false otherwise.
|
||||
@@ -209,25 +185,6 @@ public: // public accessors
|
||||
*/
|
||||
daeMetaAttribute* getIDAttribute() { return _metaID; }
|
||||
|
||||
/**
|
||||
* Gets the @c daeMetaElement associated with a child element of a given
|
||||
* element type.
|
||||
* @param elementName Name of the element to find as a child of @c this.
|
||||
* @return Returns the @c daeMetaElement describing the potential child element, or
|
||||
* NULL if no such child type exists in the context of this element.
|
||||
*/
|
||||
daeMetaElement* findChild(daeString elementName);
|
||||
|
||||
/**
|
||||
* Gets the container of this element type as defined by the COLLADA's XML
|
||||
* schema. This parent type controls where this element
|
||||
* can be directly inlined inside of another element.
|
||||
* Although an element can be referred to in multiple places, it is only
|
||||
* included in one; thus a single parent.
|
||||
* @return Returns the parent @c daeMetaElement.
|
||||
*/
|
||||
daeMetaElement* getParent() { return _parent; }
|
||||
|
||||
/**
|
||||
* Gets the name of this element type.
|
||||
* @return Returns the name of this element type.
|
||||
@@ -240,14 +197,6 @@ public: // public accessors
|
||||
*/
|
||||
void setName(daeString s) { _name = s; }
|
||||
|
||||
/**
|
||||
* Gets the array of element attributes associated with this element type.
|
||||
* @return Returns the array of potential child elements in the XML COLLADA
|
||||
* hierarchy.
|
||||
*/
|
||||
daeMetaElementAttributeArray& getMetaElements() {
|
||||
return _metaElements; }
|
||||
|
||||
/**
|
||||
* Gets the array of attributes that represent URI fields that need
|
||||
* to be "resolved" after the database is completely read in.
|
||||
@@ -266,14 +215,6 @@ public: // public accessors
|
||||
daeMetaAttributeRefArray& getMetaAttributes() {
|
||||
return _metaAttributes; }
|
||||
|
||||
/**
|
||||
* Gets the array of element attributes associated with this element type.
|
||||
* @returns Returns the array of potential child elements in the XML COLLADA
|
||||
* hierarchy.
|
||||
*/
|
||||
daeMetaElementAttributeArray& getMetaElementArray() {
|
||||
return _metaElements; }
|
||||
|
||||
/**
|
||||
* Gets the attribute which has a name as provided by the <tt><i>s</i></tt> parameter.
|
||||
* @param s String containing the desired attribute's name.
|
||||
@@ -297,13 +238,19 @@ public: // public accessors
|
||||
|
||||
public:
|
||||
/**
|
||||
* Resisters with the reflective object system that the dom class described by this @c daeMetaElement
|
||||
* Registers with the reflective object system that the dom class described by this @c daeMetaElement
|
||||
* contains a <tt><i>_contents</i></tt> array. This method is @em only for @c daeMetaElement contstuction, and
|
||||
* should only be called by the system as it sets up the Reflective Object System.
|
||||
* @param offset Byte offset for the contents field in the C++
|
||||
* element class.
|
||||
* @param offset Byte offset for the contents field in the C++ element class.
|
||||
*/
|
||||
void addContents(daeInt offset);
|
||||
/**
|
||||
* Registers with the reflective object system the array that stores the _contents ordering. This method is @em
|
||||
* only for @c daeMetaElement contstuction, and should only be called by the system as it sets up the Reflective
|
||||
* Object System.
|
||||
* @param offset Byte offset for the contents order array in the C++ element class.
|
||||
*/
|
||||
void addContentsOrder( daeInt offset );
|
||||
|
||||
/**
|
||||
* Gets the attribute associated with the contents meta information.
|
||||
@@ -312,32 +259,6 @@ public:
|
||||
*/
|
||||
daeMetaElementArrayAttribute* getContents() { return _metaContents; }
|
||||
|
||||
/**
|
||||
* Appends another element type to be a potential child
|
||||
* element of this element type.
|
||||
* @param metaElement @c daeMetaElement of the potential child element.
|
||||
* @param offset Byte offset where the corresponding C++ field lives
|
||||
* in each c++ class instance for this element type.
|
||||
* @param name The name for this attribute if the type is complex, if none is
|
||||
* specified, the name of the @c daeMetaElement will be used.
|
||||
*/
|
||||
void appendElement(daeMetaElement* metaElement, daeInt offset, daeString name=NULL);
|
||||
|
||||
/**
|
||||
* Appends the potential child element
|
||||
* as a list of potential child elements rather than as a singleton.
|
||||
* @param metaElement @c daeMetaElement of the potential child element.
|
||||
* @param offset Byte offset where the corresponding C++ field lives
|
||||
* in each C++ class instance for this element type. In this case the
|
||||
* C++ field will be an array of elements rather than merely a pointer to
|
||||
* one.
|
||||
* @param name The name for this attribute if the type is complex, if none is
|
||||
* specified, the name of the metaElement will be used.
|
||||
* @note This function is the same as @c appendElement(), except that it appends the potential child element
|
||||
* as a list of potential child elements rather than as a singleton.
|
||||
*/
|
||||
void appendArrayElement(daeMetaElement* metaElement, daeInt offset, daeString name=NULL);
|
||||
|
||||
/**
|
||||
* Appends a @c daeMetaAttribute that represents a field corresponding to an
|
||||
* XML attribute to the C++ version of this element type.
|
||||
@@ -346,34 +267,6 @@ public:
|
||||
*/
|
||||
void appendAttribute(daeMetaAttribute* attr);
|
||||
|
||||
/**
|
||||
* Appends a possible child and maps the name to the actual container.
|
||||
* @param name The name of the child element.
|
||||
* @param cont Pointer to the @c daeMetaElementAttribute which contains the element.
|
||||
* @param type The type name of the possible child.
|
||||
*/
|
||||
void appendPossibleChild( daeString name, daeMetaElementAttribute* cont, daeString type = NULL );
|
||||
|
||||
/**
|
||||
* Sets the address where the static pointer lives for this element type's
|
||||
* @c daeMetaElement. For instance, <tt> daeNode::_Meta </tt> will point to its
|
||||
* corresponding @c daeMetaElement.
|
||||
* If the @c daeMetaElement is deleted independently, this pointer is automatically set to NULL.
|
||||
* @param addr Address of the storage for the pointer to the @c daeMetaElement.
|
||||
*/
|
||||
void setStaticPointerAddress(daeMetaElement** addr) {
|
||||
_staticPointerAddress = addr; }
|
||||
|
||||
|
||||
/**
|
||||
* Gets the address where the static pointer lives for this element type's
|
||||
* @c daeMetaElement. For instance, <tt> daeNode::_Meta </tt> will point to its
|
||||
* corresponding @c daeMetaElement.
|
||||
* If the @c daeMetaElement is deleted independently, this pointer is automatically set to NULL.
|
||||
* @return Returns the address of the storage for the pointer to the @c daeMetaElement.
|
||||
*/
|
||||
daeMetaElement** getStaticPointerAddress() { return _staticPointerAddress;}
|
||||
|
||||
/**
|
||||
* Registers the function that can construct a C++ instance
|
||||
* of this class. Necessary for the factory system such that C++
|
||||
@@ -397,6 +290,7 @@ public:
|
||||
* including factory creation.
|
||||
*/
|
||||
void validate();
|
||||
|
||||
/**
|
||||
* Places a child element into the <tt><i>parent</i></tt> element where the
|
||||
* calling object is the @c daeMetaElement for the parent element.
|
||||
@@ -404,7 +298,50 @@ public:
|
||||
* @param child Child element to place in the parent.
|
||||
* @return Returns true if the operation was successful, false otherwise.
|
||||
*/
|
||||
daeBool place(daeElementRef parent, daeElementRef child);
|
||||
daeBool place(daeElement *parent, daeElement *child, daeUInt *ordinal = NULL);
|
||||
/**
|
||||
* Places a child element into the <tt><i>parent</i></tt> element at a specific location
|
||||
* where the calling object is the @c daeMetaElement for the parent element.
|
||||
* @param index The location in the contents array to insert.
|
||||
* @param parent Element to act as the container.
|
||||
* @param child Child element to place in the parent.
|
||||
* @return Returns true if the operation was successful, false otherwise.
|
||||
* @note This should only be called on elements that have a _contents array. Elements without
|
||||
* a _contents array will be placed normally.
|
||||
*/
|
||||
daeBool placeAt( daeInt index, daeElement *parent, daeElement *child );
|
||||
/**
|
||||
* Places a child element into the <tt><i>parent</i></tt> element at a specific location which is right
|
||||
* before the marker element.
|
||||
* @param marker The element location in the contents array to insert before.
|
||||
* @param parent Element to act as the container.
|
||||
* @param child Child element to place in the parent.
|
||||
* @return Returns true if the operation was successful, false otherwise.
|
||||
*/
|
||||
daeBool placeBefore( daeElement* marker, daeElement *parent, daeElement *child, daeUInt *ordinal = NULL );
|
||||
/**
|
||||
* Places a child element into the <tt><i>parent</i></tt> element at a specific location which is right
|
||||
* after the marker element.
|
||||
* @param marker The element location in the contents array to insert after.
|
||||
* @param parent Element to act as the container.
|
||||
* @param child Child element to place in the parent.
|
||||
* @return Returns true if the operation was successful, false otherwise.
|
||||
*/
|
||||
daeBool placeAfter( daeElement* marker, daeElement *parent, daeElement *child, daeUInt *ordinal = NULL );
|
||||
|
||||
/**
|
||||
* Removes a child element from its parent element.
|
||||
* @param parent Element That is the parent.
|
||||
* @param child Child element to remove.
|
||||
* @return Returns true if the operation was successful, false otherwise.
|
||||
*/
|
||||
daeBool remove( daeElement *parent, daeElement *child );
|
||||
/**
|
||||
* Gets all of the children from an element of this type.
|
||||
* @param parent The element that you want to get the children from.
|
||||
* @param array The return value. An elementref array to append this element's children to.
|
||||
*/
|
||||
void getChildren( daeElement* parent, daeElementRefArray &array );
|
||||
|
||||
/**
|
||||
* Invokes the factory element creation routine set by @c registerConstructor()
|
||||
@@ -425,35 +362,29 @@ public:
|
||||
daeElementRef create(daeString childElementTypeName);
|
||||
|
||||
/**
|
||||
* Gets the meta information for a given subelement
|
||||
* @param s Name of the child element type to look up.
|
||||
* @return Returns the meta information for a given subelement.
|
||||
* Gets the root of the content model policy tree.
|
||||
* @return Returns the root element of the tree of content model policy elements.
|
||||
*/
|
||||
daeMetaElement* getChildMetaElement(daeString s);
|
||||
|
||||
daeMetaCMPolicy *getCMRoot() { return _contentModel; }
|
||||
/**
|
||||
* Gets the meta information for a given subelement
|
||||
* @param s Name of the child element type to look up.
|
||||
* @return Returns the meta information for a given subelement.
|
||||
* Sets the root of the content model policy tree.
|
||||
* @param cm The root element of the tree of content model policy elements.
|
||||
*/
|
||||
daeMetaElementAttribute* getChildMetaElementAttribute(daeString s);
|
||||
void setCMRoot( daeMetaCMPolicy *cm ) { _contentModel = cm; }
|
||||
|
||||
public:
|
||||
/**
|
||||
* Unused
|
||||
*/
|
||||
static daeMetaElement* _Schema;
|
||||
public:
|
||||
/**
|
||||
* Empty no-op function.
|
||||
*/
|
||||
static void initializeSchemaMeta();
|
||||
|
||||
/**
|
||||
* Releases all of the meta information contained in @c daeMetaElements.
|
||||
*/
|
||||
static void releaseMetas();
|
||||
|
||||
static const daeTArray<daeSmartRef<daeMetaElement> > &getAllMetas() { return _metas; }
|
||||
};
|
||||
|
||||
typedef daeSmartRef<daeMetaElement> daeMetaElementRef;
|
||||
typedef daeTArray<daeMetaElementRef> daeMetaElementRefArray;
|
||||
|
||||
#endif //__DAE_META_ELEMENT_H__
|
||||
|
||||
|
||||
|
||||
189
Extras/COLLADA_DOM/include/dae/daeMetaElementAttribute.h
Normal file
189
Extras/COLLADA_DOM/include/dae/daeMetaElementAttribute.h
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Copyright 2006 Sony Computer Entertainment Inc.
|
||||
*
|
||||
* Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at:
|
||||
* http://research.scea.com/scea_shared_source_license.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
|
||||
#ifndef __DAE_META_ELEMENT_ATTRIBUTE_H__
|
||||
#define __DAE_META_ELEMENT_ATTRIBUTE_H__
|
||||
|
||||
#include <dae/daeTypes.h>
|
||||
#include <dae/daeMetaAttribute.h>
|
||||
#include <dae/daeMetaCMPolicy.h>
|
||||
|
||||
class daeMetaElement;
|
||||
class daeElement;
|
||||
class daeDocument;
|
||||
|
||||
/**
|
||||
* The @c daeMetaElementAttribute class represents a content model object that is an element.
|
||||
*/
|
||||
class daeMetaElementAttribute : public daeMetaAttribute, public daeMetaCMPolicy
|
||||
{
|
||||
public:
|
||||
/** The metaElement that describes the element type of this attribute */
|
||||
daeMetaElement* _elementType;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* @param container The daeMetaElement that this policy object belongs to.
|
||||
* @param parent The daeMetaCMPolicy parent of this policy object.
|
||||
* @param odinal The ordinal value offset of this specific policy object. Used for maintaining the
|
||||
* correct order of child elements.
|
||||
* @param minO The minimum number of times this CMPolicy object must appear. This value comes from the COLLADA schema.
|
||||
* @param maxO The maximum number of times this CMPolicy object may appear. This value comes from the COLLADA schema.
|
||||
*/
|
||||
daeMetaElementAttribute( daeMetaElement *container, daeMetaCMPolicy *parent = NULL, daeUInt ordinal = 0, daeInt minO = 1, daeInt maxO = 1);
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~daeMetaElementAttribute();
|
||||
|
||||
public:
|
||||
|
||||
virtual daeElement *placeElement(daeElement* parent, daeElement* child, daeUInt &ordinal, daeInt offset = 0, daeElement* before = NULL, daeElement *after = NULL);
|
||||
virtual daeBool removeElement(daeElement* parent, daeElement* child);
|
||||
|
||||
daeMetaElement *findChild( daeString elementName );
|
||||
|
||||
virtual void getChildren( daeElement* parent, daeElementRefArray &array );
|
||||
|
||||
public:
|
||||
/**
|
||||
* Sets the element type for the element that this attribute points to.
|
||||
* @param elementType @c daeMetaElement representing the type.
|
||||
*/
|
||||
void setElementType(daeMetaElement *elementType) {
|
||||
_elementType = elementType; }
|
||||
|
||||
/**
|
||||
* Gets the element type for the element that this attribute points to.
|
||||
* @return Returns the @c daeMetaElement representing the type.
|
||||
*/
|
||||
daeMetaElement* getElementType() { return _elementType; }
|
||||
|
||||
/**
|
||||
* Sets the database document associated with this element.
|
||||
* @param parent The daeElement to set the document.
|
||||
* @param c The @c daeDocument to associate with this element.
|
||||
*/
|
||||
virtual void setDocument(daeElement *parent, daeDocument* c );
|
||||
inline void setCollection(daeElement *parent, daeDocument* c ) {
|
||||
setDocument( parent, c );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of elements associated with this attribute in instance <tt><i>e.</i></tt>
|
||||
* @param e Containing element to run the operation on.
|
||||
* @return Returns the number of elements associated with this attribute
|
||||
* in instance <tt><i>e.</i></tt>
|
||||
*/
|
||||
virtual daeInt getCount(daeElement* e);
|
||||
|
||||
/**
|
||||
* Gets an element from containing element <tt><i>e</i></tt> based on <tt><i>index.</i></tt>
|
||||
* @param e Containing element from which to get the element.
|
||||
* @param index Index of the element to retrieve if indeed
|
||||
* there is an array of elements rather than a singleton.
|
||||
* @return Returns the associated element out of parent element e, based on index, if necessary.
|
||||
*/
|
||||
virtual daeMemoryRef get(daeElement* e, daeInt index);
|
||||
|
||||
/**
|
||||
* Defines the override version of base method.
|
||||
* @param element Element on which to set this attribute.
|
||||
* @param s String containing the value to be converted via the
|
||||
* atomic type system.
|
||||
*/
|
||||
virtual void set(daeElement* element, daeString s);
|
||||
/**
|
||||
* Defines the override version of base method.
|
||||
* @param toElement Pointer to a @c daeElement to copy this attribute to.
|
||||
* @param fromElement Pointer to a @c daeElement to copy this attribute from.
|
||||
*/
|
||||
virtual void copy(daeElement* toElement, daeElement* fromElement);
|
||||
|
||||
/**
|
||||
* Gets if this attribute is an array attribute.
|
||||
* @return Returns true if this attribute is an array type.
|
||||
*/
|
||||
virtual daeBool isArrayAttribute() { return false; }
|
||||
};
|
||||
typedef daeSmartRef<daeMetaElementAttribute> daeMetaElementAttributeRef;
|
||||
typedef daeTArray<daeMetaElementAttributeRef> daeMetaElementAttributeArray;
|
||||
|
||||
|
||||
/**
|
||||
* The @c daeMetaElementArrayAttribute class is similar to daeMetaElementAttribute
|
||||
* except that this meta attribute describes an array of elements rather than a singleton.
|
||||
*/
|
||||
class daeMetaElementArrayAttribute : public daeMetaElementAttribute
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* @param container The daeMetaElement that this policy object belongs to.
|
||||
* @param parent The daeMetaCMPolicy parent of this policy object.
|
||||
* @param odinal The ordinal value offset of this specific policy object. Used for maintaining the
|
||||
* correct order of child elements.
|
||||
* @param minO The minimum number of times this CMPolicy object must appear. This value comes from the COLLADA schema.
|
||||
* @param maxO The maximum number of times this CMPolicy object may appear. This value comes from the COLLADA schema.
|
||||
*/
|
||||
daeMetaElementArrayAttribute(daeMetaElement *container, daeMetaCMPolicy *parent = NULL, daeUInt ordinal = 0, daeInt minO = 1, daeInt maxO = 1);
|
||||
~daeMetaElementArrayAttribute();
|
||||
public:
|
||||
virtual daeElement *placeElement(daeElement* parent, daeElement* child, daeUInt &ordinal, daeInt offset = 0, daeElement* before = NULL, daeElement *after = NULL);
|
||||
virtual daeBool removeElement(daeElement* parent, daeElement* child);
|
||||
|
||||
void getChildren( daeElement* parent, daeElementRefArray &array );
|
||||
|
||||
/**
|
||||
* Sets the database document associated with this element.
|
||||
* @param c The @c daeDocument to associate with this element.
|
||||
*/
|
||||
virtual void setDocument(daeElement *parent, daeDocument* c );
|
||||
inline void setCollection(daeElement *parent, daeDocument* c ) {
|
||||
setDocument( parent, c );
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the override version of this method from @c daeMetaElement.
|
||||
* @param e Containing element to run the operation on.
|
||||
* @return Returns the number of particles associated with this attribute
|
||||
* in instance <tt><i>e.</i></tt>
|
||||
*/
|
||||
virtual daeInt getCount(daeElement* e);
|
||||
/**
|
||||
* Defines the override version of this method from @c daeMetaElement.
|
||||
* @param e Containing element from which to get the element.
|
||||
* @param index Index of the particle to retrieve if indeed
|
||||
* there is an array of elements rather than a singleton.
|
||||
* @return Returns the associated particle out of parent element e, based on index, if necessary.
|
||||
*/
|
||||
virtual daeMemoryRef get(daeElement* e, daeInt index);
|
||||
/**
|
||||
* Defines the override version of this method from @c daeMetaElement.
|
||||
* @param toElement Pointer to a @c daeElement to copy this attribute to.
|
||||
* @param fromElement Pointer to a @c daeElement to copy this attribute from.
|
||||
*/
|
||||
virtual void copy(daeElement* toElement, daeElement* fromElement);
|
||||
|
||||
/**
|
||||
* Gets if this attribute is an array attribute.
|
||||
* @return Returns true if this attribute is an array type.
|
||||
*/
|
||||
virtual daeBool isArrayAttribute() { return true; }
|
||||
};
|
||||
typedef daeSmartRef<daeMetaElementArrayAttribute> daeMetaElementArrayAttributeRef;
|
||||
typedef daeTArray<daeMetaElementArrayAttributeRef> daeMetaElementArrayAttributeArray;
|
||||
|
||||
#endif
|
||||
|
||||
55
Extras/COLLADA_DOM/include/dae/daeMetaGroup.h
Normal file
55
Extras/COLLADA_DOM/include/dae/daeMetaGroup.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2006 Sony Computer Entertainment Inc.
|
||||
*
|
||||
* Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at:
|
||||
* http://research.scea.com/scea_shared_source_license.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
|
||||
#ifndef __DAE_META_GROUP_H__
|
||||
#define __DAE_META_GROUP_H__
|
||||
|
||||
#include <dae/daeMetaCMPolicy.h>
|
||||
|
||||
class daeMetaElementAttribute;
|
||||
|
||||
/**
|
||||
* The daeMetaGroup class defines the behavior of an xs:group ref content model from the COLLADA Schema.
|
||||
*/
|
||||
class daeMetaGroup : public daeMetaCMPolicy
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* @param econ The daeMetaElementAttribute that represents the group element in the parent.
|
||||
* @param container The daeMetaElement that this policy object belongs to.
|
||||
* @param parent The daeMetaCMPolicy parent of this policy object.
|
||||
* @param odinal The ordinal value offset of this specific policy object. Used for maintaining the
|
||||
* correct order of child elements.
|
||||
* @param minO The minimum number of times this CMPolicy object must appear. This value comes from the COLLADA schema.
|
||||
* @param maxO The maximum number of times this CMPolicy object may appear. This value comes from the COLLADA schema.
|
||||
*/
|
||||
daeMetaGroup( daeMetaElementAttribute *econ, daeMetaElement *container, daeMetaCMPolicy *parent = NULL,
|
||||
daeUInt ordinal = 0, daeInt minO = 1, daeInt maxO = 1 );
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~daeMetaGroup();
|
||||
|
||||
daeElement *placeElement( daeElement *parent, daeElement *child, daeUInt &ordinal, daeInt offset = 0, daeElement* before = NULL, daeElement *after = NULL );
|
||||
daeBool removeElement(daeElement* parent, daeElement* child);
|
||||
daeMetaElement *findChild( daeString elementName );
|
||||
void getChildren( daeElement* parent, daeElementRefArray &array );
|
||||
|
||||
protected:
|
||||
daeMetaElementAttribute *_elementContainer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
51
Extras/COLLADA_DOM/include/dae/daeMetaSequence.h
Normal file
51
Extras/COLLADA_DOM/include/dae/daeMetaSequence.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2006 Sony Computer Entertainment Inc.
|
||||
*
|
||||
* Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at:
|
||||
* http://research.scea.com/scea_shared_source_license.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
|
||||
#ifndef __DAE_META_SEQUENCE_H__
|
||||
#define __DAE_META_SEQUENCE_H__
|
||||
|
||||
#include <dae/daeMetaCMPolicy.h>
|
||||
|
||||
/**
|
||||
* The daeMetaSequence class defines the behavior of an xs:sequence content model in the COLLADA Schema.
|
||||
*/
|
||||
class daeMetaSequence : public daeMetaCMPolicy
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* @param container The daeMetaElement that this policy object belongs to.
|
||||
* @param parent The daeMetaCMPolicy parent of this policy object.
|
||||
* @param odinal The ordinal value offset of this specific policy object. Used for maintaining the
|
||||
* correct order of child elements.
|
||||
* @param minO The minimum number of times this CMPolicy object must appear. This value comes from the COLLADA schema.
|
||||
* @param maxO The maximum number of times this CMPolicy object may appear. This value comes from the COLLADA schema.
|
||||
*/
|
||||
daeMetaSequence( daeMetaElement *container, daeMetaCMPolicy *parent = NULL, daeUInt ordinal = 0, daeInt minO = 1, daeInt maxO = 1 );
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~daeMetaSequence();
|
||||
|
||||
daeElement *placeElement( daeElement *parent, daeElement *child, daeUInt &ordinal, daeInt offset = 0, daeElement* before = NULL, daeElement *after = NULL );
|
||||
daeBool removeElement(daeElement* parent, daeElement* child);
|
||||
daeMetaElement *findChild( daeString elementName );
|
||||
void getChildren( daeElement* parent, daeElementRefArray &array );
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
149
Extras/COLLADA_DOM/include/dae/daeSIDResolver.h
Normal file
149
Extras/COLLADA_DOM/include/dae/daeSIDResolver.h
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright 2006 Sony Computer Entertainment Inc.
|
||||
*
|
||||
* Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at:
|
||||
* http://research.scea.com/scea_shared_source_license.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
|
||||
#ifndef __DAE_SIDRESOLVER_H__
|
||||
#define __DAE_SIDRESOLVER_H__
|
||||
|
||||
#include <dae/daeTypes.h>
|
||||
#include <dae/daeElement.h>
|
||||
|
||||
/**
|
||||
* The daeSIDResolver class is designed to resolve sid references within a COLLADA document.
|
||||
* The rules for sid resolution are set forth by the Addressing Syntax section in Chapter 3 of the
|
||||
* COLLADA specification which can be found at https://www.khronos.org/collada .
|
||||
* This resolver always attempts to resolve to the daeElement which is referenced. If the element contains
|
||||
* a daeDoubleArray (domFloatArray) value, the resolver will set the pointer to that array. The
|
||||
* resolver will also do this if the sid target points to a <source> element which has a <float_array> as
|
||||
* a child. If the sid target specifies a value, i.e. blah.X or blah(6), the resolver will attempt to
|
||||
* get a pointer to that specific value. The resolver only attempts to resolve to that level for values which
|
||||
* are defined in the COMMON profile glossary of the COLLADA specification, or values reference with the (#)
|
||||
* syntax. You can check the return value from getState() to see which level of resolution is possible.
|
||||
*/
|
||||
class daeSIDResolver
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* An enum describing the status of the SID resolution process.
|
||||
*/
|
||||
enum ResolveState{
|
||||
/** No target specified */
|
||||
target_empty,
|
||||
/** target specified but not resolved */
|
||||
target_loaded,
|
||||
/** Resolution failed because target was not found */
|
||||
sid_failed_not_found,
|
||||
/** Resolution successful to the Element level */
|
||||
sid_success_element,
|
||||
/** Resolution successful to the Double Array level */
|
||||
sid_success_array,
|
||||
/** Resolution successful to the Double level */
|
||||
sid_success_double
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param container The element which contains the target that you want to resolve.
|
||||
* @param target The target string which needs to be resolved.
|
||||
* @param platform The platform name of the technique to use. A NULL value indicates the common platform.
|
||||
*/
|
||||
daeSIDResolver( daeElement *container, daeString target, daeString platform = NULL );
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~daeSIDResolver();
|
||||
|
||||
/**
|
||||
* Gets the target string.
|
||||
* @return Returns the target string of this SID resolver.
|
||||
*/
|
||||
daeString getTarget() const { return target; }
|
||||
/**
|
||||
* Sets the target string.
|
||||
* @param t The new target string for this resolver.
|
||||
*/
|
||||
void setTarget( daeString t );
|
||||
|
||||
/**
|
||||
* Gets the name of the profile to use when resolving.
|
||||
* @return Returns the name of the profile or NULL for the common profile.
|
||||
*/
|
||||
daeString getProfile() const { return profile; }
|
||||
/**
|
||||
* Sets the profile to use when resolving.
|
||||
* @param p The profile name of the technique to use. A NULL value indicates the common profile.
|
||||
*/
|
||||
void setProfile( daeString p );
|
||||
|
||||
/**
|
||||
* Gets a pointer to the @c daeElement that contains the target to resolve.
|
||||
* @return Returns the pointer to the containing daeElmement.
|
||||
*/
|
||||
daeElement* getContainer() const { return container; }
|
||||
/**
|
||||
* Sets the pointer to the @c daeElement that contains the target to resolve.
|
||||
* @param element Pointer to the containing @c daeElmement.
|
||||
*/
|
||||
void setContainer(daeElement* element);
|
||||
|
||||
/**
|
||||
* Gets the resolution state.
|
||||
* @return Returns the current state of SID resolution.
|
||||
*/
|
||||
ResolveState getState() const { return state; }
|
||||
|
||||
/**
|
||||
* Gets the element that this SID resolves to.
|
||||
* @return Returns the element that the URI resolves to.
|
||||
*/
|
||||
daeElementRef getElement();
|
||||
|
||||
/**
|
||||
* Gets the value array of the element that the SID resolves to.
|
||||
* @return Returns a pointer to the value array that the SID resolves to
|
||||
* @note The daeSIDResolver can only resolve to this level for daeDoubleArray values.
|
||||
*/
|
||||
daeDoubleArray *getDoubleArray();
|
||||
|
||||
/**
|
||||
* Gets a pointer to the particle this target resolved to.
|
||||
* @return Returns a pointer to a double value which is the fully resolved target.
|
||||
* @note The daeSIDResolver can only resolve to this level for domDouble values and only if the
|
||||
* final symbolic name is from the COMMON profile or a cardinal value is specified.
|
||||
* @note The daeSIDResolver assumes the value is a 4x4 matrix if there are 2 cardinal values specified.
|
||||
*/
|
||||
daeDouble *getDouble();
|
||||
|
||||
private:
|
||||
|
||||
void resolve();
|
||||
/**
|
||||
* Recursive function which will find an element with specified sid in the subtree of el.
|
||||
*/
|
||||
daeElement *findSID( daeElement *el, daeString sid );
|
||||
|
||||
private:
|
||||
|
||||
daeString target;
|
||||
daeString profile;
|
||||
daeElement *container;
|
||||
ResolveState state;
|
||||
|
||||
daeElement *element;
|
||||
daeDoubleArray *doubleArray;
|
||||
daeDouble *doublePtr;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -57,6 +57,8 @@ private: // MEMBERS
|
||||
daeStringArray _stringBuffersList;
|
||||
|
||||
daeString allocateBuffer();
|
||||
|
||||
daeString _empty;
|
||||
};
|
||||
|
||||
#endif //__DAE_STRING_TABLE_H__
|
||||
|
||||
@@ -42,6 +42,10 @@ protected: // Attribute
|
||||
* Used to preserve order in elements that do not specify strict sequencing of sub-elements.
|
||||
*/
|
||||
daeElementRefArray _contents;
|
||||
/**
|
||||
* Used to preserve order in elements that have a complex content model.
|
||||
*/
|
||||
daeUIntArray _contentsOrder;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -81,7 +85,7 @@ public:
|
||||
* Sets the _value of this element.
|
||||
* @param val The new value for this element.
|
||||
*/
|
||||
void setValue( daeString val ) { _value = val; }
|
||||
void setValue( daeString val ) { *(daeStringRef*)&_value = val; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user