本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
订阅
您可以创建具有订阅区域和域 ID 的订阅。域 ID 表示拥有该订阅区域的域。BoundingBox2F32
描述订阅区域。使用以下函数可创建订阅:
Result<SubscriptionHandle> CreateSubscriptionBoundingBox2F32(Transaction& txn, DomainId id, const BoundingBox2F32& boundingBox)
例 示例
Result<void> CreateSubscriptionInSpatialDomain(Transaction& transaction) { WEAVERRUNTIME_TRY(Api::PartitionSet partitionSet, Api::AllPartitions(transaction)); Api::DomainId spatialDomainId; for (const Api::Partition& partition : partitionSet.partitions) { if (partition.domain_type == Api::DomainType::Spatial) { /** * Get the spatial domain ID. */ spatialDomainId = partition.domain_id; break; } } constexpr Api::BoundingBox2F32 subscriptionBounds { /* min */ { /* x */ 0, /* y */ 0 }, /* max */ { /* x */ 1000, /* y */ 1000 } } WEAVERRUNTIME_TRY( Api::SubscriptionHandle subscriptionHandle, Api::CreateSubscriptionBoundingBox2F32( transaction, spatialDomainId, subscriptionBounds)); return Success(); }
您可以使用 CreateSubscriptionBoundingBox2F32()
返回的 Api::SubscriptionHandle
来修改订阅。您可以将其作为参数传递给以下函数:
Result<void> ModifySubscriptionBoundingBox2F32(Transaction& txn, SubscriptionHandle handle, const BoundingBox2F32& boundingBox)
Result<void> DeleteSubscription(Transaction& txn, SubscriptionHandle handle)