cwFlow,cwFlowNet,cwFlowTypes : Preset compile and rewrite of network_apply_preset() and network_apply_dual_preset().
Code complete but not fully tested.
This commit is contained in:
parent
f09c9b0151
commit
07822a1c44
@ -310,7 +310,7 @@ namespace cw
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
preset_t* preset = mem::allocZ< preset_t >();
|
||||
class_preset_t* preset = mem::allocZ< class_preset_t >();
|
||||
|
||||
preset->label = pair->pair_label();
|
||||
preset->cfg = pair->pair_value();
|
||||
|
879
cwFlowNet.cpp
879
cwFlowNet.cpp
File diff suppressed because it is too large
Load Diff
138
cwFlowTypes.cpp
138
cwFlowTypes.cpp
@ -1347,8 +1347,8 @@ void cw::flow::class_desc_destroy( class_desc_t* class_desc)
|
||||
}
|
||||
|
||||
// release the preset list
|
||||
preset_t* pr0 = class_desc->presetL;
|
||||
preset_t* pr1 = nullptr;
|
||||
class_preset_t* pr0 = class_desc->presetL;
|
||||
class_preset_t* pr1 = nullptr;
|
||||
while( pr0 != nullptr )
|
||||
{
|
||||
pr1 = pr0->link;
|
||||
@ -1393,9 +1393,9 @@ cw::rc_t cw::flow::var_desc_find( class_desc_t* cd, const char* label, var_desc_
|
||||
return kOkRC;
|
||||
}
|
||||
|
||||
const cw::flow::preset_t* cw::flow::class_preset_find( const class_desc_t* cd, const char* preset_label )
|
||||
const cw::flow::class_preset_t* cw::flow::class_preset_find( const class_desc_t* cd, const char* preset_label )
|
||||
{
|
||||
const preset_t* pr;
|
||||
const class_preset_t* pr;
|
||||
for(pr=cd->presetL; pr!=nullptr; pr=pr->link)
|
||||
if( textCompare(pr->label,preset_label) == 0 )
|
||||
return pr;
|
||||
@ -1430,6 +1430,71 @@ void cw::flow::network_print( const network_t& net )
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(net.presetN > 0 )
|
||||
{
|
||||
cwLogPrint("Presets:\n");
|
||||
for(unsigned i=0; i<net.presetN; ++i)
|
||||
{
|
||||
const network_preset_t* net_preset = net.presetA + i;
|
||||
cwLogPrint("%i %s\n",i,net_preset->label);
|
||||
const preset_value_t* net_val = net_preset->value_head;
|
||||
for(; net_val!=nullptr; net_val=net_val->link)
|
||||
{
|
||||
cwLogPrint(" %s:%i %s:%i ",cwStringNullGuard(net_val->proc->label),net_val->proc->label_sfx_id,cwStringNullGuard(net_val->var->label),net_val->var->label_sfx_id);
|
||||
_value_print( &net_val->value );
|
||||
cwLogPrint("\n");
|
||||
}
|
||||
}
|
||||
cwLogPrint("\n");
|
||||
}
|
||||
}
|
||||
|
||||
const cw::flow::network_preset_t* cw::flow::network_preset_from_label( const network_t& net, const char* preset_label )
|
||||
{
|
||||
const network_preset_t* net_preset;
|
||||
for(unsigned i=0; i<net.presetN; ++i)
|
||||
if( textIsEqual(net.presetA[i].label,preset_label))
|
||||
return net.presetA + i;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
unsigned cw::flow::proc_mult_count( const network_t& net, const char* proc_label )
|
||||
{
|
||||
unsigned multN = 0;
|
||||
for(unsigned i=0; i<net.proc_arrayN; ++i)
|
||||
if( textIsEqual(net.proc_array[i]->label,proc_label) )
|
||||
multN += 1;
|
||||
|
||||
return multN;
|
||||
}
|
||||
|
||||
cw::rc_t cw::flow::proc_mult_sfx_id_array( const network_t& net, const char* proc_label, unsigned* idA, unsigned idAllocN, unsigned& idN_ref )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
unsigned multN = 0;
|
||||
|
||||
idN_ref = 0;
|
||||
|
||||
for(unsigned i=0; i<net.proc_arrayN; ++i)
|
||||
if( textIsEqual(net.proc_array[i]->label,proc_label) )
|
||||
{
|
||||
if( multN >= idAllocN )
|
||||
{
|
||||
rc = cwLogError(kBufTooSmallRC,"The mult-sfx-id result array is too small for the proc:'%s'.",cwStringNullGuard(proc_label));
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
idA[multN] = net.proc_array[i]->label_sfx_id;
|
||||
multN += 1;
|
||||
}
|
||||
|
||||
idN_ref = multN;
|
||||
|
||||
errLabel:
|
||||
|
||||
return kOkRC;
|
||||
}
|
||||
|
||||
void cw::flow::proc_destroy( proc_t* proc )
|
||||
@ -2162,6 +2227,71 @@ cw::rc_t cw::flow::var_get( variable_t* var, mbuf_t*& valRef )
|
||||
cw::rc_t cw::flow::var_get( const variable_t* var, const object_t*& valRef )
|
||||
{ return _val_get_driver(var,valRef); }
|
||||
|
||||
cw::rc_t cw::flow::cfg_to_value( const object_t* cfg, value_t& value_ref )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
|
||||
switch( cfg->type->id )
|
||||
{
|
||||
case kCharTId:
|
||||
case kUInt8TId:
|
||||
case kUInt16TId:
|
||||
case kUInt32TId:
|
||||
value_ref.tflag = kUIntTFl;
|
||||
if((rc = cfg->value(value_ref.u.u)) != kOkRC )
|
||||
rc = cwLogError(rc,"Conversion to uint failed.");
|
||||
break;
|
||||
|
||||
case kInt8TId:
|
||||
case kInt16TId:
|
||||
case kInt32TId:
|
||||
value_ref.tflag = kUIntTFl;
|
||||
if((rc = cfg->value(value_ref.u.i)) != kOkRC )
|
||||
rc = cwLogError(rc,"Conversion to int failed.");
|
||||
break;
|
||||
|
||||
case kInt64TId:
|
||||
case kUInt64TId:
|
||||
rc = cwLogError(kInvalidArgRC,"The flow system does not currently implement 64bit integers.");
|
||||
goto errLabel;
|
||||
break;
|
||||
|
||||
case kFloatTId:
|
||||
value_ref.tflag = kFloatTFl;
|
||||
if((rc = cfg->value(value_ref.u.f)) != kOkRC )
|
||||
rc = cwLogError(rc,"Conversion to float failed.");
|
||||
break;
|
||||
|
||||
case kDoubleTId:
|
||||
value_ref.tflag = kDoubleTFl;
|
||||
if((rc = cfg->value(value_ref.u.d)) != kOkRC )
|
||||
rc = cwLogError(rc,"Conversion to double failed.");
|
||||
break;
|
||||
|
||||
case kBoolTId:
|
||||
value_ref.tflag = kBoolTFl;
|
||||
if((rc = cfg->value(value_ref.u.b)) != kOkRC )
|
||||
rc = cwLogError(rc,"Conversion to bool failed.");
|
||||
break;
|
||||
|
||||
case kStringTId:
|
||||
case kCStringTId:
|
||||
value_ref.tflag = kStringTFl;
|
||||
if((rc = cfg->value(value_ref.u.s)) != kOkRC )
|
||||
rc = cwLogError(rc,"Conversion to string failed.");
|
||||
break;
|
||||
|
||||
default:
|
||||
value_ref.tflag = kCfgTFl;
|
||||
value_ref.u.cfg = cfg;
|
||||
|
||||
}
|
||||
errLabel:
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
cw::rc_t cw::flow::var_set_from_preset( variable_t* var, const object_t* value )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
|
@ -164,19 +164,19 @@ namespace cw
|
||||
struct var_desc_str* link; // class_desc->varDescL list link
|
||||
} var_desc_t;
|
||||
|
||||
typedef struct preset_str
|
||||
typedef struct class_preset_str
|
||||
{
|
||||
const char* label;
|
||||
const object_t* cfg;
|
||||
struct preset_str* link;
|
||||
} preset_t;
|
||||
const char* label;
|
||||
const object_t* cfg;
|
||||
struct class_preset_str* link;
|
||||
} class_preset_t;
|
||||
|
||||
typedef struct class_desc_str
|
||||
{
|
||||
const object_t* cfg; // class cfg
|
||||
const char* label; // class label;
|
||||
var_desc_t* varDescL; // varDescL variable description linked on var_desc_t.link
|
||||
preset_t* presetL; // presetA[ presetN ]
|
||||
class_preset_t* presetL; // presetA[ presetN ]
|
||||
class_members_t* members; // member functions for this class
|
||||
unsigned polyLimitN; // max. poly copies of this class per network_t or 0 if no limit
|
||||
} class_desc_t;
|
||||
@ -221,25 +221,12 @@ namespace cw
|
||||
} variable_t;
|
||||
|
||||
|
||||
struct proc_str;
|
||||
|
||||
typedef struct network_str
|
||||
{
|
||||
const object_t* procsCfg; // network proc list
|
||||
const object_t* presetsCfg; // presets designed for this network
|
||||
unsigned poly_cnt; // count of duplicated networks in the list
|
||||
|
||||
struct proc_str** proc_array;
|
||||
|
||||
unsigned proc_arrayAllocN;
|
||||
unsigned proc_arrayN;
|
||||
|
||||
} network_t;
|
||||
struct network_str;
|
||||
|
||||
typedef struct proc_str
|
||||
{
|
||||
struct flow_str* ctx; // global system context
|
||||
network_t* net; // network which owns this proc
|
||||
struct flow_str* ctx; // global system context
|
||||
struct network_str* net; // network which owns this proc
|
||||
|
||||
class_desc_t* class_desc; //
|
||||
|
||||
@ -260,11 +247,57 @@ namespace cw
|
||||
unsigned varMapN; // varMapN = varMapIdN * varMapChN
|
||||
variable_t** varMapA; // varMapA[ varMapN ] = allows fast lookup from ('vid','chIdx) to variable
|
||||
|
||||
network_t* internal_net;
|
||||
struct network_str* internal_net;
|
||||
|
||||
} proc_t;
|
||||
|
||||
|
||||
typedef struct preset_value_str
|
||||
{
|
||||
proc_t* proc;
|
||||
variable_t* var;
|
||||
value_t value;
|
||||
unsigned chN; // count of channels specified by this preset
|
||||
unsigned pairTblIdx; // index into the preset pair table for this preset value
|
||||
struct preset_value_str* link;
|
||||
} preset_value_t;
|
||||
|
||||
typedef struct network_preset_str
|
||||
{
|
||||
const char* label;
|
||||
preset_value_t* value_head; // List of preset_value_t for this preset.
|
||||
preset_value_t* value_tail;
|
||||
} network_preset_t;
|
||||
|
||||
typedef struct network_preset_pair_str
|
||||
{
|
||||
const proc_t* proc;
|
||||
const variable_t* var;
|
||||
unsigned chIdx;
|
||||
unsigned chN;
|
||||
const value_t* value;
|
||||
} network_preset_pair_t;
|
||||
|
||||
typedef struct network_str
|
||||
{
|
||||
const object_t* procsCfg; // network proc list
|
||||
const object_t* presetsCfg; // presets designed for this network
|
||||
unsigned poly_cnt; // count of duplicated networks in the list
|
||||
|
||||
struct proc_str** proc_array;
|
||||
|
||||
unsigned proc_arrayAllocN;
|
||||
unsigned proc_arrayN;
|
||||
|
||||
network_preset_t* presetA;
|
||||
unsigned presetN;
|
||||
|
||||
network_preset_pair_t* preset_pairA;
|
||||
unsigned preset_pairN;
|
||||
|
||||
} network_t;
|
||||
|
||||
|
||||
typedef struct flow_str
|
||||
{
|
||||
const object_t* flowCfg; // complete cfg used to create this flow
|
||||
@ -347,7 +380,7 @@ namespace cw
|
||||
const var_desc_t* var_desc_find( const class_desc_t* cd, const char* var_label );
|
||||
rc_t var_desc_find( class_desc_t* cd, const char* var_label, var_desc_t*& vdRef );
|
||||
|
||||
const preset_t* class_preset_find( const class_desc_t* cd, const char* preset_label );
|
||||
const class_preset_t* class_preset_find( const class_desc_t* cd, const char* preset_label );
|
||||
|
||||
void class_dict_print( flow_t* p );
|
||||
|
||||
@ -356,11 +389,18 @@ namespace cw
|
||||
//
|
||||
// Network
|
||||
//
|
||||
void network_print(const network_t& net );
|
||||
void network_print(const network_t& net );
|
||||
|
||||
const network_preset_t* network_preset_from_label( const network_t& net, const char* preset_label );
|
||||
|
||||
unsigned proc_mult_count( const network_t& net, const char* proc_label );
|
||||
|
||||
rc_t proc_mult_sfx_id_array( const network_t& net, const char* proc_label, unsigned* idA, unsigned idAllocN, unsigned& idN_ref );
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Instance
|
||||
// Proc
|
||||
//
|
||||
|
||||
void proc_destroy( proc_t* proc );
|
||||
@ -546,10 +586,12 @@ namespace cw
|
||||
rc_t var_find( proc_t* proc, unsigned vid, unsigned chIdx, variable_t*& varRef );
|
||||
|
||||
|
||||
// Count of numbered channels - does not count the kAnyChIdx variable procance.
|
||||
// Count of numbered channels - does not count the kAnyChIdx variable instance.
|
||||
rc_t var_channel_count( proc_t* proc, const char* label, unsigned sfx_idx, unsigned& chCntRef );
|
||||
rc_t var_channel_count( const variable_t* var, unsigned& chCntRef );
|
||||
|
||||
rc_t cfg_to_value( const object_t* cfg, value_t& value_ref );
|
||||
|
||||
|
||||
//
|
||||
// var_get() coerces the value of the variable to the type of the returned value.
|
||||
|
Loading…
Reference in New Issue
Block a user