// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool FocalMechanism::updateChild(Object* child) { Comment* commentChild = Comment::Cast(child); if ( commentChild != NULL ) { Comment* commentElement = comment(commentChild->index()); if ( commentElement != NULL ) { *commentElement = *commentChild; commentElement->update(); return true; } return false; } MomentTensor* momentTensorChild = MomentTensor::Cast(child); if ( momentTensorChild != NULL ) { MomentTensor* momentTensorElement = MomentTensor::Cast(PublicObject::Find(momentTensorChild->publicID())); if ( momentTensorElement && momentTensorElement->parent() == this ) { *momentTensorElement = *momentTensorChild; momentTensorElement->update(); return true; } return false; } return false; }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MomentTensor* FocalMechanism::findMomentTensor(const std::string& publicID) const { MomentTensor* object = MomentTensor::Cast(PublicObject::Find(publicID)); if ( object != NULL && object->parent() == this ) return object; return NULL; }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> bool FocalMechanism::add(MomentTensor* momentTensor) { if ( momentTensor == NULL ) return false; // Element has already a parent if ( momentTensor->parent() != NULL ) { SEISCOMP_ERROR("FocalMechanism::add(MomentTensor*) -> element has already a parent"); return false; } if ( PublicObject::IsRegistrationEnabled() ) { MomentTensor* momentTensorCached = MomentTensor::Find(momentTensor->publicID()); if ( momentTensorCached ) { if ( momentTensorCached->parent() ) { if ( momentTensorCached->parent() == this ) SEISCOMP_ERROR("FocalMechanism::add(MomentTensor*) -> element with same publicID has been added already"); else SEISCOMP_ERROR("FocalMechanism::add(MomentTensor*) -> element with same publicID has been added already to another object"); return false; } else momentTensor = momentTensorCached; } } // Add the element _momentTensors.push_back(momentTensor); momentTensor->setParent(this); // Create the notifiers if ( Notifier::IsEnabled() ) { NotifierCreator nc(OP_ADD); momentTensor->accept(&nc); } // Notify registered observers childAdded(momentTensor); return true; }