Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Policy.cpp
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "cheetah/rfim/policy/Policy.h"
25 
26 
27 namespace ska {
28 namespace cheetah {
29 namespace rfim {
30 namespace policy {
31 
32 namespace {
33  template<typename ReturnType, typename AdapterDataReturnType>
34  struct DoReturn
35  {
36  template<typename Adapter, typename DataType>
37  static inline
38  ReturnType exec(Adapter& adapter, DataType const&) {
39  return adapter.data();
40  }
41  };
42 
43  template<typename ReturnType>
44  struct DoReturn<ReturnType, void>
45  {
46  template<typename Adapter>
47  static inline
48  ReturnType& exec(Adapter const&, ReturnType& arg) {
49  return arg;
50  }
51  };
52 
53 } // namespace
54 
55 template<typename PolicyType>
56 Policy<PolicyType>::Policy()
57 {
58 }
59 
60 template<typename PolicyType>
61 template<typename HandlerType>
62 typename Policy<PolicyType>::ReturnType Policy<PolicyType>::exec(HandlerType handler, ArgumentType& arg)
63 {
64  AdapterType adapter( _policy.adapter(arg) );
65  handler(arg, adapter);
66  return DoReturn<ReturnType, typename PolicyInfo<PolicyType>::AdapterDataReturnType>::exec(adapter, arg);
67 }
68 
69 template<typename PolicyType>
70 typename Policy<PolicyType>::ReturnType Policy<PolicyType>::null_op(ArgumentType& arg)
71 {
72  AdapterType adapter( _policy.adapter(arg) );
73  return DoReturn<ReturnType, typename PolicyInfo<PolicyType>::AdapterDataReturnType>::exec(adapter, arg);
74 }
75 
76 } // namespace policy
77 } // namespace rfim
78 } // namespace cheetah
79 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35
ReturnType exec(Handler, ArgumentType &data)
start a single Policy sequence. 1) a data adapter is requested from the policy 2) the argument and th...
ReturnType null_op(ArgumentType &data)
Generates the appropriate ReturnType for the Policy but performs no actions in the data...
Definition: Policy.cpp:70