Commit 5d60ded8 authored by Robert Manzke's avatar Robert Manzke

factory progress

parent 53927d44
cmake_minimum_required(VERSION 3.0.0)
project(CTAG-Plug VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(ctag)
......
......@@ -21,6 +21,7 @@ foreach(VAR ${SOUND_PROCESSORS})
)
# create include file for sound processor factory
file(APPEND ${CMAKE_CURRENT_SOURCE_DIR}/gen_include/ctagSoundProcessors.h
"#include \"${MYFILE_WITHOUT_EXT}.hpp\"\n"
"#include \"${MYFILE_WITHOUT_EXT}_JSN.h\"\n"
)
# read JSON descriptor and append ID and if stereo to header file
......@@ -44,4 +45,8 @@ file(GLOB SRCS
./gen_include/*.h
)
add_library(ctag ${SRCS})
\ No newline at end of file
add_library(ctag ${SRCS})
target_include_directories(ctag PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/gen_include
)
\ No newline at end of file
......@@ -16,6 +16,8 @@ namespace CTAG{
virtual void Process(const ProcessData &) const = 0; // pure virtual --> must be implemented by derived
virtual ~ctagSoundProcessor(){};
bool GetIsStereo(){return isStereo;}
virtual const unsigned char * GetCStrJSONParamSpecs() const = 0;
virtual const unsigned char * GetCStrID() const = 0;
protected:
bool isStereo = false;
};
......
#pragma once
#include <memory>
#include <iostream>
#include <string>
#include "ctagSoundProcessor.hpp"
#include "ctagSoundProcessors.h"
namespace CTAG{
namespace SP{
class ctagSoundProcessorFactory{
public:
enum SoundProcessorIDs{
none,
am
};
static std::unique_ptr<ctagSoundProcessor> Create(const SoundProcessorIDs &id){
switch(id){
case none: return nullptr;
default: return nullptr;
static std::unique_ptr<ctagSoundProcessor> Create(const std::string type){
if(type.compare("abd") == 0) return std::make_unique<ctagSoundProcessorMonoMultiply>();
return nullptr;
}
}
};
}
}
\ No newline at end of file
#include "ctagSoundProcessorMonoMultiply.hpp"
#include "ctagSoundProcessorMonoMultiply_JSN.h"
#include <iostream>
using namespace CTAG::SP;
ctagSoundProcessorMonoMultiply::ctagSoundProcessorMonoMultiply()
......@@ -19,3 +21,11 @@ void ctagSoundProcessorMonoMultiply::Process(const ProcessData &data) const {
ctagSoundProcessorMonoMultiply::~ctagSoundProcessorMonoMultiply(){
//std::cout << "Destructor" << std::endl;
}
const unsigned char * ctagSoundProcessorMonoMultiply::GetCStrJSONParamSpecs() const{
return CTAGSOUNDPROCESSORMONOMULTIPLY_JSN;
}
const unsigned char * ctagSoundProcessorMonoMultiply::GetCStrID() const{
return CTAGSOUNDPROCESSORMONOMULTIPLY_ID;
}
......@@ -7,6 +7,8 @@ namespace CTAG{
virtual void Process(const ProcessData &) const;
virtual ~ctagSoundProcessorMonoMultiply();
ctagSoundProcessorMonoMultiply();
virtual const unsigned char * GetCStrJSONParamSpecs() const;
virtual const unsigned char * GetCStrID() const;
};
}
}
\ No newline at end of file
......@@ -7,22 +7,21 @@ using namespace CTAG::SP;
int main()
{
std::unique_ptr<ctagSoundProcessor> processor = ctagSoundProcessorFactory::Create(ctagSoundProcessorFactory::none);
assert(processor);
/*
std::unique_ptr<ctagSoundProcessor> res( new ctagSoundProcessorStereoAM());
std::unique_ptr<ctagSoundProcessor> processor = ctagSoundProcessorFactory::Create("abd");
std::cout << "isStereo: " << res->GetIsStereo() << std::endl;
std::cout << "isStereo: " << processor->GetIsStereo() << std::endl;
ProcessData data;
float b0[32], b1[32];
data.buf0 = b0;
data.buf1 = b1;
data.bufSize = 32;
res->Process(data);
processor->Process(data);
for(int i=0;i<32;i++){
std::cout << "Value " << data.buf0[i] << " " << data.buf1[i] << std::endl;
}
*/
printf("%s, %s\n", processor->GetCStrID(), processor->GetCStrJSONParamSpecs());
return 0;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment