12#include <vlutil/vlExceptions.h>
13#include <boost/bind/bind.hpp>
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);\
186 for (
auto& keyVal : map)
188 auto ptr = keyVal.second;
203 typename V::value_type ptr;
204 typename V::iterator curIter = vec.begin();
205 typename V::iterator endIter = vec.end();
206 for ( ; curIter != endIter; ++curIter )
215template <
typename Iter>
218 for(Iter cur = begin;cur != end;++cur)
224template <
typename Key,
typename Value>
227 inline bool operator()(
const std::pair<Key,Value>& a,
const std::pair<Key,Value>& b)
const
229 return a.first < b.first;
234template <
typename T,
typename R,
typename A,
typename Col>
237 typename Col::iterator curIter = col.begin();
238 typename Col::iterator endIter = col.end();
239 for(;curIter != endIter;++curIter)
241 (_this->*memfun)(*curIter);
245template <
typename Ret,
typename AT,
typename Class>
247 const Ret (Class::* memberPtr)(AT)
const,
250 return const_cast<Ret
>(_this->*(memberPtr)(param));
255template <
typename T,
void(T::*MF)()>
261template <
class InputIterator1,
class InputIterator2,
class OutputIterator1,
class OutputIterator2>
263 InputIterator2 first2, InputIterator2 last2,
264 OutputIterator1 result1,
265 OutputIterator2 result2 )
267 while (first1!=last1 && first2!=last2)
271 *result1++ = *first1++;
273 else if (*first2<*first1)
275 *result2++ = *first2++;
284 copy(first1,last1,result1);
285 copy(first2,last2,result2);
313template <
typename iter,
typename T>
314iter
fasterFind(
size_t size, iter begin, iter end,
const T& value)
320template <
typename iter,
typename F>
327template <
typename T,
typename Ax >
330 size_t size = list.size();
337 typename std::vector<T,Ax>::iterator i =
fasterFind(size,list.begin(),list.end(),value);
346 if(&(*i) != &list.back())
350 list.resize(size - 1);
356template <
typename T,
typename Ax >
359 size_t size = list.size();
370 typename std::vector<T*,Ax>::iterator i =
fasterFind(size,list.begin(),list.end(),value);
373 if(&(*i) != &list.back())
377 list.resize(size - 1);
382template <
typename T,
typename Ax,
typename Function >
385 size_t size = list.size();
392 typename std::vector<T,Ax>::iterator i =
fastFindPred(size,list.begin(),list.end(),f);
395 if(&(*i) != &list.back())
399 list.resize(size - 1);
404template <
typename T,
typename Ax,
typename Function>
407 size_t size = list.size();
414 typename std::vector<T*,Ax>::iterator i =
fastFindPred(size,list.begin(),list.end(), f );
417 if(&(*i) != &list.back())
421 list.resize(size - 1);
426template <
typename Ret,
typename T>
448template <
typename Ret,
typename T>
454template <
typename Ret,
typename T>
479template <
typename Ret,
typename T>
486template <
typename K,
typename V>
487const V&
findOrThrow(
const std::map<K,V,std::less<K>, std::allocator<std::pair<const K, V> > >& map, K key)
489 typename std::map<K,V>::const_iterator iter = map.find(key);
490 if(iter == map.end())
492 DtTHROW_NEW(DtInvalidInput,
"Unable to find key");
498template <
typename K,
typename V>
499const V&
findByIndexOrThrow(
const std::map<K,V,std::less<K>, std::allocator<std::pair<const K, V> > >& map,
int index)
501 if(index >= (
int)map.size())
503 DtTHROW_NEW(DtInvalidInput,
"Index out of range.");
505 typename std::map<K,V>::const_iterator i = map.begin();
506 std::advance(i,index);
514 if(index >= (
int)vec.size())
516 DtTHROW_NEW(DtInvalidInput,
"Index out of range.");
518 typename std::vector<V>::const_iterator i = vec.begin();
519 std::advance(i,index);
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer,...
Definition DtDe.h:77
Contains DtCreateSensorFieldOfViewCommand and DtCreateSensorFieldOfViewCommandCreator class declarati...
Definition DtGridLinesSettingsRecord.h:16
iter fastFindPred(size_t size, iter begin, iter end, const F &pred)
Definition templateUtil.h:321
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:499
Ret callConstFunction1(const Class *_this, const Ret(Class::*memberPtr)(AT) const, AT param)
Definition templateUtil.h:246
void DtMemberFunctionCallback(DtDe *de, void *data)
Definition templateUtil.h:256
SortPointersByFunction_T< Ret, T > SortPointersByFunction(Ret(T::*ptr)() const)
Definition templateUtil.h:449
void DtClearAndDeletePointersInMap(M &map)
Definition templateUtil.h:184
iter fasterFind(size_t size, iter begin, iter end, const T &value)
boost::signalslib::signal<void (Argument)>& forwarder)
Definition templateUtil.h:314
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:487
void DtClearAndDeletePointersInVector(V &vec)
Definition templateUtil.h:201
void fastEraseFromUnsortedVector(std::vector< T, Ax > &list, const T &value)
Definition templateUtil.h:328
void forEachCallMember(T *_this, R(T::*memfun)(A), Col &col)
Definition templateUtil.h:235
void set_split_difference(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator1 result1, OutputIterator2 result2)
Definition templateUtil.h:262
EqualPointerByFunction_T< Ret, T > EqualPointerByFunction(Ret(T::*ptr)() const, Ret value)
Definition templateUtil.h:480
void DtDeletePointersInIterators(Iter begin, Iter end)
Definition templateUtil.h:216
void fastEraseFromUnsortedVectorPred(std::vector< T, Ax > &list, const Function &f)
Definition templateUtil.h:383
Definition templateUtil.h:456
EqualPointerByFunction_T(const SortPointersByFunction_T< Ret, T > &second)
Definition templateUtil.h:467
Ret(T::* MemberFnPtr)() const
Definition templateUtil.h:457
MemberFnPtr myPtr
Definition templateUtil.h:458
Ret myValue
Definition templateUtil.h:459
EqualPointerByFunction_T(MemberFnPtr memFun, Ret value)
Definition templateUtil.h:461
bool operator()(const T *a) const
Definition templateUtil.h:473
Definition templateUtil.h:226
bool operator()(const std::pair< Key, Value > &a, const std::pair< Key, Value > &b) const
Definition templateUtil.h:227
Definition templateUtil.h:428
SortPointersByFunction_T(const SortPointersByFunction_T< Ret, T > &second)
Definition templateUtil.h:437
bool operator()(const T *a, const T *b) const
Definition templateUtil.h:442
MemberFnPtr myPtr
Definition templateUtil.h:430
SortPointersByFunction_T(MemberFnPtr memFun)
Definition templateUtil.h:432
Ret(T::* MemberFnPtr)() const
Definition templateUtil.h:429
#define FAST_REPEATED_CALL(count, x)
Definition templateUtil.h:152