-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduced the concept of an IPADataProcessor and removed the
ExternalClientResponseListener.h
- Loading branch information
Showing
10 changed files
with
146 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
.../w3cipa/w3cipaframework/include/w3c/voiceinteraction/ipa/ExternalClientResponseListener.h
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
source/w3cipa/w3cipaframework/include/w3c/voiceinteraction/ipa/IPADataProcessor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* IPA Reference Implementation: https://github.com/w3c/voiceinteraction | ||
* | ||
* Copyright (C) 2024 World Wide Web Consortium. All Rights Reserved. | ||
* | ||
* This work is distributed under the W3C Software and Document License [1] | ||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even | ||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* | ||
* [1] https://www.w3.org/Consortium/Legal/copyright-software | ||
*/ | ||
|
||
#ifndef IPADATAPROCESSOR_H | ||
#define IPADATAPROCESSOR_H | ||
|
||
#include <list> | ||
|
||
#include "IPAData.h" | ||
|
||
namespace w3c { | ||
namespace voiceinteraction { | ||
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 { | ||
public: | ||
/** | ||
* Creates a new instance. | ||
*/ | ||
IPADataProcessor(); | ||
|
||
/** | ||
* Destroys this instance. | ||
*/ | ||
virtual ~IPADataProcessor(); | ||
|
||
/** | ||
* Processes the data and informs all registered listeners afterwards | ||
* via {@link #notifyListeners}. | ||
* | ||
* Conceptually, this method can be called multiple times depending on | ||
* how many other processors this instance has been subsribed to. | ||
* @param data the data to process; | ||
*/ | ||
virtual void processIPAData(std::shared_ptr<IPAData> data) = 0; | ||
|
||
/** | ||
* Adds the given listener to the list of known listeners. | ||
* @param listener the listener to add | ||
*/ | ||
void addIPADataProcessorListener( | ||
const std::shared_ptr<IPADataProcessor>& listener); | ||
|
||
protected: | ||
/** | ||
* Asynchronously notifies all listeners about the processed data. | ||
* @param data the processed data | ||
*/ | ||
void notifyListeners(std::shared_ptr<IPAData> data); | ||
|
||
private: | ||
/** List of known listeners for processed results. */ | ||
std::list<std::shared_ptr<IPADataProcessor>> listeners; | ||
}; | ||
|
||
} // namespace ipa | ||
} // namespace voiceinteraction | ||
} // namespace w3c | ||
|
||
#endif // IPADATAPROCESSOR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
source/w3cipa/w3cipaframework/src/w3c/voiceinteraction/ipa/IPADataProcessor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* IPA Reference Implementation: https://github.com/w3c/voiceinteraction | ||
* | ||
* Copyright (C) 2024 World Wide Web Consortium. All Rights Reserved. | ||
* | ||
* This work is distributed under the W3C Software and Document License [1] | ||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even | ||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* | ||
* [1] https://www.w3.org/Consortium/Legal/copyright-software | ||
*/ | ||
|
||
#include <thread> | ||
|
||
#include "w3c/voiceinteraction/ipa/IPADataProcessor.h" | ||
|
||
namespace w3c { | ||
namespace voiceinteraction { | ||
namespace ipa { | ||
|
||
IPADataProcessor::IPADataProcessor() { | ||
} | ||
|
||
IPADataProcessor::~IPADataProcessor() { | ||
} | ||
|
||
void IPADataProcessor::addIPADataProcessorListener( | ||
const std::shared_ptr<IPADataProcessor>& listener) { | ||
listeners.push_back(listener); | ||
} | ||
|
||
void IPADataProcessor::notifyListeners(std::shared_ptr<IPAData> data) { | ||
for (const std::shared_ptr<IPADataProcessor>& listener : listeners) { | ||
std::thread thread([&data, &listener]{ | ||
listener->processIPAData(data); | ||
}); | ||
thread.join(); | ||
} | ||
} | ||
|
||
|
||
} // namespace ipa | ||
} // namespace voiceinteraction | ||
} // namespace w3c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters