SocketPolicy.ct
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief Policy Framework non-inline template implemenation
16  */
17 
18 #include "SocketPolicy.ih"
19 
20 // Custom includes
21 #include <senf/Utils/Exception.hh>
22 #include "senf/Utils/IgnoreValue.hh"
23 
24 #define prefix_
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 
27 #define SP_TemplateArgs(x1,x2,n,SomePolicy) BOOST_PP_COMMA_IF(n) class BOOST_PP_CAT(SomePolicy,_)
28 #define SP_TemplateParams(x1,x2,n,SomePolicy) BOOST_PP_COMMA_IF(n) BOOST_PP_CAT(SomePolicy,_)
29 
30 template < BOOST_PP_SEQ_FOR_EACH_I( SP_TemplateArgs, , SENF_SOCKET_POLICIES ) >
31 prefix_ void senf::SocketPolicy< BOOST_PP_SEQ_FOR_EACH_I( SP_TemplateParams, , SENF_SOCKET_POLICIES ) >::
32 checkBaseOf(SocketPolicyBase const & other)
33 {
34  // check, wether each policy of other is (dynamically!) convertible
35  // to the corresponding (static) policy of this class. Throws
36  // std::bad_cast on failure
37 
38 # define SP_CheckPolicy(x1,x2,SomePolicy) \
39  senf::IGNORE( dynamic_cast<BOOST_PP_CAT(SomePolicy,_) const &>( \
40  other.BOOST_PP_CAT(the,SomePolicy)()) );
41 
42  try {
43  BOOST_PP_SEQ_FOR_EACH( SP_CheckPolicy, , SENF_SOCKET_POLICIES )
44  }
45  SENF_WRAP_EXC_MSG(std::bad_cast, "in SP_CheckPolicy")
46 
47 # undef SP_CheckPolicy
48 }
49 
50 #undef SP_TemplateArgs
51 #undef SP_TemplateParams
52 
53 //-/////////////////////////////////////////////////////////////////////////////////////////////////
54 #undef prefix_
55 
56 
57 // Local Variables:
58 // mode: c++
59 // fill-column: 100
60 // c-file-style: "senf"
61 // indent-tabs-mode: nil
62 // ispell-local-dictionary: "american"
63 // compile-command: "scons -u test"
64 // comment-column: 40
65 // End: