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

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

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

	// Add the element
	_routes.push_back(route);
	route->setParent(this);

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

	// Notify registered observers
	childAdded(route);
	
	return true;
}
コード例 #3
0
ファイル: routing.cpp プロジェクト: ovsm-dev/seiscomp3
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool Routing::updateChild(Object* child) {
	Route* routeChild = Route::Cast(child);
	if ( routeChild != NULL ) {
		Route* routeElement
			= Route::Cast(PublicObject::Find(routeChild->publicID()));
		if ( routeElement && routeElement->parent() == this ) {
			*routeElement = *routeChild;
			return true;
		}
		return false;
	}

	Access* accessChild = Access::Cast(child);
	if ( accessChild != NULL ) {
		Access* accessElement = access(accessChild->index());
		if ( accessElement != NULL ) {
			*accessElement = *accessChild;
			return true;
		}
		return false;
	}

	return false;
}