diff options
Diffstat (limited to 'src/plugins/core')
-rw-r--r-- | src/plugins/core/VRRequestProcessor.h | 19 | ||||
-rw-r--r-- | src/plugins/core/VRRequestProcessorImpl.cpp | 19 | ||||
-rw-r--r-- | src/plugins/core/include/VRAgentsObserver.h | 17 | ||||
-rw-r--r-- | src/plugins/core/include/VRRequest.h | 21 | ||||
-rw-r--r-- | src/plugins/core/include/VRRequestProcessorDelegate.h | 23 | ||||
-rw-r--r-- | src/plugins/core/src/VRAgentsObserverImpl.cpp | 15 | ||||
-rw-r--r-- | src/plugins/core/src/VRRequestImpl.cpp | 19 | ||||
-rw-r--r-- | src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp | 23 | ||||
-rw-r--r-- | src/plugins/core/test/VRRequestProcessorTest.cpp | 9 | ||||
-rw-r--r-- | src/plugins/core/test/VRRequestTest.cpp | 9 |
10 files changed, 82 insertions, 92 deletions
diff --git a/src/plugins/core/VRRequestProcessor.h b/src/plugins/core/VRRequestProcessor.h index c349a19..97e277a 100644 --- a/src/plugins/core/VRRequestProcessor.h +++ b/src/plugins/core/VRRequestProcessor.h @@ -25,8 +25,7 @@ #include "interfaces/voiceagents/IVoiceAgentsChangeObserver.h" using namespace std; - -namespace vshl { +namespace vshlcore { namespace core { /* * This class is the entry point for all the voice recognition request @@ -36,8 +35,8 @@ class VRRequestProcessor { public: // Create a VRRequestProcessor. static unique_ptr<VRRequestProcessor> create( - shared_ptr<vshl::common::interfaces::ILogger> logger, - shared_ptr<vshl::core::VRRequestProcessorDelegate> delegate); + shared_ptr<vshlcore::common::interfaces::ILogger> logger, + shared_ptr<vshlcore::core::VRRequestProcessorDelegate> delegate); // Triggers a voiceagent to start listening to user speech input. // Returns the request ID. If start fails, then empty request ID @@ -48,7 +47,7 @@ public: void cancel(); // Returns the voiceagents observer that belongs to the core module. - shared_ptr<vshl::common::interfaces::IVoiceAgentsChangeObserver> getVoiceAgentsChangeObserver() const; + shared_ptr<vshlcore::common::interfaces::IVoiceAgentsChangeObserver> getVoiceAgentsChangeObserver() const; // Destructor ~VRRequestProcessor(); @@ -56,17 +55,17 @@ public: private: // Constructor VRRequestProcessor( - shared_ptr<vshl::common::interfaces::ILogger> logger, - shared_ptr<vshl::core::VRRequestProcessorDelegate> delegate); + shared_ptr<vshlcore::common::interfaces::ILogger> logger, + shared_ptr<vshlcore::core::VRRequestProcessorDelegate> delegate); // Voiceagents observer - shared_ptr<vshl::common::interfaces::IVoiceAgentsChangeObserver> mVoiceAgentsChangeObserver; + shared_ptr<vshlcore::common::interfaces::IVoiceAgentsChangeObserver> mVoiceAgentsChangeObserver; // Request Processor Delegate - shared_ptr<vshl::core::VRRequestProcessorDelegate> mDelegate; + shared_ptr<vshlcore::core::VRRequestProcessorDelegate> mDelegate; // Logger - shared_ptr<vshl::common::interfaces::ILogger> mLogger; + shared_ptr<vshlcore::common::interfaces::ILogger> mLogger; }; } // namespace core diff --git a/src/plugins/core/VRRequestProcessorImpl.cpp b/src/plugins/core/VRRequestProcessorImpl.cpp index 7441a7d..c07f745 100644 --- a/src/plugins/core/VRRequestProcessorImpl.cpp +++ b/src/plugins/core/VRRequestProcessorImpl.cpp @@ -16,23 +16,22 @@ #include "core/include/VRAgentsObserver.h" -static string TAG = "vshl::core::VRRequestProcessor"; +static string TAG = "vshlcore::core::VRRequestProcessor"; -using Level = vshl::utilities::logging::Logger::Level; - -namespace vshl { +using Level = vshlcore::utilities::logging::Logger::Level; +namespace vshlcore { namespace core { // Create a VRRequestProcessor. unique_ptr<VRRequestProcessor> VRRequestProcessor::create( - shared_ptr<vshl::common::interfaces::ILogger> logger, - shared_ptr<vshl::core::VRRequestProcessorDelegate> delegate) { + shared_ptr<vshlcore::common::interfaces::ILogger> logger, + shared_ptr<vshlcore::core::VRRequestProcessorDelegate> delegate) { auto processor = std::unique_ptr<VRRequestProcessor>(new VRRequestProcessor(logger, delegate)); return processor; } VRRequestProcessor::VRRequestProcessor( - shared_ptr<vshl::common::interfaces::ILogger> logger, - shared_ptr<vshl::core::VRRequestProcessorDelegate> delegate) : + shared_ptr<vshlcore::common::interfaces::ILogger> logger, + shared_ptr<vshlcore::core::VRRequestProcessorDelegate> delegate) : mLogger(logger), mDelegate(delegate) { mVoiceAgentsChangeObserver = VRAgentsObserver::create(mDelegate); @@ -46,7 +45,7 @@ string VRRequestProcessor::startListening() { // Currently start is simply going to send the request to // the default voice agent as the wake word detection is not // enabled. - shared_ptr<vshl::common::interfaces::IVoiceAgent> defaultVA = mDelegate->getDefaultVoiceAgent(); + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> defaultVA = mDelegate->getDefaultVoiceAgent(); if (!defaultVA) { mLogger->log(Level::ERROR, TAG, "Failed to start. No default voiceagent found."); return ""; @@ -63,7 +62,7 @@ void VRRequestProcessor::cancel() { mDelegate->cancelAllRequests(); } -shared_ptr<vshl::common::interfaces::IVoiceAgentsChangeObserver> VRRequestProcessor::getVoiceAgentsChangeObserver() +shared_ptr<vshlcore::common::interfaces::IVoiceAgentsChangeObserver> VRRequestProcessor::getVoiceAgentsChangeObserver() const { return mVoiceAgentsChangeObserver; } diff --git a/src/plugins/core/include/VRAgentsObserver.h b/src/plugins/core/include/VRAgentsObserver.h index d4c0c7b..ce1bd43 100644 --- a/src/plugins/core/include/VRAgentsObserver.h +++ b/src/plugins/core/include/VRAgentsObserver.h @@ -22,15 +22,14 @@ #include "utilities/logging/Logger.h" using namespace std; - -namespace vshl { +namespace vshlcore { namespace core { /* * This class will observe the changes to the voiceagents data and transfers * the actual handling responsibility to its delegate. */ class VRAgentsObserver - : public vshl::common::interfaces::IVoiceAgentsChangeObserver { + : public vshlcore::common::interfaces::IVoiceAgentsChangeObserver { public: // Create a VRAgentsObserver. static shared_ptr<VRAgentsObserver> @@ -40,18 +39,18 @@ public: protected: void OnDefaultVoiceAgentChanged( - shared_ptr<vshl::common::interfaces::IVoiceAgent> defaultVoiceAgent) + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> defaultVoiceAgent) override; void OnVoiceAgentAdded( - shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) override; + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) override; void OnVoiceAgentRemoved( - shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) override; + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) override; void OnVoiceAgentActiveWakeWordChanged( - shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) override; + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) override; void OnVoiceAgentActivated( - shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) override; + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) override; void OnVoiceAgentDeactivated( - shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) override; + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) override; private: // Constructor diff --git a/src/plugins/core/include/VRRequest.h b/src/plugins/core/include/VRRequest.h index 522ec78..8b9e842 100644 --- a/src/plugins/core/include/VRRequest.h +++ b/src/plugins/core/include/VRRequest.h @@ -22,8 +22,7 @@ #include "interfaces/voiceagents/IVoiceAgent.h" using namespace std; - -namespace vshl { +namespace vshlcore { namespace core { /* * This class implements the notion of a Voice Recognition Request. @@ -37,10 +36,10 @@ public: // Create a VRRequest. static unique_ptr<VRRequest> create( - shared_ptr<vshl::common::interfaces::ILogger> logger, - shared_ptr<vshl::common::interfaces::IAFBApi> afbApi, + shared_ptr<vshlcore::common::interfaces::ILogger> logger, + shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi, string requestId, - shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent); + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent); // Destructor ~VRRequest(); @@ -56,22 +55,22 @@ public: private: // Constructor VRRequest( - shared_ptr<vshl::common::interfaces::ILogger> logger, - shared_ptr<vshl::common::interfaces::IAFBApi> afbApi, + shared_ptr<vshlcore::common::interfaces::ILogger> logger, + shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi, const string requestId, - shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent); + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent); // Binding API reference. - shared_ptr<vshl::common::interfaces::IAFBApi> mApi; + shared_ptr<vshlcore::common::interfaces::IAFBApi> mApi; // Voice agent associated with this request - shared_ptr<vshl::common::interfaces::IVoiceAgent> mVoiceAgent; + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> mVoiceAgent; // Request ID string mRequestId; // Logger - shared_ptr<vshl::common::interfaces::ILogger> mLogger; + shared_ptr<vshlcore::common::interfaces::ILogger> mLogger; }; } // namespace core diff --git a/src/plugins/core/include/VRRequestProcessorDelegate.h b/src/plugins/core/include/VRRequestProcessorDelegate.h index 94b7304..2c36d38 100644 --- a/src/plugins/core/include/VRRequestProcessorDelegate.h +++ b/src/plugins/core/include/VRRequestProcessorDelegate.h @@ -25,8 +25,7 @@ #include "utilities/uuid/UUIDGeneration.h" using namespace std; - -namespace vshl { +namespace vshlcore { namespace core { /* * This is a delegate for VRRequestProcessor actions. @@ -39,22 +38,22 @@ class VRRequestProcessorDelegate { public: // create method static shared_ptr<VRRequestProcessorDelegate> create( - shared_ptr<vshl::common::interfaces::ILogger> logger, - shared_ptr<vshl::common::interfaces::IAFBApi> afbApi); + shared_ptr<vshlcore::common::interfaces::ILogger> logger, + shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi); // Destructor ~VRRequestProcessorDelegate(); // Set default voiceagent - void setDefaultVoiceAgent(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent); + void setDefaultVoiceAgent(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent); // Get the default voiceagent - shared_ptr<vshl::common::interfaces::IVoiceAgent> getDefaultVoiceAgent() const; + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> getDefaultVoiceAgent() const; // Add new request to the list and start processing it. // New request is created and startListening on the // voiceagent is called. - string startRequestForVoiceAgent(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent); + string startRequestForVoiceAgent(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent); // Cancel all requests void cancelAllRequests(); @@ -66,20 +65,20 @@ public: private: // Constructor VRRequestProcessorDelegate( - shared_ptr<vshl::common::interfaces::ILogger> logger, - shared_ptr<vshl::common::interfaces::IAFBApi> afbApi); + shared_ptr<vshlcore::common::interfaces::ILogger> logger, + shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi); // Binding API reference - shared_ptr<vshl::common::interfaces::IAFBApi> mApi; + shared_ptr<vshlcore::common::interfaces::IAFBApi> mApi; // Default voiceagent - shared_ptr<vshl::common::interfaces::IVoiceAgent> mDefaultVoiceAgent; + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> mDefaultVoiceAgent; // A map of voiceagent IDs and their respective VR Request objects. unordered_map<string, shared_ptr<VRRequest>> mVRRequests; // Logger - shared_ptr<vshl::common::interfaces::ILogger> mLogger; + shared_ptr<vshlcore::common::interfaces::ILogger> mLogger; }; } // namespace core diff --git a/src/plugins/core/src/VRAgentsObserverImpl.cpp b/src/plugins/core/src/VRAgentsObserverImpl.cpp index 7ee4a7e..b44a9a0 100644 --- a/src/plugins/core/src/VRAgentsObserverImpl.cpp +++ b/src/plugins/core/src/VRAgentsObserverImpl.cpp @@ -13,8 +13,7 @@ * permissions and limitations under the License. */ #include "core/include/VRAgentsObserver.h" - -namespace vshl { +namespace vshlcore { namespace core { shared_ptr<VRAgentsObserver> VRAgentsObserver::create(weak_ptr<VRRequestProcessorDelegate> delegate) { @@ -29,26 +28,26 @@ VRAgentsObserver::VRAgentsObserver(weak_ptr<VRRequestProcessorDelegate> delegate VRAgentsObserver::~VRAgentsObserver() { } -void VRAgentsObserver::OnDefaultVoiceAgentChanged(shared_ptr<vshl::common::interfaces::IVoiceAgent> defaultVoiceAgent) { +void VRAgentsObserver::OnDefaultVoiceAgentChanged(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> defaultVoiceAgent) { if (auto delegate = mWeakDelegate.lock()) { delegate->setDefaultVoiceAgent(defaultVoiceAgent); } } -void VRAgentsObserver::OnVoiceAgentAdded(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) { +void VRAgentsObserver::OnVoiceAgentAdded(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) { } -void VRAgentsObserver::OnVoiceAgentRemoved(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) { +void VRAgentsObserver::OnVoiceAgentRemoved(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) { } -void VRAgentsObserver::OnVoiceAgentActiveWakeWordChanged(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) { +void VRAgentsObserver::OnVoiceAgentActiveWakeWordChanged(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) { // Not Implemented } -void VRAgentsObserver::OnVoiceAgentActivated(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) { +void VRAgentsObserver::OnVoiceAgentActivated(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) { } -void VRAgentsObserver::OnVoiceAgentDeactivated(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) { +void VRAgentsObserver::OnVoiceAgentDeactivated(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) { } } // namespace core } // namespace vshl diff --git a/src/plugins/core/src/VRRequestImpl.cpp b/src/plugins/core/src/VRRequestImpl.cpp index 00adf96..63302d8 100644 --- a/src/plugins/core/src/VRRequestImpl.cpp +++ b/src/plugins/core/src/VRRequestImpl.cpp @@ -24,21 +24,20 @@ break; \ } -static string TAG = "vshl::core::VRRequest"; +static string TAG = "vshlcore::core::VRRequest"; -using Level = vshl::common::interfaces::ILogger::Level; - -namespace vshl { +using Level = vshlcore::common::interfaces::ILogger::Level; +namespace vshlcore { namespace core { string VRRequest::VA_VERB_STARTLISTENING = "startListening"; string VRRequest::VA_VERB_CANCEL = "cancel"; unique_ptr<VRRequest> VRRequest::create( - shared_ptr<vshl::common::interfaces::ILogger> logger, - shared_ptr<vshl::common::interfaces::IAFBApi> afbApi, + shared_ptr<vshlcore::common::interfaces::ILogger> logger, + shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi, const string requestId, - shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) { + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) { if (logger == nullptr) { return nullptr; } @@ -53,10 +52,10 @@ unique_ptr<VRRequest> VRRequest::create( } VRRequest::VRRequest( - shared_ptr<vshl::common::interfaces::ILogger> logger, - shared_ptr<vshl::common::interfaces::IAFBApi> afbApi, + shared_ptr<vshlcore::common::interfaces::ILogger> logger, + shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi, string requestId, - shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) : + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) : mApi(afbApi), mRequestId(requestId), mVoiceAgent(voiceAgent), diff --git a/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp b/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp index e20b22e..78ef10a 100644 --- a/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp +++ b/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp @@ -14,22 +14,21 @@ */ #include "core/include/VRRequestProcessorDelegate.h" -static string TAG = "vshl::core::VRRequestProcessorDelegate"; +static string TAG = "vshlcore::core::VRRequestProcessorDelegate"; -using Level = vshl::common::interfaces::ILogger::Level; - -namespace vshl { +using Level = vshlcore::common::interfaces::ILogger::Level; +namespace vshlcore { namespace core { shared_ptr<VRRequestProcessorDelegate> VRRequestProcessorDelegate::create( - shared_ptr<vshl::common::interfaces::ILogger> logger, - shared_ptr<vshl::common::interfaces::IAFBApi> afbApi) { + shared_ptr<vshlcore::common::interfaces::ILogger> logger, + shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi) { auto delegate = std::shared_ptr<VRRequestProcessorDelegate>(new VRRequestProcessorDelegate(logger, afbApi)); return delegate; } VRRequestProcessorDelegate::VRRequestProcessorDelegate( - shared_ptr<vshl::common::interfaces::ILogger> logger, - shared_ptr<vshl::common::interfaces::IAFBApi> afbApi) : + shared_ptr<vshlcore::common::interfaces::ILogger> logger, + shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi) : mApi(afbApi), mLogger(logger) { } @@ -39,14 +38,14 @@ VRRequestProcessorDelegate::~VRRequestProcessorDelegate() { } string VRRequestProcessorDelegate::startRequestForVoiceAgent( - shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) { + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) { if (!mApi) { mLogger->log(Level::ERROR, TAG, "Failed to startRequestForVoiceAgent: " + voiceAgent->getId() + ", No API."); return ""; } // Generate a new request ID. - string newReqId = vshl::utilities::uuid::generateUUID(); + string newReqId = vshlcore::utilities::uuid::generateUUID(); // Create a new request and start listening. shared_ptr<VRRequest> newRequest = VRRequest::create(mLogger, mApi, newReqId, voiceAgent); @@ -81,11 +80,11 @@ unordered_map<string, shared_ptr<VRRequest>> VRRequestProcessorDelegate::getAllR return mVRRequests; } -void VRRequestProcessorDelegate::setDefaultVoiceAgent(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) { +void VRRequestProcessorDelegate::setDefaultVoiceAgent(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) { mDefaultVoiceAgent = voiceAgent; } -shared_ptr<vshl::common::interfaces::IVoiceAgent> VRRequestProcessorDelegate::getDefaultVoiceAgent() const { +shared_ptr<vshlcore::common::interfaces::IVoiceAgent> VRRequestProcessorDelegate::getDefaultVoiceAgent() const { return mDefaultVoiceAgent; } diff --git a/src/plugins/core/test/VRRequestProcessorTest.cpp b/src/plugins/core/test/VRRequestProcessorTest.cpp index c1a37df..caa62b8 100644 --- a/src/plugins/core/test/VRRequestProcessorTest.cpp +++ b/src/plugins/core/test/VRRequestProcessorTest.cpp @@ -22,11 +22,10 @@ #include "test/common/ConsoleLogger.h" #include "test/mocks/AFBApiMock.h" -using namespace vshl::core; -using namespace vshl::voiceagents; -using namespace vshl::test::common; - -namespace vshl { +using namespace vshlcore::core; +using namespace vshlcore::voiceagents; +using namespace vshlcore::test::common; +namespace vshlcore { namespace test { class VRRequestProcessorTest : public ::testing::Test { diff --git a/src/plugins/core/test/VRRequestTest.cpp b/src/plugins/core/test/VRRequestTest.cpp index b1cd0a6..a7bb3db 100644 --- a/src/plugins/core/test/VRRequestTest.cpp +++ b/src/plugins/core/test/VRRequestTest.cpp @@ -22,11 +22,10 @@ #include "test/common/ConsoleLogger.h" #include "test/mocks/AFBApiMock.h" -using namespace vshl::core; -using namespace vshl::voiceagents; -using namespace vshl::test::common; - -namespace vshl { +using namespace vshlcore::core; +using namespace vshlcore::voiceagents; +using namespace vshlcore::test::common; +namespace vshlcore { namespace test { class VRRequestTest : public ::testing::Test { |