[62] | 1 | /* |
---|
| 2 | * $Id: Component_test_map.cpp 97 2008-12-19 15:34:00Z 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) |
---|
[97] | 50 | if (((*i)->_instance & INSTANCE_COMPONENT) != 0) |
---|
| 51 | { |
---|
| 52 | test_ok &= (*i)->_entity->test_map(depth+1,false,is_behavioural); |
---|
| 53 | if (recursive) |
---|
| 54 | try |
---|
| 55 | { |
---|
| 56 | test_ok &= (*i)->_component->test_map(depth+1,recursive); |
---|
| 57 | } |
---|
| 58 | catch (morpheo::ErrorMorpheo & error) |
---|
| 59 | { |
---|
| 60 | // no error propagation, only top level |
---|
| 61 | } |
---|
| 62 | } |
---|
[62] | 63 | |
---|
| 64 | log_printf(FUNC,Behavioural,FUNCTION,"End"); |
---|
| 65 | |
---|
| 66 | if (test_ok == false) |
---|
[82] | 67 | throw (ERRORMORPHEO (FUNCTION,_("A lot of port is not connected.\n"))); |
---|
[62] | 68 | |
---|
| 69 | return test_ok; |
---|
| 70 | }; |
---|
| 71 | |
---|
[82] | 72 | // #undef FUNCTION |
---|
| 73 | // #define FUNCTION "Component::test_equi" |
---|
| 74 | // bool Component::test_equi (bool recursive) |
---|
| 75 | // { |
---|
[88] | 76 | // log_printf(INFO,Behavioural,FUNCTION, "Test port equi and interface."); |
---|
[82] | 77 | // return test_equi (0, recursive); |
---|
| 78 | // } |
---|
[62] | 79 | |
---|
[82] | 80 | // bool Component::test_equi (uint32_t depth, bool recursive) |
---|
| 81 | // { |
---|
| 82 | // log_printf(FUNC,Behavioural,FUNCTION,"Begin"); |
---|
| 83 | |
---|
[94] | 84 | // std::string tab = tab(depth); |
---|
[82] | 85 | // std::string name = _entity->get_name(); |
---|
| 86 | // bool test_ok = true; |
---|
| 87 | |
---|
| 88 | // test_ok &= _entity->test_equi(depth+1); |
---|
| 89 | |
---|
| 90 | // for (std::list<Tcomponent_t *>::iterator i= _list_component->begin(); |
---|
| 91 | // i != _list_component->end(); |
---|
| 92 | // ++i) |
---|
| 93 | // { |
---|
| 94 | // test_ok &= (*i)->_entity->test_equi(depth+1); |
---|
| 95 | // if (recursive) |
---|
| 96 | // try |
---|
| 97 | // { |
---|
| 98 | // test_ok &= (*i)->_component->test_equi(depth+1,recursive); |
---|
| 99 | // } |
---|
| 100 | // catch (morpheo::ErrorMorpheo & error) |
---|
| 101 | // { |
---|
| 102 | // // no error propagation, only top level |
---|
| 103 | // } |
---|
| 104 | // } |
---|
| 105 | |
---|
| 106 | // log_printf(FUNC,Behavioural,FUNCTION,"End"); |
---|
| 107 | |
---|
| 108 | // if (test_ok == false) |
---|
| 109 | // throw (ERRORMORPHEO (FUNCTION,_("A lot of port is not connected.\n"))); |
---|
| 110 | |
---|
| 111 | // return test_ok; |
---|
| 112 | // }; |
---|
| 113 | |
---|
| 114 | |
---|
[62] | 115 | }; // end namespace behavioural |
---|
| 116 | }; // end namespace morpheo |
---|