AnnotationRouter.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 AnnotationRouter non-inline template implementation */
16 
17 //#include "AnnotationRouter.ih"
18 
19 // Custom includes
20 
21 #define prefix_
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 template <class AnnotationType>
25 prefix_ senf::ppi::module::AnnotationRouter<AnnotationType>::AnnotationRouter()
26 {
27  noroute(input);
28  noroute(defaultOutput);
29  input.onRequest(&AnnotationRouter::request);
30  input.throttlingDisc( senf::ppi::ThrottlingDiscipline::NONE);
31 }
32 
33 template <class AnnotationType>
34 prefix_ AnnotationType senf::ppi::module::AnnotationRouter<AnnotationType>::
35 connectorSetup(connector::ActiveOutput<> & conn, AnnotationType const & key)
36 {
37  if (this->connectors().find(key) != this->connectors().end())
38  throw DuplicateKeyException(key);
39  route(input, conn).autoThrottling( false);
40  return key;
41 }
42 
43 template <class AnnotationType>
44 prefix_ void senf::ppi::module::AnnotationRouter<AnnotationType>::request()
45 {
46  Packet const & p (input());
47  typename AnnotationRouter::ContainerType::iterator i (
48  this->connectors().find(p.annotation<AnnotationType>()));
49  if (SENF_UNLIKELY(i == this->connectors().end()))
50  defaultOutput.write(p);
51  else
52  i->second->write(p);
53 }
54 
55 //-/////////////////////////////////////////////////////////////////////////////////////////////////
56 #undef prefix_
57 
58 
59 // Local Variables:
60 // mode: c++
61 // fill-column: 100
62 // comment-column: 40
63 // c-file-style: "senf"
64 // indent-tabs-mode: nil
65 // ispell-local-dictionary: "american"
66 // compile-command: "scons -u test"
67 // End: