From 190ead625f54c67a2e3c1e469a939a61963f6619 Mon Sep 17 00:00:00 2001 From: kevin Date: Fri, 17 Mar 2023 18:24:07 -0400 Subject: [PATCH] cwFlow.h/cpp : Argument object to test() now contains the name of the flow_proc_dict file rather than receiving it as a separate arg.. --- cwFlow.cpp | 33 ++++++++++++++++++++++++++++----- cwFlow.h | 2 +- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/cwFlow.cpp b/cwFlow.cpp index 01f55b9..621a042 100644 --- a/cwFlow.cpp +++ b/cwFlow.cpp @@ -873,8 +873,12 @@ namespace cw rc_t rc = kOkRC; for(instance_t* inst = p->network_head; inst!=nullptr; inst=inst->link) + { if((rc = inst->class_desc->members->exec(inst)) != kOkRC ) - break; + { + break; + } + } return rc; } @@ -1079,18 +1083,18 @@ cw::rc_t cw::flow::exec( handle_t h ) while( true ) { rc = _exec_cycle(p); - + if( rc == kEofRC ) { rc = kOkRC; break; - } + } p->cycleIndex += 1; if( p->maxCycleCount > 0 && p->cycleIndex >= p->maxCycleCount ) break; } - + return rc; } @@ -1210,17 +1214,34 @@ void cw::flow::print_network( handle_t h ) } -cw::rc_t cw::flow::test( const object_t* class_cfg, const object_t* cfg ) +cw::rc_t cw::flow::test( const object_t* cfg ) { rc_t rc = kOkRC; handle_t flowH; + object_t* class_cfg = nullptr; + const char* flow_proc_fname; + + if((rc = cfg->getv("flow_proc_fname",flow_proc_fname)) != kOkRC ) + { + rc = cwLogError(rc,"The name of the flow_proc_dict file could not be parsed."); + goto errLabel; + } + + if((rc = objectFromFile(flow_proc_fname,class_cfg)) != kOkRC ) + { + rc = cwLogError(rc,"The flow proc dict could not be read from '%s'.",cwStringNullGuard(flow_proc_fname)); + goto errLabel; + } + // create the flow object if((rc = create( flowH, *class_cfg, *cfg)) != kOkRC ) { rc = cwLogError(rc,"Flow object create failed."); goto errLabel; } + + //print_network(flowH); // run the network if((rc = exec( flowH )) != kOkRC ) @@ -1235,6 +1256,8 @@ cw::rc_t cw::flow::test( const object_t* class_cfg, const object_t* cfg ) } errLabel: + if( class_cfg != nullptr ) + class_cfg->free(); return rc; } diff --git a/cwFlow.h b/cwFlow.h index 8e6dc29..69e024d 100644 --- a/cwFlow.h +++ b/cwFlow.h @@ -82,7 +82,7 @@ namespace cw void print_class_list( handle_t h ); void print_network( handle_t h ); - rc_t test( const object_t* class_cfg, const object_t* cfg ); + rc_t test( const object_t* cfg );