/usr/include/opencollada/COLLADAStreamWriter/COLLADASWParamTemplate.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 | /*
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_PARAM_TEMPLATE_H__
#define __COLLADASTREAMWRITER_PARAM_TEMPLATE_H__
#include "COLLADASWPrerequisites.h"
#include "COLLADASWParamBase.h"
#include "COLLADASWAnnotation.h"
#include "COLLADASWValueType.h"
#include "COLLADASWSampler.h"
#include "COLLADASWConstants.h"
namespace COLLADASW
{
/** A class to add a param to the stream.*/
template < const String* paramName, ValueType::ColladaType paramType=ValueType::VALUE_TYPE_UNSPECIFIED >
class BaseParamTemplate : public ParamBase
{
public:
/** Constructor
@param streamWriter The stream the asset should be written to.*/
BaseParamTemplate ( StreamWriter* streamWriter )
: ParamBase ( streamWriter, paramName, paramType )
{}
/** Destructor*/
virtual ~BaseParamTemplate() {}
};
/** A class to add a <newparam> to the stream.*/
template < const ValueType::ColladaType paramType=ValueType::VALUE_TYPE_UNSPECIFIED >
class NewParam : public BaseParamTemplate < &CSWC::CSW_ELEMENT_NEWPARAM, paramType >
{
public:
/** Provides additional information about the volatility or linkage of
a <newparam> declaration. Allows COLLADASW FX parameter declarations to
specify constant, external, or uniform parameters. */
enum Modifier
{
MODI_CONST,
MODI_UNIFORM,
MODI_VARYING,
MODI_STATIC,
MODI_VOLATILE,
MODI_EXTERN,
MODI_SHARED
};
public:
/** Constructor
@param streamWriter The stream the asset should be written to.*/
NewParam ( StreamWriter* streamWriter )
: BaseParamTemplate < &CSWC::CSW_ELEMENT_NEWPARAM, paramType > ( streamWriter )
{}
/** Destructor*/
virtual ~NewParam() {}
/**
Opens the param element and set the attributes.
@param sid Identifier for this parameter (that is, the variable name). Required.
*/
virtual void openParam ( const String& sid )
{
this->mParamCloser = this->mSW->openElement ( this->mParamName );
this->mSW->appendAttribute ( CSWC::CSW_ATTRIBUTE_SID, sid );
}
/** Allows COLLADASW FX parameter declarations to specify constant,
external, or uniform parameters. */
void addModifier ( const Modifier& modifier )
{
this->mSW->openElement ( CSWC::CSW_ELEMENT_MODIFIER );
this->mSW->appendValues ( getModifierString ( modifier ) );
this->mSW->closeElement ();
}
private:
/** Returns the modifier as string. */
const String& getModifierString ( const Modifier& modifier )
{
switch ( modifier )
{
case MODI_CONST: return CSWC::CSW_MODIFIER_CONST;
case MODI_UNIFORM: return CSWC::CSW_MODIFIER_UNIFORM;
case MODI_VARYING: return CSWC::CSW_MODIFIER_VARYING;
case MODI_STATIC: return CSWC::CSW_MODIFIER_STATIC;
case MODI_VOLATILE: return CSWC::CSW_MODIFIER_VOLATILE;
case MODI_EXTERN: return CSWC::CSW_MODIFIER_EXTERN;
case MODI_SHARED: return CSWC::CSW_MODIFIER_SHARED;
default: return CSWC::EMPTY_STRING;
}
}
};
typedef NewParam < ValueType::BOOL > NewParamBool;
typedef NewParam < ValueType::INT > NewParamInt;
typedef NewParam < ValueType::INT2 > NewParamInt2;
typedef NewParam < ValueType::INT3 > NewParamInt3;
typedef NewParam < ValueType::STRING > NewParamString;
typedef NewParam < ValueType::DOUBLE > NewParamDouble;
typedef NewParam < ValueType::DOUBLE2 > NewParamDouble2;
typedef NewParam < ValueType::DOUBLE3 > NewParamDouble3;
typedef NewParam < ValueType::DOUBLE4 > NewParamDouble4;
typedef NewParam < ValueType::FLOAT > NewParamFloat;
typedef NewParam < ValueType::FLOAT2 > NewParamFloat2;
typedef NewParam < ValueType::FLOAT3 > NewParamFloat3;
typedef NewParam < ValueType::FLOAT4 > NewParamFloat4;
typedef NewParam < ValueType::FLOAT4x4 > NewParamFloat4x4;
typedef NewParam < ValueType::SURFACE > NewParamSurface;
typedef NewParam < ValueType::VALUE_TYPE_UNSPECIFIED> NewParamSampler;
/** A class to add a <setparam> to the stream.*/
template < const ValueType::ColladaType paramType=ValueType::VALUE_TYPE_UNSPECIFIED >
class SetParam : public BaseParamTemplate < &CSWC::CSW_ELEMENT_SETPARAM, paramType >
{
public:
/** Constructor
@param streamWriter The stream the asset should be written to.*/
SetParam ( StreamWriter* streamWriter )
: BaseParamTemplate < &CSWC::CSW_ELEMENT_SETPARAM, paramType > ( streamWriter )
{}
/** Destructor*/
virtual ~SetParam() {}
/**
Opens the param element and set the attributes.
@param refe Attempts to reference the predefined parameter that will
have its value set. Required.
@param program Optional in <usertype> and in <technique> for GLSL and
CG profiles; not valid in GLES profile, <generator>, or
<instance_effect>.
*/
void openParam ( const String& refe, const String& program = "" )
{
this->mParamCloser = this->mSW->openElement ( this->mParamName );
this->mSW->appendAttribute ( CSWC::CSW_ATTRIBUTE_REF, refe );
if ( !program.empty() )
this->mSW->appendAttribute ( CSWC::CSW_ATTRIBUTE_PROGRAM, program );
}
};
typedef SetParam < ValueType::BOOL > SetParamBool;
typedef SetParam < ValueType::INT > SetParamInt;
typedef SetParam < ValueType::STRING > SetParamString;
typedef SetParam < ValueType::FLOAT > SetParamFloat;
typedef SetParam < ValueType::FLOAT2 > SetParamFloat2;
typedef SetParam < ValueType::FLOAT3 > SetParamFloat3;
typedef SetParam < ValueType::FLOAT4 > SetParamFloat4;
typedef SetParam < ValueType::FLOAT4x4 > SetParamFloat4x4;
typedef SetParam < ValueType::SURFACE > SetParamSurface;
typedef SetParam < ValueType::VALUE_TYPE_UNSPECIFIED > SetParamSampler;
} //namespace COLLADASW
#endif //__COLLADASTREAMWRITER_PARAM_TEMPLATE_H__
|