/usr/include/opencollada/COLLADAStreamWriter/COLLADASWSource.h is in opencollada-dev 0.1.0~20160714.0ec5063+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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | /*
Copyright (c) 2008-2009 NetAllied Systems GmbH
This file is part of COLLADAStreamWriter.
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 __COLLADASTREAMWRITER_SOURCE_H__
#define __COLLADASTREAMWRITER_SOURCE_H__
#include "COLLADASWPrerequisites.h"
#include "COLLADASWElementWriter.h"
#include "COLLADASWConstants.h"
#include <string>
#include <vector>
namespace COLLADASW
{
/** A class to add a source, including the array and an accessor.
It is the base class for the Source template class.*/
class SourceBase : public ElementWriter
{
public:
/** A list that contains the names of all the parameter in the accessor*/
typedef std::vector<String> ParameterNameList;
private:
TagCloser mSourceCloser;
/** The id of the source*/
String mNodeId;
/** The name of source node */
String mNodeName;
/** The id of the array*/
String mArrayId;
/** The value of the count attribute of the accessor*/
unsigned long mAccessorCount;
/** The value of the stride attribute of the accessor*/
unsigned long mAccessorStride;
/** The list with the parameters. */
ParameterNameList mParameterNameList;
public:
SourceBase ( StreamWriter* streamWriter )
: ElementWriter ( streamWriter )
, mAccessorCount (0)
, mAccessorStride (0)
{}
/** Returns a reference to the id of the source*/
const String& getId() const
{
return mNodeId;
}
/** Sets the id of the source*/
void setId ( const String& id )
{
mNodeId = id;
}
/** Returns a reference to the name of the source*/
const String& getNodeName() const
{
return mNodeName;
}
/** Sets the name of the source*/
void setNodeName ( const String& name )
{
mNodeName = name;
}
/** Returns a reference to the id of the array of the node*/
const String& getArrayId() const
{
return mArrayId;
}
/** Sets the id of the array of the node*/
void setArrayId ( const String& arrayId )
{
mArrayId = arrayId;
}
/** Returns the value of the count attribute of the accessor*/
unsigned long getAccessorCount() const
{
return mAccessorCount;
}
/** Sets the count attribute of the accessor*/
void setAccessorCount ( unsigned long accessorCount )
{
mAccessorCount = accessorCount;
}
/** Returns the value of the stride attribute of the accessor*/
unsigned long getAccessorStride() const
{
return mAccessorStride;
}
/** Sets the stride attribute of the accessor*/
void setAccessorStride ( unsigned long accessorStride )
{
mAccessorStride = accessorStride;
}
/** Returns a reference to the parameter list*/
ParameterNameList& getParameterNameList()
{
return mParameterNameList;
}
protected:
/** Prepares to fill the array. This member must be called exactly once
before add is called the first time.*/
void prepareBaseToAppendValues ( const String* arrayName );
/** This function must be called after the last value has been added to the array and before another
element has been opened*/
void finishBase ( const String* parameterTypeName, bool closeSourceElement=true );
/** Close the array element. */
void closeArray();
/** Close the source element. */
void closeSource();
/** Adds the base technique common to the source. */
void addBaseTechnique ( const String* parameterTypeName );
};
/** A class template to add a source, including an the array and an accessor*/
template < class Type, const String* arrayName, const String* parameterTypeName >
class Source : public SourceBase
{
private:
const String* mParameterTypeName;
public:
Source ( StreamWriter * streamWriter )
: SourceBase ( streamWriter )
, mParameterTypeName ( parameterTypeName )
{}
/** Prepares to fill the array. This member must be called exactly once
before add is called the first time.*/
inline void prepareToAppendValues()
{
prepareBaseToAppendValues ( arrayName );
}
/** Adds @a value to the array*/
void appendValues ( const double matrix[][4] )
{
mSW->appendValues ( matrix );
}
/** Adds @a value to the array*/
void appendValues ( const float matrix[][4] )
{
mSW->appendValues ( matrix );
}
/** Adds @a value to the array*/
void appendValues ( const std::vector<Type>& value )
{
mSW->appendValues ( value );
}
/** Adds @a value to the array*/
void appendValues ( const Type value )
{
mSW->appendValues ( value );
}
/** Adds @a value1 and @a value2 to the array*/
void appendValues ( const Type value1, const Type value2 )
{
mSW->appendValues ( value1, value2 );
}
/** Adds @a value1, @a value2 and @a value3 to the array*/
void appendValues ( const Type value1, const Type value2, const Type value3 )
{
mSW->appendValues ( value1, value2, value3 );
}
/** Adds @a value1, @a value2, @a value3 and @a value4 to the array*/
void appendValues ( const Type value1, const Type value2, const Type value3, const Type value4 )
{
mSW->appendValues ( value1, value2, value3, value4 );
}
/**
* This function must be called after the last value has been added to the array
* and before another element has been opened.
* @param closeSourceElement false, if we want to add some extra tags and close the element later.
*/
void finish ( bool closeSourceElement=true )
{
finishBase ( mParameterTypeName, closeSourceElement );
}
/** Close the source element. */
void closeSourceElement()
{
closeSource();
}
/** Sets the parameter type name */
void setParameterTypeName ( const String* paramTypeName )
{
mParameterTypeName = paramTypeName;
}
};
/** Param type independent source with double values. */
typedef Source < double, &CSWC::CSW_ELEMENT_FLOAT_ARRAY, &CSWC::EMPTY_STRING > TypeIndependentSource;
/** Param type independent source with float values. */
typedef Source < float, &CSWC::CSW_ELEMENT_FLOAT_ARRAY, &CSWC::EMPTY_STRING > TypeIndependentSourceF;
/** Param type "FLOAT" source with double values. */
typedef Source < double, &CSWC::CSW_ELEMENT_FLOAT_ARRAY, &CSWC::CSW_VALUE_TYPE_FLOAT > FloatSource;
/** Param type "FLOAT" source with float values. */
typedef Source < float, &CSWC::CSW_ELEMENT_FLOAT_ARRAY, &CSWC::CSW_VALUE_TYPE_FLOAT > FloatSourceF;
/** Param type "FLOAT4x4" source with double values. */
typedef Source < double, &CSWC::CSW_ELEMENT_FLOAT_ARRAY, &CSWC::CSW_VALUE_TYPE_FLOAT4x4 > Float4x4Source;
/** Param type "FLOAT4x4" source with double values. */
typedef Source < float, &CSWC::CSW_ELEMENT_FLOAT_ARRAY, &CSWC::CSW_VALUE_TYPE_FLOAT4x4 > Float4x4SourceF;
/** Param type "NAME" source with String values. */
typedef Source < String, &CSWC::CSW_ELEMENT_NAME_ARRAY, &CSWC::CSW_VALUE_TYPE_NAME > NameSource;
/** Param type "NAME" source with String values. */
typedef Source < String, &CSWC::CSW_ELEMENT_IDREF_ARRAY, &CSWC::CSW_VALUE_TYPE_IDREF > IdRefSource;
} //namespace COLLADASW
#endif //__COLLADASTREAMWRITER_SOURCE_H_
|