[88] | 1 | /* |
---|
| 2 | * $Id: Instance_test_use.cpp 88 2008-12-10 18:31:39Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/Configuration/include/Instance.h" |
---|
| 9 | |
---|
| 10 | namespace morpheo { |
---|
| 11 | namespace behavioural { |
---|
| 12 | namespace configuration { |
---|
| 13 | |
---|
| 14 | #undef FUNCTION |
---|
| 15 | #define FUNCTION "Instance::test_use" |
---|
| 16 | void Instance::test_use (void) |
---|
| 17 | { |
---|
| 18 | log_begin(Configuration,FUNCTION); |
---|
| 19 | |
---|
| 20 | std::vector<std::string> list_not_use; |
---|
| 21 | |
---|
| 22 | for (list_links_t::iterator it1 = _list_links->begin(); |
---|
| 23 | it1 != _list_links->end(); |
---|
| 24 | ++it1) |
---|
| 25 | for (list_link_t::iterator it2 = it1->second.begin(); |
---|
| 26 | it2 != it1->second.end(); |
---|
| 27 | ++it2) |
---|
| 28 | { |
---|
| 29 | Link_affectation * link = it2->second; |
---|
| 30 | if (link->_use == false) |
---|
| 31 | { |
---|
| 32 | std::string str = link->_name; |
---|
| 33 | |
---|
| 34 | list_not_use.push_back(toString(_("Link \"%s[%s]\""),str.c_str(),link->_src.c_str())); |
---|
| 35 | } |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | test_use("", |
---|
| 39 | _list_parameters, |
---|
| 40 | _list_components, |
---|
| 41 | list_not_use); |
---|
| 42 | |
---|
| 43 | if (list_not_use.size() != 0) |
---|
| 44 | { |
---|
| 45 | std::string str = ""; |
---|
| 46 | for (uint32_t i=0; i<list_not_use.size(); ++i) |
---|
| 47 | { |
---|
| 48 | str += list_not_use[i]+_("\n"); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | throw ERRORMORPHEO(FUNCTION,toString(_("A lot of parameters is not used :\n%s"),str.c_str())); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | log_end(Configuration,FUNCTION); |
---|
| 55 | }; |
---|
| 56 | |
---|
| 57 | #undef FUNCTION |
---|
| 58 | #define FUNCTION "Instance::test_use" |
---|
| 59 | void Instance::test_use (std::string name, |
---|
| 60 | list_parameters_t * list_parameters, |
---|
| 61 | list_components_t * list_components, |
---|
| 62 | std::vector<std::string> & list_not_use) |
---|
| 63 | { |
---|
| 64 | log_begin(Configuration,FUNCTION); |
---|
| 65 | |
---|
| 66 | for (list_parameters_t::iterator it = list_parameters->begin(); |
---|
| 67 | it != list_parameters->end(); |
---|
| 68 | ++it) |
---|
| 69 | { |
---|
| 70 | Parameter_affectation * param = it->second; |
---|
| 71 | if (param->_use == false) |
---|
| 72 | { |
---|
| 73 | std::string str = ((name == "")?"":(name+".")) + param->_name; |
---|
| 74 | |
---|
| 75 | list_not_use.push_back(toString(_("Parameter \"%s\""),str.c_str())); |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | for (list_components_t::iterator it1 = list_components->begin(); |
---|
| 80 | it1 != list_components->end(); |
---|
| 81 | ++it1) |
---|
| 82 | for (list_instances_t::iterator it2 = it1->second.begin(); |
---|
| 83 | it2 != it1->second.end(); |
---|
| 84 | ++it2) |
---|
| 85 | { |
---|
| 86 | Instance_component * instance = it2->second; |
---|
| 87 | |
---|
| 88 | test_use(((name == "")?"":(name+"."))+instance->_name+"["+instance->_id+"]", |
---|
| 89 | instance->_list_parameters, |
---|
| 90 | instance->_list_components, |
---|
| 91 | list_not_use); |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | log_end(Configuration,FUNCTION); |
---|
| 95 | }; |
---|
| 96 | |
---|
| 97 | }; // end namespace configuration |
---|
| 98 | }; // end namespace behavioural |
---|
| 99 | }; // end namespace morpheo |
---|