| 135 | *****************************************************************************/ |
| 136 | |
| 137 | uint16_t PluginFactory::generateUID() |
| 138 | { |
| 139 | uint16_t uid; |
| 140 | bool isFound; |
| 141 | |
| 142 | do |
| 143 | { |
| 144 | isFound = false; |
| 145 | uid = random(UINT16_MAX); |
| 146 | |
| 147 | if (0U < m_plugins.size()) |
| 148 | { |
| 149 | ListOfPlugins::const_iterator it = m_plugins.begin(); |
| 150 | |
| 151 | /* Ensure that UID is really unique. */ |
| 152 | while ((it != m_plugins.end()) && (false == isFound)) |
| 153 | { |
| 154 | const IPluginMaintenance* currentPlugin = *it; |
| 155 | |
| 156 | if (currentPlugin->getUID() == uid) |
| 157 | { |
| 158 | isFound = true; |
| 159 | } |
| 160 | |
| 161 | ++it; |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | while (true == isFound); |
| 166 | |
| 167 | return uid; |
| 168 | } |
| 169 | |
| 170 | /****************************************************************************** |
| 171 | * External Functions |