VR-Forces 4.0.4 Class Documentation
include/vrvUtil/DtContainerInitializers.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 20012 MAK Technologies, Inc. 
00003 ** All rights reserved. 
00004 ******************************************************************************/
00005 
00009 
00010 #pragma once
00011 
00012 #include <map>
00013 #include <list>
00014 #include <vector>
00015 #include <deque>
00016 
00017 
00026 #define DEFINE_MAP_CREATOR(PREFIX, MAP_CLASS)                                 \
00027 template<typename K, typename V>                                              \
00028 class PREFIX##MapCreator                                                      \
00029 {                                                                             \
00030 public:                                                                       \
00031    PREFIX##MapCreator(const K& key, const V& val)                             \
00032    {                                                                          \
00033       myMap[key] = val;                                                       \
00034    }                                                                          \
00035                                                                               \
00036    PREFIX##MapCreator<K, V>& operator()(const K& key, const V& val)           \
00037    {                                                                          \
00038       myMap[key] = val;                                                       \
00039       return *this;                                                           \
00040    }                                                                          \
00041                                                                               \
00042    operator MAP_CLASS<K, V>()                                                 \
00043    {                                                                          \
00044       return myMap;                                                           \
00045    }                                                                          \
00046                                                                               \
00047 private:                                                                      \
00048    MAP_CLASS<K, V> myMap;                                                     \
00049 }                                                                             \
00050 
00051 
00062 #define DEFINE_SEQUENCE_CREATOR(PREFIX, SEQUENCE, SEQUENCE_CLASS)             \
00063 template<typename V>                                                          \
00064 class PREFIX##SEQUENCE##Creator                                               \
00065 {                                                                             \
00066 public:                                                                       \
00067    PREFIX##SEQUENCE##Creator(const V& val)                                    \
00068    {                                                                          \
00069       mySequence.push_back(val);                                              \
00070    }                                                                          \
00071                                                                               \
00072    PREFIX##SEQUENCE##Creator<V>& operator()(const V& val)                     \
00073    {                                                                          \
00074       mySequence.push_back(val);                                              \
00075       return *this;                                                           \
00076    }                                                                          \
00077                                                                               \
00078    operator SEQUENCE_CLASS<V>()                                               \
00079    {                                                                          \
00080       return mySequence;                                                      \
00081    }                                                                          \
00082                                                                               \
00083 private:                                                                      \
00084    SEQUENCE_CLASS<V> mySequence;                                              \
00085 };                                                                            \
00086 
00087 
00088 namespace makVrv 
00089 {
00090 
00097    DEFINE_MAP_CREATOR(Std, std::map);
00098 
00105    DEFINE_SEQUENCE_CREATOR(Std, List, std::list);
00106 
00113    DEFINE_SEQUENCE_CREATOR(Std, Vector, std::vector);
00114 
00121    DEFINE_SEQUENCE_CREATOR(Std, Deque, std::deque);
00122 
00123 }

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)