Directory: | ./ |
---|---|
File: | src/Function/DataFunctionCall_impl.h |
Date: | 2025-03-14 12:18:05 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 12 | 15 | 80.0% |
Branches: | 15 | 34 | 44.1% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /*************************************** | ||
2 | Auteur : Pierre Aubert | ||
3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
4 | Licence : CeCILL-C | ||
5 | ****************************************/ | ||
6 | |||
7 | #ifndef __DATA_FUNCTION_CALL_H_IMPL__ | ||
8 | #define __DATA_FUNCTION_CALL_H_IMPL__ | ||
9 | |||
10 | #include "phoenix_type_stream.h" | ||
11 | #include "DataFunctionCall.h" | ||
12 | #include "phoenix_function_call.h" | ||
13 | |||
14 | ///Default constructor of DataFunctionCall | ||
15 | /** @param function : function to be called on a given data | ||
16 | * @param name : name of the function | ||
17 | */ | ||
18 | template<typename _Data> | ||
19 | 6 | DataFunctionCall<_Data>::DataFunctionCall(bool (*function)(const _Data &), const PString & name) | |
20 | 6 | :AbstractDataFunction(name), p_function(function) | |
21 | { | ||
22 | //The prototype is compose only of the given data which is normal for dispatching | ||
23 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
6 | setPrototype(phoenix_getTypeToStr<_Data>()); |
24 | 6 | initialisationDataFunctionCall(); | |
25 | 6 | } | |
26 | |||
27 | ///Destructor of DataFunctionCall | ||
28 | template<typename _Data> | ||
29 | ✗ | DataFunctionCall<_Data>::~DataFunctionCall(){ | |
30 | |||
31 | } | ||
32 | |||
33 | ///Call the function with parameter | ||
34 | /** @param[out] log : logger | ||
35 | * @param data : data given to the function | ||
36 | * @return true on success, false otherwise | ||
37 | */ | ||
38 | template<typename _Data> | ||
39 | 6 | bool DataFunctionCall<_Data>::call(PLog & log, const Data & data){ | |
40 |
1/1✓ Branch 1 taken 3 times.
|
6 | _Data value(phoenix_getValueFromData<_Data>(data)); |
41 |
2/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
6 | if(p_function(value)){ |
42 |
9/9✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 25 taken 3 times.
|
6 | log.getLogDebug() << "DataFunctionCall<_Data>::call : function 'bool '"<<getName()<<"(const "<<getPrototype()<<" &) success" << std::endl; |
43 | 6 | return true; | |
44 | }else{ | ||
45 | ✗ | log.getLogError() << "DataFunctionCall<_Data>::call : function 'bool '"<<getName()<<"(const "<<getPrototype()<<" &) failed" << std::endl; | |
46 | ✗ | return false; | |
47 | } | ||
48 | } | ||
49 | |||
50 | ///Initialisation function of the class DataFunctionCall | ||
51 | template<typename _Data> | ||
52 | 6 | void DataFunctionCall<_Data>::initialisationDataFunctionCall(){ | |
53 | |||
54 | 6 | } | |
55 | |||
56 | |||
57 | |||
58 | |||
59 | |||
60 | #endif | ||
61 | |||
62 | |||
63 | |||
64 |