cwFlowTypes.h/cpp,cwFlow.cpp,cwFlowNet.cpp : Updates to support recd_fmt_t.
Changed cfg_to_value() to value_from_cfg() and moved it to cwFlowValue.
This commit is contained in:
parent
e3423e775e
commit
5d748bdb7e
15
cwFlow.cpp
15
cwFlow.cpp
@ -75,7 +75,7 @@ namespace cw
|
|||||||
{ "midi_file", &midi_file::members },
|
{ "midi_file", &midi_file::members },
|
||||||
{ "midi_merge", &midi_merge::members },
|
{ "midi_merge", &midi_merge::members },
|
||||||
{ "score_player", &score_player::members },
|
{ "score_player", &score_player::members },
|
||||||
{ "midi_to_msg", &midi_to_msg::members },
|
// { "midi_to_msg", &midi_to_msg::members },
|
||||||
{ "score_follower", &score_follower::members },
|
{ "score_follower", &score_follower::members },
|
||||||
{ nullptr, nullptr }
|
{ nullptr, nullptr }
|
||||||
};
|
};
|
||||||
@ -233,6 +233,7 @@ namespace cw
|
|||||||
if((rc = vd->cfg->getv_opt("flags", var_flags_obj,
|
if((rc = vd->cfg->getv_opt("flags", var_flags_obj,
|
||||||
"type", var_value_type_str,
|
"type", var_value_type_str,
|
||||||
"value", vd->val_cfg,
|
"value", vd->val_cfg,
|
||||||
|
"fmt", vd->fmt_cfg,
|
||||||
"proxy", proxy_string )) != kOkRC )
|
"proxy", proxy_string )) != kOkRC )
|
||||||
{
|
{
|
||||||
rc = cwLogError(rc,"Parsing optional fields failed.");
|
rc = cwLogError(rc,"Parsing optional fields failed.");
|
||||||
@ -241,11 +242,23 @@ namespace cw
|
|||||||
|
|
||||||
// convert the type string to a numeric type flag
|
// convert the type string to a numeric type flag
|
||||||
if( var_value_type_str != nullptr )
|
if( var_value_type_str != nullptr )
|
||||||
|
{
|
||||||
if( (vd->type = value_type_label_to_flag( var_value_type_str )) == kInvalidTId )
|
if( (vd->type = value_type_label_to_flag( var_value_type_str )) == kInvalidTId )
|
||||||
{
|
{
|
||||||
rc = cwLogError(kSyntaxErrorRC,"Invalid variable description type flag: '%s' was encountered.", var_value_type_str );
|
rc = cwLogError(kSyntaxErrorRC,"Invalid variable description type flag: '%s' was encountered.", var_value_type_str );
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if this is a 'record' type with a 'fmt' specifier
|
||||||
|
if( vd->type & kRBufTFl && vd->fmt_cfg != nullptr )
|
||||||
|
{
|
||||||
|
if((rc = recd_format_create( vd->fmt.recd_fmt, vd->fmt_cfg )) != kOkRC )
|
||||||
|
{
|
||||||
|
rc = cwLogError(rc,"The record type associated with the 'fmt' field could not be created.");
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// parse the proxy string into it's two parts: <proc>.<var>
|
// parse the proxy string into it's two parts: <proc>.<var>
|
||||||
if( proxy_string != nullptr )
|
if( proxy_string != nullptr )
|
||||||
|
@ -1953,6 +1953,7 @@ namespace cw
|
|||||||
rc = cwLogError(rc,"Input connection processing failed.");
|
rc = cwLogError(rc,"Input connection processing failed.");
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Connect the proxied vars in this subnet proc to their respective proxy vars.
|
// Connect the proxied vars in this subnet proc to their respective proxy vars.
|
||||||
if((rc = _subnet_connect_proxy_vars( proc, proxyVarL )) != kOkRC )
|
if((rc = _subnet_connect_proxy_vars( proc, proxyVarL )) != kOkRC )
|
||||||
@ -2267,7 +2268,7 @@ namespace cw
|
|||||||
preset_value_t* preset_value = mem::allocZ<preset_value_t>();
|
preset_value_t* preset_value = mem::allocZ<preset_value_t>();
|
||||||
|
|
||||||
// cfg to value
|
// cfg to value
|
||||||
if((rc = cfg_to_value( value_cfg, preset_value->value )) != kOkRC )
|
if((rc = value_from_cfg( value_cfg, preset_value->value )) != kOkRC )
|
||||||
{
|
{
|
||||||
rc = cwLogError(rc,"The preset cfg to value conversion failed on '%s:%i'-'%s:%i'.",cwStringNullGuard(var->label),var->label_sfx_id,cwStringNullGuard(proc->label),proc->label_sfx_id);
|
rc = cwLogError(rc,"The preset cfg to value conversion failed on '%s:%i'-'%s:%i'.",cwStringNullGuard(var->label),var->label_sfx_id,cwStringNullGuard(proc->label),proc->label_sfx_id);
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
|
@ -534,6 +534,9 @@ void cw::flow::var_desc_destroy( var_desc_t* var_desc )
|
|||||||
{
|
{
|
||||||
if( var_desc != nullptr )
|
if( var_desc != nullptr )
|
||||||
{
|
{
|
||||||
|
if( var_desc_has_recd_format(var_desc) )
|
||||||
|
recd_format_destroy(var_desc->fmt.recd_fmt);
|
||||||
|
|
||||||
mem::release(var_desc->proxyProcLabel);
|
mem::release(var_desc->proxyProcLabel);
|
||||||
mem::release(var_desc->proxyVarLabel);
|
mem::release(var_desc->proxyVarLabel);
|
||||||
mem::release(var_desc);
|
mem::release(var_desc);
|
||||||
@ -621,6 +624,11 @@ cw::rc_t cw::flow::var_desc_find( class_desc_t* cd, const char* label, var_desc_
|
|||||||
return kOkRC;
|
return kOkRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cw::flow::var_desc_has_recd_format( var_desc_t* vd )
|
||||||
|
{
|
||||||
|
return vd!=nullptr && vd->type & kRBufTFl && vd->fmt_cfg != nullptr && vd->fmt.recd_fmt != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
const cw::flow::class_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 class_preset_t* pr;
|
const class_preset_t* pr;
|
||||||
@ -1396,6 +1404,9 @@ bool cw::flow::is_connected_to_source( const variable_t* var )
|
|||||||
bool cw::flow::is_a_source_var( const variable_t* var )
|
bool cw::flow::is_a_source_var( const variable_t* var )
|
||||||
{ return var->dst_head != nullptr; }
|
{ return var->dst_head != nullptr; }
|
||||||
|
|
||||||
|
bool cw::flow::var_has_recd_format( const variable_t* var )
|
||||||
|
{ return var!=nullptr && var_desc_has_recd_format(var->varDesc); }
|
||||||
|
|
||||||
|
|
||||||
void cw::flow::var_connect( variable_t* src_var, variable_t* in_var )
|
void cw::flow::var_connect( variable_t* src_var, variable_t* in_var )
|
||||||
{
|
{
|
||||||
@ -1634,77 +1645,13 @@ cw::rc_t cw::flow::var_get( variable_t* var, rbuf_t*& valRef )
|
|||||||
cw::rc_t cw::flow::var_get( const variable_t* var, const object_t*& valRef )
|
cw::rc_t cw::flow::var_get( const variable_t* var, const object_t*& valRef )
|
||||||
{ return _val_get_driver(var,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 = kIntTFl;
|
|
||||||
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_cfg( variable_t* var, const object_t* cfg_value )
|
cw::rc_t cw::flow::var_set_from_cfg( variable_t* var, const object_t* cfg_value )
|
||||||
{
|
{
|
||||||
rc_t rc = kOkRC;
|
rc_t rc = kOkRC;
|
||||||
value_t v;
|
value_t v;
|
||||||
|
|
||||||
if((rc = cfg_to_value(cfg_value, v)) != kOkRC )
|
if((rc = value_from_cfg(cfg_value, v)) != kOkRC )
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
|
|
||||||
if((rc = var_set(var,&v)) != kOkRC )
|
if((rc = var_set(var,&v)) != kOkRC )
|
||||||
|
@ -29,15 +29,21 @@ namespace cw
|
|||||||
member_func_t exec;
|
member_func_t exec;
|
||||||
member_func_t report;
|
member_func_t report;
|
||||||
} class_members_t;
|
} class_members_t;
|
||||||
|
|
||||||
typedef struct var_desc_str
|
typedef struct var_desc_str
|
||||||
{
|
{
|
||||||
const object_t* cfg; // The cfg object that describes this variable from 'flow_class'.
|
const object_t* cfg; // The cfg object that describes this variable from 'flow_class'.
|
||||||
const object_t* val_cfg; // An object containing the default value for this variable.
|
const object_t* val_cfg; // An object containing the default value for this variable.
|
||||||
|
const object_t* fmt_cfg; // An object containg the format (e.g. record fields) information
|
||||||
const char* label; // Name of this var.
|
const char* label; // Name of this var.
|
||||||
unsigned type; // Value type id (e.g. kBoolTFl, kIntTFl, ...)
|
unsigned type; // Value type id (e.g. kBoolTFl, kIntTFl, ...)
|
||||||
unsigned flags; // Attributes for this var. (e.g. kSrcVarFl )
|
unsigned flags; // Attributes for this var. (e.g. kSrcVarFl )
|
||||||
const char* docText; // User help string for this var.
|
const char* docText; // User help string for this var.
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
recd_fmt_t* recd_fmt; // the 'recd_type.base' is never set in 'recd_type' because it is only valid once the var is instantiated
|
||||||
|
} fmt;
|
||||||
|
|
||||||
char* proxyProcLabel;
|
char* proxyProcLabel;
|
||||||
char* proxyVarLabel;
|
char* proxyVarLabel;
|
||||||
@ -92,7 +98,7 @@ namespace cw
|
|||||||
unsigned local_value_idx; // local_value[] is double buffered to allow the cur value of the buf[] to be held while the next value is validated (see _var_set_template())
|
unsigned local_value_idx; // local_value[] is double buffered to allow the cur value of the buf[] to be held while the next value is validated (see _var_set_template())
|
||||||
struct variable_str* src_var; // pointer to this input variables source link (or null if it uses the local_value)
|
struct variable_str* src_var; // pointer to this input variables source link (or null if it uses the local_value)
|
||||||
value_t* value; // pointer to the value associated with this variable
|
value_t* value; // pointer to the value associated with this variable
|
||||||
|
|
||||||
struct variable_str* var_link; // instance.varL list link
|
struct variable_str* var_link; // instance.varL list link
|
||||||
struct variable_str* ch_link; // list of channels that share this variable (rooted on 'any' channel - in order by channel number)
|
struct variable_str* ch_link; // list of channels that share this variable (rooted on 'any' channel - in order by channel number)
|
||||||
|
|
||||||
@ -291,6 +297,8 @@ namespace cw
|
|||||||
const var_desc_t* var_desc_find( const class_desc_t* cd, const char* var_label );
|
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 );
|
rc_t var_desc_find( class_desc_t* cd, const char* var_label, var_desc_t*& vdRef );
|
||||||
|
|
||||||
|
bool var_desc_has_recd_format( var_desc_t* vd );
|
||||||
|
|
||||||
const class_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 );
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -389,6 +397,9 @@ namespace cw
|
|||||||
// Return true if this var is acting as a source for another var.
|
// Return true if this var is acting as a source for another var.
|
||||||
bool is_a_source_var( const variable_t* var );
|
bool is_a_source_var( const variable_t* var );
|
||||||
|
|
||||||
|
// Returns true if var->varDesc->fmt.recd_fmt is valid.
|
||||||
|
bool var_has_recd_format( const variable_t* var );
|
||||||
|
|
||||||
// Connect in_var to src_var.
|
// Connect in_var to src_var.
|
||||||
void var_connect( variable_t* src_var, variable_t* in_var );
|
void var_connect( variable_t* src_var, variable_t* in_var );
|
||||||
|
|
||||||
@ -529,7 +540,6 @@ namespace cw
|
|||||||
rc_t var_channel_count( proc_t* proc, const char* label, unsigned sfx_idx, unsigned& chCntRef );
|
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 var_channel_count( const variable_t* var, unsigned& chCntRef );
|
||||||
|
|
||||||
rc_t cfg_to_value( const object_t* cfg, value_t& value_ref );
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user