コード例 #1
0
ファイル: config.cpp プロジェクト: ovsm-dev/seiscomp3
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ConfigModule* Config::findConfigModule(const std::string& publicID) const {
	ConfigModule* object = ConfigModule::Cast(PublicObject::Find(publicID));
	if ( object != NULL && object->parent() == this )
		return object;
	
	return NULL;
}
コード例 #2
0
ファイル: config.cpp プロジェクト: ovsm-dev/seiscomp3
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool Config::updateChild(Object* child) {
	ParameterSet* parameterSetChild = ParameterSet::Cast(child);
	if ( parameterSetChild != NULL ) {
		ParameterSet* parameterSetElement
			= ParameterSet::Cast(PublicObject::Find(parameterSetChild->publicID()));
		if ( parameterSetElement && parameterSetElement->parent() == this ) {
			*parameterSetElement = *parameterSetChild;
			return true;
		}
		return false;
	}

	ConfigModule* configModuleChild = ConfigModule::Cast(child);
	if ( configModuleChild != NULL ) {
		ConfigModule* configModuleElement
			= ConfigModule::Cast(PublicObject::Find(configModuleChild->publicID()));
		if ( configModuleElement && configModuleElement->parent() == this ) {
			*configModuleElement = *configModuleChild;
			return true;
		}
		return false;
	}

	return false;
}
コード例 #3
0
ファイル: config.cpp プロジェクト: ovsm-dev/seiscomp3
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool Config::add(ConfigModule* configModule) {
	if ( configModule == NULL )
		return false;

	// Element has already a parent
	if ( configModule->parent() != NULL ) {
		SEISCOMP_ERROR("Config::add(ConfigModule*) -> element has already a parent");
		return false;
	}

	if ( PublicObject::IsRegistrationEnabled() ) {
		ConfigModule* configModuleCached = ConfigModule::Find(configModule->publicID());
		if ( configModuleCached ) {
			if ( configModuleCached->parent() ) {
				if ( configModuleCached->parent() == this )
					SEISCOMP_ERROR("Config::add(ConfigModule*) -> element with same publicID has been added already");
				else
					SEISCOMP_ERROR("Config::add(ConfigModule*) -> element with same publicID has been added already to another object");
				return false;
			}
			else
				configModule = configModuleCached;
		}
	}

	// Add the element
	_configModules.push_back(configModule);
	configModule->setParent(this);

	// Create the notifiers
	if ( Notifier::IsEnabled() ) {
		NotifierCreator nc(OP_ADD);
		configModule->accept(&nc);
	}

	// Notify registered observers
	childAdded(configModule);
	
	return true;
}