52 virtual void open(
const std::vector<adtf_file::Stream>& streams,
const std::string& destination_url) = 0;
76 void open(
const std::vector<adtf_file::Stream>& streams,
const std::string& destination_url)
override
78 if (streams.size() != 1)
80 throw std::runtime_error(
"processor '" +
getProcessorIdentifier() +
"' supports a single input stream only. Open was called with " + std::to_string(streams.size()) +
" streams.");
82 open(streams.front(), destination_url);
110 template <
typename PROCESSOR_CLASS>
120 return std::make_shared<PROCESSOR_CLASS>();
134 void add(
const std::shared_ptr<const ProcessorFactory>& factory)
136 auto processor = factory->makeProcessor();
137 _factories[processor->getProcessorIdentifier()] = factory;
145 std::shared_ptr<Processor>
makeProcessor(
const std::string& processor_id)
const
147 auto factory = _factories.find(processor_id);
148 if (factory == _factories.end())
150 throw std::runtime_error(
"no factory for processor " + processor_id);
153 return factory->second->makeProcessor();
166 const std::function<
bool(
const std::shared_ptr<Processor>&)> callback_processor,
169 for (
auto& factory : _factories)
171 const auto processor = factory.second->makeProcessor();
172 processor->setConfiguration(configuration);
173 if (processor->isCompatible(stream))
175 if (!callback_processor(processor))
186 const std::unordered_map<std::string, std::shared_ptr<const ProcessorFactory>>&
getFactories()
const
191 std::unordered_map<std::string, std::shared_ptr<const ProcessorFactory>> _factories;
Definition: configuration.h:314
class to create or read a file item. This file item is either a sample, streamtype or trigger.
Definition: reader.h:156
base interface class for all available objects of the ADTF File Library that can be added to the obje...
Definition: object.h:33
class to create and describe a stream within a adtf_file::Reader. Each stream has an identifier strea...
Definition: reader.h:134
Definition: processor.h:128
std::shared_ptr< Processor > makeProcessor(const std::string &processor_id) const
make a processor with the given processor_id
Definition: processor.h:145
const std::unordered_map< std::string, std::shared_ptr< const ProcessorFactory > > & getFactories() const
Get the Factories.
Definition: processor.h:186
void add(const std::shared_ptr< const ProcessorFactory > &factory)
Definition: processor.h:134
void getCapableProcessors(const adtf_file::Stream &stream, const std::function< bool(const std::shared_ptr< Processor > &)> callback_processor, const adtf_file::Configuration &configuration={}) const
Get the capable and compatible processors for the given stream. It will make all capable processors a...
Definition: processor.h:165
Definition: processor.h:112
std::shared_ptr< Processor > makeProcessor() const override
create a processor
Definition: processor.h:118
Definition: processor.h:99
virtual std::shared_ptr< Processor > makeProcessor() const =0
Definition: processor.h:31
virtual bool isCompatible(const adtf_file::Stream &stream) const =0
virtual void open(const std::vector< adtf_file::Stream > &streams, const std::string &destination_url)=0
virtual void process(const adtf_file::FileItem &item)=0
virtual std::string getProcessorIdentifier() const =0
Definition: processor.h:65
virtual void open(const adtf_file::Stream &stream, const std::string &destination_url)=0
void open(const std::vector< adtf_file::Stream > &streams, const std::string &destination_url) override
Definition: processor.h:76
std::unordered_map< std::string, PropertyValue > Configuration
Configuration class as set of key - property value pairs This configuration is used to adjust the rea...
Definition: configuration.h:143
namespace for ADTF DAT Processing library.
Definition: ddl_helpers.h:38