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