/** Function oyHash_Get_ * @memberof oyHash_s * @brief Get a new Oyranos cache entry * @internal * * @since Oyranos: version 0.1.8 * @date 24 november 2007 (API 0.1.8) */ oyHash_s_ * oyHash_Get_ ( const char * hash_text, oyObject_s object ) { oyHash_s_ * s = 0; int error = !hash_text; uint32_t * val = 0; if(error <= 0) { s = oyHash_New_(object); error = !s; } if(error <= 0) { val = (uint32_t*) s->oy_->hash_ptr_; if(oyStrlen_(hash_text) < OY_HASH_SIZE*2-1) memcpy(s->oy_->hash_ptr_, hash_text, oyStrlen_(hash_text)+1); else #if 0 error = oyMiscBlobGetMD5_( (void*)hash_text, oyStrlen_(hash_text), s->oy_->hash_ ); #else (*val) = oyMiscBlobGetL3_( (void*)hash_text, oyStrlen_(hash_text) ); #endif } if(error <= 0) error = oyObject_SetName(s->oy_, hash_text, oyNAME_NAME); return s; }
/** Function oyConfigs_FromDeviceClass * @memberof oyConfigs_s * @brief Ask a module for device informations or other direct calls * * @param[in] device_type the device type ::oyFILTER_REG_TYPE, * defaults to OY_TYPE_STD (optional) * @param[in] device_class the device class, e.g. "monitor", * ::oyFILTER_REG_APPLICATION * @param[in] options options to pass to the module, for zero * the usage instructions are requested, * a option "device_name" can be used * as filter * @param[out] devices the devices * @param[in] object the optional object * @return 0 - good, >= 1 - error * * @verbatim // pass empty options to the module to get a usage message oyOptions_s * options = 0; int error = oyConfigs_FromDeviceClass( OY_TYPE_STD, "monitor", options, 0, 0 ); @endverbatim * * @version Oyranos: 0.1.10 * @since 2009/01/28 (Oyranos: 0.1.10) * @date 2009/01/30 */ OYAPI int OYEXPORT oyConfigs_FromDeviceClass ( const char * device_type, const char * device_class, oyOptions_s * options, oyConfigs_s ** devices, oyObject_s object ) { int error = !device_class || !device_class[0]; oyConfig_s * device = 0; oyConfigs_s * configs = 0; int i, j, j_n; uint32_t count = 0, * rank_list = 0; char ** texts = 0, * device_class_registration = 0; const char * tmp = 0, * device_name = 0; if(error > 0) { WARNc_S( "\n No device_class argument provided. Give up" ); return 0; } /** 1. obtain detailed and expensive device informations */ if(options) { options = oyOptions_Copy( options, 0 ); device_name = oyOptions_FindString( options, "device_name", 0 ); } /** 1.2.1 build a device class registration string */ if(error <= 0) { device_class_registration = oyDeviceRegistrationCreate_( device_type, device_class, device_name, device_class_registration ); error = !device_class_registration; } /** 1.2.2 get all device class module names */ if(error <= 0) error = oyConfigDomainList ( device_class_registration, &texts, &count, &rank_list, 0 ); if(devices && !*devices) *devices = oyConfigs_New( object ); /** 1.3 ask each module */ for( i = 0; i < count; ++i ) { const char * registration_domain = texts[i]; /** 1.3.1 call into module */ error = oyConfigs_FromDomain( registration_domain, options, &configs, object); if(devices && *devices) j_n = oyConfigs_Count( configs ); else j_n = 0; for( j = 0; j < j_n; ++j ) { device = oyConfigs_Get( configs, j ); if(device_name) { /** 1.3.1.1 Compare the device_name with the device_name option * and collect the matching devices. */ tmp = oyConfig_FindString( device, "device_name", 0 ); if(tmp && oyStrcmp_( tmp, device_name ) == 0) oyConfigs_MoveIn( *devices, &device, -1 ); } else /** 1.3.1.2 ... or collect all device configurations */ oyConfigs_MoveIn( *devices, &device, -1 ); oyConfig_Release( &device ); } oyConfigs_Release( &configs ); } if(devices) j_n = oyConfigs_Count( *devices ); else j_n = 0; for( j = 0; j < j_n; ++j ) { device = oyConfigs_Get( *devices, j ); /** The basic call on how to obtain the configuration is added here as * the objects name. "properties" and "list" are known. */ if(oyOptions_FindString( options, "command", "properties" ) || oyOptions_FindString( options, "oyNAME_DESCRIPTION", 0 )) oyObject_SetName( device->oy_, "properties", oyNAME_NAME ); else if(oyOptions_FindString( options, "list", 0 )) oyObject_SetName( device->oy_, "list", oyNAME_NAME ); oyConfig_Release( &device ); } oyOptions_Release( &options ); return error; }
/** Function oyFilterNode_GetText * @memberof oyFilterNode_s * @brief Serialise filter node to text * * Serialise into: * - oyNAME_NICK: XML ID * - oyNAME_NAME: XML from module * - oyNAME_DESCRIPTION: ?? * * This function provides a complete description of the context. It might be * more adequate to use only a subset for hashing as not all data and options * might have an effect to the context data result. * The oyCMMapi4_s::oyCMMFilterNode_GetText() function provides a way to let a * module decide about what to place into a hash text. * * @param[in,out] node filter node * @param[out] name_type the type * @return the text * * @version Oyranos: 0.3.3 * @date 2011/11/22 * @since 2008/07/17 (Oyranos: 0.1.8) */ const char * oyFilterNode_GetText ( oyFilterNode_s * node, oyNAME_e name_type ) { const char * tmp = 0; char * hash_text = 0; oyFilterNode_s_ * s = (oyFilterNode_s_*)node; oyStructList_s * in_datas = 0, * out_datas = 0; if(!node) return 0; if( s->core && s->core->api4_ && s->core->api4_->oyCMMFilterNode_GetText && name_type == oyNAME_NAME ) { hash_text = s->core->api4_->oyCMMFilterNode_GetText( node, oyNAME_NICK, oyAllocateFunc_ ); if(hash_text) { oyObject_SetName( s->oy_, hash_text, oyNAME_NAME ); oyDeAllocateFunc_( hash_text ); hash_text = 0; hash_text = (oyChar*) oyObject_GetName( s->oy_, oyNAME_NAME ); return hash_text; } } /* 1. create hash text */ hashTextAdd_m( "<oyFilterNode_s>\n " ); /* the filter text */ hashTextAdd_m( oyFilterCore_GetText( (oyFilterCore_s*)s->core, oyNAME_NAME ) ); /* pick all plug (input) data */ in_datas = oyFilterNode_GetData_( s, 1 ); /* pick all sockets (output) data */ out_datas = oyFilterNode_GetData_( s, 0 ); /* make a description */ if(s->core) tmp = oyContextCollectData_( (oyStruct_s*)s, s->core->options_, in_datas, out_datas ); hashTextAdd_m( tmp ); hashTextAdd_m( "</oyFilterNode_s>\n" ); oyObject_SetName( s->oy_, hash_text, oyNAME_NICK ); if(s->oy_->deallocateFunc_) s->oy_->deallocateFunc_( hash_text ); hash_text = 0; hash_text = (oyChar*) oyObject_GetName( s->oy_, oyNAME_NICK ); return hash_text; }
/** Function: oyNamedColor_GetName * @memberof oyNamedColor_s * @brief get color channels * * @since Oyranos: version 0.1.8 * @date 22 december 2007 (API 0.1.8) */ const char * oyNamedColor_GetName( oyNamedColor_s * color, oyNAME_e type, uint32_t flags ) { const char * text = 0; oyNamedColor_s_ * s = (oyNamedColor_s_*) color; if(!s) return 0; if(!s->oy_) return 0; text = oyObject_GetName( s->oy_, type ); if(!text && flags) { const char * tmp = 0; char * txt = 0; double l[3]; int i; icSignature sig = oyProfile_GetSignature( s->profile_, oySIGNATURE_COLOR_SPACE ); oyAllocHelper_m_( txt, char, 1024, 0, return 0 ); oyNamedColor_GetColorStd( color, oyEDITING_LAB, l, oyDOUBLE, 0, 0 ); switch(type) { case oyNAME_DESCRIPTION: tmp = oyObject_GetName( s->oy_, oyNAME_NAME ); if(!tmp) tmp = oyObject_GetName( s->oy_, oyNAME_NICK ); if(tmp) oySprintf_(txt, "%s: CIE*Lab: ", tmp ); else oySprintf_(txt, "CIE*Lab: "); for(i = 0; i < 3; ++i) oySprintf_( &txt[ oyStrlen_(txt) ], "%.02f ", l[i] ); tmp = oyICCColorSpaceGetName( sig ); if(tmp) oySprintf_( &txt[ oyStrlen_(txt) ], "; %s:", tmp ); if( s->channels_ ) for(i = 0; i < oyICCColorSpaceGetChannelCount( sig ); ++i) oySprintf_( &txt[ oyStrlen_(txt) ], "%.02f ", s->channels_[i] ); break; default: break; } oyObject_SetName ( s->oy_, txt, type ); oyFree_m_( txt ); text = oyObject_GetName( s->oy_, type ); } if(!text && type > oyNAME_NICK) text = oyObject_GetName( s->oy_, type - 2 ); if(!text && type > oyNAME_NAME) text = oyObject_GetName( s->oy_, type - 1 ); if(!text && type < oyNAME_NICK ) text = oyObject_GetName( s->oy_, type + 2 ); if(!text && type < oyNAME_DESCRIPTION ) text = oyObject_GetName( s->oy_, type + 1 ); if(!text) text = _("----"); return text; }