| 21 | static Mutex instance_mutex; |
| 22 | |
| 23 | void addService(std::shared_ptr<const ServiceManifest> manifest, bool autoStart) { |
| 24 | assert(manifest != nullptr); |
| 25 | // We'll move the manifest pointer, but we'll need to id later |
| 26 | const auto& id = manifest->id; |
| 27 | |
| 28 | LOGGER.info("Adding {}", id); |
| 29 | |
| 30 | manifest_mutex.lock(); |
| 31 | if (service_manifest_map[id] == nullptr) { |
| 32 | service_manifest_map[id] = std::move(manifest); |
| 33 | } else { |
| 34 | LOGGER.error("Service id in use: {}", id); |
| 35 | } |
| 36 | manifest_mutex.unlock(); |
| 37 | |
| 38 | if (autoStart) { |
| 39 | startService(id); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | void addService(const ServiceManifest& manifest, bool autoStart) { |
| 44 | addService(std::make_shared<const ServiceManifest>(manifest), autoStart); |
no test coverage detected