Commit 1f9b688f authored by Robert Manzke's avatar Robert Manzke

factory done

parent 5d60ded8
......@@ -34,17 +34,22 @@ foreach(VAR ${SOUND_PROCESSORS})
file(APPEND ${CMAKE_CURRENT_SOURCE_DIR}/gen_include/${MYFILE_WITHOUT_EXT}_JSN.h
"const bool ${MYFILE_WITHOUT_EXT_UC}_ISSTEREO = ${JSON_DATA_PARSED.isStereo};\n\n"
)
# prepare big if variable for factory
set(BIG_IF "${BIG_IF}if(type.compare(\"${JSON_DATA_PARSED.id}\") == 0) return std::make_unique<${MYFILE_WITHOUT_EXT}>();\t\t\t\t\t\t\n")
sbeClearJson(example)
endforeach()
#
# create big if structure for factory
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ctagSoundProcessorFactory.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/gen_include/ctagSoundProcessorFactory.hpp @ONLY )
# add sources to config, headers added for intellij
file(GLOB SRCS
*.cpp
*.hpp
./gen_include/*.h
)
# set library target
add_library(ctag ${SRCS})
target_include_directories(ctag PUBLIC
......
#pragma once
#include <memory>
#include <iostream>
#include <string>
#include "ctagSoundProcessor.hpp"
#include "ctagSoundProcessors.h"
namespace CTAG{
namespace SP{
class ctagSoundProcessorFactory{
public:
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
......@@ -7,8 +7,8 @@ using namespace CTAG::SP;
ctagSoundProcessorMonoMultiply::ctagSoundProcessorMonoMultiply()
{
//std::cout << "Constructor" << std::endl;
isStereo = false;
std::cout << "Constructor " << CTAGSOUNDPROCESSORMONOMULTIPLY_ID << std::endl;
isStereo = CTAGSOUNDPROCESSORMONOMULTIPLY_ISSTEREO;
}
void ctagSoundProcessorMonoMultiply::Process(const ProcessData &data) const {
......@@ -19,7 +19,7 @@ void ctagSoundProcessorMonoMultiply::Process(const ProcessData &data) const {
}
ctagSoundProcessorMonoMultiply::~ctagSoundProcessorMonoMultiply(){
//std::cout << "Destructor" << std::endl;
std::cout << "Destructor " << CTAGSOUNDPROCESSORMONOMULTIPLY_ID << std::endl;
}
const unsigned char * ctagSoundProcessorMonoMultiply::GetCStrJSONParamSpecs() const{
......
#include "ctagSoundProcessorStereoAM.hpp"
#include "ctagSoundProcessorStereoAM_JSN.h"
#include <iostream>
using namespace CTAG::SP;
ctagSoundProcessorStereoAM::ctagSoundProcessorStereoAM()
{
//std::cout << "Constructor" << std::endl;
isStereo = true;
std::cout << "Constructor " << CTAGSOUNDPROCESSORSTEREOAM_ID << std::endl;
isStereo = CTAGSOUNDPROCESSORSTEREOAM_ISSTEREO;
}
void ctagSoundProcessorStereoAM::Process(const ProcessData &data) const{
......@@ -17,5 +18,13 @@ void ctagSoundProcessorStereoAM::Process(const ProcessData &data) const{
}
ctagSoundProcessorStereoAM::~ctagSoundProcessorStereoAM(){
//std::cout << "Destructor" << std::endl;
std::cout << "Destructor " << CTAGSOUNDPROCESSORSTEREOAM_ID << std::endl;
}
const unsigned char * ctagSoundProcessorStereoAM::GetCStrJSONParamSpecs() const{
return CTAGSOUNDPROCESSORSTEREOAM_JSN;
}
const unsigned char * ctagSoundProcessorStereoAM::GetCStrID() const{
return CTAGSOUNDPROCESSORSTEREOAM_ID;
}
......@@ -7,6 +7,8 @@ namespace CTAG{
virtual void Process(const ProcessData &) const;
virtual ~ctagSoundProcessorStereoAM();
ctagSoundProcessorStereoAM();
virtual const unsigned char * GetCStrJSONParamSpecs() const;
virtual const unsigned char * GetCStrID() const;
};
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ using namespace CTAG::SP;
int main()
{
std::unique_ptr<ctagSoundProcessor> processor = ctagSoundProcessorFactory::Create("abd");
auto processor = ctagSoundProcessorFactory::Create("monomult");
std::cout << "isStereo: " << processor->GetIsStereo() << std::endl;
......@@ -22,6 +22,9 @@ int main()
}
printf("%s, %s\n", processor->GetCStrID(), processor->GetCStrJSONParamSpecs());
processor = ctagSoundProcessorFactory::Create("stereoam");
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