[62] | 1 | /* |
---|
| 2 | * $Id: Component_test_map.cpp 88 2008-12-10 18:31:39Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/include/Component.h" |
---|
| 9 | |
---|
| 10 | namespace morpheo { |
---|
| 11 | namespace behavioural { |
---|
| 12 | |
---|
| 13 | #undef FUNCTION |
---|
| 14 | #define FUNCTION "Component::test_map" |
---|
[78] | 15 | bool Component::test_map (bool recursive) |
---|
[62] | 16 | { |
---|
[88] | 17 | log_printf(INFO,Behavioural,FUNCTION, "Test port map and interface."); |
---|
[78] | 18 | return test_map (0, recursive); |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | bool Component::test_map (uint32_t depth, bool recursive) |
---|
| 22 | { |
---|
[62] | 23 | log_printf(FUNC,Behavioural,FUNCTION,"Begin"); |
---|
| 24 | |
---|
[88] | 25 | std::string tab = std::string(depth,' '); |
---|
[75] | 26 | std::string name = _entity->get_name(); |
---|
[62] | 27 | bool test_ok = true; |
---|
[78] | 28 | |
---|
[82] | 29 | bool is_behavioural = _list_component->empty (); |
---|
| 30 | if (is_behavioural) |
---|
[78] | 31 | { |
---|
[88] | 32 | log_printf(INFO,Interface,FUNCTION, "%s* Component \"%s\" is a behavioural description",tab.c_str(),name.c_str()); |
---|
[78] | 33 | } |
---|
[62] | 34 | else |
---|
| 35 | { |
---|
[88] | 36 | log_printf(INFO,Interface,FUNCTION, "%s* Component \"%s\" is a structural description",tab.c_str(),name.c_str()); |
---|
[82] | 37 | } |
---|
[62] | 38 | |
---|
[82] | 39 | |
---|
[88] | 40 | // log_printf(INFO,Behavioural,FUNCTION, "%s* Test port I/O",tab.c_str()); |
---|
[82] | 41 | |
---|
| 42 | test_ok &= _entity->test_map(depth+1,true,is_behavioural); |
---|
| 43 | |
---|
[88] | 44 | // log_printf(INFO,Behavioural,FUNCTION, "%s* Test all internal component",tab.c_str()); |
---|
[62] | 45 | |
---|
[82] | 46 | for (std::list<Tcomponent_t *>::iterator i= _list_component->begin(); |
---|
| 47 | i != _list_component->end(); |
---|
| 48 | ++i) |
---|
| 49 | { |
---|
| 50 | test_ok &= (*i)->_entity->test_map(depth+1,false,is_behavioural); |
---|
| 51 | if (recursive) |
---|
| 52 | try |
---|
| 53 | { |
---|
| 54 | test_ok &= (*i)->_component->test_map(depth+1,recursive); |
---|
| 55 | } |
---|
| 56 | catch (morpheo::ErrorMorpheo & error) |
---|
| 57 | { |
---|
| 58 | // no error propagation, only top level |
---|
| 59 | } |
---|
[62] | 60 | } |
---|
| 61 | |
---|
| 62 | log_printf(FUNC,Behavioural,FUNCTION,"End"); |
---|
| 63 | |
---|
| 64 | if (test_ok == false) |
---|
[82] | 65 | throw (ERRORMORPHEO (FUNCTION,_("A lot of port is not connected.\n"))); |
---|
[62] | 66 | |
---|
| 67 | return test_ok; |
---|
| 68 | }; |
---|
| 69 | |
---|
[82] | 70 | // #undef FUNCTION |
---|
| 71 | // #define FUNCTION "Component::test_equi" |
---|
| 72 | // bool Component::test_equi (bool recursive) |
---|
| 73 | // { |
---|
[88] | 74 | // log_printf(INFO,Behavioural,FUNCTION, "Test port equi and interface."); |
---|
[82] | 75 | // return test_equi (0, recursive); |
---|
| 76 | // } |
---|
[62] | 77 | |
---|
[82] | 78 | // bool Component::test_equi (uint32_t depth, bool recursive) |
---|
| 79 | // { |
---|
| 80 | // log_printf(FUNC,Behavioural,FUNCTION,"Begin"); |
---|
| 81 | |
---|
| 82 | // std::string tab = std::string(depth,'\t'); |
---|
| 83 | // std::string name = _entity->get_name(); |
---|
| 84 | // bool test_ok = true; |
---|
| 85 | |
---|
| 86 | // test_ok &= _entity->test_equi(depth+1); |
---|
| 87 | |
---|
| 88 | // for (std::list<Tcomponent_t *>::iterator i= _list_component->begin(); |
---|
| 89 | // i != _list_component->end(); |
---|
| 90 | // ++i) |
---|
| 91 | // { |
---|
| 92 | // test_ok &= (*i)->_entity->test_equi(depth+1); |
---|
| 93 | // if (recursive) |
---|
| 94 | // try |
---|
| 95 | // { |
---|
| 96 | // test_ok &= (*i)->_component->test_equi(depth+1,recursive); |
---|
| 97 | // } |
---|
| 98 | // catch (morpheo::ErrorMorpheo & error) |
---|
| 99 | // { |
---|
| 100 | // // no error propagation, only top level |
---|
| 101 | // } |
---|
| 102 | // } |
---|
| 103 | |
---|
| 104 | // log_printf(FUNC,Behavioural,FUNCTION,"End"); |
---|
| 105 | |
---|
| 106 | // if (test_ok == false) |
---|
| 107 | // throw (ERRORMORPHEO (FUNCTION,_("A lot of port is not connected.\n"))); |
---|
| 108 | |
---|
| 109 | // return test_ok; |
---|
| 110 | // }; |
---|
| 111 | |
---|
| 112 | |
---|
[62] | 113 | }; // end namespace behavioural |
---|
| 114 | }; // end namespace morpheo |
---|