[42] | 1 | #ifdef POSITION |
---|
| 2 | /* |
---|
| 3 | * $Id$ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "Behavioural/include/Component.h" |
---|
| 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
| 13 | |
---|
[43] | 14 | #undef FUNCTION |
---|
| 15 | #define FUNCTION "Component::interface_map" |
---|
[42] | 16 | void Component::interface_map (string component_src , |
---|
| 17 | string port_src , |
---|
| 18 | string component_dest, |
---|
| 19 | string port_dest ) |
---|
| 20 | { |
---|
[43] | 21 | log_printf(FUNC,Behavioural,FUNCTION,"Begin"); |
---|
| 22 | |
---|
[42] | 23 | // First entity |
---|
| 24 | Entity * entity_dest = find_entity(component_dest); |
---|
| 25 | |
---|
| 26 | string name_entity = _entity->get_name(); |
---|
| 27 | |
---|
| 28 | if (entity_dest == NULL) |
---|
[44] | 29 | throw (ErrorMorpheo ("<Component::interface_map> Component \""+name_entity+"\", port map with unknow component \""+component_dest+"\".")); |
---|
[42] | 30 | |
---|
| 31 | bool is_top_level_dest = (name_entity == component_dest); |
---|
| 32 | |
---|
| 33 | Interface * interface_dest = entity_dest->find_interface(port_dest); |
---|
| 34 | |
---|
| 35 | if (interface_dest == NULL) |
---|
[44] | 36 | throw (ErrorMorpheo ("<Component::interface_map> Component \""+name_entity+"\", port map with component \""+component_dest+"\" and a unknow interface \""+port_dest+"\".")); |
---|
[42] | 37 | |
---|
| 38 | // Second entity |
---|
| 39 | Entity * entity_src = find_entity(component_src); |
---|
| 40 | |
---|
| 41 | if (entity_src == NULL) |
---|
[44] | 42 | throw (ErrorMorpheo ("<Component::interface_map> Component \""+name_entity+"\", port map with unknow component \""+component_src+"\".")); |
---|
[42] | 43 | |
---|
| 44 | bool is_top_level_src = (name_entity == component_src); |
---|
| 45 | |
---|
| 46 | Interface * interface_src = entity_src->find_interface(port_src); |
---|
| 47 | |
---|
| 48 | if (interface_src == NULL) |
---|
[44] | 49 | throw (ErrorMorpheo ("<Component::interface_map> Component \""+name_entity+"\", port map with component \""+component_src+"\" and a unknow interface \""+port_src+"\".")); |
---|
[42] | 50 | |
---|
| 51 | // all is ok - link |
---|
| 52 | if (is_top_level_dest == false) |
---|
| 53 | interface_dest->interface_map(static_cast<void *>(entity_src ), |
---|
| 54 | static_cast<void *>(interface_src)); |
---|
| 55 | |
---|
| 56 | if (is_top_level_src == false) |
---|
| 57 | interface_src->interface_map(static_cast<void *>(entity_dest ), |
---|
| 58 | static_cast<void *>(interface_dest)); |
---|
[43] | 59 | |
---|
| 60 | log_printf(FUNC,Behavioural,FUNCTION,"End"); |
---|
[42] | 61 | }; |
---|
| 62 | |
---|
| 63 | }; // end namespace behavioural |
---|
| 64 | }; // end namespace morpheo |
---|
| 65 | #endif |
---|