| 177 | } |
| 178 | |
| 179 | const Counter* CounterDirectory::RegisterCounter(const std::string& applicationName, |
| 180 | const uint16_t uid, |
| 181 | const std::string& parentCategoryName, |
| 182 | uint16_t counterClass, |
| 183 | uint16_t interpolation, |
| 184 | double multiplier, |
| 185 | const std::string& name, |
| 186 | const std::string& description, |
| 187 | const arm::pipe::Optional<std::string>& units, |
| 188 | const arm::pipe::Optional<uint16_t>& numberOfCores, |
| 189 | const arm::pipe::Optional<uint16_t>& deviceUid, |
| 190 | const arm::pipe::Optional<uint16_t>& counterSetUid) |
| 191 | { |
| 192 | // Check that the given parent category name is valid |
| 193 | if (parentCategoryName.empty() || |
| 194 | !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(parentCategoryName)) |
| 195 | { |
| 196 | throw arm::pipe::InvalidArgumentException("Trying to register a counter with an invalid parent category name"); |
| 197 | } |
| 198 | |
| 199 | // Check that the given class is valid |
| 200 | if (counterClass != 0 && counterClass != 1) |
| 201 | { |
| 202 | throw arm::pipe::InvalidArgumentException("Trying to register a counter with an invalid class"); |
| 203 | } |
| 204 | |
| 205 | // Check that the given interpolation is valid |
| 206 | if (interpolation != 0 && interpolation != 1) |
| 207 | { |
| 208 | throw arm::pipe::InvalidArgumentException("Trying to register a counter with an invalid interpolation"); |
| 209 | } |
| 210 | |
| 211 | // Check that the given multiplier is valid |
| 212 | if (multiplier == .0f) |
| 213 | { |
| 214 | throw arm::pipe::InvalidArgumentException("Trying to register a counter with an invalid multiplier"); |
| 215 | } |
| 216 | |
| 217 | // Check that the given name is valid |
| 218 | if (name.empty() || |
| 219 | !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(name)) |
| 220 | { |
| 221 | throw arm::pipe::InvalidArgumentException("Trying to register a counter with an invalid name"); |
| 222 | } |
| 223 | |
| 224 | // Check that the given description is valid |
| 225 | if (description.empty() || |
| 226 | !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceCharPolicy>(description)) |
| 227 | { |
| 228 | throw arm::pipe::InvalidArgumentException("Trying to register a counter with an invalid description"); |
| 229 | } |
| 230 | |
| 231 | // Check that the given units are valid |
| 232 | if (units.has_value() |
| 233 | && !arm::pipe::IsValidSwTraceString<arm::pipe::SwTraceNameCharPolicy>(units.value())) |
| 234 | { |
| 235 | throw arm::pipe::InvalidArgumentException("Trying to register a counter with a invalid units"); |
| 236 | } |
no test coverage detected