12 #include <vlutil/vlExceptions.h>
18 #define DO_PP(MACRO) MACRO
25 #define MAKE_STREAM_1(word) word##1
26 #define MAKE_STREAM_2(word) MAKE_STREAM_1(word)<<word##2
27 #define MAKE_STREAM_3(word) MAKE_STREAM_2(word)<<word##3
28 #define MAKE_STREAM_4(word) MAKE_STREAM_3(word)<<word##4
29 #define MAKE_STREAM_5(word) MAKE_STREAM_4(word)<<word##5
30 #define MAKE_STREAM_6(word) MAKE_STREAM_5(word)<<word##6
31 #define MAKE_STREAM_7(word) MAKE_STREAM_6(word)<<word##7
32 #define MAKE_STREAM_8(word) MAKE_STREAM_7(word)<<word##8
33 #define MAKE_STREAM_9(word) MAKE_STREAM_8(word)<<word##9
34 #define MAKE_STREAM_10(word) MAKE_STREAM_9(word)<<word##10
36 #define MAKE_STREAM(word,count) DO_PP(MAKE_STREAM_##count(word))
42 #define MAKE_STREAMOUT_1(word) word##1
43 #define MAKE_STREAMOUT_2(word) MAKE_STREAMOUT_1(word)>>word##2
44 #define MAKE_STREAMOUT_3(word) MAKE_STREAMOUT_2(word)>>word##3
45 #define MAKE_STREAMOUT_4(word) MAKE_STREAMOUT_3(word)>>word##4
46 #define MAKE_STREAMOUT_5(word) MAKE_STREAMOUT_4(word)>>word##5
47 #define MAKE_STREAMOUT_6(word) MAKE_STREAMOUT_5(word)>>word##6
48 #define MAKE_STREAMOUT_7(word) MAKE_STREAMOUT_6(word)>>word##7
49 #define MAKE_STREAMOUT_8(word) MAKE_STREAMOUT_7(word)>>word##8
50 #define MAKE_STREAMOUT_9(word) MAKE_STREAMOUT_8(word)>>word##9
51 #define MAKE_STREAMOUT_10(word) MAKE_STREAMOUT_9(word)>>word##10
53 #define MAKE_STREAMOUT(word,count) DO_PP(MAKE_STREAMOUT_##count(word))
60 #define MAKE_LIST_1(word) word##1
61 #define MAKE_LIST_2(word) MAKE_LIST_1(word),word##2
62 #define MAKE_LIST_3(word) MAKE_LIST_2(word),word##3
63 #define MAKE_LIST_4(word) MAKE_LIST_3(word),word##4
64 #define MAKE_LIST_5(word) MAKE_LIST_4(word),word##5
65 #define MAKE_LIST_6(word) MAKE_LIST_5(word),word##6
66 #define MAKE_LIST_7(word) MAKE_LIST_6(word),word##7
67 #define MAKE_LIST_8(word) MAKE_LIST_7(word),word##8
68 #define MAKE_LIST_9(word) MAKE_LIST_8(word),word##9
69 #define MAKE_LIST_10(word) MAKE_LIST_9(word),word##10
71 #define MAKE_LIST(word,count) DO_PP(MAKE_LIST_##count(word))
77 #define MAKE_MULTILIST_1(first,second) first##1 second##1
78 #define MAKE_MULTILIST_2(first,second) MAKE_MULTILIST_1(first,second),first##2 second##2
79 #define MAKE_MULTILIST_3(first,second) MAKE_MULTILIST_2(first,second),first##3 second##3
80 #define MAKE_MULTILIST_4(first,second) MAKE_MULTILIST_3(first,second),first##4 second##4
81 #define MAKE_MULTILIST_5(first,second) MAKE_MULTILIST_4(first,second),first##5 second##5
82 #define MAKE_MULTILIST_6(first,second) MAKE_MULTILIST_5(first,second),first##6 second##6
83 #define MAKE_MULTILIST_7(first,second) MAKE_MULTILIST_6(first,second),first##7 second##7
84 #define MAKE_MULTILIST_8(first,second) MAKE_MULTILIST_7(first,second),first##8 second##8
85 #define MAKE_MULTILIST_9(first,second) MAKE_MULTILIST_8(first,second),first##9 second##9
86 #define MAKE_MULTILIST_10(first,second) MAKE_MULTILIST_9(first,second),first##10 second##10
88 #define MAKE_MULTILIST(first,second,count) DO_PP(MAKE_MULTILIST_##count(first,second))
95 #define MAKE_CAST_CALL_1(first,second,third,forth) first##1 second(third,forth##1)
96 #define MAKE_CAST_CALL_2(first,second,third,forth) MAKE_CAST_CALL_1(first,second,third,forth),first##2 second(third,forth##2)
97 #define MAKE_CAST_CALL_3(first,second,third,forth) MAKE_CAST_CALL_2(first,second,third,forth),first##3 second(third,forth##3)
98 #define MAKE_CAST_CALL_4(first,second,third,forth) MAKE_CAST_CALL_3(first,second,third,forth),first##4 second(third,forth##4)
99 #define MAKE_CAST_CALL_5(first,second,third,forth) MAKE_CAST_CALL_4(first,second,third,forth),first##5 second(third,forth##5)
100 #define MAKE_CAST_CALL_6(first,second,third,forth) MAKE_CAST_CALL_5(first,second,third,forth),first##6 second(third,forth##6)
101 #define MAKE_CAST_CALL_7(first,second,third,forth) MAKE_CAST_CALL_6(first,second,third,forth),first##7 second(third,forth##7)
102 #define MAKE_CAST_CALL_8(first,second,third,forth) MAKE_CAST_CALL_7(first,second,third,forth),first##8 second(third,forth##8)
103 #define MAKE_CAST_CALL_9(first,second,third,forth) MAKE_CAST_CALL_8(first,second,third,forth),first##9 second(third,forth##9)
104 #define MAKE_CAST_CALL_10(first,second,third,forth) MAKE_CAST_CALL_9(first,second,third,forth),first##10 second(third,forth##10)
106 #define MAKE_CAST_CALL(first,second,third,forth,count) DO_PP(MAKE_CAST_CALL_##count(first,second,third,forth))
112 #define MAKE_DECL_LIST_1(word) word##1
113 #define MAKE_DECL_LIST_2(word) MAKE_DECL_LIST_1(word);word##2
114 #define MAKE_DECL_LIST_3(word) MAKE_DECL_LIST_2(word);word##3
115 #define MAKE_DECL_LIST_4(word) MAKE_DECL_LIST_3(word);word##4
116 #define MAKE_DECL_LIST_5(word) MAKE_DECL_LIST_4(word);word##5
117 #define MAKE_DECL_LIST_6(word) MAKE_DECL_LIST_5(word);word##6
118 #define MAKE_DECL_LIST_7(word) MAKE_DECL_LIST_6(word);word##7
119 #define MAKE_DECL_LIST_8(word) MAKE_DECL_LIST_7(word);word##8
120 #define MAKE_DECL_LIST_9(word) MAKE_DECL_LIST_8(word);word##9
121 #define MAKE_DECL_LIST_10(word) MAKE_DECL_LIST_9(word);word##10
123 #define MAKE_DECL_LIST(word,count) DO_PP(MAKE_DECL_LIST_##count(word))
128 #define MAKE_DECL_MULTILIST_1(first,second) first##1 second##1
129 #define MAKE_DECL_MULTILIST_2(first,second) MAKE_DECL_MULTILIST_1(first,second);first##2 second##2
130 #define MAKE_DECL_MULTILIST_3(first,second) MAKE_DECL_MULTILIST_2(first,second);first##3 second##3
131 #define MAKE_DECL_MULTILIST_4(first,second) MAKE_DECL_MULTILIST_3(first,second);first##4 second##4
132 #define MAKE_DECL_MULTILIST_5(first,second) MAKE_DECL_MULTILIST_4(first,second);first##5 second##5
133 #define MAKE_DECL_MULTILIST_6(first,second) MAKE_DECL_MULTILIST_5(first,second);first##6 second##6
134 #define MAKE_DECL_MULTILIST_7(first,second) MAKE_DECL_MULTILIST_6(first,second);first##7 second##7
135 #define MAKE_DECL_MULTILIST_8(first,second) MAKE_DECL_MULTILIST_7(first,second);first##8 second##8
136 #define MAKE_DECL_MULTILIST_9(first,second) MAKE_DECL_MULTILIST_8(first,second);first##9 second##9
137 #define MAKE_DECL_MULTILIST_10(first,second) MAKE_DECL_MULTILIST_9(first,second);first##10 second##10
139 #define MAKE_DECL_MULTILIST(first,second,count) DO_PP(MAKE_DECL_MULTILIST_##count(first,second))
142 #define EXPORT_TEMPLATE_TYPEDEF(C,TD)\
145 #define EXPORT_TEMPLATE_TYPEDEF(C,TD)\
152 #define FAST_REPEATED_CALL(count,x) \
156 size_t __FAST_ITERATE_count = count;\
157 size_t __FAST_ITERATE_n = (__FAST_ITERATE_count + 7) >> 3; \
158 switch (__FAST_ITERATE_count & 7) \
168 } while (--__FAST_ITERATE_n > 0);\
178 template <
typename K,
typename V,
typename Pr,
typename Alloc>
181 typename std::map<K,V,Pr,Alloc>::const_iterator iter = map.find(key);
182 if(iter == map.end())
188 return const_cast<V*
>(&iter->second);
197 template <
typename M>
200 typename M::mapped_type ptr;
201 typename M::iterator curIter = map.begin();
202 typename M::const_iterator endIter = map.end();
203 for ( ; curIter != endIter; ++curIter )
205 ptr = curIter->second;
217 template <
typename V>
220 typename V::value_type ptr;
221 typename V::iterator curIter = vec.begin();
222 typename V::iterator endIter = vec.end();
223 for ( ; curIter != endIter; ++curIter )
232 template <
typename Iter>
235 for(Iter cur = begin;cur != end;++cur)
241 template <
typename Key,
typename Value>
244 inline bool operator()(
const std::pair<Key,Value>& a,
const std::pair<Key,Value>& b)
const
246 return a.first < b.first;
260 template <
typename T,
typename R,
typename A>
263 return std::bind1st(std::mem_fun(memfun),ptr);
266 template <
typename T,
typename R,
typename A>
269 return std::bind1st(std::mem_fun(memfun),ptr);
272 template <
typename T,
typename R,
typename A>
275 return std::bind1st(std::mem_fun(memfun),ptr);
278 template <
typename T,
typename R,
typename A,
typename Col>
281 typename Col::iterator curIter = col.begin();
282 typename Col::iterator endIter = col.end();
283 for(;curIter != endIter;++curIter)
285 (_this->*memfun)(*curIter);
289 template <
typename Ret,
typename AT,
typename Class>
291 const Ret (Class::* memberPtr)(AT)
const,
294 return const_cast<Ret
>(_this->*(memberPtr)(param));
299 template <
typename T,
void(T::*MF)()>
305 template <
class InputIterator1,
class InputIterator2,
class OutputIterator1,
class OutputIterator2>
307 InputIterator2 first2, InputIterator2 last2,
308 OutputIterator1 result1,
309 OutputIterator2 result2 )
311 while (first1!=last1 && first2!=last2)
315 *result1++ = *first1++;
317 else if (*first2<*first1)
319 *result2++ = *first2++;
328 copy(first1,last1,result1);
329 copy(first2,last2,result2);
357 template <
typename iter,
typename T>
364 template <
typename iter,
typename F>
371 template <
typename T,
typename Ax >
374 size_t size = list.size();
381 typename std::vector<T,Ax>::iterator i =
fasterFind(size,list.begin(),list.end(),value);
390 if(&(*i) != &list.back())
394 list.resize(size - 1);
400 template <
typename T,
typename Ax >
403 size_t size = list.size();
414 typename std::vector<T*,Ax>::iterator i =
fasterFind(size,list.begin(),list.end(),value);
417 if(&(*i) != &list.back())
421 list.resize(size - 1);
426 template <
typename T,
typename Ax,
typename Function >
429 size_t size = list.size();
440 typename std::vector<T,Ax>::iterator i =
fastFindPred(size,list.begin(),list.end(),f);
443 if(&(*i) != &list.back())
447 list.resize(size - 1);
452 template <
typename T,
typename Ax,
typename Function>
455 size_t size = list.size();
466 typename std::vector<T*,Ax>::iterator i =
fastFindPred(size,list.begin(),list.end(), f );
469 if(&(*i) != &list.back())
473 list.resize(size - 1);
478 template <
typename Ret,
typename T>
500 template <
typename Ret,
typename T>
506 template <
typename Ret,
typename T>
531 template <
typename Ret,
typename T>
538 template <
typename K,
typename V>
539 const V&
findOrThrow(
const std::map<K,V,std::less<K>, std::allocator<std::pair<const K, V> > >& map, K key)
541 typename std::map<K,V>::const_iterator iter = map.find(key);
542 if(iter == map.end())
544 DtTHROW_NEW(DtInvalidInput,
"Unable to find key");
550 template <
typename K,
typename V>
551 const V&
findByIndexOrThrow(
const std::map<K,V,std::less<K>, std::allocator<std::pair<const K, V> > >& map,
int index)
553 if(index >= (
int)map.size())
555 DtTHROW_NEW(DtInvalidInput,
"Index out of range.");
557 typename std::map<K,V>::const_iterator i = map.begin();
558 std::advance(i,index);
563 template <
typename V>
566 if(index >= (
int)vec.size())
568 DtTHROW_NEW(DtInvalidInput,
"Index out of range.");
570 typename std::vector<V>::const_iterator i = vec.begin();
571 std::advance(i,index);
Ret myValue
Definition: templateUtil.h:511
std::binder1st< std::mem_fun1_t< R, T, A > > callMemberRefFunction(R(T::*memfun)(A &), T *ptr)
Definition: templateUtil.h:267
bool operator()(const T *a, const T *b) const
Definition: templateUtil.h:494
voidpf void uLong size
Definition: ioapi.h:39
void DtMemberFunctionCallback(DtDe *de, void *data)
Definition: templateUtil.h:300
EqualPointerByFunction_T< Ret, T > EqualPointerByFunction(Ret(T::*ptr)() const, Ret value)
Definition: templateUtil.h:532
const V & findByIndexOrThrow(const std::map< K, V, std::less< K >, std::allocator< std::pair< const K, V > > > &map, int index)
Find a value by index in a map, or throw an DtInvalidInput exception.
Definition: templateUtil.h:551
std::binder1st< std::mem_fun1_t< R, T, A > > callMemberConstRefFunction(R(T::*memfun)(const A &), T *ptr)
Definition: templateUtil.h:273
Ret callConstFunction1(const Class *_this, const Ret(Class::*memberPtr)(AT) const, AT param)
Definition: templateUtil.h:290
const V & findOrThrow(const std::map< K, V, std::less< K >, std::allocator< std::pair< const K, V > > > &map, K key)
Find a value in a map, or throw an DtInvalidInput exception.
Definition: templateUtil.h:539
void DtClearAndDeletePointersInMap(M &map)
Deletes all pointers in a map then clears it.
Definition: templateUtil.h:198
Definition: templateUtil.h:507
bool operator()(const T *a) const
Definition: templateUtil.h:525
SortPointersByFunction_T< Ret, T > SortPointersByFunction(Ret(T::*ptr)() const)
Definition: templateUtil.h:501
bool operator()(const std::pair< Key, Value > &a, const std::pair< Key, Value > &b) const
Definition: templateUtil.h:244
Definition: templateUtil.h:242
#define FAST_REPEATED_CALL(count, x)
Definition: templateUtil.h:152
SortPointersByFunction_T(MemberFnPtr memFun)
Definition: templateUtil.h:484
EqualPointerByFunction_T(MemberFnPtr memFun, Ret value)
Definition: templateUtil.h:513
MemberFnPtr myPtr
Definition: templateUtil.h:482
Definition: templateUtil.h:479
void DtDeletePointersInIterators(Iter begin, Iter end)
Definition: templateUtil.h:233
void DtClearAndDeletePointersInVector(V &vec)
Deletes all pointers in a vector then clears it.
Definition: templateUtil.h:218
SortPointersByFunction_T(const SortPointersByFunction_T< Ret, T > &second)
Definition: templateUtil.h:489
iter fastFindPred(size_t size, iter begin, iter end, const F &pred)
Definition: templateUtil.h:365
MemberFnPtr myPtr
Definition: templateUtil.h:510
V * DtFindPointerInMap(const std::map< K, V, Pr, Alloc > &map, K key)
Definition: templateUtil.h:179
void fastEraseFromUnsortedVectorPred(std::vector< T, Ax > &list, const Function &f)
Definition: templateUtil.h:427
EqualPointerByFunction_T(const SortPointersByFunction_T< Ret, T > &second)
Definition: templateUtil.h:519
Ret(T::* MemberFnPtr)() const
Definition: templateUtil.h:481
void forEachCallMember(T *_this, R(T::*memfun)(A), Col &col)
Definition: templateUtil.h:279
std::binder1st< std::mem_fun1_t< R, T, A > > callMemberFunction(R(T::*memfun)(A), T *ptr)
A helper template for binding a single argument member function.
Definition: templateUtil.h:261
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
iter fasterFind(size_t size, iter begin, iter end, const T &value)
boost::signalslib::signal<void (Argument)>& forwarder)
Definition: templateUtil.h:358
void fastEraseFromUnsortedVector(std::vector< T, Ax > &list, const T &value)
Definition: templateUtil.h:372
Ret(T::* MemberFnPtr)() const
Definition: templateUtil.h:509
void set_split_difference(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator1 result1, OutputIterator2 result2)
Definition: templateUtil.h:306