#include "tensorstore/context.h"
template <typename Provider>
class tensorstore::Context::Resource;

Variant type that either specifies an unresolved context resource, or holds a shared handle to a context resource.

Unresolved context resources may either be specified directly or by a named reference, and are resolved by calling Context::GetResource.

Types

using ToJsonOptions = JsonSerializationOptions;
using FromJsonOptions = JsonSerializationOptions;

JSON serialization options.

Constructors

Resource();

Constructs an invalid handle.

Methods

static Resource<Provider> DefaultSpec();

Returns a resource spec that refers to the default value within the Context.

autoget() const noexcept;
autooperator->() const noexcept;
autooperator*() const noexcept;

Returns a pointer to the resource object of type Provider::Resource, or nullptr if no resource is bound.

bool has_resource() const;

Returns true if this is not null and corresponds to a bound resource (rather than a resource spec).

bool valid() const;

Returns true if this corresponds to a resource spec or bound resource.

Result<::nlohmann::json>
ToJson(const ToJsonOptionsoptions = ToJsonOptions{}) const;

Converts to a JSON representation.

static Result<Resource<Provider>>
FromJson(::nlohmann::json j,
         
const FromJsonOptionsoptions = FromJsonOptions{});

Returns a resource spec from a JSON representation.

absl::Status BindContext(const Contextcontext);

If !this->has_resource(), resolves this to a resource using the specified context. Otherwise, does nothing.

void StripContext();

If this is non-null, resets it to DefaultSpec(). If this is null, it remains null.

Friend functions

friend bool operator==(const Resourceaconst Resourceb);
friend bool operator!=(const Resourceaconst Resourceb);

Checks if a and b refer to the same resource or resource spec.