void
GeneratorPersistenceH::doComposition(CIDL::CompositionDef_ptr composition)
{
	//
	// determine the componentDef and HomeDef
	//
	composition_ = composition;
	IR__::ComponentDef_var component = composition->ccm_component();
	IR__::HomeDef_var home = composition->ccm_home();

	//
	// determine lifecycle
	//
	CIDL::LifecycleCategory lc = composition->lifecycle();
	
	//
	// generate persistence for home
	//
	out << "\n\n";
	open_module(out, component, "");
	out << "\n\n";
	genHomePersistence(home, lc);
	close_module(out, component);
	out << "\n\n";

	//
	// generate persistence for component
	//
	open_module(out, component, "");
	out << "\n\n";
	genComponentPersistence(component, lc);
	close_module(out, component);
}
void 
GeneratorServantH::doComposition(CIDL::CompositionDef_ptr composition)
{
	//
	// determine the componentDef and HomeDef
	//
	component_ = composition->ccm_component();
	IR__::HomeDef_var home = composition->ccm_home();

	//
	// determine lifecycle
	//
	CIDL::LifecycleCategory lc = composition->lifecycle();

	//
	// generate home
	//

	// achtung: wenn kein modul, sollte vielleicht Servant_ der prefix für alle servants sein?
	open_module(out, component_, "SERVANT_");
	out << "\n\n";

	genHomeServantBegin(home, lc);
	genHomeServant(home, lc);
	out.unindent();
	out << "};\n\n\n";

	close_module(out, component_);

	//
	// entry point
	//
	out << "\n//\n// entry point\n//\n";
	out << "extern \"C\" {\n";
	out << "#ifdef _WIN32\n";
	out << "__declspec(dllexport)\n";
	out << "#else\n";
	out << "#endif\n";
	out << "Qedo::HomeServantBase* create_" << home->name() << "S(void);\n";
	out << "}\n\n";

	//
	// generate component
	//
	open_module(out, component_, "SERVANT_");
	out << "\n\n";

	genContextServant(component_, lc);
	genComponentServant(component_, lc);

	close_module(out, component_);

}
Ejemplo n.º 3
0
SharedLibrary::~SharedLibrary()
{
    if (--(*_ref_count) == 0){
        close_module();
        delete _ref_count;
    }
}
Ejemplo n.º 4
0
static int event_handler(input_module_t *mod, enum event_type ev, void *param)
{
    im_sndio_state *s = mod->internal;

    switch(ev)
    {
        case EVENT_SHUTDOWN:
            close_module(mod);
            break;
        case EVENT_NEXTTRACK:
            s->newtrack = 1;
            break;
        case EVENT_METADATAUPDATE:
            thread_mutex_lock(&s->metadatalock);
            if(s->metadata)
            {
                char **md = s->metadata;
                while(*md)
                    free(*md++);
                free(s->metadata);
            }
            s->metadata = (char **)param;
            s->newtrack = 1;
            thread_mutex_unlock(&s->metadatalock);
            break;
        default:
            LOG_WARN1("Unhandled event %d", ev);
            return -1;
    }

    return 0;
}
Ejemplo n.º 5
0
static guint
queue_one_module_or_library(const gchar *filename,
                            GwyErrorList **errorlist)
{
    GError *error = NULL;
    GModule *mod = open_module_file(filename, &error);
    if (!mod) {
        log_module_failure(error, 0, filename, TRUE);
        gwy_error_list_propagate(errorlist, error);
        return 0;
    }

    // First try opening the file as a module library.  Ignore the lookup error.
    const gchar *library_symbol = GWY_MODULE_INFO_SYMBOL;
    const GwyModuleLibraryRecord *records = find_module_info(mod,
                                                             library_symbol,
                                                             NULL);
    if (records)
        return queue_opened_module_library(mod, records, errorlist);

    // Then as a single module.
    gchar *modname;
    if (!(modname = module_name_from_path(filename, &error))) {
        log_module_failure(error, 0, filename, FALSE);
        gwy_error_list_propagate(errorlist, error);
        close_module(mod, filename);
        return 0;
    }

    GQuark qname = g_quark_from_string(modname);
    g_free(modname);

    gchar *symbol = g_strconcat(GWY_MODULE_INFO_SYMBOL "_",
                                g_quark_to_string(qname), NULL);
    const GwyModuleInfo *module_info = find_module_info(mod, symbol, &error);
    g_free(symbol);

    if (!module_info || !queue_opened_module(mod, module_info, qname, &error)) {
        log_module_failure(error, qname, filename, FALSE);
        gwy_error_list_propagate(errorlist, error);
        close_module(mod, filename);
        return 0;
    }

    return 1;
}
void 
GeneratorPersistenceH::doAbstractStorageHome(IR__::AbstractStorageHomeDef_ptr abs_storagehome)
{
	IR__::AbstractStorageTypeDef_var abs_storagetype = abs_storagehome->managed_abstract_storagetype();

	// achtung: wenn kein modul, sollte vielleicht PSS_ der prefix für alle pss sein?
	out << "\n\n";
	open_module(out, abs_storagetype, "");
	out << "\n\n";

	out << "class " << std::string(abs_storagetype->name()) << ";\n";
	out << "class " << std::string(abs_storagetype->name()) << "Ref;\n\n";

	std::string strClassName = std::string(abs_storagehome->name());
	strActBasename_ = strClassName;

	out << "class " << strClassName << "\n";
	out.indent();
	
	IR__::InterfaceDefSeq_var abs_storagehome_seq = abs_storagehome->base_abstract_storagehomes();
	if(abs_storagehome_seq->length()==0)
		out << ": public virtual CosPersistentState::StorageHomeBase\n";
	else
		for(CORBA::ULong i=0; i<abs_storagehome_seq->length(); i++)
		{
			i==0 ? out << ": " : out << ", ";
			out << "public virtual " << ((*abs_storagehome_seq)[i])->name() << "\n";
		};

	out.unindent();
	out << "{\n\npublic:\n\n";
	out.indent();
    //out << strClassName << "();\n";
	//out << "~" << strClassName << "();\n";

	bAbstract_ = true;
	handleAttribute(abs_storagehome);
	handleOperation(abs_storagehome);
	handleFactory(abs_storagehome);
	handleKey(abs_storagehome);
	
	//generate _duplicate and _downcast operation
	//genDuplAndDown(strClassName);

	out.unindent();
	out << "};\n\n";
	out << "#ifdef ORBACUS_ORB\n";
	out << "typedef OB::ObjVar< " << strClassName << " > " << strClassName << "_var;\n";
	out << "typedef OB::ObjVar< " << strClassName << " > " << strClassName << "_out;\n";
	out << "#endif\n";
    out << "#ifdef MICO_ORB\n";
	out << "typedef ObjVar< " << strClassName << " > " << strClassName << "_var;\n";
	out << "typedef ObjVar< " << strClassName << " > " << strClassName << "_out;\n";
	out << "#endif\n";
	out << "\n\n";

	close_module(out, abs_storagetype);
}
Ejemplo n.º 7
0
void
GeneratorLIDL::doComposition(CIDL::CompositionDef_ptr composition)
{
	//
	// determin the lifecycle
	//
	CIDL::LifecycleCategory lc = composition->lifecycle();

	//
	// detemine the component
	//
	component_ = composition->ccm_component();

	//
	// generate
	//

	open_module(component_);
	//
	// container specific context interface 
	//
	out << "//\n// container interface for the context for " << component_->id() << "\n//\n";
	out << "local interface CCM_" << component_->name() << "_ContextImpl : ";
	out << "CCM_" << component_->name() << "_Context,\n";

	switch(lc) {
	case (CIDL::lc_Session) : 
		{
			out << "::Components::SessionContext";
			break;
		}
	case (CIDL::lc_Entity) :
	case (CIDL::lc_Process) :
		{
			out << "::Components::EntityContext";
			break;
		}
	case (CIDL::lc_Extension) :
		{
			out << "::Components::ExtensionContext";
			break;
		}
	default:
		{
			//unsupported lifecycle category
			std::cerr << "unsupported lifecycle category" << std::endl;
		}
	}

	out << "\n{ };\n\n";

	close_module(component_);
}
Ejemplo n.º 8
0
static guint
queue_opened_module_library(GModule *mod,
                            const GwyModuleLibraryRecord *records,
                            GwyErrorList **errorlist)
{
    GHashTable *modules = ensure_module_table();
    GError *error = NULL;
    guint count = 0, i;

    for (i = 0; records[i].name; i++) {
        GQuark qname = g_quark_from_string(records[i].name);
        if (!module_name_is_valid(records[i].name, &error)) {
            log_module_failure(error, qname, g_module_name(mod), TRUE);
            gwy_error_list_propagate(errorlist, error);
            continue;
        }

        ModuleInfo *modinfo = NULL;
        if (!(modinfo = fill_module_info(records[i].info, qname, mod, TRUE,
                                         &error))) {
            log_module_failure(error, qname, g_module_name(mod), TRUE);
            gwy_error_list_propagate(errorlist, error);
            continue;
        }

        if (!handle_overriding(modinfo, &error)) {
            log_module_failure(error, qname, g_module_name(mod), TRUE);
            gwy_error_list_propagate(errorlist, error);
            module_info_free(modinfo);
            continue;
        }

        gpointer key = GUINT_TO_POINTER(qname);
        g_hash_table_insert(modules, key, modinfo);
        count++;
    }

    if (count)
        return count;

    if (!i) {
        g_set_error(&error, GWY_MODULE_ERROR, GWY_MODULE_ERROR_EMPTY_LIBRARY,
                    _("Module library ‘%s’ is empty."),
                    g_module_name(mod));
        log_module_failure(error, 0, g_module_name(mod), TRUE);
        gwy_error_list_propagate(errorlist, error);
    }
    // We should have at least error logged for this library one way or
    // another when we choose to fail.
    close_module(mod, NULL);

    return 0;
}
Ejemplo n.º 9
0
SharedLibrary& SharedLibrary::operator= (const SharedLibrary& lib)
{
    ++(*lib._ref_count);

    if (--(*_ref_count) == 0)
    {
        close_module();
        delete _ref_count;
    }

    _ref_count = lib._ref_count;
    _module = lib._module;

    return *this;
}
Ejemplo n.º 10
0
void 
GeneratorPersistenceH::doAbstractStorageType(IR__::AbstractStorageTypeDef_ptr abs_storagetype)
{
	out << "\n\n";
	open_module(out, abs_storagetype, "");
	out << "\n\n";

	// generate normal class
	genAbstractStorageTypeBody(abs_storagetype/*, false*/);
	// generate ref class
	// Don't known how to build a Ref-class :-(
	//genAbstractStorageTypeBody(abs_storagetype, true);
	genAbstractRefBody(abs_storagetype); // Hopefully it's right!

	close_module(out, abs_storagetype);
}
Ejemplo n.º 11
0
/* Close the audio output and close the module */
void close_output_module( audio_output_t* ao ) 
{
	if (!ao) return; /* That covers buffer mode, too (ao == NULL there). */
	
	debug("closing output module");
	/* Close the audio output */
	if(ao->is_open && ao->close != NULL) ao->close(ao);

	/* Deinitialise the audio output */
	if (ao->deinit) ao->deinit( ao );
	
	/* Unload the module */
	if (ao->module) close_module( ao->module );

	/* Free up memory */
	free( ao );
}
Ejemplo n.º 12
0
void 
GeneratorPersistenceH::doStorageType(IR__::StorageTypeDef_ptr storagetype)
{
	// achtung: wenn kein modul, sollte vielleicht PSS_ der prefix für alle pss sein?
	out << "\n\n";	
	open_module(out, storagetype, "");
	out << "\n\n";

	// generate normal class
	genStorageTypeBody(storagetype/*, false*/);
	// generate ref class
	// Don't known how to build a Ref-class :-(
	//genStorageTypeBody(storagetype, true);
	genRefBody(storagetype); // Hopefully it's right!

	close_module(out, storagetype);
}
Ejemplo n.º 13
0
static int event_handler(input_module_t *mod, enum event_type ev, void *param)
{
    switch(ev)
    {
        case EVENT_SHUTDOWN:
            close_module(mod);
            break;
        case EVENT_NEXTTRACK:
            LOG_INFO0("Moving to next file in playlist.");
            ((playlist_state_t *)mod->internal)->nexttrack = 1;
            break;
        default:
            LOG_WARN1("Unhandled event %d", ev);
            return -1;
    }

    return 0;
}
Ejemplo n.º 14
0
void 
GeneratorLIDL::generate_component(IR__::ComponentDef* a_component, CIDL::LifecycleCategory lc)
 {
	// base component
	IR__::ComponentDef_var base_component = a_component->base_component();
	if ( ! CORBA::is_nil(base_component)) {
		this->generate_component(base_component, lc);

	}
	//
	// generate
	//

	open_module(a_component);
	//
	// container specific context interface 
	//
	out << "//\n// container interface for the context for " << a_component->id() << "\n//\n";
	out << "local interface CCM_" << a_component->name() << "_ContextImpl : ";
	out << "CCM_" << a_component->name() << "_Context,\n";

	switch(lc) {
	case (CIDL::lc_Session) : 
		{
			out << "::Components::SessionContext";
			break;
		}
	case (CIDL::lc_Extension) :
		{
			out << "::Components::ExtensionContext";
			break;
		}
	default:
		{
			//unsupported lifecycle category
			std::cerr << "unsupported lifecycle category" << std::endl;
		}
	}

	out << "\n{ };\n\n";

	close_module(a_component);

}
Ejemplo n.º 15
0
void 
GeneratorServantH::generate_component(IR__::ComponentDef* a_component, CIDL::LifecycleCategory lc ) {

	// base component
	IR__::ComponentDef_var base_component = a_component->base_component();
	if ( ! CORBA::is_nil(base_component)) {
		this->generate_component(base_component, lc);
	}

	//
	// generate component
	//
	open_module(out, a_component, "SERVANT_");
	out << "\n\n";

	genContextServant(a_component, lc);
	genComponentServant(a_component, lc);

	close_module(out, a_component);

}
Ejemplo n.º 16
0
// For a module file.
// Thus *must* get non-NULL error.
static GQuark
queue_one_module(const gchar *filename,
                 GError **error)
{
    gchar *modname;
    GError *err = NULL;

    if (!(modname = module_name_from_path(filename, &err))) {
        log_module_failure(err, 0, filename, FALSE);
        g_propagate_error(error, err);
        return 0;
    }

    // XXX: Somewhere here we had code for avoiding attempt to load pygyw if
    // Python is not available.

    GQuark qname = g_quark_from_string(modname);
    g_free(modname);

    GModule *mod = open_module_file(filename, &err);
    if (!mod) {
        log_module_failure(err, qname, filename, FALSE);
        g_propagate_error(error, err);
        return 0;
    }

    gchar *symbol = g_strconcat(GWY_MODULE_INFO_SYMBOL "_",
                                g_quark_to_string(qname), NULL);
    const GwyModuleInfo *module_info = find_module_info(mod, symbol, &err);
    g_free(symbol);

    if (!module_info || !queue_opened_module(mod, module_info, qname, &err)) {
        log_module_failure(err, qname, filename, FALSE);
        g_propagate_error(error, err);
        close_module(mod, filename);
        return 0;
    }

    return qname;
}
Ejemplo n.º 17
0
void
GeneratorServantC::doComposition(CIDL::CompositionDef_ptr composition)
{
	composition_ = CIDL::CompositionDef::_duplicate(composition);
	filename_ = mapAbsoluteName(composition->ccm_component(), "_");
	filename_.append("_SERVANT");
	string header_name = filename_ + ".h";
	filename_.append(".cpp");
	out.open(filename_.c_str());


	out << "//\n";
	out << "// generated by Qedo\n";
	out << "//\n\n";
	out << "#include \"" << header_name << "\"\n";
	out << "#include \"Output.h\"\n\n\n";

	// achtung: wenn kein modul, sollte vielleicht Servant_ der prefix für alle servants sein?
	open_module(out, composition->ccm_component(), "Servants_");
	out << "\n\n";

	doComponent(composition->ccm_component());
	doHome(composition->ccm_home());

	close_module(out, composition->ccm_component());


	//
	// entry point
	//
	out << "\n\n//\n// entry point\n//\n";
	out << "Qedo::HomeServantBase*\n";
	out << "create_" << composition->ccm_home()->name() << "S(void)\n{\n";
	out.indent();
	out << "return new " << mapFullNameServant(composition->ccm_home()) << "_servant();\n";
	out.unindent();
	out << "}\n\n";

	out.close();
}
Ejemplo n.º 18
0
void
kernel_mod_init2(void)
{
    struct module *shell;

    fs = (struct fs_module *)open_module("fs", SYS_VER);

    /* Open the shell; this should be enough for it to get a toe-hold
       in the system :) */
    shell = open_module("shell", SYS_VER);
    if(shell == NULL)
    {
	kprintf("Can't open shell.module; stopping\n");
	/* No point going any further. */
	while(1) ;
    }
#if 0
    /* Don't ever close the shell. */
    close_module(shell);
#endif
    collect_shell_cmds();
}
Ejemplo n.º 19
0
static value loader_loadmodule( value mname, value vthis ) {
	value o = val_this();
	value cache;
	val_check(o,object);
	val_check(mname,string);
	val_check(vthis,object);
	cache = val_field(o,id_cache);
	val_check(cache,object);
	{
		reader r;
		readp p;
		neko_module *m;
		neko_vm *vm = NEKO_VM();
		field mid = val_id(val_string(mname));
		value mv = val_field(cache,mid);
		if( val_is_kind(mv,neko_kind_module) ) {
			m = (neko_module*)val_data(mv);
			return m->exports;
		}
		open_module(val_field(o,id_path),val_string(mname),&r,&p);
		if( vm->fstats ) vm->fstats(vm,"neko_read_module",1);
		m = neko_read_module(r,p,vthis);
		if( vm->fstats ) vm->fstats(vm,"neko_read_module",0);
		close_module(p);
		if( m == NULL ) {
			buffer b = alloc_buffer("Invalid module : ");
			val_buffer(b,mname);
			bfailure(b);
		}
		m->name = alloc_string(val_string(mname));
		mv = alloc_abstract(neko_kind_module,m);
		alloc_field(cache,mid,mv);
		if( vm->fstats ) vm->fstats(vm,val_string(mname),1);
		neko_vm_execute(neko_vm_current(),m);
		if( vm->fstats ) vm->fstats(vm,val_string(mname),0);
		return m->exports;
	}
}
Ejemplo n.º 20
0
static guint
queue_module_library(const gchar *filename,
                     GwyErrorList **errorlist)
{
    GError *error = NULL;
    GModule *mod = open_module_file(filename, &error);
    if (!mod) {
        log_module_failure(error, 0, filename, TRUE);
        gwy_error_list_propagate(errorlist, error);
        return 0;
    }

    const gchar *symbol = GWY_MODULE_INFO_SYMBOL;
    const GwyModuleLibraryRecord *records = find_module_info(mod, symbol,
                                                             &error);
    if (!records) {
        log_module_failure(error, 0, filename, TRUE);
        gwy_error_list_propagate(errorlist, error);
        close_module(mod, filename);
        return 0;
    }

    return queue_opened_module_library(mod, records, errorlist);
}
void
GeneratorBusinessH::doComposition(CIDL::CompositionDef_ptr composition)
{
	CORBA::ULong i ;
	composition_ = CIDL::CompositionDef::_duplicate(composition);
	filename_ = "";

	//
	// determine whether defined in module (needed for namespace opening and closing)
	//
	IR__::Contained_ptr module_def = 0;
	string id = composition->id();
	string::size_type pos = id.find_last_of("/");
	if(pos != string::npos)
	{
		id.replace(pos, string::npos, ":1.0");
		module_def = repository_->lookup_id(id.c_str());
		filename_ = getAbsoluteName(module_def, "_");
		filename_.append("_");
	}
	filename_.append(composition->name());
	string header_name = filename_;
	filename_.append(".h");
	
	//
	// parse for user sections and write header in the output file
	//
	out.initUserSections(filename_.c_str());
	out.open(filename_.c_str());
	out << "//\n";
	out << "// generated by Qedo\n";
	out << "//\n\n";
	out << "#ifndef _" << header_name << "_H_\n";
	out << "#define _" << header_name << "_H_\n\n\n"; 
	out.insertUserSection("file_pre", 2);
	out << "#include <CORBA.h>\n";
	out << "#include \"" << file_prefix_ << "_BUSINESS.h\"\n";
	if(composition->lifecycle()==CIDL::lc_Entity || composition->lifecycle()==CIDL::lc_Process)
	    out << "#include \"" << file_prefix_ << "_PSS.h\"\n";
	out << "#include \"valuetypes.h\"\n";
	out << "#include \"RefCountBase.h\"\n";
	if(composition->lifecycle()==CIDL::lc_Entity)
		out << "#include \"CCMContext.h\"\n";
	out << "#include <string>\n\n\n";
	out.insertUserSection("file_post", 2);

	if(module_def)
	{
		open_module(out, module_def);
		out << "namespace " << mapName(module_def) << "\n{\n";
		out.indent();
	}

	CIDL::SegmentDefSeq_var segment_seq = composition->executor_def()->segments();
	std::string executor_name = composition->executor_def()->name();
	std::string executor_class_name = mapName(executor_name);
	std::string executor_locator_name = composition->name();
	std::string executor_locator_class_name = mapName(executor_locator_name);
	std::string home_name = composition->home_executor()->name();
	std::string home_class_name = mapName(home_name);

	//
	// executor
	//
	out << "\n//\n// executor\n//\n";
	out << "class " << executor_class_name << "\n";
	out.indent();
	out << ": public virtual CORBA::LocalObject\n";
	out << ", public virtual " << mapScopeName(composition) << "::CCM_" << executor_name << "\n";
	out.unindent(); out.unindent();
	out << "#ifndef MICO_ORB\n";
	out.indent(); out.indent();
	out << ", public virtual Qedo::RefCountLocalObject\n";
	out.unindent(); out.unindent();
	out << "#endif\n";
	out.indent(); out.indent();
	out.insertUserSection(string("INHERITANCE_") + executor_name, 0);
	out.unindent();
	out << "{\n\n";
	out << "private:\n\n";
	out.indent();
    out << mapFullNameLocal(composition->ccm_component()) << "_ContextImpl_var context_;\n\n";
	out.unindent();
	out << "public:\n\n";
	out.indent();
	switch(composition->lifecycle())
	{
	case CIDL::lc_Session :
		out << executor_class_name << "();\n";
		break;
	case CIDL::lc_Entity :
		out << executor_class_name << "(" << mapFullNamePK(composition->ccm_home()->primary_key()) << "* pkey);\n";
		break;
	default :
		out << "// not supported lifecycle\n";
	}
	out << "virtual ~" << executor_class_name << "();\n\n";
	out << "void set_context(" << mapFullNameLocal(composition->ccm_component()) << "_ContextImpl_ptr context)\n";
	out << "    throw (CORBA::SystemException, Components::CCMException);\n\n";
    out << "void configuration_complete()\n";
	out << "    throw (CORBA::SystemException, Components::InvalidConfiguration);\n\n";
    out << "void remove()\n";
	out << "    throw (CORBA::SystemException);\n\n";
	if(composition->lifecycle() == CIDL::lc_Service)
	{
		out << "void preinvoke(const char* comp_id, const char* operation)\n";
		out << "    throw (CORBA::SystemException);\n\n";
		out << "void postinvoke(const char* comp_id, const char* operation)\n";
		out << "    throw (CORBA::SystemException);\n\n";
	}
	need_push_ = true;
	doComponent(composition->ccm_component());
	out.unindent();
	out << "\n";
	out.insertUserSection(executor_name);
	out << "};\n\n";

	//
	// segment
	//
	for (i = 0; i < segment_seq->length(); i++)
	{
		std::string segment_name = segment_seq[i]->name();
		std::string segment_class_name = mapName(segment_name);
		out << "\n//\n// segment\n//\n";
		out << "class " << segment_class_name << "\n";
		out.indent();
		out << ": public virtual CORBA::LocalObject\n";
		out << ", public virtual " << mapScopeName(composition) << "::CCM_" << segment_name << "\n";
		out.unindent(); out.unindent();
		out << "#ifndef MICO_ORB\n";
		out.indent(); out.indent();
		out << ", public virtual Qedo::RefCountLocalObject\n";
		out.unindent(); out.unindent();
		out << "#endif\n";
		out.indent(); out.indent();
		out.insertUserSection(string("INHERITANCE_") + segment_name, 0);
		out.unindent();
		out << "{\n\n";
		out << "private:\n\n";
		out.indent();
		out << mapFullNameLocal(composition->ccm_component()) << "_ContextImpl_var context_;\n\n";
		out.unindent();
		out << "public:\n\n";
		out.indent();
		out << segment_class_name << "();\n";
		out << "virtual ~" << segment_class_name << "();\n\n";
		out << "void set_context(" << mapFullNameLocal(composition->ccm_component()) << "_ContextImpl_ptr context)\n";
		out << "    throw (CORBA::SystemException, Components::CCMException);\n\n";
		out << "void configuration_complete()\n";
		out << "    throw (CORBA::SystemException, Components::InvalidConfiguration);\n\n";
		
		//
		// for each implemented facet
		//
		IR__::ProvidesDefSeq_var provided_seq = segment_seq[i]->provided_facets();
		handled_interfaces_.clear();
		for (CORBA::ULong ii = 0; ii < provided_seq->length(); ii++)
		{
			IR__::InterfaceDef_var intf = IR__::InterfaceDef::_narrow(provided_seq[ii]->interface_type());
			if( !CORBA::is_nil(intf) )
			{
				doInterface(intf);
			}
		}
		out.unindent();
		out << "\n";
		out.insertUserSection(segment_name);
		out << "};\n\n";
	}

	//
	// executor locator
	//
	out << "\n//\n// executor locator\n//\n";
	out << "class " << executor_locator_class_name << "\n";
	out.indent();
	out << ": public virtual CORBA::LocalObject\n";
	//
	// determin the lifecycle
	//
	CIDL::LifecycleCategory lc = composition->lifecycle();
	switch(lc) {
		case (CIDL::lc_Service) :
			{
				// this is a prelimenary version of container service
				out << ", public virtual Components::CCMService\n";

			}
		case (CIDL::lc_Session) : 
			{
				out << ", public virtual Components::SessionExecutorLocator\n";
				break;
			}
        case (CIDL::lc_Entity) :
            {
		        out << ", public virtual Components::EntityExecutorLocator\n";
		        break;
            }
		case (CIDL::lc_Extension) :
			{
				out << ", public virtual Components::ExtensionExecutorLocator\n";
				break;
			}
		default:
			{
				//unsupported lifecycle category
			}
		}

	out.unindent(); out.unindent();
	out << "#ifndef MICO_ORB\n";
	out.indent(); out.indent();
	out << ", public virtual Qedo::RefCountLocalObject\n";
	out.unindent(); out.unindent();
	out << "#endif\n";
	out.indent(); out.indent();

	out.insertUserSection(string("INHERITANCE_") + executor_locator_name, 0);
	out.unindent();
	out << "{\n\n";
	out << "private:\n\n";
	out.indent();
    out << mapFullNameLocal(composition->ccm_component()) << "_ContextImpl_var context_;\n\n";
	out << mapName(composition->executor_def()) << "* component_;\n\n";
	for (i = 0; i < segment_seq->length(); i++)	{
		out << mapName(segment_seq[i]) << "* " << segment_seq[i]->name() << "_;\n\n";
	}
	out.unindent();
	out << "public:\n\n";
	out.indent();
	switch(composition->lifecycle())
	{
	case CIDL::lc_Session :
		out << executor_locator_class_name << "();\n";
		break;
	case CIDL::lc_Entity :
		out << executor_locator_class_name << "(" << mapFullNamePK(composition->ccm_home()->primary_key()) << "* pkey);\n";
		break;
	default :
		out << "// not supported lifecycle\n";
	}
    out << "virtual ~" << executor_locator_class_name << "();\n\n";
	IR__::InterfaceDef_ptr executor_locator;
	switch(lc) {
		case (CIDL::lc_Service) :
			{
				//prelimenary version of container services
				executor_locator = IR__::InterfaceDef::_narrow(repository_->lookup_id("IDL:Components/CCMService:1.0"));
				break;
			}
		case (CIDL::lc_Session) : 
			{
				executor_locator = IR__::InterfaceDef::_narrow(repository_->lookup_id("IDL:Components/SessionExecutorLocator:1.0"));
				break;
			}
        case (CIDL::lc_Entity) : 
			{
				executor_locator = IR__::InterfaceDef::_narrow(repository_->lookup_id("IDL:Components/EntityExecutorLocator:1.0"));
		        break;
			}
		case (CIDL::lc_Extension) :
			{
				executor_locator = IR__::InterfaceDef::_narrow(repository_->lookup_id("IDL:Components/ExtensionExecutorLocator:1.0"));
				break;
			}
		default:
			{
				//unsupported lifecycle category
			}
	}

	doInterface(executor_locator);
	out.unindent();
	out << "\n";
	out.insertUserSection(executor_locator_name);
	out << "};\n\n";

	//
	// home executor
	//
	out << "\n//\n// home executor\n//\n";
	out << "class " << home_class_name << "\n";
	out.indent();
	out << ": public virtual CORBA::LocalObject\n";
	out << ", public virtual " << getLocalName(composition->ccm_home()) << "\n";
	out.unindent(); out.unindent();
	out << "#ifndef MICO_ORB\n";
	out.indent(); out.indent();
	out << ", public virtual Qedo::RefCountLocalObject\n";
	out.unindent(); out.unindent();
	out << "#endif\n";
	out.indent(); out.indent();
	out.insertUserSection(std::string("INHERITANCE_") + home_name, 0);
	out.unindent();
	out << "{\n\n";
	out << "private:\n\n";
	out.indent();
    out << "Components::HomeContext_var context_;\n\n";
	out.unindent();
	out << "public:\n";
	out.indent();
    out << home_class_name << "();\n";
    out << "virtual ~" << home_class_name << "();\n\n";
	out << "//\n// IDL:Components/HomeExecutorBase/set_context:1.0\n//\n";
	out << "virtual void set_context (Components::HomeContext_ptr ctx)\n";
	out << "    throw (CORBA::SystemException, Components::CCMException);\n\n";
	out << "//\n// IDL:Components/HomeExecutorBase/set_storagehome_in_context:1.0\n//\n";
	out << "virtual void set_storagehome_in_context (::CosPersistentState::StorageHomeBase_ptr storHomeBase)\n";
	out << "    throw (CORBA::SystemException, Components::CCMException);\n\n";
	out << "//\n// IDL:Components/HomeExecutorBase/get_storagehome_from_context:1.0\n//\n";
	out << "virtual ::CosPersistentState::StorageHomeBase_ptr get_storagehome_from_context ()\n";
	out << "    throw (CORBA::SystemException, Components::CCMException);\n\n";
    out << "//\n// IDL:.../create:1.0\n//\n";
	switch(composition->lifecycle())
	{
	case CIDL::lc_Session :
		out << "virtual ::Components::EnterpriseComponent_ptr create()\n";
		out << "    throw (CORBA::SystemException, Components::CreateFailure);\n";
		break;
	case CIDL::lc_Entity :
		out << "virtual ::Components::EnterpriseComponent_ptr create(" << mapFullNamePK(composition->ccm_home()->primary_key()) << "* pkey)\n";
		out << "    throw(CORBA::SystemException, Components::CreateFailure, Components::DuplicateKeyValue, Components::InvalidKey);\n\n";
/*
		out << "virtual ::Components::EnterpriseComponent_ptr find_by_primary_key(" << mapFullNamePK(composition->ccm_home()->primary_key()) << "* pkey)\n"; 
		out << "	throw(CORBA::SystemException, Components::FinderFailure, Components::UnknownKeyValue, Components::InvalidKey);\n\n";

		out << "void remove(" << mapFullNamePK(composition->ccm_home()->primary_key()) << "* pkey)\n"; 
		out << "	throw(CORBA::SystemException, Components::RemoveFailure, Components::UnknownKeyValue, Components::InvalidKey);\n\n";
*/
		//get_primary_key(...)??? !!!

		break;
	default :
		out << "// not supported lifecycle\n";
	}
	doHome(composition->ccm_home());
	out.unindent();
	out << "\n";
	out.insertUserSection(home_name);
	out << "};\n\n";


	// close namespace
	if(module_def)
	{
		out.unindent();
		out << "};\n";
		close_module(out, module_def);
	}

	//
	// entry point
	//
	out << "\n//\n// entry point\n//\n";
	out << "extern \"C\" {\n";
	out << "#ifdef _WIN32\n";
	out << "__declspec(dllexport)\n";
	out << "#else\n";
	out << "#endif\n";
	out << "::Components::HomeExecutorBase_ptr create_" << composition->ccm_home()->name() << "E(void);\n";
	out << "}\n\n";

	out << "#endif\n";
	out.close();
}
Ejemplo n.º 22
0
int list_modules( const char *type, char ***names, char ***descr, int verbose
,	const char* bindir )
{
	char *moddir  = NULL;
	int count = 0;
	struct compat_dir *dir;
	char *filename;

	debug1("verbose:%i", verbose);

	*names = NULL;
	*descr = NULL;

	moddir = get_module_dir(verbose, bindir);
	if(moddir == NULL)
	{
		if(verbose > -1)
			error("Failure getting module directory! (Perhaps set MPG123_MODDIR?)");
		return -1;
	}
	debug1("module dir: %s", moddir);

	/* Open the module directory */
	dir = compat_diropen(moddir);
	if (dir==NULL) {
		if(verbose > -1)
			error2("Failed to open the module directory (%s): %s\n"
			,	moddir, strerror(errno));
		free(moddir);
		return -1;
	}

	while((filename=compat_nextfile(dir)))
	{
		/* Pointers to the pieces. */
		char *module_name = NULL;
		char *module_type = NULL;
		char *uscore_pos = NULL;
		mpg123_module_t *module = NULL;
		char* ext;
		size_t name_len;

		/* Various checks as loop shortcuts, avoiding too much nesting. */
		debug1("checking entry: %s", filename);

		name_len = strlen(filename);
		if(name_len < strlen(LT_MODULE_EXT))
			goto list_modules_continue;
		ext = filename
		+	name_len
		-	strlen(LT_MODULE_EXT);
		if(strcmp(ext, LT_MODULE_EXT))
			goto list_modules_continue;
		debug("has suffix");

		/* Extract the module type and name */
		uscore_pos = strchr( filename, '_' );
		if(   uscore_pos==NULL
		  || (uscore_pos>=filename+name_len+1) )
		{
			debug("no underscore");
			goto list_modules_continue;
		}
		*uscore_pos = '\0';
		module_type = filename;
		module_name = uscore_pos+1;
		/* Only list modules of desired type. */
		if(strcmp(type, module_type))
		{
			debug("wrong type");
			goto list_modules_continue;
		}
		debug("has type");

		/* Extract the short name of the module */
		name_len -= uscore_pos - filename + 1;
		if(name_len <= strlen(LT_MODULE_EXT))
		{
			debug("name too short");
			goto list_modules_continue;
		}
		name_len -= strlen(LT_MODULE_EXT);
		module_name[name_len] = '\0';

		debug("opening module");
		/* Open the module
		   Yes, this re-builds the file name we chopped to pieces just now. */
		if((module=open_module_here(moddir, module_type, module_name, verbose)))
		{
			if( stringlists_add( names, descr
			,	module->name, module->description, &count) )
				if(verbose > -1)
					error("OOM");
			/* Close the module again */
			close_module(module, verbose);
		}
list_modules_continue:
		free(filename);
	}
	compat_dirclose(dir);
	return count;
}
Ejemplo n.º 23
0
void 
GeneratorPersistenceH::doStorageHome(IR__::StorageHomeDef_ptr storagehome)
{
	IR__::StorageTypeDef_var storagetype = storagehome->managed_storagetype();

	// achtung: wenn kein modul, sollte vielleicht PSS_ der prefix für alle pss sein?
	out << "\n\n";
	open_module(out, storagetype, "");
	out << "\n\n";
	
	out << "class " << std::string(storagetype->name()) << ";\n";
	out << "class " << std::string(storagetype->name()) << "Ref;\n\n";

	std::string strClassName = std::string(storagehome->name());
	strActBasename_ = strClassName;

	out << "class " << strClassName << "\n";
	out.indent();
	
	IR__::StorageHomeDef_var base_storagehome = storagehome->base_storagehome();
	if(base_storagehome)
		out << ": public virtual " << base_storagehome->name() << "\n";
	else
		out << ": public virtual StorageHomeBaseImpl\n";

	IR__::InterfaceDefSeq_var supported_infs = storagehome->supported_interfaces();
	for(CORBA::ULong i=0; i<supported_infs->length(); i++) 
		out << ", public virtual " << ((*supported_infs)[i])->name() << "\n";

	out.unindent();
	out << "{\n\npublic:\n\n";
	out.indent();
    out << strClassName << "();\n";
	out << "~" << strClassName << "();\n\n";

	genCreateOperation(storagehome, false);
	genCreateOperation(storagehome, true);

	//
	//generate find_(ref)_by_primary_key, which is appropriate to find_by_primary_key from home
	//
	if( composition_->lifecycle()==CIDL::lc_Entity )
	{
		IR__::HomeDef_var home = composition_->ccm_home();
		IR__::PrimaryKeyDef_var pkey = IR__::PrimaryKeyDef::_duplicate(home->primary_key());
		if( !CORBA::is_nil(pkey) )
		{
			out << map_psdl_return_type(storagetype, false) << " find_by_primary_key(" << mapFullNamePK(pkey) << "* pkey)\n"; 
			out.indent();
			out << "throw(CosPersistentState::NotFound);\n";
			out.unindent();
		}
	}

	for(CORBA::ULong i=0; i<supported_infs->length(); i++) 
	{
		IR__::AbstractStorageHomeDef_var abs_storagehome_inh;
		abs_storagehome_inh = IR__::AbstractStorageHomeDef::_narrow((*supported_infs)[i]);
		genAbstractObjsForConcreteHome(abs_storagehome_inh);
	};

	bAbstract_ = false;
	bASHKey_ = false;
	handleAttribute(storagehome);
	handleOperation(storagehome);
	handleFactory(storagehome);
	handleKey(storagehome);

	//generate _duplicate and _downcast operation
	//genDuplAndDown(strClassName);

	out.unindent();

	out << "};\n\n\n";

	out << "typedef HomeFactoryTemplate<" << storagehome->name() << "> " << storagehome->name() << "Factory;\n\n";
	
	close_module(out, storagetype);
}
Ejemplo n.º 24
0
void
GeneratorEIDL::generate(std::string target, std::string fileprefix)
{
	try { initialize(target, fileprefix); }
	catch (InitializeError) { return; }
	
	//
	// open temp file without includes
	//
	filename_ = file_prefix_ + "_EQUIVALENT.idl";
	string temp_filename = filename_ + ".temp";
	out.open(temp_filename.c_str());

	//
	// forward declarations
	//
	out << "//\n// forward declarations\n//\n"; 
	CORBA::ULong len = m_to_generate_interface_seq->length();
	CORBA::ULong i;
	for(i = 0; i < len; i++)
	{
		if ((*m_to_generate_interface_seq)[i]->describe()->kind == CORBA__::dk_Interface) {
			open_module((*m_to_generate_interface_seq)[i]);
			out << "interface " << (*m_to_generate_interface_seq)[i]->name() << ";\n";
			close_module((*m_to_generate_interface_seq)[i]);
		}
		if ((*m_to_generate_interface_seq)[i]->describe()->kind == CORBA__::dk_Component) {
			open_module((*m_to_generate_interface_seq)[i]);
			out << "interface " << (*m_to_generate_interface_seq)[i]->name() << ";\n";
			close_module((*m_to_generate_interface_seq)[i]);
		};
		if ((*m_to_generate_interface_seq)[i]->describe()->kind == CORBA__::dk_Home) {
			open_module((*m_to_generate_interface_seq)[i]);
			out << "interface " << (*m_to_generate_interface_seq)[i]->name() << ";\n";
			close_module((*m_to_generate_interface_seq)[i]);
		};

	}
	out << "\n";

	//
	// generate
	//
	doGenerate();
	out.close();

	//
	// insert includes
	//
	std::ifstream temp_file;
	temp_file.open(temp_filename.c_str());
	out.open(filename_.c_str());
	out << "#ifndef __" << file_prefix_ << "_EQUIVALENT_IDL\n";
	out << "#define __" << file_prefix_ << "_EQUIVALENT_IDL\n\n";
	out << "#include \"Components.idl\"\n";
	out << "#include \"orb.idl\"\n";
	
	std::map < std::string, bool > ::iterator it;
	for(it = includes_.begin(); it != includes_.end(); it++)
	{
		out << "#include \"" << it->first << "\"\n";
	}
	out << "\n";

	out << temp_file;
	out << "\n#endif\n";
	out.close();
	temp_file.close();
	unlink(temp_filename.c_str());
}
Ejemplo n.º 25
0
input_module_t *alsa_open_module(module_param_t *params)
{
    input_module_t *mod = calloc(1, sizeof(input_module_t));
    im_alsa_state *s;
    module_param_t *current;
    char *device = "plughw:0,0"; /* default device */
    int format = AFMT_S16_LE;
    int channels, rate;
    int use_metadata = 1; /* Default to on */
    unsigned int buffered_time;

    snd_pcm_stream_t stream = SND_PCM_STREAM_CAPTURE;
    snd_pcm_hw_params_t *hwparams;

    int err;

    mod->type = ICES_INPUT_PCM;
    mod->subtype = INPUT_PCM_LE_16;
    mod->getdata = alsa_read;
    mod->handle_event = event_handler;
    mod->metadata_update = metadata_update;

    mod->internal = calloc(1, sizeof(im_alsa_state));
    s = mod->internal;

    s->fd = NULL; /* Set it to something invalid, for now */
    s->rate = 44100; /* Defaults */
    s->channels = 2; 

    thread_mutex_create(&s->metadatalock);

    current = params;

    while(current)
    {
        if(!strcmp(current->name, "rate"))
            s->rate = atoi(current->value);
        else if(!strcmp(current->name, "channels"))
            s->channels = atoi(current->value);
        else if(!strcmp(current->name, "device"))
            device = current->value;
        else if(!strcmp(current->name, "metadata"))
            use_metadata = atoi(current->value);
        else if(!strcmp(current->name, "metadatafilename"))
            ices_config->metadata_filename = current->value;
        else
            LOG_WARN1("Unknown parameter %s for alsa module", current->name);

        current = current->next;
    }

    snd_pcm_hw_params_alloca(&hwparams);

    if ((err = snd_pcm_open(&s->fd, device, stream, 0)) < 0)
    {
        LOG_ERROR2("Failed to open audio device %s: %s", device, snd_strerror(err));
        goto fail;
    }

    if ((err = snd_pcm_hw_params_any(s->fd, hwparams)) < 0)
    {
        LOG_ERROR1("Failed to initialize hwparams: %s", snd_strerror(err));
        goto fail;
    }
    if ((err = snd_pcm_hw_params_set_access(s->fd, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
    {
        LOG_ERROR1("Error setting access: %s", snd_strerror(err));
        goto fail;
    }
    if ((err = snd_pcm_hw_params_set_format(s->fd, hwparams, SND_PCM_FORMAT_S16_LE)) < 0)
    {
        LOG_ERROR1("Couldn't set sample format to SND_PCM_FORMAT_S16_LE: %s", snd_strerror(err));
        goto fail;
    }
    if ((err = snd_pcm_hw_params_set_rate_near(s->fd, hwparams, &s->rate, 0)) < 0)
    {
        LOG_ERROR1("Error setting rate: %s", snd_strerror(err));
        goto fail;
    }
    if ((err = snd_pcm_hw_params_set_channels(s->fd, hwparams, s->channels)) < 0)
    {
        LOG_ERROR1("Error setting channels: %s", snd_strerror(err));
        goto fail;
    }
    if ((err = snd_pcm_hw_params_set_periods(s->fd, hwparams, 2, 0)) < 0)
    {
        LOG_ERROR1("Error setting periods: %s", snd_strerror(err));
        goto fail;
    }
    buffered_time = 500000;
    if ((err = snd_pcm_hw_params_set_buffer_time_near(s->fd, hwparams, &buffered_time, 0)) < 0)
    {
        LOG_ERROR1("Error setting buffersize: %s", snd_strerror(err));
        goto fail;
    }
    if ((err = snd_pcm_hw_params(s->fd, hwparams)) < 0)
    {
        LOG_ERROR1("Error setting HW params: %s", snd_strerror(err));
        goto fail;
    }

    /* We're done, and we didn't fail! */
    LOG_INFO3("Opened audio device %s at %d channel(s), %d Hz", 
            device, s->channels, s->rate);

    if(use_metadata)
    {
        if(ices_config->metadata_filename)
            thread_create("im_alsa-metadata", metadata_thread_signal, mod, 1);
        else
            thread_create("im_alsa-metadata", metadata_thread_stdin, mod, 1);
        LOG_INFO0("Started metadata update thread");
    }

    return mod;

fail:
    close_module(mod); /* safe, this checks for valid contents */
    return NULL;
}
Ejemplo n.º 26
0
void
GeneratorBIDL::doComposition(CIDL::CompositionDef_ptr composition)
{
	//
	// get the module where the composition is defined in and open it
	//
	string id = composition->id();
	IR__::Contained_ptr module_def = 0;
	string::size_type pos = id.find_last_of("/");
	if(pos != string::npos)
	{
		id.replace(pos, string::npos, ":1.0");
		module_def = repository_->lookup_id(id.c_str());
		open_module(module_def);
		out << "\nmodule " << module_def->name() << "\n{\n";
		out.indent();
	}


	string facet_type;
	map < string, bool > facet_types;
	map < string, bool > implemented_facets;
	

	//
	// local interface for each segment
	//
	CIDL::SegmentDefSeq_var segment_seq = composition->executor()->segments();
	CORBA::ULong len = segment_seq->length();
	for (CORBA::ULong i = 0; i < len; i++)
	{
		facet_types.clear();
		out << "//\n// " << segment_seq[i]->id() << "\n//\n";
		out << "local interface CCM_" << segment_seq[i]->name() << " : ::Components::EnterpriseComponent";

		// inherit from each implemented facet type
		IR__::ProvidesDefSeq_var provided_seq = segment_seq[i]->provided_facets();
		for (CORBA::ULong ii = 0; ii < provided_seq->length(); ii++)
		{
			implemented_facets[provided_seq[ii]->name()] = true;
			facet_type = provided_seq[ii]->interface_type()->id();
			
			// if type already inherited, skip it
			if(facet_types.find(facet_type) == facet_types.end())
			{
				out << ", " << mapLocalName(provided_seq[ii]->interface_type());
				facet_types[facet_type] = true;
			}
		}
		out << "\n{\n};\n\n";
	}


	//
	// local interface for the executor
	//
	facet_types.clear();
	out << "//\n// " << composition->executor()->id() << "\n//\n";
	out << "local interface CCM_" << composition->executor()->name() << " : ";
	out << mapLocalName(composition->ccm_component()) << "_Executor";
	

	// inherit from each implemented facet type
	IR__::ProvidesDefSeq_var provides_seq = composition->ccm_component()->provides_interfaces();
	len = provides_seq->length();
	for (i = 0; i < len; i++)
	{
		// facet already implemented by segment?
		if(implemented_facets.find(provides_seq[i]->name()) == implemented_facets.end())
		{
			facet_type = provides_seq[i]->interface_type()->id();
			
			// if type already inherited, skip it
			if(facet_types.find(facet_type) == facet_types.end())
			{
				facet_types[facet_type] = true;
				if(!facet_types.empty())
				{
					out << ", ";
				}
				out << map_absolute_name(provides_seq[i]->interface_type());
			}
		}
	}
	out << "\n{\n};\n\n";


	if(module_def)
	{
		out.unindent();
		out << "};\n";
		close_module(module_def);
	}
}
void
GeneratorValuetypesC::doValue(IR__::ValueDef_ptr value)
{
	open_module(out, value);
	class_name_ = mapName(value) + "Impl";
	
	out << "void\n";
	out << class_name_ << "::operator= (const " << class_name_ << "& v)\n{\n";
	out.indent();
	handleValueMember(value);
	out.insertUserSection(class_name_ + "::operator=", 0);
	out.unindent();
	out << "}\n\n\n";

	out << class_name_ << "::" << class_name_ << "(const " << class_name_ << "& v)\n{\n";
	out.indent();
	handleValueMember(value);
	out.insertUserSection(class_name_ + "::" + class_name_ + "1", 0);
	out.unindent();
	out << "}\n\n\n";

	// check whether this value(eventtype) has members.
	IR__::ContainedSeq_var contained_seq = value->contents(CORBA__::dk_ValueMember, false);
	if( contained_seq->length() > 0 ) // if has some, generate the constructor with parameters
	{
		out << class_name_ << "::" << class_name_ << "(";
		generateMemberParam( value, false );
		out << ")\n: " << mapFullNameWithPrefix(value, "OBV_") << "(";
		generateMemberInit( value, false );
		out << ")\n{\n";
		out.indent();
		out.insertUserSection(class_name_ + "::" + class_name_ + "2", 0);
		out.unindent();
		out << "}\n\n\n";
	}

	out << class_name_ << "::" << class_name_ << "()\n{\n";
	out.indent();
	out.insertUserSection(class_name_ + "::" + class_name_ + "3", 0);
	out.unindent();
	out << "}\n\n\n";

	out << class_name_ << "::~" << class_name_ << "()\n{\n";
	out.indent();
	out.insertUserSection(class_name_ + "::~" + class_name_, 0);
	out.unindent();
	out << "}\n\n\n";

	out << "CORBA::ValueBase*\n";
	out << class_name_ << "::_copy_value()\n{\n";
	out.indent();
	out << class_name_ << " *val = new " << class_name_ << "(* this);\n";
	out.insertUserSection(class_name_ + "::_copy_value", 0);
	out << "return val;\n";
	out.unindent();
	out << "}\n\n\n";

	//
	// supported interfaces
	//
	CORBA::ULong i;
	handled_interfaces_.clear();
	IR__::InterfaceDefSeq_var supp_intfs = value->supported_interfaces();
	for(i = 0; i < supp_intfs->length(); i++)
	{
		handleAttribute((*supp_intfs)[i]);
		handleOperation((*supp_intfs)[i]);
	};
	//
	// base value
	//
	IR__::ValueDef_var base = value->base_value();
	if(! CORBA::is_nil(base))
	{
		// todo
	}
	//
	// abstract base values
	//
	IR__::ValueDefSeq_var abstr = value->abstract_base_values();
	for(i = 0; i < abstr->length(); i++)
	{
		// todo
	};

	//
	// value type factory
	//
	out << "CORBA::ValueBase *\n";
	out << value->name() << "FactoryImpl::create_for_unmarshal ()\n{\n";
	out.indent();
	out << "return new " << mapFullName( value ) << "Impl();\n";
	out.unindent();
	out << "}\n\n\n";

	//
	// initializers
	//
	IR__::InitializerSeq_var ini = value->initializers();
	for(i = 0; i < ini->length(); i++)
	{
		// todo
	};

	//
	// static factory cleaner
	//
	out << "static Qedo::ValueFactoryCleaner " << value->name() << "Factory_cleaner( new ";
	out << value->name() << "FactoryImpl(), \"" << value->id() << "\" );\n";

	close_module(out, value);
}
Ejemplo n.º 28
0
/* Open an audio output module, trying modules in list (comma-separated). */
audio_output_t* open_output_module( const char* names )
{
	mpg123_module_t *module = NULL;
	audio_output_t *ao = NULL;
	int result = 0;
	char *curname, *modnames;

	if(param.usebuffer || names==NULL) return NULL;

	/* Use internal code. */
	if(param.outmode != DECODE_AUDIO) return open_fake_module();

	modnames = strdup(names);
	if(modnames == NULL)
	{
		error("Error allocating memory for module names.");
		return NULL;
	}
	/* Now loop over the list of possible modules to find one that works. */
	curname = strtok(modnames, ",");
	while(curname != NULL)
	{
		char* name = curname;
		curname = strtok(NULL, ",");
		if(param.verbose > 1) fprintf(stderr, "Trying output module %s.\n", name);
		/* Open the module, initial check for availability+libraries. */
		module = open_module( "output", name );
		if(module == NULL) continue;
		/* Check if module supports output */
		if(module->init_output == NULL)
		{
			error1("Module '%s' does not support audio output.", name);
			close_module(module);
			continue; /* Try next one. */
		}
		/* Allocation+initialization of memory for audio output type. */
		ao = alloc_audio_output();
		if(ao==NULL)
		{
			error("Failed to allocate audio output structure.");
			close_module(module);
			break; /* This is fatal. */
		}

		/* Call the init function */
		ao->device = param.output_device;
		ao->flags  = param.output_flags;
		/* Should I do funny stuff with stderr file descriptor instead? */
		if(curname == NULL)
		{
			if(param.verbose > 1)
			fprintf(stderr, "Note: %s is the last output option... showing you any error messages now.\n", name);
		}
		else ao->auxflags |= MPG123_OUT_QUIET; /* Probing, so don't spill stderr with errors. */
		ao->is_open = FALSE;
		ao->module = module; /* Need that to close module later. */
		result = module->init_output(ao);
		if(result == 0)
		{ /* Try to open the device. I'm only interested in actually working modules. */
			result = open_output(ao);
			close_output(ao);
		}
		else error2("Module '%s' init failed: %i", name, result);

		if(result!=0)
		{ /* Try next one... */
			close_module(module);
			free(ao);
			ao = NULL;
		}
		else 
		{ /* All good, leave the loop. */
			if(param.verbose > 1) fprintf(stderr, "Output module '%s' chosen.\n", name);

			ao->auxflags &= ~MPG123_OUT_QUIET;
			break;
		}
	}

	free(modnames);
	if(ao==NULL) error1("Unable to find a working output module in this list: %s", names);

	return ao;
}
Ejemplo n.º 29
0
input_module_t *sndio_open_module(module_param_t *params)
{
    input_module_t *mod = calloc(1, sizeof(input_module_t));
    im_sndio_state *s;
    module_param_t *current;
    char *device = NULL; /* default device */
    int sample_rate = 44100;
    int channels = 2;
    int use_metadata = 1; /* Default to on */

    mod->type = ICES_INPUT_PCM;
#ifdef WORDS_BIGENDIAN
    mod->subtype = INPUT_PCM_BE_16;
#else
    mod->subtype = INPUT_PCM_LE_16;
#endif
    mod->getdata = sndio_read;
    mod->handle_event = event_handler;
    mod->metadata_update = metadata_update;

    mod->internal = calloc(1, sizeof(im_sndio_state));
    s = mod->internal;

    thread_mutex_create(&s->metadatalock);

    current = params;

    while (current) {
        if (!strcmp(current->name, "rate"))
            sample_rate = atoi(current->value);
        else if (!strcmp(current->name, "channels"))
            channels = atoi(current->value);
        else if (!strcmp(current->name, "device"))
            device = current->value;
        else if (!strcmp(current->name, "metadata"))
            use_metadata = atoi(current->value);
        else if(!strcmp(current->name, "metadatafilename"))
            ices_config->metadata_filename = current->value;
        else
            LOG_WARN1("Unknown parameter %s for sndio module", current->name);
        current = current->next;
    }

    /* First up, lets open the audio device */
    if((s->hdl = sio_open(device, SIO_REC, 0)) == NULL) {
        LOG_ERROR0("Failed to open sndio device");
        goto fail;
    }

    /* Try and set up what we want */
    sio_initpar(&s->par);
    s->par.rate = sample_rate;
    s->par.rchan = channels; 
    s->par.bits = 16;
    s->par.sig = 1;
    s->par.le = SIO_LE_NATIVE;
    s->par.round = BUFSIZE;
    s->par.appbufsz = BUFSIZE * 4;

    if (!sio_setpar(s->hdl, &s->par) || !sio_getpar(s->hdl, &s->par)) {
        LOG_ERROR0("Failed to configure sndio device");
        goto fail;
    }

    /* Check all went according to plan */
    if (s->par.rate != sample_rate) {
        LOG_ERROR0("Couldn't set sampling rate");
        goto fail;
    }
    if (s->par.rchan != channels) {
        LOG_ERROR0("Couldn't set number of channels");
        goto fail;
    }
    if (s->par.bits != 16) {
        LOG_ERROR0("Couldn't set 16 bit precision");
        goto fail;
    }
    if (s->par.sig != 1) {
        LOG_ERROR0("Couldn't set signed linear encoding");
        goto fail;
    }
    if (s->par.le != SIO_LE_NATIVE) {
        LOG_ERROR0("Couldn't set proper endianness");
        goto fail;
    }

    if (!sio_start(s->hdl)) {
        LOG_ERROR0("Couldn't start sndio");
        goto fail;
    }

    /* We're done, and we didn't fail! */
    LOG_INFO2("Opened audio device for %d channel(s), %d Hz", 
            channels, sample_rate);

    if(use_metadata)
    {
        LOG_INFO0("Starting metadata update thread");
        if(ices_config->metadata_filename)
            thread_create("im_sndio-metadata", metadata_thread_signal, mod, 1);
        else
            thread_create("im_sndio-metadata", metadata_thread_stdin, mod, 1);
    }

    return mod;

fail:
    close_module(mod); /* safe, this checks for valid contents */
    return NULL;
}
Ejemplo n.º 30
0
//
// composition
//
void
GeneratorBIDL::doComposition(CIDL::CompositionDef_ptr composition)
{
	//
	// get the module where the composition is defined in and open it
	//
	string id = composition->id();
	IR__::Contained_ptr module_def = 0;
	string::size_type pos = id.find_last_of("/");
	if(pos != string::npos)
	{
		id.replace(pos, string::npos, ":1.0");
		module_def = repository_->lookup_id(id.c_str());
		open_module(module_def);
		out << "\nmodule " << module_def->name() << "\n{\n";
		out.indent();
	}

	string facet_type;
	t_string_map facet_types;
	t_string_map implemented_facets;
	CORBA::ULong i;

	//
	// local interface for each segment
	//
	CIDL::SegmentDefSeq_var segment_seq = composition->executor_def()->segments();
	CORBA::ULong len = segment_seq->length();
	for (i = 0; i < len; i++)
	{
		facet_types.clear();
		out << "//\n// " << segment_seq[i]->id() << "\n//\n";
		out << "local interface CCM_" << segment_seq[i]->name() << " : ::Components::EnterpriseComponent";

		// inherit from each implemented facet type
		IR__::ProvidesDefSeq_var provided_seq = segment_seq[i]->provided_facets();
		for (CORBA::ULong ii = 0; ii < provided_seq->length(); ii++)
		{
			implemented_facets[provided_seq[ii]->name()] = true;
			IR__::InterfaceDef_var intf = IR__::InterfaceDef::_narrow(provided_seq[ii]->interface_type());
			if( !CORBA::is_nil(intf) )
			{
				facet_type = intf->id();
			}
			else
			{
				facet_type = "IDL:omg.org/CORBA/Object:1.0";
			}
			
			// if type already inherited, skip it
			if(facet_types.find(facet_type) == facet_types.end())
			{
				out << ", " << getLocalName(provided_seq[ii]->interface_type());
				facet_types[facet_type] = true;
			}
		}
		out << "\n{\n};\n\n";
	}


	//
	// local interface for the executor
	//
	facet_types.clear();
	out << "//\n// " << composition->executor_def()->id() << "\n//\n";
	out << "local interface CCM_" << composition->executor_def()->name() << " : ";
	out << getLocalName(composition->ccm_component()) << "_Executor";
	
	this -> gen_facet(composition->ccm_component(), implemented_facets, facet_types);
	/*
	//
	// inherit from each implemented facet type
	//
	IR__::ProvidesDefSeq_var provides_seq = composition->ccm_component()->provides_interfaces();
	len = provides_seq->length();
	for (i = 0; i < len; i++)
	{
		IR__::InterfaceDef_var intf = IR__::InterfaceDef::_narrow(provides_seq[i]->interface_type());
		if( CORBA::is_nil(intf) )
		{
			continue;
		}

		//
		// facet not already implemented by segment
		//
		if(implemented_facets.find(provides_seq[i]->name()) == implemented_facets.end())
		{
			// if type already inherited, skip it
			facet_type = intf->id();
			if(facet_types.find(facet_type) == facet_types.end())
			{
				facet_types[facet_type] = true;
				if(!facet_types.empty()) {
					out << ", ";
				}
				out << getLocalName(intf);
			}
		}
	}
	*/
	/*
	// inherit from consumer for each event
	facet_types.clear();
	IR__::ConsumesDefSeq_var consumes_seq = composition->ccm_component()->consumes_events();
	len = consumes_seq->length();
	for (i = 0; i < len; i++)
	{
		facet_type = consumes_seq[i]->event()->id();
			
		// if type already inherited, skip it
		if(facet_types.find(facet_type) == facet_types.end())
		{
			facet_types[facet_type] = true;
			out << ", " << getLocalName(consumes_seq[i]->event()) << "Consumer";
		}
	}
*/
	out << "\n{\n};\n\n";


	if(module_def)
	{
		out.unindent();
		out << "};\n";
		close_module(module_def);
	}
}