/** Function oyFilterNode_ShowConnector * @memberof oyFilterNode_s * @brief Get a connector description from a filter module * * The path to obtain a new connector. * The filter can say it has more connectors to provide for a certain kind of * static connector eigther described in oyCMMapi4_s::inputs or * oyCMMapi4_s::outputs. * * @param[in] node the module filter node * @param[in] as_pos the according oyConnector_s * @param[in] is_plug select from 0 - plugs or 1 - sockets * @return the new oyConnector_s * * @version Oyranos: 0.1.10 * @since 2008/07/28 (Oyranos: 0.1.8) * @date 2008/12/27 */ OYAPI oyConnector_s * OYEXPORT oyFilterNode_ShowConnector ( oyFilterNode_s * node, int as_pos, int is_plug ) { oyConnector_s * pattern = 0; oyObject_s object = 0; oyFilterNode_s_ ** node_ = (oyFilterNode_s_**)&node; if(!node || !(*node_)->core || node->type_ != oyOBJECT_FILTER_NODE_S || !(*node_)->api7_) return 0; object = oyObject_New (); if(is_plug) { if((*node_)->api7_->plugs_n <= (size_t)as_pos && as_pos < oyFilterNode_EdgeCount( node, 1, 0 )) as_pos = (*node_)->api7_->plugs_n - 1; if((*node_)->api7_->plugs_n > (size_t)as_pos) { if((*node_)->api7_->plugs[as_pos] && (*node_)->api7_->plugs[as_pos]->copy) { pattern = (oyConnector_s*) (*node_)->api7_->plugs[as_pos]->copy( (oyStruct_s*) (*node_)->api7_->plugs[as_pos], object ); if(oy_debug_objects >= 0) oyObjectDebugMessage_( (*node_)->api7_->plugs[as_pos]->oy_, __func__, oyStructTypeToText((*node_)->api7_->plugs[as_pos]->type_) ); } else { pattern = oyConnector_Copy( (*node_)->api7_->plugs[as_pos], object ); } } } else { if((*node_)->api7_->sockets_n <= (size_t)as_pos && as_pos < oyFilterNode_EdgeCount( node, 0, 0 )) as_pos = (*node_)->api7_->sockets_n - 1; if((*node_)->api7_->sockets_n > (size_t)as_pos) { if((*node_)->api7_->sockets[as_pos] && (*node_)->api7_->sockets[as_pos]->copy) { pattern = (oyConnector_s*) (*node_)->api7_->sockets[as_pos]->copy( (oyStruct_s*) (*node_)->api7_->sockets[as_pos], object ); if(oy_debug_objects >= 0) oyObjectDebugMessage_( (*node_)->api7_->sockets[as_pos]->oy_, __func__, oyStructTypeToText((*node_)->api7_->sockets[as_pos]->type_) ); } else { pattern = oyConnector_Copy( (*node_)->api7_->sockets[as_pos], object ); } } } oyObject_Release( &object ); return pattern; }
/** Function: oyNamedColor_CreateWithName * @memberof oyNamedColor_s * @brief create a oyNamedColor_s struct * * @since Oyranos: version 0.1.8 * @date 22 december 2007 (API 0.1.8) * * @param[in] nick very short, only a few letters * @param[in] name of the color * @param[in] description description * @param[in] chan pointer to channel data with a number of elements specified in sig or channels_n * @param[in] XYZ reference values * @param[in] blob CGATS or other reference data * @param[in] blob_len length of the data blob * @param[in] profile_ref profile * @param[in] object memory management * @return a oyNamedColor_s * */ oyNamedColor_s * oyNamedColor_CreateWithName ( const char * nick, const char * name, const char * description, const double * chan, const double * XYZ, const char * blob, int blob_len, oyProfile_s * profile_ref, oyObject_s object ) { int error = 0; oyNamedColor_s_ * s = 0; oyObject_s s_obj = oyObject_NewFrom( object ); error = !s_obj; if(error <= 0) error = oyObject_SetNames( s_obj, nick, name, description ); s = (oyNamedColor_s_*) oyNamedColor_Create( chan, blob, blob_len, profile_ref, s_obj ); error =!s; oyObject_Release( &s_obj ); if(error <= 0 && XYZ) oyCopyColor( XYZ, s->XYZ_, 1, 0, 0 ); return (oyNamedColor_s*) s; }
/** @internal * Function oyOption_Release_ * @memberof oyOption_s_ * @brief release and possibly deallocate a Option object * * @param[in,out] option Option struct object * * @version Oyranos: * @since 2010/04/26 (Oyranos: 0.1.10) * @date 2010/04/26 */ int oyOption_Release_( oyOption_s_ **option ) { /* ---- start of common object destructor ----- */ oyOption_s_ *s = 0; if(!option || !*option) return 0; s = *option; *option = 0; if(oyObject_UnRef(s->oy_)) return 0; /* ---- end of common object destructor ------- */ /* ---- start of custom Option destructor ----- */ oyOption_Release__Members( s ); /* ---- end of custom Option destructor ------- */ if(s->oy_->deallocateFunc_) { oyDeAlloc_f deallocateFunc = s->oy_->deallocateFunc_; oyObject_Release( &s->oy_ ); deallocateFunc( s ); } return 0; }
/** @internal * Function oyProfileTag_Release_ * @memberof oyProfileTag_s_ * @brief release and possibly deallocate a ProfileTag object * * @param[in,out] profiletag ProfileTag struct object * * @version Oyranos: * @since 2010/04/26 (Oyranos: 0.1.10) * @date 2010/04/26 */ int oyProfileTag_Release_( oyProfileTag_s_ **profiletag ) { /* ---- start of common object destructor ----- */ oyProfileTag_s_ *s = 0; if(!profiletag || !*profiletag) return 0; s = *profiletag; *profiletag = 0; if(oyObject_UnRef(s->oy_)) return 0; /* ---- end of common object destructor ------- */ /* ---- start of custom ProfileTag destructor ----- */ oyProfileTag_Release__Members( s ); /* ---- end of custom ProfileTag destructor ------- */ if(s->oy_->deallocateFunc_) { oyDeAlloc_f deallocateFunc = s->oy_->deallocateFunc_; oyObject_Release( &s->oy_ ); deallocateFunc( s ); } return 0; }
/** @internal * Function oyNamedColor_Release_ * @memberof oyNamedColor_s_ * @brief release and possibly deallocate a NamedColor object * * @param[in,out] namedcolor NamedColor struct object * * @version Oyranos: * @since 2010/04/26 (Oyranos: 0.1.10) * @date 2010/04/26 */ int oyNamedColor_Release_( oyNamedColor_s_ **namedcolor ) { /* ---- start of common object destructor ----- */ oyNamedColor_s_ *s = 0; if(!namedcolor || !*namedcolor) return 0; s = *namedcolor; *namedcolor = 0; if(oyObject_UnRef(s->oy_)) return 0; /* ---- end of common object destructor ------- */ /* ---- start of custom NamedColor destructor ----- */ oyNamedColor_Release__Members( s ); /* ---- end of custom NamedColor destructor ------- */ if(s->oy_->deallocateFunc_) { oyDeAlloc_f deallocateFunc = s->oy_->deallocateFunc_; oyObject_Release( &s->oy_ ); deallocateFunc( s ); } return 0; }
/** @internal * Function oyFilterGraph_Release_ * @memberof oyFilterGraph_s_ * @brief release and possibly deallocate a FilterGraph object * * @param[in,out] filtergraph FilterGraph struct object * * @version Oyranos: 0.9.7 * @date 2018/10/03 * @since 2010/04/26 (Oyranos: 0.1.10) */ int oyFilterGraph_Release_( oyFilterGraph_s_ **filtergraph ) { const char * track_name = NULL; int observer_refs = 0, i; /* ---- start of common object destructor ----- */ oyFilterGraph_s_ *s = 0; if(!filtergraph || !*filtergraph) return 0; s = *filtergraph; /* static object */ if(!s->oy_) return 0; *filtergraph = 0; observer_refs = oyStruct_ObservationCount( (oyStruct_s*)s, 0 ); if(oy_debug_objects >= 0) { const char * t = getenv(OY_DEBUG_OBJECTS); int id_ = -1; if(t) id_ = atoi(t); else id_ = oy_debug_objects; if((id_ >= 0 && s->oy_->id_ == id_) || (t && (strstr(oyStructTypeToText(s->type_), t) != 0)) || id_ == 1) { oyStruct_s ** parents = NULL; int n = oyStruct_GetParents( (oyStruct_s*)s, &parents ); if(n != s->oy_->ref_) { int i; #ifdef HAVE_BACKTRACE int j, nptrs; void *buffer[BT_BUF_SIZE]; char **strings; nptrs = backtrace(buffer, BT_BUF_SIZE); /* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO) would produce similar output to the following: */ strings = backtrace_symbols(buffer, nptrs); if( strings == NULL ) { perror("backtrace_symbols"); } else { int start = nptrs-1; do { --start; } while( start >= 0 && (strstr(strings[start], "(main+") == NULL) ); fprintf(stderr, "\n"); for(j = start; j >= 0; j--) { if(oy_debug) fprintf(stderr, "%s\n", strings[j]); else { char * t = NULL, * txt = NULL; const char * line = strings[j], * tmp = strchr( line, '(' ); if(tmp) t = oyStringCopy( &tmp[1], NULL ); else t = oyStringCopy( line, NULL ); txt = strchr( t, '+' ); if(txt) txt[0] = '\000'; if(j > 0 && (strstr(strings[j-1], t) != NULL) ) oyFree_m_(t); if(t) { if(j==0) fprintf(stderr, "%s() ", t); else fprintf(stderr, "%s()->", t); oyFree_m_(t); } } } free(strings); } #endif track_name = oyStructTypeToText(s->type_); fprintf( stderr, "%s[%d] unref with refs: %d observers: %d parents: %d\n", track_name, s->oy_->id_, s->oy_->ref_, observer_refs, n ); for(i = 0; i < n; ++i) { track_name = oyStructTypeToText(parents[i]->type_); fprintf( stderr, "parent[%d]: %s[%d]\n", i, track_name, parents[i]->oy_->id_ ); } } } } if((oyObject_UnRef(s->oy_) - observer_refs) > 0) return 0; /* ---- end of common object destructor ------- */ if(oy_debug_objects >= 0) { const char * t = getenv(OY_DEBUG_OBJECTS); int id_ = -1; if(t) id_ = atoi(t); else id_ = oy_debug_objects; if((id_ >= 0 && s->oy_->id_ == id_) || (t && s && (strstr(oyStructTypeToText(s->type_), t) != 0)) || id_ == 1) { track_name = oyStructTypeToText(s->type_); fprintf( stderr, "%s[%d] destruct\n", track_name, s->oy_->id_); } } /* ---- start of custom FilterGraph destructor ----- */ oyFilterGraph_Release__Members( s ); /* ---- end of custom FilterGraph destructor ------- */ /* model and observer reference each other. So release the object two times. * The models and and observers are released later inside the * oyObject_s::handles. */ for(i = 0; i < observer_refs; ++i) { oyObject_UnRef(s->oy_); oyObject_UnRef(s->oy_); } if(s->oy_->deallocateFunc_) { oyDeAlloc_f deallocateFunc = s->oy_->deallocateFunc_; int id = s->oy_->id_; int refs = s->oy_->ref_; if(refs > 1) fprintf( stderr, "!!!ERROR: node[%d]->object can not be untracked with refs: %d\n", id, refs); oyObject_Release( &s->oy_ ); if(track_name) fprintf( stderr, "%s[%d] destructed\n", track_name, id ); deallocateFunc( s ); } return 0; }
/** @internal * Function oyFilterGraph_New_ * @memberof oyFilterGraph_s_ * @brief allocate a new oyFilterGraph_s_ object * * @version Oyranos: * @since 2010/04/26 (Oyranos: 0.1.10) * @date 2010/04/26 */ oyFilterGraph_s_ * oyFilterGraph_New_ ( oyObject_s object ) { /* ---- start of common object constructor ----- */ oyOBJECT_e type = oyOBJECT_FILTER_GRAPH_S; int error = 0; oyObject_s s_obj = oyObject_NewFrom( object ); oyFilterGraph_s_ * s = 0; if(s_obj) s = (oyFilterGraph_s_*)s_obj->allocateFunc_(sizeof(oyFilterGraph_s_)); else { WARNc_S(_("MEM Error.")); return NULL; } if(!s) { if(s_obj) oyObject_Release( &s_obj ); WARNc_S(_("MEM Error.")); return NULL; } error = !memset( s, 0, sizeof(oyFilterGraph_s_) ); if(error) WARNc_S( "memset failed" ); memcpy( s, &type, sizeof(oyOBJECT_e) ); s->copy = (oyStruct_Copy_f) oyFilterGraph_Copy; s->release = (oyStruct_Release_f) oyFilterGraph_Release; s->oy_ = s_obj; /* ---- start of custom FilterGraph constructor ----- */ error += !oyObject_SetParent( s_obj, oyOBJECT_FILTER_GRAPH_S, (oyPointer)s ); /* ---- end of custom FilterGraph constructor ------- */ /* ---- end of common object constructor ------- */ if(error) WARNc_S( "oyObject_SetParent failed" ); /* ---- start of custom FilterGraph constructor ----- */ error += oyFilterGraph_Init__Members( s ); /* ---- end of custom FilterGraph constructor ------- */ if(!oy_filtergraph_init_) { oy_filtergraph_init_ = 1; oyStruct_RegisterStaticMessageFunc( type, oyFilterGraph_StaticMessageFunc_ ); } if(error) WARNc1_S("%d", error); if(oy_debug_objects >= 0) oyObject_GetId( s->oy_ ); return s; }