Ejemplo n.º 1
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ParameterSet* Config::findParameterSet(const std::string& publicID) const {
	ParameterSet* object = ParameterSet::Cast(PublicObject::Find(publicID));
	if ( object != NULL && object->parent() == this )
		return object;
	
	return NULL;
}
Ejemplo n.º 2
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
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;
}
Ejemplo n.º 3
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool Config::add(ParameterSet* parameterSet) {
	if ( parameterSet == NULL )
		return false;

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

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

	// Add the element
	_parameterSets.push_back(parameterSet);
	parameterSet->setParent(this);

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

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