2
Copyright (c) 2008-2009 NetAllied Systems GmbH
4
This file is part of COLLADAStreamWriter.
6
Licensed under the MIT Open Source License,
7
for details please see LICENSE file or the website
8
http://www.opensource.org/licenses/mit-license.php
11
#ifndef __COLLADASTREAMWRITER_PARAM_H__
12
#define __COLLADASTREAMWRITER_PARAM_H__
14
#include "COLLADASWPrerequisites.h"
15
#include "COLLADASWElementWriter.h"
16
#include "COLLADASWAnnotation.h"
17
#include "COLLADASWValueType.h"
18
#include "COLLADASWSampler.h"
19
#include "COLLADASWConstants.h"
24
/** A class to add a param to the stream.*/
25
class ParamBase : public ElementWriter
30
/** Used to close the current param. */
31
TagCloser mParamCloser;
33
/** The parameter's name. */
36
/** Flag, if the value element is opened. */
37
bool mValueElementIsOpen;
39
/** The type of the current parameter. */
40
ValueType::ColladaType mParamType;
45
@param streamWriter The stream the asset should be written to.*/
47
StreamWriter* streamWriter,
48
const String* paramName=&CSWC::CSW_ELEMENT_PARAM,
49
const ValueType::ColladaType& paramType=ValueType::VALUE_TYPE_UNSPECIFIED );
52
virtual ~ParamBase() {}
54
/** Set the current param type. */
55
void setParamType ( const ValueType::ColladaType& paramType );
57
/** Set the current param name. */
58
void setParamName ( const String& paramName );
60
/** Returns the name of the current parameter. */
61
const String& getParamName () const { return mParamName; }
63
/** Opens the current param element. */
64
virtual void openParam ( const String& refe="" );
66
/** Set a param attribute */
67
void appendAttribute ( const String& name, const String& val );
69
/** Writes the semantic of the parameter. */
70
void addSemantic ( const String &semantic );
72
/** Adds a annotation to the param. */
76
const ValueType::ColladaType &valueType,
79
COLLADASW::Annotation annotation ( mSW );
80
annotation.openAnnotation ( name );
81
annotation.openValuesElement ( valueType );
82
annotation.appendValues ( val );
83
annotation.closeValuesElement ();
84
annotation.closeAnnotation ();
87
/** Adds a annotation to the param. */
91
const ValueType::ColladaType &valueType,
95
COLLADASW::Annotation annotation ( mSW );
96
annotation.openAnnotation ( name );
97
annotation.openValuesElement ( valueType );
98
annotation.appendValues ( val, nval );
99
annotation.closeValuesElement ();
100
annotation.closeAnnotation ();
103
/** Adds a annotation to the param. */
104
void addAnnotations ( std::vector<Annotation>& annotations )
106
for ( size_t i=0; i<annotations.size (); ++i )
108
COLLADASW::Annotation& annotation = annotations [i];
113
/** Opens the param's value element of the given type. */
114
void openValuesElement ();
116
/** Close the param's value element of the given type. */
117
void closeValuesElement ();
119
/** Adds @a value to the array*/
120
template <class Type>
121
void appendValues ( const std::vector<Type>& value )
123
openValuesElement ();
124
mSW->appendValues ( value );
127
/** Adds @a value to the array*/
128
template <class Type>
129
void appendValues ( const Type value )
131
openValuesElement ();
132
mSW->appendValues ( value );
135
/** Adds @a value1 and @a value2 to the array*/
136
template <class Type>
137
void appendValues ( const Type value1, const Type value2 )
139
openValuesElement ();
140
mSW->appendValues ( value1, value2 );
144
/** Adds @a value1, @a value2 and @a value3 to the array*/
145
template <class Type>
146
void appendValues ( const Type value1, const Type value2, const Type value3 )
148
openValuesElement ();
149
mSW->appendValues ( value1, value2, value3 );
152
/** Adds @a value1, @a value2, @a value3 and @a value4 to the array*/
153
template <class Type>
154
void appendValues ( const Type value1, const Type value2, const Type value3, const Type value4 )
156
openValuesElement ();
157
mSW->appendValues ( value1, value2, value3, value4 );
161
* This function must be called after the last value has been added to the array
162
* and before another element has been opened.
163
* @param closeSourceElement false, if we want to add some extra tags and close the element later.
169
/** Returns the closer tag for the current parameter. */
170
TagCloser& getParamCloser () { return mParamCloser; }
172
/** Set the current tag closer. */
173
void setParamCloser ( const TagCloser& tagCloser ) { mParamCloser = tagCloser; }
177
} //namespace COLLADASW
180
#endif //__COLLADASTREAMWRITER_PARAM_H__