From 0ade63294c2ccba09ca707584a82d40196b03bb2 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Tue, 23 May 2017 10:28:21 +0100 Subject: [PATCH] Minor cleanups. --- src/control.cc | 2 +- src/load_service.cc | 2 +- src/service.cc | 10 +++++----- src/service.h | 21 ++++++++------------- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/control.cc b/src/control.cc index 0580301..a827a07 100644 --- a/src/control.cc +++ b/src/control.cc @@ -102,7 +102,7 @@ bool ControlConn::processFindLoad(int pktType) } else { // FINDSERVICE - record = service_set->findService(serviceName.c_str()); + record = service_set->find_service(serviceName.c_str()); } if (record != nullptr) { diff --git a/src/load_service.cc b/src/load_service.cc index 1124785..b4322be 100644 --- a/src/load_service.cc +++ b/src/load_service.cc @@ -309,7 +309,7 @@ ServiceRecord * ServiceSet::loadServiceRecord(const char * name) using std::pair; // First try and find an existing record... - ServiceRecord * rval = findService(string(name)); + ServiceRecord * rval = find_service(string(name)); if (rval != 0) { if (rval->isDummy()) { throw ServiceCyclicDependency(name); diff --git a/src/service.cc b/src/service.cc index c15c80d..fe18e51 100644 --- a/src/service.cc +++ b/src/service.cc @@ -29,7 +29,7 @@ void setup_external_log() noexcept; extern EventLoop_t eventLoop; // Find the requested service by name -static ServiceRecord * findService(const std::list & records, +static ServiceRecord * find_service(const std::list & records, const char *name) noexcept { using std::list; @@ -42,9 +42,9 @@ static ServiceRecord * findService(const std::list & records, return (ServiceRecord *)0; } -ServiceRecord * ServiceSet::findService(const std::string &name) noexcept +ServiceRecord * ServiceSet::find_service(const std::string &name) noexcept { - return ::findService(records, name.c_str()); + return ::find_service(records, name.c_str()); } void ServiceSet::startService(const char *name) @@ -58,7 +58,7 @@ void ServiceSet::startService(const char *name) void ServiceSet::stopService(const std::string & name) noexcept { - ServiceRecord *record = findService(name); + ServiceRecord *record = find_service(name); if (record != nullptr) { record->stop(); processQueues(false); @@ -1099,7 +1099,7 @@ void ServiceRecord::unpin() noexcept void ServiceRecord::queueForConsole() noexcept { - service_set->consoleQueueTail(this); + service_set->append_console_queue(this); } void ServiceRecord::releaseConsole() noexcept diff --git a/src/service.h b/src/service.h index a07e0d1..262ada8 100644 --- a/src/service.h +++ b/src/service.h @@ -104,8 +104,8 @@ class ServiceLoadExc const char *excDescription; protected: - ServiceLoadExc(std::string serviceName) noexcept - : serviceName(serviceName) + ServiceLoadExc(std::string serviceName, const char *desc) noexcept + : serviceName(serviceName), excDescription(desc) { } }; @@ -114,9 +114,8 @@ class ServiceNotFound : public ServiceLoadExc { public: ServiceNotFound(std::string serviceName) noexcept - : ServiceLoadExc(serviceName) + : ServiceLoadExc(serviceName, "Service description not found.") { - excDescription = "Service description not found."; } }; @@ -124,21 +123,17 @@ class ServiceCyclicDependency : public ServiceLoadExc { public: ServiceCyclicDependency(std::string serviceName) noexcept - : ServiceLoadExc(serviceName) + : ServiceLoadExc(serviceName, "Has cyclic dependency.") { - excDescription = "Has cyclic dependency."; } }; class ServiceDescriptionExc : public ServiceLoadExc { public: - std::string extraInfo; - ServiceDescriptionExc(std::string serviceName, std::string extraInfo) noexcept - : ServiceLoadExc(serviceName), extraInfo(extraInfo) + : ServiceLoadExc(serviceName, extraInfo.c_str()) { - excDescription = extraInfo.c_str(); } }; @@ -622,7 +617,7 @@ class ServiceSet void startService(const char *name); // Locate an existing service record. - ServiceRecord *findService(const std::string &name) noexcept; + ServiceRecord *find_service(const std::string &name) noexcept; // Find a loaded service record, or load it if it is not loaded. // Throws: @@ -630,7 +625,7 @@ class ServiceSet // std::bad_alloc on out-of-memory condition ServiceRecord *loadService(const std::string &name) { - ServiceRecord *record = findService(name); + ServiceRecord *record = find_service(name); if (record == nullptr) { record = loadServiceRecord(name.c_str()); } @@ -693,7 +688,7 @@ class ServiceSet } // Set the console queue tail (returns previous tail) - ServiceRecord * consoleQueueTail(ServiceRecord * newTail) noexcept + ServiceRecord * append_console_queue(ServiceRecord * newTail) noexcept { auto prev_tail = console_queue_tail; console_queue_tail = newTail; -- 2.25.1