| 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 | using namespace Swarm; | ||
| 15 | |||
| 16 | ///Default constructor of DataFunctionCall | ||
| 17 | /** @param function : function to be called on a given data | ||
| 18 | * @param name : name of the function | ||
| 19 | */ | ||
| 20 | template<typename _Data> | ||
| 21 | 2 | DataFunctionCall<_Data>::DataFunctionCall(PUncastableBool (*function)(const _Data &), const PString & name) | |
| 22 | 2 | :AbstractDataFunction(name), p_function(function) | |
| 23 | { | ||
| 24 | //The prototype is compose only of the given data which is normal for dispatching | ||
| 25 |
3/3✓ Branch 0 (3→4) taken 2 times.
✓ Branch 2 (4→5) taken 2 times.
✓ Branch 4 (5→6) taken 2 times.
|
2 | setPrototype(phoenix_getTypeToStr<_Data>()); |
| 26 | 2 | initialisationDataFunctionCall(); | |
| 27 | 2 | } | |
| 28 | |||
| 29 | ///Destructor of DataFunctionCall | ||
| 30 | template<typename _Data> | ||
| 31 | ✗ | DataFunctionCall<_Data>::~DataFunctionCall(){ | |
| 32 | |||
| 33 | ✗ | } | |
| 34 | |||
| 35 | ///Call the function with parameter | ||
| 36 | /** @param[out] log : logger | ||
| 37 | * @param data : data given to the function | ||
| 38 | * @return true on success, false otherwise | ||
| 39 | */ | ||
| 40 | template<typename _Data> | ||
| 41 | 2 | bool DataFunctionCall<_Data>::call(PLog & log, const Data & data){ | |
| 42 |
1/1✓ Branch 0 (2→3) taken 2 times.
|
2 | _Data value(phoenix_getValueFromData<_Data>(data)); |
| 43 |
2/3✓ Branch 0 (3→4) taken 2 times.
✓ Branch 2 (6→7) taken 2 times.
✗ Branch 3 (6→17) not taken.
|
2 | if(p_function(value) == UNCASTABLE_TRUE){ |
| 44 |
9/9✓ Branch 0 (7→8) taken 2 times.
✓ Branch 2 (8→9) taken 2 times.
✓ Branch 4 (9→10) taken 2 times.
✓ Branch 6 (10→11) taken 2 times.
✓ Branch 8 (11→12) taken 2 times.
✓ Branch 10 (12→13) taken 2 times.
✓ Branch 12 (13→14) taken 2 times.
✓ Branch 14 (14→15) taken 2 times.
✓ Branch 16 (15→16) taken 2 times.
|
2 | log.getLogDebug() << "DataFunctionCall<_Data>::call : function 'bool '"<<getName()<<"(const "<<getPrototype()<<" &) success" << std::endl; |
| 45 | 2 | return true; | |
| 46 | }else{ | ||
| 47 | ✗ | log.getLogError() << "DataFunctionCall<_Data>::call : function 'bool '"<<getName()<<"(const "<<getPrototype()<<" &) failed" << std::endl; | |
| 48 | ✗ | return false; | |
| 49 | } | ||
| 50 | 1 | } | |
| 51 | |||
| 52 | ///Initialisation function of the class DataFunctionCall | ||
| 53 | template<typename _Data> | ||
| 54 | 2 | void DataFunctionCall<_Data>::initialisationDataFunctionCall(){ | |
| 55 | |||
| 56 | 2 | } | |
| 57 | |||
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | |||
| 62 | #endif | ||
| 63 | |||
| 64 | |||
| 65 | |||
| 66 |