1 | /* |
---|
2 | * $Id: Component_test_map.cpp 97 2008-12-19 15:34:00Z rosiere $ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | */ |
---|
7 | |
---|
8 | #include "Behavioural/include/Component.h" |
---|
9 | #include "Common/include/Tabulation.h" |
---|
10 | |
---|
11 | namespace morpheo { |
---|
12 | namespace behavioural { |
---|
13 | |
---|
14 | #undef FUNCTION |
---|
15 | #define FUNCTION "Component::test_map" |
---|
16 | bool Component::test_map (bool recursive) |
---|
17 | { |
---|
18 | log_printf(INFO,Behavioural,FUNCTION, "Test port map and interface."); |
---|
19 | return test_map (0, recursive); |
---|
20 | } |
---|
21 | |
---|
22 | bool Component::test_map (uint32_t depth, bool recursive) |
---|
23 | { |
---|
24 | log_printf(FUNC,Behavioural,FUNCTION,"Begin"); |
---|
25 | |
---|
26 | std::string tab = morpheo::tab(depth); |
---|
27 | std::string name = _entity->get_name(); |
---|
28 | bool test_ok = true; |
---|
29 | |
---|
30 | bool is_behavioural = _list_component->empty (); |
---|
31 | if (is_behavioural) |
---|
32 | { |
---|
33 | log_printf(INFO,Interface,FUNCTION, "%s* Component \"%s\" is a behavioural description",tab.c_str(),name.c_str()); |
---|
34 | } |
---|
35 | else |
---|
36 | { |
---|
37 | log_printf(INFO,Interface,FUNCTION, "%s* Component \"%s\" is a structural description",tab.c_str(),name.c_str()); |
---|
38 | } |
---|
39 | |
---|
40 | |
---|
41 | // log_printf(INFO,Behavioural,FUNCTION, "%s* Test port I/O",tab.c_str()); |
---|
42 | |
---|
43 | test_ok &= _entity->test_map(depth+1,true,is_behavioural); |
---|
44 | |
---|
45 | // log_printf(INFO,Behavioural,FUNCTION, "%s* Test all internal component",tab.c_str()); |
---|
46 | |
---|
47 | for (std::list<Tcomponent_t *>::iterator i= _list_component->begin(); |
---|
48 | i != _list_component->end(); |
---|
49 | ++i) |
---|
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 | } |
---|
63 | |
---|
64 | log_printf(FUNC,Behavioural,FUNCTION,"End"); |
---|
65 | |
---|
66 | if (test_ok == false) |
---|
67 | throw (ERRORMORPHEO (FUNCTION,_("A lot of port is not connected.\n"))); |
---|
68 | |
---|
69 | return test_ok; |
---|
70 | }; |
---|
71 | |
---|
72 | // #undef FUNCTION |
---|
73 | // #define FUNCTION "Component::test_equi" |
---|
74 | // bool Component::test_equi (bool recursive) |
---|
75 | // { |
---|
76 | // log_printf(INFO,Behavioural,FUNCTION, "Test port equi and interface."); |
---|
77 | // return test_equi (0, recursive); |
---|
78 | // } |
---|
79 | |
---|
80 | // bool Component::test_equi (uint32_t depth, bool recursive) |
---|
81 | // { |
---|
82 | // log_printf(FUNC,Behavioural,FUNCTION,"Begin"); |
---|
83 | |
---|
84 | // std::string tab = tab(depth); |
---|
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 | |
---|
115 | }; // end namespace behavioural |
---|
116 | }; // end namespace morpheo |
---|