Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
instantiate.hpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2010, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage, Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $Id: instantiate.hpp 4354 2012-02-10 00:25:18Z mdixon $
35  *
36  */
37 #ifndef PCL_IMPL_INSTANTIATE_H_
38 #define PCL_IMPL_INSTANTIATE_H_
39 
40 #include <boost/preprocessor/seq/for_each.hpp>
41 #include <boost/preprocessor/seq/for_each_product.hpp>
42 #include <boost/preprocessor/seq/to_tuple.hpp>
43 #include <boost/preprocessor/cat.hpp>
44 #include <boost/preprocessor/expand.hpp>
45 
46 //#define PCL_POINT_TYPES (bool)(int)(float)(double)
47 //#define PCL_TEMPLATES (Type)(Othertype)
48 
49 //
50 // PCL_INSTANTIATE: call to instantiate template TEMPLATE for all
51 // POINT_TYPES
52 //
53 #define PCL_INSTANTIATE_IMPL(r, TEMPLATE, POINT_TYPE) \
54  BOOST_PP_CAT(PCL_INSTANTIATE_, TEMPLATE)(POINT_TYPE)
55 
56 #define PCL_INSTANTIATE(TEMPLATE, POINT_TYPES) \
57  BOOST_PP_SEQ_FOR_EACH(PCL_INSTANTIATE_IMPL, TEMPLATE, POINT_TYPES)
58 
59 
60 //
61 // PCL_INSTANTIATE_PRODUCT(templatename, (seq1)(seq2)...(seqN))
62 //
63 // instantiate templates
64 //
65 // A call to PCL_INSTANTIATE_PRODUCT(T, ((a)(b)) ((d)(e)) ) results in calls
66 //
67 // PCL_INSTANTIATE_T(a, d)
68 // PCL_INSTANTIATE_T(a, e)
69 // PCL_INSTANTIATE_T(b, d)
70 // PCL_INSTANTIATE_T(b, e)
71 //
72 // That is, PCL_INSTANTIATE_T is called for the cartesian product of the sequences seq1 ... seqN
73 //
74 // BE CAREFUL WITH YOUR PARENTHESIS! The argument PRODUCT is a
75 // sequence of sequences. e.g. if it were three sequences of,
76 // 1. letters, 2. numbers, and 3. our favorite transylvanians, it
77 // would be
78 //
79 // ((x)(y)(z))((1)(2)(3))((dracula)(radu))
80 //
81 #ifdef _MSC_VER
82 #define PCL_INSTANTIATE_PRODUCT_IMPL(r, product) \
83  BOOST_PP_CAT(PCL_INSTANTIATE_, BOOST_PP_SEQ_HEAD(product)) \
84  BOOST_PP_EXPAND(BOOST_PP_SEQ_TO_TUPLE(BOOST_PP_SEQ_TAIL(product)))
85 #else
86 #define PCL_INSTANTIATE_PRODUCT_IMPL(r, product) \
87  BOOST_PP_EXPAND(BOOST_PP_CAT(PCL_INSTANTIATE_, BOOST_PP_SEQ_HEAD(product)) \
88  BOOST_PP_SEQ_TO_TUPLE(BOOST_PP_SEQ_TAIL(product)))
89 #endif
90 
91 
92 #define PCL_INSTANTIATE_PRODUCT(TEMPLATE, PRODUCT) \
93  BOOST_PP_SEQ_FOR_EACH_PRODUCT(PCL_INSTANTIATE_PRODUCT_IMPL, ((TEMPLATE))PRODUCT)
94 
95 
96 #endif