From b8cb37c8b7be3d9299f7c178ffed08f139128a16 Mon Sep 17 00:00:00 2001 From: Owen Green Date: Tue, 28 Aug 2018 10:34:47 +0100 Subject: [PATCH] fdNRTBase Tidy up the class and make useful --- fdNRTBase/fdNRTBase.cpp | 84 +++++++++++++---------------------------- 1 file changed, 27 insertions(+), 57 deletions(-) diff --git a/fdNRTBase/fdNRTBase.cpp b/fdNRTBase/fdNRTBase.cpp index b7aebfc..c312f9f 100644 --- a/fdNRTBase/fdNRTBase.cpp +++ b/fdNRTBase/fdNRTBase.cpp @@ -89,64 +89,28 @@ namespace sc{ mCompletionMsgSize,mCompletionMsgData); } - - - void cm() - { - cmd("Bob"); - } - - - public: NRTCommandBase() = delete; NRTCommandBase(NRTCommandBase&) = delete; NRTCommandBase& operator=(NRTCommandBase&) = delete; - - - NRTCommandBase(size_t buffers_in, size_t buffers_out, World *inWorld, void* inUserData, struct sc_msg_iter *args, void *replyAddr): - input_buffers(buffers_in,-1), output_buffers(buffers_out,-1), - mWorld(inWorld),mReplyAddr(replyAddr) - { - for(auto&& i: input_buffers) - i = args->geti(); - - for(auto&& o: output_buffers) - o = args->geti(); - - mCompletionMsgSize = args->getbsize(); - mCompletionMsgData = 0; - if(mCompletionMsgSize) - { - //allocate string - mCompletionMsgData = (char*)RTAlloc(mWorld,mCompletionMsgSize); - args->getb(mCompletionMsgData,mCompletionMsgSize); - } - - } + + NRTCommandBase(World *inWorld, void* inUserData, struct sc_msg_iter *args, void *replyAddr): + mWorld(inWorld),mReplyAddr(replyAddr){} - virtual void process() + virtual ~NRTCommandBase() = default; + + /**Override these**/ + virtual bool process() { return true; } //NRT + virtual bool post_processing() { return true; } //RT + virtual bool post_complete() { return true; } //NRT + void cleanup() {} + + /**Probably not this though**/ + void runCommand(std::string name) { - + cmd (name); } - private: - - bool do_processing() - { - - return true; - } - bool post_processing() - { - return true; - } - bool dummy_stage() { return true; } - void dummy_cleanup() {} - - std::vector input_buffers; - std::vector output_buffers; - protected: World * mWorld; void* mReplyAddr; @@ -155,6 +119,17 @@ namespace sc{ size_t mCompletionMsgSize; char* mCompletionMsgData; + void handleCompletionMessage(struct sc_msg_iter *args) + { + mCompletionMsgSize = args->getbsize(); + mCompletionMsgData = 0; + if(mCompletionMsgSize) + { + //allocate string + mCompletionMsgData = (char*)RTAlloc(mWorld,mCompletionMsgSize); + args->getb(mCompletionMsgData,mCompletionMsgSize); + } + } }; } //namespace supercollider }//namespace fluid @@ -164,20 +139,15 @@ template void command(World *inWorld, void* inUserData, struct sc_msg_iter *args, void *replyAddr) { NRT_Plug cmd(inWorld, inUserData, args, replyAddr); - - - + cmd.runCommand("AysncCommand"); } template void registerCommand(InterfaceTable* ft, const char* name) { - //typedef void (*PlugInCmdFunc)(World *inWorld, void* inUserData, struct sc_msg_iter *args, void *replyAddr); + //(World *inWorld, void* inUserData, struct sc_msg_iter *args, void *replyAddr); PlugInCmdFunc cmd = command; - - - (*ft->fDefinePlugInCmd)(name,cmd,nullptr); }