InterfaceAPI.cti
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 InterfaceAPI inline template implementation */
16 
17 // Custom includes
18 
19 #define prefix_ inline
20 //-/////////////////////////////////////////////////////////////////////////////////////////////////
21 
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 // senf::emu::detail::InterfaceAccess<Interface>
24 
25 template <class Interface>
26 prefix_ senf::emu::detail::InterfaceAccess<Interface>::~InterfaceAccess()
27 {}
28 
29 template <class Interface>
30 prefix_ Interface & senf::emu::detail::InterfaceAccess<Interface>::interface()
31 {
32  try {
33  return dynamic_cast<Interface &>(*this);
34  }
35  SENF_WRAP_EXC(std::bad_cast)
36 }
37 
38 template <class Interface>
39 prefix_ Interface const & senf::emu::detail::InterfaceAccess<Interface>::interface()
40  const
41 {
42  try {
43  return dynamic_cast<Interface const &>(*this);
44  }
45  SENF_WRAP_EXC(std::bad_cast)
46 }
47 
48 //-/////////////////////////////////////////////////////////////////////////////////////////////////
49 // senf::emu::detail::CommfaceAccess<Receiver,Transmitter>
50 
51 template <class Receiver, class Transmitter>
52 prefix_ senf::emu::detail::CommfaceAccess<Receiver,Transmitter>::~CommfaceAccess()
53 {}
54 
55 template <class Receiver, class Transmitter>
56 prefix_ Receiver & senf::emu::detail::CommfaceAccess<Receiver,Transmitter>::receiver()
57 {
58  try {
59  return dynamic_cast<Receiver &>(*this);
60  }
61  SENF_WRAP_EXC(std::bad_cast)
62 }
63 
64 template <class Receiver, class Transmitter>
65 prefix_ Receiver const & senf::emu::detail::CommfaceAccess<Receiver,Transmitter>::receiver()
66  const
67 {
68  try {
69  return dynamic_cast<Receiver const &>(*this);
70  }
71  SENF_WRAP_EXC(std::bad_cast)
72 }
73 
74 template <class Receiver, class Transmitter>
75 prefix_ Transmitter & senf::emu::detail::CommfaceAccess<Receiver,Transmitter>::transmitter()
76 {
77  try {
78  return dynamic_cast<Transmitter &>(*this);
79  }
80  SENF_WRAP_EXC(std::bad_cast)
81 }
82 
83 template <class Receiver, class Transmitter>
84 prefix_ Transmitter const &
85 senf::emu::detail::CommfaceAccess<Receiver,Transmitter>::transmitter()
86  const
87 {
88  try {
89  return dynamic_cast<Transmitter const &>(*this);
90  }
91  SENF_WRAP_EXC(std::bad_cast)
92 }
93 
94 //-/////////////////////////////////////////////////////////////////////////////////////////////////
95 #undef prefix_
96 
97 
98 // Local Variables:
99 // mode: c++
100 // fill-column: 100
101 // comment-column: 40
102 // c-file-style: "senf"
103 // indent-tabs-mode: nil
104 // ispell-local-dictionary: "american"
105 // compile-command: "scons -u test"
106 // End: