/** Function    oyCMMapi4_Create
 *  @memberof   oyCMMapi4_s
 *  @brief      Custom CMMapi4 constructor
 *
 *  @param         init                custom initialisation
 *  @param         msg_set             message function setter
 *  @param         registration        the modules @ref registration string,
 *  @param         version             module version
 *  - 0: major - should be stable for the live time of a filter
 *  - 1: minor - mark new features
 *  - 2: patch version - correct errors
 *  @param         module_api          tell compatibility with Oyranos API
 *  - 0: last major Oyranos version during development time, e.g. 0
 *  - 1: last minor Oyranos version during development time, e.g. 9
 *  - 2: last Oyranos patch version during development time, e.g. 5
 *  @param         context_type        tell the context type, if any
 *  the data type of the context returned by oyCMMapi4_s::oyCMMFilterNode_ContextToMem_f, mandatory in case of a set oyCMMapi4_s::oyCMMFilterNode_ContextToMem
 *  e.g. ::oyCOLOR_ICC_DEVICE_LINK / "oyDL"
 *  @param         contextToMem 
 *  only mandatory for context producing filters, e.g. "//color/icc"
 *  @param         getText             optionally set a 
 *                                     oyCMMFilterNode_ContextToMem,
 *  used to override a Oyranos side hash creation
 *  @param         ui                  a UI description
 *  provide a oyCMMapi4_s::ui->getText( select, type ) call. The "select"
 *  argument shall cover at least "name" and "help"
 *  @param         object              a optional object
 *
 *  @version Oyranos: 0.9.5
 *  @since   2013/06/09 (Oyranos: 0.9.5)
 *  @date    2013/06/09
 */
OYAPI oyCMMapi4_s*  OYEXPORT
                   oyCMMapi4_Create  ( oyCMMInit_f         init,
                                       oyCMMMessageFuncSet_f msg_set,
                                       const char        * registration,
                                       int32_t             version[3],
                                       int32_t             module_api[3],
                                       const char        * context_type,
                                       oyCMMFilterNode_ContextToMem_f contextToMem,
                                       oyCMMFilterNode_GetText_f getText,
                                       oyCMMui_s         * ui,
                                       oyObject_s          object )
{
  oyCMMapi4_s_ * api4 = (oyCMMapi4_s_*) oyCMMapi4_New( object ); 
  if(!api4)
  {
    WARNc_S(_("MEM Error."));
    return NULL;
  }

  oyCMMapi_Set( (oyCMMapi_s*) api4, init, msg_set, registration,
                version, module_api );

  if(context_type)
    memcpy( api4->context_type, context_type, 8 );
  api4->oyCMMFilterNode_ContextToMem = contextToMem;
  api4->oyCMMFilterNode_GetText = getText;
  api4->ui = (oyCMMui_s_*) oyCMMui_Copy( ui, object );
  if(api4->ui)
  {
    api4->ui->parent = (oyCMMapiFilter_s*) oyCMMapi4_Copy( (oyCMMapi4_s*) api4, NULL );
  }

  return (oyCMMapi4_s*) api4;
}
Example #2
0
/** Function  oyCMMapi7_Create
 *  @memberof oyCMMapi7_s
 *  @brief    Create a oyCMMapi7_s filter object
 *
 *  @param         init                custom initialisation
 *  @param         msg_set             message function setter
 *  @param         registration        the modules @ref registration string,
 *  @param         version             module version
 *  - 0: major - should be stable for the live time of a filter
 *  - 1: minor - mark new features
 *  - 2: patch version - correct errors
 *  @param         module_api          tell compatibility with Oyranos API
 *  - 0: last major Oyranos version during development time, e.g. 0
 *  - 1: last minor Oyranos version during development time, e.g. 9
 *  - 2: last Oyranos patch version during development time, e.g. 5
 *  @param         context_type        four byte identifier if a context is needed
 *                                     A additional oyCMMapi6_s module can, 
 *                                     then be provided to convert between
 *                                     context formats, registred by this
 *                                     identifier.
 *  @param         run                 the filter function
 *  @param         plugs               a zero terminated list of connectors
 *  @param         plugs_n             the number of plugs in 'plugs'
 *  @param         plugs_last_add      the number of accepted repeats of the
 *                                     last plug
 *  @param         sockets             a zero terminated list of connectors
 *  @param         sockets_n           the number of sockets in 'sockets'
 *  @param         sockets_last_add    the number of accepted repeats of the
 *                                     last socket
 *  @param         properties
 *  A zero terminated list of strings. The semantics are plugin defined.
 *  e.g.: {"key1=value1","key2=value2",0}
 *  @param         object              Oyranos object (optional)
 *
 *  @see     oyCMMapi_s::oyCMMapi_Set()
 *
 *  @version Oyranos: 0.9.5
 *  @since   2013/07/11 (Oyranos: 0.9.5)
 *  @date    2013/07/11
 */
OYAPI oyCMMapi7_s *  OYEXPORT
             oyCMMapi7_Create        ( oyCMMInit_f         init,
                                       oyCMMMessageFuncSet_f msg_set,
                                       const char        * registration,
                                       int32_t             version[3],
                                       int32_t             module_api[3],
                                       const char        * context_type,
                                       oyCMMFilterPlug_Run_f run,
                                       oyConnector_s    ** plugs,
                                       uint32_t            plugs_n,
                                       uint32_t            plugs_last_add,
                                       oyConnector_s    ** sockets,
                                       uint32_t            sockets_n,
                                       uint32_t            sockets_last_add,
                                       const char       ** properties,
                                       oyObject_s          object )
{
  oyCMMapi7_s_ * s = (oyCMMapi7_s_*) oyCMMapi7_New( object );
  int n = 0;

  if(!s) return NULL;

  oyCMMapi_Set( (oyCMMapi_s*) s, init, msg_set, registration,
                version, module_api );

  s->oyCMMFilterPlug_Run = run;
  if(context_type)
    memcpy( s->context_type, context_type, 4 );
  s->plugs = plugs;
  s->plugs_n = plugs_n;
  s->plugs_last_add = plugs_last_add;
  s->sockets = sockets;
  s->sockets_n = sockets_n;
  s->sockets_last_add = sockets_last_add;
  while(properties && properties[n]) ++n;
  oyStringListAdd ( &s->properties, 0, properties, n,
                    oyObject_GetAlloc( s->oy_ ),
                    oyObject_GetDeAlloc( s->oy_ ) );

  return (oyCMMapi7_s*) s;
}