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" |
---|
15 | bool Component::test_map (bool recursive) |
---|
16 | { |
---|
17 | log_printf(INFO,Behavioural,FUNCTION, "Test port map and interface."); |
---|
18 | return test_map (0, recursive); |
---|
19 | } |
---|
20 | |
---|
21 | bool Component::test_map (uint32_t depth, bool recursive) |
---|
22 | { |
---|
23 | log_printf(FUNC,Behavioural,FUNCTION,"Begin"); |
---|
24 | |
---|
25 | std::string tab = std::string(depth,' '); |
---|
26 | std::string name = _entity->get_name(); |
---|
27 | bool test_ok = true; |
---|
28 | |
---|
29 | bool is_behavioural = _list_component->empty (); |
---|
30 | if (is_behavioural) |
---|
31 | { |
---|
32 | log_printf(INFO,Interface,FUNCTION, "%s* Component \"%s\" is a behavioural description",tab.c_str(),name.c_str()); |
---|
33 | } |
---|
34 | else |
---|
35 | { |
---|
36 | log_printf(INFO,Interface,FUNCTION, "%s* Component \"%s\" is a structural description",tab.c_str(),name.c_str()); |
---|
37 | } |
---|
38 | |
---|
39 | |
---|
40 | // log_printf(INFO,Behavioural,FUNCTION, "%s* Test port I/O",tab.c_str()); |
---|
41 | |
---|
42 | test_ok &= _entity->test_map(depth+1,true,is_behavioural); |
---|
43 | |
---|
44 | // log_printf(INFO,Behavioural,FUNCTION, "%s* Test all internal component",tab.c_str()); |
---|
45 | |
---|
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 | } |
---|
60 | } |
---|
61 | |
---|
62 | log_printf(FUNC,Behavioural,FUNCTION,"End"); |
---|
63 | |
---|
64 | if (test_ok == false) |
---|
65 | throw (ERRORMORPHEO (FUNCTION,_("A lot of port is not connected.\n"))); |
---|
66 | |
---|
67 | return test_ok; |
---|
68 | }; |
---|
69 | |
---|
70 | // #undef FUNCTION |
---|
71 | // #define FUNCTION "Component::test_equi" |
---|
72 | // bool Component::test_equi (bool recursive) |
---|
73 | // { |
---|
74 | // log_printf(INFO,Behavioural,FUNCTION, "Test port equi and interface."); |
---|
75 | // return test_equi (0, recursive); |
---|
76 | // } |
---|
77 | |
---|
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 | |
---|
113 | }; // end namespace behavioural |
---|
114 | }; // end namespace morpheo |
---|