/** @internal * Function oyOption_Copy__Members * @memberof oyOption_s * @brief Custom Option copy constructor * * This function makes a copy of all values from the input * to the output object. The destination object and all of its * members should already be allocated. * * @param[in] src the oyOption_s_ input object * @param[out] dst the output oyOption_s_ object * * @version Oyranos: x.x.x * @since YYYY/MM/DD (Oyranos: x.x.x) * @date YYYY/MM/DD */ int oyOption_Copy__Members( oyOption_s_ * dst, oyOption_s_ * src) { oyAlloc_f allocateFunc_ = 0; oyDeAlloc_f deallocateFunc_ = 0; int error = 0; if(!dst || !src) return 1; allocateFunc_ = dst->oy_->allocateFunc_; deallocateFunc_ = dst->oy_->deallocateFunc_; /* Copy each value of src to dst here */ if(dst->value_type == src->value_type && oyValueEqual( dst->value, src->value, dst->value_type, -1 )) return -1; /* oyOption_Clear does normally signal emitting; block that. */ oyStruct_DisableSignalSend( (oyStruct_s*)dst ); error = oyOption_Clear( (oyOption_s*)dst ); oyStruct_EnableSignalSend( (oyStruct_s*)dst ); dst->registration = oyStringCopy_( src->registration, allocateFunc_ ); dst->value_type = src->value_type; dst->value = allocateFunc_(sizeof(oyValue_u)); memset(dst->value, 0, sizeof(oyValue_u)); oyValueCopy( dst->value, src->value, dst->value_type, allocateFunc_, deallocateFunc_ ); dst->source = src->source; dst->flags = src->flags; oyStruct_ObserverSignal( (oyStruct_s*)dst, oySIGNAL_DATA_CHANGED, 0 ); return error; }
/** Function oyNamedColor_Copy__Members * @memberof oyNamedColor_s * @brief Custom NamedColor copy constructor * @internal * * This function makes a copy of all values from the input * to the output object. The destination object and all of its * members should already be allocated. * * @param[in] src the oyNamedColor_s_ input object * @param[out] dst the output oyNamedColor_s_ object * * @version Oyranos: x.x.x * @since YYYY/MM/DD (Oyranos: x.x.x) * @date YYYY/MM/DD */ int oyNamedColor_Copy__Members( oyNamedColor_s_ * dst, oyNamedColor_s_ * src) { int error = 0; oyNamedColor_s_ * s = dst; oyAlloc_f allocateFunc_ = 0; const double * chan; const char * blob; int blob_len; oyProfile_s * ref; int n = 0; if(!dst || !src) return 1; allocateFunc_ = dst->oy_->allocateFunc_; chan = src->channels_; blob = src->blob_; blob_len = src->blob_len_; ref = src->profile_; /* Copy each value of src to dst here */ if(error <= 0) { s->profile_ = oyProfile_Copy( ref, 0 ); } n = oyProfile_GetChannelsCount( s->profile_ ); if(n) s->channels_ = allocateFunc_( n * sizeof(double) ); oyCopyColor( chan, &s->channels_[0], 1, ref, n ); oyCopyColor( 0, &s->XYZ_[0], 1, 0, 0 ); if(error <= 0 && blob && blob_len) { s->blob_ = allocateFunc_( blob_len ); if(!s->blob_) error = 1; if(error <= 0) error = !memcpy( s->blob_, blob, blob_len ); if(error <= 0) s->blob_len_ = blob_len; } return error; }
/** Function oyPixelAccess_Copy__Members * @memberof oyPixelAccess_s * @brief Custom PixelAccess copy constructor * @internal * * This function makes a copy of all values from the input * to the output object. The destination object and all of its * members should already be allocated. * * @param[in] src the oyPixelAccess_s_ input object * @param[out] dst the output oyPixelAccess_s_ object * * @version Oyranos: x.x.x * @since YYYY/MM/DD (Oyranos: x.x.x) * @date YYYY/MM/DD */ int oyPixelAccess_Copy__Members( oyPixelAccess_s_ * dst, oyPixelAccess_s_ * src) { int error = 0, len; oyAlloc_f allocateFunc_ = 0; #if 0 oyDeAlloc_f deallocateFunc_ = 0; #endif if(!dst || !src) return 1; allocateFunc_ = dst->oy_->allocateFunc_; #if 0 deallocateFunc_ = dst->oy_->deallocateFunc_; #endif /* Copy each value of src to dst here */ dst->start_xy_old[0] = dst->start_xy[0] = src->start_xy[0]; dst->start_xy_old[1] = dst->start_xy[1] = src->start_xy[1]; dst->array_n = src->array_n; if(src->array_xy && src->array_n) { len = sizeof(int32_t) * 2 * src->array_n; dst->array_xy = allocateFunc_(len); error = !dst->array_xy; if(error <= 0) error = !memcpy(dst->array_xy, src->array_xy, len); } /* reset to properly initialise the new iterator */ dst->index = 0; dst->pixels_n = src->pixels_n; dst->workspace_id = src->workspace_id; dst->output_array_roi = (oyRectangle_s_*)oyRectangle_Copy( (oyRectangle_s*)src->output_array_roi, dst->oy_ ); dst->output_image = oyImage_Copy( src->output_image, 0 ); dst->array = oyArray2d_Copy( src->array, 0 ); if(src->user_data && src->user_data->copy) dst->user_data = src->user_data->copy( src->user_data, 0 ); else dst->user_data = src->user_data; dst->graph = (oyFilterGraph_s_*)oyFilterGraph_Copy( (oyFilterGraph_s*)src->graph, 0 ); return error; }
/** Function oyFilterNode_GetSocket * @memberof oyFilterNode_s * @brief Get a oyFilterSocket_s of type from a FilterNode * * @param node filter node * @param pos absolute position of connector * @return the socket * * @version Oyranos: 0.1.8 * @since 2008/07/30 (Oyranos: 0.1.8) * @date 2008/07/30 */ OYAPI oyFilterSocket_s * OYEXPORT oyFilterNode_GetSocket ( oyFilterNode_s * node, int pos ) { oyFilterSocket_s_ * s = 0; oyFilterNode_s_ * node_ = (oyFilterNode_s_*)node; if(node_ && node_->type_ == oyOBJECT_FILTER_NODE_S && /* do a range check */ (0 <= pos && pos < oyFilterNode_EdgeCount( (oyFilterNode_s*)node_, 0, 0 ))) { oyAlloc_f allocateFunc_ = node_->oy_->allocateFunc_; if(!node_->sockets) { int count = oyFilterNode_EdgeCount( (oyFilterNode_s*)node_, 0, 0 ); size_t len; if(count < 0) count = 0; len = sizeof(oyFilterSocket_s*) * (count + 1); node_->sockets = allocateFunc_( len ); memset( node_->sockets, 0, len ); } if(!node_->sockets[pos]) { s = (oyFilterSocket_s_*)oyFilterSocket_New( node_->oy_ ); s->pattern = oyFilterNode_ShowConnector( (oyFilterNode_s*)node_, pos, 0 ); s->node = (oyFilterNode_s_*)oyFilterNode_Copy( (oyFilterNode_s*)node_,0 ); oyFilterSocket_Copy((oyFilterSocket_s*)s, 0); /* ref for node */ s->relatives_ = oyStringCopy_( node_->relatives_, allocateFunc_ ); node_->sockets[pos] = s; } s = (oyFilterSocket_s_*)oyFilterSocket_Copy((oyFilterSocket_s*)node_->sockets[pos], 0); } return (oyFilterSocket_s*)s; }
/** Function oyFilterNode_GetPlug * @memberof oyFilterNode_s * @brief Get a oyFilterPlug_s of type from a FilterNode * * @param node filter node * @param pos position of connector from filter * @return the plug * * @version Oyranos: 0.1.8 * @since 2008/07/30 (Oyranos: 0.1.8) * @date 2008/07/30 */ OYAPI oyFilterPlug_s * OYEXPORT oyFilterNode_GetPlug ( oyFilterNode_s * node, int pos ) { oyFilterNode_s_ * node_ = (oyFilterNode_s_*)node; oyFilterPlug_s_ * s = 0; if(node_ && node_->type_ == oyOBJECT_FILTER_NODE_S && pos < oyFilterNode_EdgeCount( (oyFilterNode_s*)node_, 1, 0 )) { oyAlloc_f allocateFunc_ = node_->oy_->allocateFunc_; if(!node_->plugs) { int count = oyFilterNode_EdgeCount( (oyFilterNode_s*)node_, 1, 0 ); size_t len; if(count < 0) count = 0; len = sizeof(oyFilterPlug_s*) * (count + 1); node_->plugs = allocateFunc_( len ); memset( node_->plugs, 0, len ); } if(!node_->plugs[pos]) { s = (oyFilterPlug_s_*)oyFilterPlug_New( node_->oy_ ); s->pattern = oyFilterNode_ShowConnector( (oyFilterNode_s*)node_, pos, 1 ); s->node = (oyFilterNode_s_*)oyFilterNode_Copy( (oyFilterNode_s*)node_, 0); oyFilterPlug_Copy((oyFilterPlug_s*)s,0); /* ref node */ s->relatives_ = oyStringCopy_( node_->relatives_, allocateFunc_ ); node_->plugs[pos] = s; } s = node_->plugs[pos]; } oyFilterPlug_Copy((oyFilterPlug_s*)s,0); return (oyFilterPlug_s*)s; }
/** Function oyFilterNode_Create * @memberof oyFilterNode_s * @brief Initialise a new filter node object properly * * @param registration the processing filter @ref registration string * @param filter the context filter * @param object the optional object * * @version Oyranos: 0.9.6 * @date 2014/07/01 * @since 2008/07/30 (Oyranos: 0.1.8) */ oyFilterNode_s * oyFilterNode_Create(const char * registration, oyFilterCore_s * filter, oyObject_s object ) { oyFilterNode_s_ * s = 0; int error = 0; oyAlloc_f allocateFunc_ = 0; oyFilterCore_s_ * filter_ = (oyFilterCore_s_*)filter; if(!filter) return (oyFilterNode_s*) s; s = (oyFilterNode_s_*) oyFilterNode_New( object ); error = !s; if(error <= 0) { allocateFunc_ = s->oy_->allocateFunc_; s->core = (oyFilterCore_s_*)oyFilterCore_Copy( filter, object ); if(!s->core) { WARNc2_S("Could not copy filter: %s %s", filter_->registration_, filter_->category_) error = 1; } if(error <= 0) s->api7_ = (oyCMMapi7_s_*) oyCMMsGetFilterApi_( registration, oyOBJECT_CMM_API7_S ); if(error <= 0 && !s->api7_) { WARNc2_S("Could not obtain filter api7 for: %s %s", filter_->registration_, filter_->category_) error = 1; } if(s->api7_) { s->plugs_n_ = s->api7_->plugs_n + s->api7_->plugs_last_add; if(s->api7_->plugs_last_add) --s->plugs_n_; s->sockets_n_ = s->api7_->sockets_n + s->api7_->sockets_last_add; if(s->api7_->sockets_last_add) --s->sockets_n_; } if(s->core) { int count = oyFilterNode_EdgeCount( (oyFilterNode_s*) s, 0, 0 ); size_t len; if(count < 0) count = 0; len = sizeof(oyFilterSocket_s*) * (count + 1); s->sockets = allocateFunc_( len ); memset( s->sockets, 0, len ); len = sizeof(oyFilterSocket_s*) * (oyFilterNode_EdgeCount( (oyFilterNode_s*) s, 1, 0 ) + 1); len = len?len:sizeof(oyFilterSocket_s*); s->plugs = allocateFunc_( len ); memset( s->plugs, 0, len ); s->relatives_ = allocateFunc_( oyStrlen_(filter_->category_) + 24 ); oySprintf_( s->relatives_, "%d: %s", oyObject_GetId(s->oy_), s->core->category_); } } if(error) oyFilterNode_Release( (oyFilterNode_s**) &s ); return (oyFilterNode_s*) s; }