diff --git a/src/lib_modules/core/output.hpp b/src/lib_modules/core/output.hpp index 4de714aa..416b0349 100644 --- a/src/lib_modules/core/output.hpp +++ b/src/lib_modules/core/output.hpp @@ -75,18 +75,21 @@ class IOutputCap { protected: template InstanceType* addOutput(Args&&... args) { - auto p = createOutput(getAllocatorSize(), std::forward(args)...); - addOutputInternal(p); + auto p = createOutput(allocatorSize, std::forward(args)...); + outputs.push_back(uptr(p)); return safe_cast(p); } - virtual size_t getAllocatorSize() const = 0; - virtual void addOutputInternal(IOutput *p) = 0; + /*FIXME: we need to have factories to move these back to the implementation - otherwise pins created from the constructor may crash*/ + std::vector> outputs; + /*const*/ size_t allocatorSize; }; class OutputCap : public virtual IOutputCap { public: - OutputCap(size_t allocatorSize) : allocatorSize(allocatorSize) {} + OutputCap(size_t allocatorSize) { + this->allocatorSize = allocatorSize; + } virtual ~OutputCap() noexcept(false) {} virtual size_t getNumOutputs() const override { @@ -95,19 +98,6 @@ class OutputCap : public virtual IOutputCap { virtual IOutput* getOutput(size_t i) const override { return outputs[i].get(); } - -protected: - virtual size_t getAllocatorSize() const override { - assert(allocatorSize > 0); - return allocatorSize; - } - virtual void addOutputInternal(IOutput *p) override { - outputs.push_back(uptr(p)); - } - -private: - std::vector> outputs; - const size_t allocatorSize; }; } diff --git a/src/lib_modules/utils/helper.hpp b/src/lib_modules/utils/helper.hpp index dadd3300..b81b89ea 100644 --- a/src/lib_modules/utils/helper.hpp +++ b/src/lib_modules/utils/helper.hpp @@ -10,7 +10,7 @@ namespace Modules { /* this default factory creates output pins with the default output - create another one for other uses such as low latency */ template -struct ModuleDefault : public virtual OutputCap, public virtual InstanceType { +struct ModuleDefault : public OutputCap, public InstanceType { template ModuleDefault(size_t allocatorSize, Args&&... args) : OutputCap(allocatorSize), InstanceType(std::forward(args)...) {} }; diff --git a/src/lib_modules/utils/pipeline.cpp b/src/lib_modules/utils/pipeline.cpp index 028e40ea..38085838 100644 --- a/src/lib_modules/utils/pipeline.cpp +++ b/src/lib_modules/utils/pipeline.cpp @@ -53,18 +53,8 @@ class PipelinedInput : public IInput { IProcessExecutor &executor; }; -/* Fake: requested by IOuputCap */ -struct OutputCapFake : public virtual IOutputCap { - virtual size_t getAllocatorSize() const override final { - throw Exception("getAllocatorSize() not implemented for Pipeline"); - } - virtual void addOutputInternal(IOutput *p) override final { - throw Exception("addOutputInternal() not implemented for Pipeline"); - } -}; - /* Wrapper around the module. */ -class PipelinedModule : public ICompletionNotifier, public IPipelinedModule, public InputCap, public OutputCapFake { +class PipelinedModule : public ICompletionNotifier, public IPipelinedModule, public InputCap { public: /* take ownership of module */ PipelinedModule(IModule *module, ICompletionNotifier *notify)