43 #ifndef __H__UG_BRIDGE__PARAMETER_STACK__
44 #define __H__UG_BRIDGE__PARAMETER_STACK__
47 #define untested() ( std::cerr << "@@#\n@@@:"<< __FILE__ << ":"<< __LINE__ \
48 <<":" << __func__ << "\n" )
83 nIndex = stackSize + nIndex;
85 if(nIndex < 0 || nIndex >= stackSize)
86 UG_THROW(
"Invalid index "<<nIndex<<
" used in Parameter Stack.");
118 UG_THROW(
"ClassNameNode missing in Parameter stack.");
136 template <
typename TType,
typename TNode>
144 template <
typename TNative>
147 template <
typename TType,
typename TNode>
155 template <
typename TNative>
158 template <
typename T>
161 T::___UG_REGISTRY_ERROR___FUNCTION_OR_METHOD_PARAMETERS_RESTRICTED_to__NATIVE_TYPES__or__POINTER_resp_SMARTPOINTER_to_registered_types____();
167 template <
typename T>
283 template <
typename T>
285 this->push_type<T>();
289 template <
typename TPtr,
typename TType>
291 this->push_type<TType>();
303 template <
typename T>
320 this->push_type<std::vector<T> >();
334 template <
typename TVo
id>
353 template <
typename TVo
id,
typename TPtr,
typename TNode>
358 for(
size_t i = 0; i < vec.size(); ++i){
367 inline void push(
void* ptr,
const ClassNameNode* classNameNode){_push_void_pointer<void*>(ptr, classNameNode);}
368 inline void push(
const void* ptr,
const ClassNameNode* classNameNode){_push_void_pointer<const void*>(ptr, classNameNode);}
375 inline void push(
SmartPtr<std::vector<std::pair<void*, const ClassNameNode*> > > spVec){_push_void_pointer_vector<void*>(spVec);}
376 inline void push(
SmartPtr<std::vector<std::pair<const void*, const ClassNameNode*> > > spVec){_push_void_pointer_vector<const void*>(spVec);}
383 inline void push(
SmartPtr<std::vector<bool> > spVec){_push_vector<bool>(spVec);}
384 inline void push(
SmartPtr<std::vector<size_t> > spVec){_push_vector<size_t>(spVec);}
385 inline void push(
SmartPtr<std::vector<int> > spVec){_push_vector<int>(spVec);}
386 inline void push(
SmartPtr<std::vector<float> > spVec){_push_vector<float>(spVec);}
387 inline void push(
SmartPtr<std::vector<double> > spVec){_push_vector<double>(spVec);}
388 inline void push(
SmartPtr<std::vector<const char*> > spVec){_push_vector<const char*>(spVec);}
389 inline void push(
SmartPtr<std::vector<std::string> > spVec){_push_vector<std::string>(spVec);}
393 template <
typename T>
396 T::___UG_REGISTRY_ERROR___FUNCTION_OR_METHOD_PARAMETERS_RESTRICTED_to__NATIVE_TYPES__or__POINTER_resp_SMARTPOINTER_to_registered_types____();
401 template <
typename T>
409 template <
typename T>
424 template <
typename T,
typename TPtr,
typename TVo
id>
428 TPtr ptr = ClassCastProvider::cast_to<T>(
m_vEntry[index].to<TVoid>(), pClassNameNode);
433 template <
typename T>
438 if(spVec.
invalid())
UG_THROW(
"Cannot cast back to std::vector<T> for native type.");
443 template <
typename T,
typename TPtr,
typename TVo
id>
448 if(spVec.
invalid())
UG_THROW(
"Cannot cast back to std::vector<T> for native type.");
452 for(
size_t i = 0; i < spVec->size(); ++i){
453 sp->push_back(ClassCastProvider::cast_to<T>((*spVec)[i].first, (*spVec)[i].second));
462 template <
typename TPtr>
467 if(spVec.
invalid())
UG_THROW(
"Cannot cast back to std::vector<T> for native type.");
472 template <
typename T>
475 return T::___UG_REGISTRY_ERROR___FUNCTION_OR_METHOD_PARAMETERS_RESTRICTED_to__NATIVE_TYPES__or__POINTER_resp_SMARTPOINTER_to_registered_types____();
480 template <
typename T>
Definition: smart_pointer.h:650
Definition: smart_pointer.h:296
Definition: smart_pointer.h:51
Definition: smart_pointer.h:525
SmartPtr< T, TFreePolicy > cast_reinterpret() const
Returns a SmartPtr with the specified type and shared reference counting.
Definition: smart_pointer.h:599
Definition: smart_pointer.h:108
bool invalid() const
returns true if the pointer is invalid, false if not.
Definition: smart_pointer.h:212
Handle for a lua reference.
Definition: lua_function_handle.h:40
Handle for a lua reference.
Definition: lua_table_handle.h:49
A variant can represent variables of different types.
Definition: variant.h:87
Type
Definition: variant.h:89
node for class names
Definition: class_name_provider.h:65
bool named() const
returns if a name has been set by the user
Definition: class_name_provider.cpp:63
const std::string & name() const
returns own name
Definition: class_name_provider.h:77
provides the name for a class
Definition: class_name_provider.h:102
static const ClassNameNode & class_name_node()
return the class name node in the class hierarchy
Definition: class_name_provider.h:136
a stack holding parameter infos about a parameter stack
Definition: parameter_stack.h:73
int m_numEntries
number of currently stored entries
Definition: parameter_stack.h:186
Variant::Type type(int index) const
returns ParameterType enum of data type for a stack entry
Definition: parameter_stack.h:109
static const int PARAMETER_STACK_MAX_SIZE
maximal number of parameter in a parameter list
Definition: parameter_stack.h:76
void _push_type()
Definition: parameter_stack.h:137
bool is_vector(int index) const
returns if index is a std::vector
Definition: parameter_stack.h:103
void _push_vector_type()
Definition: parameter_stack.h:156
bool parameter_named(int index) const
returns true if a parameter of the stack has been named by user
Definition: parameter_stack.h:128
ParameterInfo()
default constructor
Definition: parameter_stack.h:93
EntryType m_vEntryType[PARAMETER_STACK_MAX_SIZE]
Definition: parameter_stack.h:183
void push_type()
pushes a type to the parameter stack
Definition: parameter_stack.h:168
const char * class_name(int index) const
returns the class name for an element in the param stack
Definition: parameter_stack.h:123
const ClassNameNode * class_name_node(int index) const
returns the class name node for an element in the param stack
Definition: parameter_stack.h:115
static int ARRAY_INDEX_TO_STACK_INDEX(int index, int stackSize)
help function to compute correct parameter index
Definition: parameter_stack.h:79
void _push_type()
Definition: parameter_stack.h:145
void _push_vector_type()
Definition: parameter_stack.h:148
int size() const
returns number of parameters in the param stack
Definition: parameter_stack.h:100
A stack that can hold values together with their type-id.
Definition: parameter_stack.h:270
void _push_void_pointer(T val, const ClassNameNode *classNameNode)
Definition: parameter_stack.h:304
void push(SmartPtr< std::vector< const char * > > spVec)
Definition: parameter_stack.h:388
void push(SmartPtr< std::vector< std::string > > spVec)
Definition: parameter_stack.h:389
void _push_pointer_vector(const std::vector< TPtr > &vec)
Definition: parameter_stack.h:354
Variant m_vEntry[PARAMETER_STACK_MAX_SIZE]
fixed size array storing the data for a stack entry
Definition: parameter_stack.h:488
T to(int index) const
return element in param stack casted to type
Definition: parameter_stack.h:481
std::vector< SmartPtr< void > > m_vStoredSmartPtr
Definition: parameter_stack.h:459
T _to_native(int index) const
return element in param stack casted to native type
Definition: parameter_stack.h:410
void push(SmartPtr< std::vector< float > > spVec)
Definition: parameter_stack.h:386
void push(const void *ptr, const ClassNameNode *classNameNode)
Definition: parameter_stack.h:368
std::vector< T > & _to_native_vector(int index) const
return element in param stack casted to native type vector
Definition: parameter_stack.h:434
void push(ConstSmartPtr< void > ptr, const ClassNameNode *classNameNode)
Definition: parameter_stack.h:370
void push(SmartPtr< std::vector< int > > spVec)
Definition: parameter_stack.h:385
SmartPtr< std::vector< std::pair< TPtr, const ClassNameNode * > > > _to_void_pointer_vector(int index) const
return element in param stack casted to native type vector
Definition: parameter_stack.h:463
void push(SmartPtr< std::vector< std::pair< ConstSmartPtr< void >, const ClassNameNode * > > > spVec)
Definition: parameter_stack.h:378
void push(void *ptr, const ClassNameNode *classNameNode)
Definition: parameter_stack.h:367
void push(SmartPtr< std::vector< std::pair< SmartPtr< void >, const ClassNameNode * > > > spVec)
Definition: parameter_stack.h:377
void _push_vector(SmartPtr< std::vector< T > > spVec)
Definition: parameter_stack.h:318
void push(SmartPtr< std::vector< bool > > spVec)
Definition: parameter_stack.h:383
void _push_pointer(TPtr val)
Definition: parameter_stack.h:290
void _push_native(const T &val)
Definition: parameter_stack.h:284
void push(SmartPtr< std::vector< double > > spVec)
Definition: parameter_stack.h:387
void push(SmartPtr< std::vector< std::pair< void *, const ClassNameNode * > > > spVec)
Definition: parameter_stack.h:375
void _push_void_pointer_vector(SmartPtr< std::vector< std::pair< TVoid, const ClassNameNode * > > > spVec, const ClassNameNode *baseNameNode=NULL)
Definition: parameter_stack.h:335
std::vector< TPtr > & _to_pointer_vector(int index) const
return element in param stack casted to native type vector
Definition: parameter_stack.h:444
TPtr _to_pointer(int index) const
returns element in param stack casted to pointer type
Definition: parameter_stack.h:425
void push(T data)
return element in param stack casted to type
Definition: parameter_stack.h:402
const Variant & get(int index) const
return element in param stack as plain variant
Definition: parameter_stack.h:484
void push(SmartPtr< void > ptr, const ClassNameNode *classNameNode)
Definition: parameter_stack.h:369
void push(SmartPtr< std::vector< size_t > > spVec)
Definition: parameter_stack.h:384
void push(SmartPtr< std::vector< std::pair< const void *, const ClassNameNode * > > > spVec)
Definition: parameter_stack.h:376
const int UG_REGISTRY_MAX_NUM_ARGS
Definition: function_traits.h:46
#define UG_THROW(msg)
Definition: error.h:57
Definition: smart_pointer.h:814
structure to store a data entry with additional information
Definition: parameter_stack.h:172
const ClassNameNode * pClassNameNode
Definition: parameter_stack.h:177
bool bVector
Definition: parameter_stack.h:178
Variant::Type type
Definition: parameter_stack.h:176
EntryType()
Definition: parameter_stack.h:173
static void push(ParameterInfo *This)
Definition: parameter_stack.h:209
static void push(ParameterInfo *This)
Definition: parameter_stack.h:208
static void push(ParameterInfo *This)
Definition: parameter_stack.h:204
static void push(ParameterInfo *This)
Definition: parameter_stack.h:206
static void push(ParameterInfo *This)
Definition: parameter_stack.h:190
static void push(ParameterInfo *This)
Definition: parameter_stack.h:205
static void push(ParameterInfo *This)
Definition: parameter_stack.h:207
static void push(ParameterInfo *This)
Definition: parameter_stack.h:195
static void push(ParameterInfo *This)
Definition: parameter_stack.h:197
static void push(ParameterInfo *This)
Definition: parameter_stack.h:253
static void push(ParameterInfo *This)
Definition: parameter_stack.h:249
static void push(ParameterInfo *This)
Definition: parameter_stack.h:241
static void push(ParameterInfo *This)
Definition: parameter_stack.h:230
static void push(ParameterInfo *This)
Definition: parameter_stack.h:245
static void push(ParameterInfo *This)
Definition: parameter_stack.h:235
static void push(ParameterInfo *This)
Definition: parameter_stack.h:234
static void push(ParameterInfo *This)
Definition: parameter_stack.h:233
static void push(ParameterInfo *This)
Definition: parameter_stack.h:231
static void push(ParameterInfo *This)
Definition: parameter_stack.h:232
static void push(ParameterInfo *This)
Definition: parameter_stack.h:236
static void push(ParameterInfo *This)
Definition: parameter_stack.h:194
static void push(ParameterInfo *This)
Definition: parameter_stack.h:193
static void push(ParameterInfo *This)
Definition: parameter_stack.h:191
static void push(ParameterInfo *This)
Definition: parameter_stack.h:192
static void push(ParameterInfo *This)
Definition: parameter_stack.h:196
static void push(ParameterInfo *This)
Definition: parameter_stack.h:251
static void push(ParameterInfo *This)
Definition: parameter_stack.h:247
static void push(ParameterInfo *This)
Definition: parameter_stack.h:239
static void push(ParameterInfo *This)
Definition: parameter_stack.h:212
static void push(ParameterInfo *This)
Definition: parameter_stack.h:243
static void push(ParameterInfo *This)
Definition: parameter_stack.h:217
static void push(ParameterInfo *This)
Definition: parameter_stack.h:216
static void push(ParameterInfo *This)
Definition: parameter_stack.h:215
static void push(ParameterInfo *This)
Definition: parameter_stack.h:213
static void push(ParameterInfo *This)
Definition: parameter_stack.h:214
static void push(ParameterInfo *This)
Definition: parameter_stack.h:218
Definition: parameter_stack.h:159
static void push(ParameterInfo *This)
Definition: parameter_stack.h:160
static void push(ParameterStack *This, ConstSmartPtr< T > data)
Definition: parameter_stack.h:542
static void push(ParameterStack *This, SmartPtr< T > data)
Definition: parameter_stack.h:541
static void push(ParameterStack *This, T *data)
Definition: parameter_stack.h:537
static void push(ParameterStack *This, T &data)
Definition: parameter_stack.h:538
static void push(ParameterStack *This, bool data)
Definition: parameter_stack.h:496
static void push(ParameterStack *This, const T *data)
Definition: parameter_stack.h:539
static void push(ParameterStack *This, const T &data)
Definition: parameter_stack.h:540
static void push(ParameterStack *This, const char *data)
Definition: parameter_stack.h:501
static void push(ParameterStack *This, const std::string &data)
Definition: parameter_stack.h:503
static void push(ParameterStack *This, const std::vector< ConstSmartPtr< T > > &data)
Definition: parameter_stack.h:559
static void push(ParameterStack *This, const std::vector< SmartPtr< T > > &data)
Definition: parameter_stack.h:555
static void push(ParameterStack *This, const std::vector< T * > &data)
Definition: parameter_stack.h:547
static void push(ParameterStack *This, const std::vector< bool > &spVec)
Definition: parameter_stack.h:528
static void push(ParameterStack *This, const std::vector< const T * > &data)
Definition: parameter_stack.h:551
static void push(ParameterStack *This, const std::vector< const char * > &spVec)
Definition: parameter_stack.h:533
static void push(ParameterStack *This, const std::vector< double > &spVec)
Definition: parameter_stack.h:532
static void push(ParameterStack *This, const std::vector< float > &spVec)
Definition: parameter_stack.h:531
static void push(ParameterStack *This, const std::vector< int > &spVec)
Definition: parameter_stack.h:529
static void push(ParameterStack *This, const std::vector< size_t > &spVec)
Definition: parameter_stack.h:530
static void push(ParameterStack *This, const std::vector< std::string > &spVec)
Definition: parameter_stack.h:534
static void push(ParameterStack *This, double data)
Definition: parameter_stack.h:500
static void push(ParameterStack *This, float data)
Definition: parameter_stack.h:499
static void push(ParameterStack *This, int data)
Definition: parameter_stack.h:497
static void push(ParameterStack *This, size_t data)
Definition: parameter_stack.h:498
static void push(ParameterStack *This, std::string data)
Definition: parameter_stack.h:502
static void push(ParameterStack *This, const std::vector< ConstSmartPtr< T > > &data)
Definition: parameter_stack.h:557
static void push(ParameterStack *This, const std::vector< SmartPtr< T > > &data)
Definition: parameter_stack.h:553
static void push(ParameterStack *This, const std::vector< T * > &data)
Definition: parameter_stack.h:545
static void push(ParameterStack *This, const std::vector< bool > &spVec)
Definition: parameter_stack.h:510
static void push(ParameterStack *This, const std::vector< const T * > &data)
Definition: parameter_stack.h:549
static void push(ParameterStack *This, const std::vector< const char * > &spVec)
Definition: parameter_stack.h:515
static void push(ParameterStack *This, const std::vector< double > &spVec)
Definition: parameter_stack.h:514
static void push(ParameterStack *This, const std::vector< float > &spVec)
Definition: parameter_stack.h:513
static void push(ParameterStack *This, const std::vector< int > &spVec)
Definition: parameter_stack.h:511
static void push(ParameterStack *This, const std::vector< size_t > &spVec)
Definition: parameter_stack.h:512
static void push(ParameterStack *This, const std::vector< std::string > &spVec)
Definition: parameter_stack.h:516
Definition: parameter_stack.h:394
static void push(ParameterStack *This, T data)
Definition: parameter_stack.h:395
static ConstSmartPtr< T > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:592
static ConstSmartPtr< void > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:584
static SmartPtr< T > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:591
static SmartPtr< std::vector< std::pair< void *, const ClassNameNode * > > > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:639
static SmartPtr< std::vector< std::pair< const void *, const ClassNameNode * > > > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:640
static SmartPtr< std::vector< std::pair< ConstSmartPtr< void >, const ClassNameNode * > > > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:642
static SmartPtr< std::vector< std::pair< SmartPtr< void >, const ClassNameNode * > > > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:641
static SmartPtr< void > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:583
static T * to(const ParameterStack *This, int index)
Definition: parameter_stack.h:587
static T & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:588
static bool to(const ParameterStack *This, int index)
Definition: parameter_stack.h:567
static const T * to(const ParameterStack *This, int index)
Definition: parameter_stack.h:589
static const T & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:590
static const char * to(const ParameterStack *This, int index)
Definition: parameter_stack.h:572
static const std::string & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:574
static const std::vector< ConstSmartPtr< T > > & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:636
static const std::vector< SmartPtr< T > > & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:632
static const std::vector< T * > & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:624
static const std::vector< bool > & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:613
static const std::vector< const T * > & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:628
static const std::vector< const char * > & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:618
static const std::vector< double > & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:617
static const std::vector< float > & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:616
static const std::vector< int > & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:614
static const std::vector< size_t > & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:615
static const std::vector< std::string > & to(const ParameterStack *This, int index)
Definition: parameter_stack.h:619
static const void * to(const ParameterStack *This, int index)
Definition: parameter_stack.h:582
static double to(const ParameterStack *This, int index)
Definition: parameter_stack.h:571
static float to(const ParameterStack *This, int index)
Definition: parameter_stack.h:570
static int to(const ParameterStack *This, int index)
Definition: parameter_stack.h:568
static size_t to(const ParameterStack *This, int index)
Definition: parameter_stack.h:569
static std::string to(const ParameterStack *This, int index)
Definition: parameter_stack.h:573
static std::vector< ConstSmartPtr< T > > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:634
static std::vector< SmartPtr< T > > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:630
static std::vector< T * > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:622
static std::vector< bool > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:595
static std::vector< const T * > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:626
static std::vector< const char * > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:600
static std::vector< double > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:599
static std::vector< float > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:598
static std::vector< int > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:596
static std::vector< size_t > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:597
static std::vector< std::string > to(const ParameterStack *This, int index)
Definition: parameter_stack.h:601
static void * to(const ParameterStack *This, int index)
Definition: parameter_stack.h:581
Definition: parameter_stack.h:473
static T to(const ParameterStack *This, int index)
Definition: parameter_stack.h:474