Skip to content

Commit

Permalink
refactoring: introduced a new method to start the IPADataProcessor
Browse files Browse the repository at this point in the history
without any arguments
Some documentation corrections
  • Loading branch information
schnelle committed May 8, 2024
1 parent 1d673de commit 93bb114
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 40 deletions.
5 changes: 3 additions & 2 deletions source/w3cipa/w3cipademo/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
#include <log4cplus/initializer.h>

#include <w3c/voiceinteraction/ipa/client/ModalityManager.h>
#include <w3c/voiceinteraction/ipa/external/ipa/ProviderRegistry.h>

#include "w3c/voiceinteraction/ipa/reference/IntegerRequestId.h"
#include "w3c/voiceinteraction/ipa/external/ProviderSelectionService.h"
#include "w3c/voiceinteraction/ipa/reference/client/ConsoleTextModalityComponent.h"
#include "w3c/voiceinteraction/ipa/reference/dialog/ReferenceIPAService.h"
#include "w3c/voiceinteraction/ipa/reference/client/TakeFirstInputModalityComponentListener.h"
Expand Down Expand Up @@ -74,7 +75,7 @@ int main() {
modalityManager->startInput();

// Actually start processing
inputListener->processIPAData(nullptr);
inputListener->IPADataProcessor::processIPAData();

return 0;
}
4 changes: 2 additions & 2 deletions source/w3cipa/w3cipaframework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

if (CMAKE_BUILD_TYPE MATCHES "^[Rr]elease")
#if (CMAKE_BUILD_TYPE MATCHES "^[Rr]elease")
# check if Doxygen is installed
find_package(Doxygen)
if (DOXYGEN_FOUND)
Expand All @@ -119,4 +119,4 @@ if (CMAKE_BUILD_TYPE MATCHES "^[Rr]elease")
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif()
#endif()
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace ipa {
* An IPA data processor is able to consume {@link IPAData}, process it
* and forward the processed result to registered other IPA data processors
* to eventually further process the data.
*
* @author Dirk Schnelle-Walka
*/
class IPADataProcessor {
Expand All @@ -39,6 +40,12 @@ class IPADataProcessor {
*/
virtual ~IPADataProcessor();

/**
* Starts processing with {@code nullptr} in
* {@link processIPAData(std::shared_ptr<IPAData> data)}.
*/
virtual void processIPAData();

/**
* Processes the data and informs all registered listeners afterwards
* via {@link #notifyListeners}.
Expand All @@ -50,7 +57,7 @@ class IPADataProcessor {
* they can handle. As a result of chaining, inputs may be received from
* multiple sources. This method should return immediately, if there is
* nothing to do with the received data.
* @param data the data to process;
* @param data the data to process
*/
virtual void processIPAData(std::shared_ptr<IPAData> data) = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ namespace voiceinteraction {
namespace ipa {

/**
* Interfacce for meta data of {@link w3c::voiceinteraction::ClientRequest}.
* Interfacce for meta data of a {@link ClientRequest}.
* @author Dirk Schnelle-Walka
*/
class MetaData
{
class MetaData {

public:
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class ProviderSelectionService : public IPADataProcessor {
/**
* Processes the input and forwards it to the relevant IPA providers.
* @param data incoming data.
* @return list of responses from the IPA providers
*/
void processIPAData(std::shared_ptr<IPAData> data) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,25 @@
#ifndef IPASERVICE_H
#define IPASERVICE_H

#include <memory>

#include "w3c/voiceinteraction/ipa/external/ProviderSelectionService.h"

namespace w3c {
namespace voiceinteraction {
namespace ipa {
namespace external {
namespace ipa {

/**
* @brief The IPAService class
* The IPAService is the base class for the IPA service.
*
* Usually, this insance is only needed in case multiple clients need to be
* handled or the input is forwarded simultaneously to a local IPA and
* external IPAs.
*
* @author Dirk Schnelle-Walka
*/
class IPAService {
public:
/**
* Constructs a new object.
* @param service The provider selection service.
*/
IPAService();

Expand All @@ -41,7 +40,6 @@ class IPAService {
*/
virtual ~IPAService();

protected:
};

} // namespace ipa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ namespace w3c {
namespace voiceinteraction {
namespace ipa {

/**
* Constructs a new object.
* @param multiModalInputs The multimodal inputs to be sent to the client.
*/
ClientRequest::ClientRequest(const std::shared_ptr<SessionId>& sessionIdentifier,
const std::shared_ptr<RequestId>& requestIdentifier,
const std::shared_ptr<MultiModalInputs>& multiModalInputs,
Expand All @@ -30,33 +26,18 @@ ClientRequest::ClientRequest(const std::shared_ptr<SessionId>& sessionIdentifier
metaData(metaDataToSend) {
}

/**
* Destroys the object.
*/
ClientRequest::~ClientRequest() {

}

/**
* Returns the audio data to be played to the user.
* @return The audio data to be played to the user.
*/
const std::shared_ptr<AudioData>& ClientRequest::getAudioData() {
return audioData;
}

/**
* Returns the multimodal inputs to be sent to the client.
* qreturn The multimodal inputs to be sent to the client.
*/
const std::shared_ptr<MultiModalInputs>& ClientRequest::getMultiModalInputs() {
return inputs;
}

/**
* Returns the metadata of the request.
* @return The metadata of the request.
*/
const std::shared_ptr<MetaData>& ClientRequest::getMetaData() {
return metaData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ IPADataProcessor::IPADataProcessor() {
IPADataProcessor::~IPADataProcessor() {
}

void IPADataProcessor::processIPAData() {
processIPAData(nullptr);
}

void IPADataProcessor::addIPADataProcessorListener(
const std::shared_ptr<IPADataProcessor>& listener) {
listeners.push_back(listener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ namespace client {
*/
class TakeFirstInputModalityComponentListener
: public ::client::InputModalityComponentListener,
public IPADataProcessor {
public IPADataProcessor {

public:
/**
* Constructs a new object.
*/
TakeFirstInputModalityComponentListener();

void processIPAData(std::shared_ptr<IPAData> data) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
#define REFERENCEIPASERVICE_H

#include <memory>
#include <map>

#include <log4cplus/logger.h>

#include "w3c/voiceinteraction/ipa/CombinedId.h"
#include "w3c/voiceinteraction/ipa/IPADataProcessor.h"
#include <w3c/voiceinteraction/ipa/IPADataProcessor.h>
#include <w3c/voiceinteraction/ipa/ClientRequest.h>
#include <w3c/voiceinteraction/ipa/ExternalClientResponse.h>
#include <w3c/voiceinteraction/ipa/external/ipa/IPAService.h>

using namespace w3c::voiceinteraction::ipa::external;
Expand All @@ -34,7 +34,7 @@ namespace dialog {
* @brief A reference implementation of an IPA Service
* @author Dirk Schnelle-Walka
*/
class ReferenceIPAService : public IPAService, public IPADataProcessor {
class ReferenceIPAService : public external::ipa::IPAService, public IPADataProcessor {
public:
ReferenceIPAService();

Expand Down

0 comments on commit 93bb114

Please sign in to comment.