/usr/include/opencollada/COLLADASaxFrameworkLoader/COLLADASaxFWLSidTreeNode.h is in opencollada-dev 0.1.0~20140703.ddf8f47+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | /*
Copyright (c) 2008-2009 NetAllied Systems GmbH
This file is part of COLLADASaxFrameworkLoader.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/
#ifndef __COLLADASAXFWL_SIDTREENODE_H__
#define __COLLADASAXFWL_SIDTREENODE_H__
#include "COLLADASaxFWLPrerequisites.h"
#include "COLLADAFWAnimatable.h"
#include "COLLADAFWObject.h"
#include <map>
#include <vector>
namespace COLLADASaxFWL
{
class IntermediateTargetable;
/** The SidTreeNode is used to build the Sid tree. The Sid tree represents the parent child relation between elements
that can have sids. This tree is used to resolve sids.
TODO the sid node tree currently does not support multiple occurrences of an sid on the same hierarchy in different
techniques.
*/
class SidTreeNode
{
public:
struct SidIdentifier
{
SidIdentifier( const String& _sid, size_t _hierarchyLevel)
: sid(_sid), hierarchyLevel(_hierarchyLevel){}
const String& sid;
/** Defines how deep in the hierarchy the node is placed. For the determination of the hierarchy level
only elements with an sid are considered.*/
size_t hierarchyLevel;
bool operator<(const SidIdentifier& rhs)const;
};
typedef std::map< SidIdentifier, SidTreeNode*> SidIdentifierSidTreeNodeMap;
typedef std::vector< SidTreeNode*> SidTreeNodeList;
enum TargetTypeClass
{
TARGETTYPECLASS_UNKNOWN,
TARGETTYPECLASS_OBJECT,
TARGETTYPECLASS_ANIMATABLE,
TARGETTYPECLASS_INTERMEDIATETARGETABLE
};
private:
union Target
{
COLLADAFW::Animatable * animatable;
COLLADAFW::Object * object;
IntermediateTargetable * intermediateTargetable;
};
private:
/** The parent node.*/
SidTreeNode *mParent;
/** Maps sids to the children. One sid can appear more than once, since COLLADA allows sids to appear more than once
in different technique elements of the same parent.*/
SidIdentifierSidTreeNodeMap mChildren;
/** List of all direct children. Is used to delete all of them.*/
SidTreeNodeList mDirectChildren;
/** The target the sid points to. Different types of targets are supported. @see mTargetType*/
Target mTarget;
/** The type of the target.*/
TargetTypeClass mTargetType;
/** The sid of the node.*/
String mSid;
public:
/** Constructor. */
SidTreeNode( const String& sid, SidTreeNode *mParent);
/** Destructor. */
virtual ~SidTreeNode();
/** Returns the parent.*/
SidTreeNode * getParent() { return mParent; }
/** Returns the type of the target.*/
TargetTypeClass getTargetType() const { return mTargetType; }
/** Sets the type of the target.*/
void setTargetType(TargetTypeClass targetType) { mTargetType = targetType; }
/** Returns the target, if it is an object, null otherwise.*/
COLLADAFW::Object* getObjectTarget() const { return (mTargetType==TARGETTYPECLASS_OBJECT) ? mTarget.object : 0; }
/** Returns the target, if it is an animatable, null otherwise.*/
COLLADAFW::Animatable* getAnimatableTarget() const { return (mTargetType==TARGETTYPECLASS_ANIMATABLE) ? mTarget.animatable: 0; }
/** Returns the target, if it is a IntermediateTargetable, null otherwise.*/
IntermediateTargetable* getIntermediateTargetableTarget() const { return (mTargetType==TARGETTYPECLASS_INTERMEDIATETARGETABLE) ? mTarget.intermediateTargetable : 0; }
/** Sets the target to @a target and the target type to @a TARGETTYPECLASS_OBJECT.*/
void setTarget(COLLADAFW::Object* target) { mTarget.object = target; mTargetType = TARGETTYPECLASS_OBJECT; }
/** Sets the target to @a target and the target type to @a TARGETTYPECLASS_ANIMATABLE.*/
void setTarget(COLLADAFW::Animatable* target) { mTarget.animatable = target; mTargetType = TARGETTYPECLASS_ANIMATABLE; }
/** Sets the target to @a target and the target type to @a TARGETTYPECLASS_ANIMATABLE.*/
void setTarget(IntermediateTargetable* target) { mTarget.intermediateTargetable= target; mTargetType = TARGETTYPECLASS_INTERMEDIATETARGETABLE; }
/** Creates a new child with sid @a sid and adds it to the list of children. */
SidTreeNode* createAndAddChild( const String& sid);
/** Returns the sid.*/
const String& getSid() const { return mSid; };
/** Searches for a child with @a sid in the entire sub hierarchy. If there exist more then one child with @a sid,
the one with the lowest hierarchy level is returned. If no child could be found, null is returned.*/
SidTreeNode* findChildBySid( const String& sid);
private:
/** Disable default copy ctor. */
SidTreeNode( const SidTreeNode& pre );
/** Disable default assignment operator. */
const SidTreeNode& operator= ( const SidTreeNode& pre );
/** Adds @a sidTreeNode to the children map of all the parent nodes. For each level in the hierarchy */
void addChildToParents( SidTreeNode *sidTreeNode, const SidIdentifier& sidIdentifier);
};
} // namespace COLLADASAXFWL
#endif // __COLLADASAXFWL_SIDTREENODE_H__
|