コード例 #1
0
ファイル: momenttensor.cpp プロジェクト: ovsm-dev/seiscomp3
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
MomentTensorStationContribution* MomentTensor::findMomentTensorStationContribution(const std::string& publicID) const {
	MomentTensorStationContribution* object = MomentTensorStationContribution::Cast(PublicObject::Find(publicID));
	if ( object != NULL && object->parent() == this )
		return object;
	
	return NULL;
}
コード例 #2
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool MomentTensor::add(MomentTensorStationContribution* momentTensorStationContribution) {
	if ( momentTensorStationContribution == NULL )
		return false;

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

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

	// Add the element
	_momentTensorStationContributions.push_back(momentTensorStationContribution);
	momentTensorStationContribution->setParent(this);

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

	// Notify registered observers
	childAdded(momentTensorStationContribution);
	
	return true;
}
コード例 #3
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool MomentTensor::updateChild(Object* child) {
	Comment* commentChild = Comment::Cast(child);
	if ( commentChild != NULL ) {
		Comment* commentElement = comment(commentChild->index());
		if ( commentElement != NULL ) {
			*commentElement = *commentChild;
			return true;
		}
		return false;
	}

	// Do not know how to fetch child of type DataUsed without an index

	MomentTensorPhaseSetting* momentTensorPhaseSettingChild = MomentTensorPhaseSetting::Cast(child);
	if ( momentTensorPhaseSettingChild != NULL ) {
		MomentTensorPhaseSetting* momentTensorPhaseSettingElement = momentTensorPhaseSetting(momentTensorPhaseSettingChild->index());
		if ( momentTensorPhaseSettingElement != NULL ) {
			*momentTensorPhaseSettingElement = *momentTensorPhaseSettingChild;
			return true;
		}
		return false;
	}

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

	return false;
}