NMDeviceFactory * nm_device_factory_manager_find_factory_for_connection (NMConnection *connection) { const char *stypes[2] = { nm_connection_get_connection_type (connection), NULL }; g_assert (stypes[0]); return find_factory (NULL, stypes); }
NMDeviceFactory * nm_device_factory_manager_find_factory_for_link_type (NMLinkType link_type) { const NMLinkType ltypes[2] = { link_type, NM_LINK_TYPE_NONE }; if (link_type == NM_LINK_TYPE_UNKNOWN) return NULL; g_return_val_if_fail (link_type > NM_LINK_TYPE_UNKNOWN, NULL); return find_factory (ltypes, NULL); }
void BlockStoreFactory::destroy(string const & i_name, StringSeq const & i_args) throw(InternalError, NotFoundError, ValueError) { LOG(lgr, 4, "destroy " << i_name); return find_factory(i_name)->bsf_destroy(i_args); }
BlockStoreHandle BlockStoreFactory::create(string const & i_factname, string const & i_instname, size_t i_size, StringSeq const & i_args) throw(InternalError, NotFoundError, NotUniqueError, ValueError) { LOG(lgr, 4, "create" << ' ' << i_factname << ' ' << i_instname << ' ' << i_size); { ACE_Guard<ACE_Thread_Mutex> guard(g_bsfmutex); // Does this instance already exist? BlockStoreInstanceMap::iterator pos = g_bsim.find(i_instname); if (pos != g_bsim.end()) throwstream(NotUniqueError, "blockstore instance for \"" << i_instname << "\" already exists"); // Reserve the name with a placeholder. g_bsim.insert(make_pair(i_instname, BlockStoreHandle(NULL))); } // Unlock the mutex while we create the blockstore ... try { BlockStoreHandle bsh = find_factory(i_factname)->bsf_create(i_instname, i_size, i_args); // Replace the placeholder w/ the real thing. ACE_Guard<ACE_Thread_Mutex> guard(g_bsfmutex); g_bsim[i_instname] = bsh; // And return it ... return bsh; } catch (...) { // Remove the placeholder. ACE_Guard<ACE_Thread_Mutex> guard(g_bsfmutex); g_bsim.erase(i_instname); throw; // Rethrow the exception. } }
void RedClient::create_channel(uint32_t type, uint32_t id) { ChannelFactory* factory = find_factory(type); if (!factory) { return; } RedChannel* channel = factory->construct(*this, id); ASSERT(channel); Lock lock(_channels_lock); _channels.push_back(channel); channel->start(); channel->connect(); _migrate.add_channel(new MigChannel(type, id, channel->get_common_caps(), channel->get_caps())); }
static gboolean _add_factory (NMDeviceFactory *factory, gboolean check_duplicates, const char *path, NMDeviceFactoryManagerFactoryFunc callback, gpointer user_data) { NMDeviceFactory *found = NULL; const NMLinkType *link_types = NULL; const char **setting_types = NULL; int i; g_return_val_if_fail (factories_by_link, FALSE); g_return_val_if_fail (factories_by_setting, FALSE); nm_device_factory_get_supported_types (factory, &link_types, &setting_types); if (check_duplicates) { found = find_factory (link_types, setting_types); if (found) { nm_log_warn (LOGD_HW, "Loading device plugin failed: multiple plugins " "for same type (using '%s' instead of '%s')", (char *) g_object_get_data (G_OBJECT (found), PLUGIN_PATH_TAG), path); return FALSE; } } g_object_set_data_full (G_OBJECT (factory), PLUGIN_PATH_TAG, g_strdup (path), g_free); for (i = 0; link_types && link_types[i] > NM_LINK_TYPE_UNKNOWN; i++) g_hash_table_insert (factories_by_link, GUINT_TO_POINTER (link_types[i]), g_object_ref (factory)); for (i = 0; setting_types && setting_types[i]; i++) g_hash_table_insert (factories_by_setting, (char *) setting_types[i], g_object_ref (factory)); callback (factory, user_data); nm_log_info (LOGD_HW, "Loaded device plugin: %s (%s)", G_OBJECT_TYPE_NAME (factory), path); return TRUE; }