VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
varType.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 ******************************************************************************/
5 
6 
8 
9 #ifndef varType_H_
10 #define varType_H_
11 
12 #ifdef DtUSE_UTILITIES_NAMESPACE
13 namespace DtUSE_UTILITIES_NAMESPACE
14 {
15 #endif
16 
17 
18 // A Internal template typedefs set of
19 template <typename T>
21 {
22  typedef DtString Type;
23 };
24 
28 template <typename T>
30 {
32 
33  //Get the native type string.
34  static DtString nativeNameOfType();
35 
36  //Get the CmdLine ARG type string.
37  static DtString argNameOfType();
38 
39  //Get the XML schema type string.
40  static DtString xsNameOfType();
41 
42  //To and from CmdLine Argument types.
43  static ArgType convertToArgType(T value);
44  static T convertFromArgType(ArgType value);
45 
46  //To and From String conversions
47  static DtString convertToString(T value);
48  static T convertFromString(const DtString& value);
49 
50  //Get Schema Type
51  static DtEnvValueSP createSchemaType(DtEnvironment);
52 
53  //To and From Environment Value
54  static void convertToEnvironmentValue(DtEnvironment env,T value);
55  static T convertFromEnvironmentValue(DtEnvironment env);
56 };
57 
58 //Macro To Declare a simple Var Type. This macro should be placed in a header.
59 #define DtDeclareVarType(NativeType,CmdLineType)\
60  template <>\
61  struct _NativeTypeToArg<NativeType>\
62  {\
63  typedef CmdLineType Type;\
64  };\
65  template <>\
66  DtString DtVarType<NativeType>::nativeNameOfType();\
67  template <>\
68  DtString DtVarType<NativeType>::argNameOfType();\
69  template <>\
70  DtString DtVarType<NativeType>::xsNameOfType();\
71  template <>\
72  DtVarType<NativeType>::ArgType DtVarType<NativeType>::convertToArgType(NativeType);\
73  template <>\
74  NativeType DtVarType<NativeType>::convertFromArgType(DtVarType<NativeType>::ArgType);\
75  template <>\
76  DtString DtVarType<NativeType>::convertToString(NativeType);\
77  template <>\
78  NativeType DtVarType<NativeType>::convertFromString(const DtString&);\
79  template <>\
80  DtEnvValueSP DtVarType<NativeType>::createSchemaType(DtEnvironment);\
81  template <>\
82  void DtVarType<NativeType>::convertToEnvironmentValue(DtEnvironment env,NativeType value);\
83  template <>\
84  NativeType DtVarType<NativeType>::convertFromEnvironmentValue(DtEnvironment env);\
85 
86 //Macro To Define the names a simple Var Type. This macro should be placed in a source file.
87 #define DtDefineVarTypeNames(NativeType,ArgNameStr,xsTypeStr)\
88  template<>\
89  DtString DtVarType<NativeType>::nativeNameOfType()\
90  {\
91  return #NativeType;\
92  };\
93  template<>\
94  DtString DtVarType<NativeType>::argNameOfType()\
95  {\
96  return ArgNameStr;\
97  }\
98  template<>\
99  DtString DtVarType<NativeType>::xsNameOfType()\
100  {\
101  return xsTypeStr;\
102  }\
103 
104 // Macro to Define the conversion functions of a simple Var Type.This macro should be placed in a source file.
105 #define DtDefineVarTypeArgFunctions(NativeType,ToStrFunction,FromStrFunction,ToArgFunction,FromArgFunction)\
106  template<>\
107  DtVarType<NativeType>::ArgType DtVarType<NativeType>::convertToArgType(NativeType value)\
108  {\
109  return ToArgFunction;\
110  }\
111  template<>\
112  NativeType DtVarType<NativeType>::convertFromArgType(DtVarType<NativeType>::ArgType value)\
113  {\
114  return FromArgFunction;\
115  }\
116  template<>\
117  DtString DtVarType<NativeType>::convertToString(NativeType value)\
118  {\
119  return ToStrFunction;\
120  }\
121  template<>\
122  NativeType DtVarType<NativeType>::convertFromString(const DtString& value)\
123  {\
124  return FromStrFunction;\
125  }
126 
127 // Macro to Define the schema functions. This macro should be placed in a source file.
128 #define DtDefineVarTypeEnvFunctions(NativeType,SchemaTypeFunction,ToEnvironmentFunction,FromEnvironmentFunction)\
129  template <>\
130  DtEnvValueSP DtVarType<NativeType>::createSchemaType(DtEnvironment env)\
131  {\
132  return SchemaTypeFunction;\
133  }\
134  template <>\
135  void DtVarType<NativeType>::convertToEnvironmentValue(DtEnvironment env,NativeType value)\
136  {\
137  ToEnvironmentFunction;\
138  }\
139  template <>\
140  NativeType DtVarType<NativeType>::convertFromEnvironmentValue(DtEnvironment env)\
141  {\
142  return FromEnvironmentFunction;\
143  }\
144 
145 #ifdef DtUSE_UTILITIES_NAMESPACE
146 }
147 #endif
148 
149 
150 #endif

Document ID: Generated on Fri Dec 2 02:42:08 EST 2016 from SVN revision 171416
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)