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..

This commit is contained in:
kevin 2023-03-17 18:24:07 -04:00
parent 6815f87256
commit 190ead625f
2 changed files with 29 additions and 6 deletions

View File

@ -873,8 +873,12 @@ namespace cw
rc_t rc = kOkRC; rc_t rc = kOkRC;
for(instance_t* inst = p->network_head; inst!=nullptr; inst=inst->link) for(instance_t* inst = p->network_head; inst!=nullptr; inst=inst->link)
{
if((rc = inst->class_desc->members->exec(inst)) != kOkRC ) if((rc = inst->class_desc->members->exec(inst)) != kOkRC )
break; {
break;
}
}
return rc; return rc;
} }
@ -1079,18 +1083,18 @@ cw::rc_t cw::flow::exec( handle_t h )
while( true ) while( true )
{ {
rc = _exec_cycle(p); rc = _exec_cycle(p);
if( rc == kEofRC ) if( rc == kEofRC )
{ {
rc = kOkRC; rc = kOkRC;
break; break;
} }
p->cycleIndex += 1; p->cycleIndex += 1;
if( p->maxCycleCount > 0 && p->cycleIndex >= p->maxCycleCount ) if( p->maxCycleCount > 0 && p->cycleIndex >= p->maxCycleCount )
break; break;
} }
return rc; 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; rc_t rc = kOkRC;
handle_t flowH; 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 // create the flow object
if((rc = create( flowH, *class_cfg, *cfg)) != kOkRC ) if((rc = create( flowH, *class_cfg, *cfg)) != kOkRC )
{ {
rc = cwLogError(rc,"Flow object create failed."); rc = cwLogError(rc,"Flow object create failed.");
goto errLabel; goto errLabel;
} }
//print_network(flowH);
// run the network // run the network
if((rc = exec( flowH )) != kOkRC ) 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: errLabel:
if( class_cfg != nullptr )
class_cfg->free();
return rc; return rc;
} }

View File

@ -82,7 +82,7 @@ namespace cw
void print_class_list( handle_t h ); void print_class_list( handle_t h );
void print_network( 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 );