Decentralised Art Server
High-performance C++ backend that exposes HTML interface and a secure REST API for managing Performative Transactions entities
 
Loading...
Searching...
No Matches
dcn::Registry Class Reference

A class that represents a registry of features, transformations, and conditions. More...

#include <registry.hpp>

Classes

struct  Node
 

Public Member Functions

 Registry ()=delete
 
 Registry (asio::io_context &io_context)
 
 Registry (const Registry &)=delete
 
Registryoperator= (const Registry &)=delete
 
 ~Registry ()=default
 
asio::awaitable< booladdFeature (evmc::address address, Feature feature, evmc::address owner, std::filesystem::path source)
 Adds a feature to the registry.
 
asio::awaitable< std::optional< Feature > > getNewestFeature (const std::string &name) const
 Retrieves the newest feature by name.
 
asio::awaitable< std::optional< Feature > > getFeature (const std::string &name, const evmc::address &address) const
 Retrieves a specific feature by name and address.
 
asio::awaitable< booladdTransformation (evmc::address address, Transformation transformation, evmc::address owner, std::filesystem::path source)
 Adds a transformation to the registry.
 
asio::awaitable< std::optional< Transformation > > getNewestTransformation (const std::string &name) const
 Retrieves the newest transformation by name.
 
asio::awaitable< std::optional< Transformation > > getTransformation (const std::string &name, const evmc::address &address) const
 Retrieves a specific transformation by name and address.
 
asio::awaitable< booladdCondition (evmc::address address, Condition condition, std::filesystem::path source)
 Adds a condition to the registry.
 
asio::awaitable< std::optional< Condition > > getNewestCondition (const std::string &name) const
 Retrieves the newest condition by name.
 
asio::awaitable< std::optional< Condition > > getCondition (const std::string &name, const evmc::address &address) const
 Retrieves a specific condition by name and address.
 
asio::awaitable< boolcheckIfSubFeaturesExist (const Feature &feature) const
 Recursively checks if all subfeatures exist in the registry.
 
asio::awaitable< absl::flat_hash_set< std::string > > getOwnedFeatures (const evmc::address &address) const
 
asio::awaitable< absl::flat_hash_set< std::string > > getOwnedTransformations (const evmc::address &address) const
 

Protected Member Functions

asio::awaitable< boolcontainsFeatureBucket (const std::string &name) const
 Checks if a feature bucket exists in the registry.
 
asio::awaitable< boolcontainsTransformationBucket (const std::string &name) const
 Checks if a transformation bucket exists in the registry.
 
asio::awaitable< boolcontainsConditionBucket (const std::string &name) const
 Checks if a condition bucket exists in the registry.
 
asio::awaitable< boolisFeatureBucketEmpty (const std::string &name) const
 Checks if a feature bucket is empty.
 
asio::awaitable< boolisTransformationBucketEmpty (const std::string &name) const
 Checks if a transformation bucket is empty.
 
asio::awaitable< boolisConditionBucketEmpty (const std::string &name) const
 Checks if a condition bucket is empty.
 

Detailed Description

A class that represents a registry of features, transformations, and conditions.

This class is used to store and manage features, transformations, and conditions. It provides methods to add, get, and remove features, transformations, and conditions. It also provides methods to check if a feature, transformation, or condition exists.

Constructor & Destructor Documentation

◆ Registry() [1/3]

dcn::Registry::Registry ( )
delete

◆ Registry() [2/3]

dcn::Registry::Registry ( asio::io_context &  io_context)

◆ Registry() [3/3]

dcn::Registry::Registry ( const Registry )
delete

◆ ~Registry()

dcn::Registry::~Registry ( )
default

Member Function Documentation

◆ addCondition()

asio::awaitable< bool > dcn::Registry::addCondition ( evmc::address  address,
Condition  condition,
std::filesystem::path  source 
)

Adds a condition to the registry.

Parameters
conditionThe condition to add.

This function adds a condition to the registry. The condition is added to a bucket with its name as the key. If the condition already exists, the function returns std::nullopt. If the condition does not exist, it is added and the hash of the condition is returned.

◆ addFeature()

asio::awaitable< bool > dcn::Registry::addFeature ( evmc::address  address,
Feature  feature,
evmc::address  owner,
std::filesystem::path  source 
)

Adds a feature to the registry.

Parameters
featureThe feature to add.

This function adds a feature to the registry. The feature is added to a bucket with its name as the key. If the feature already exists, the function returns std::nullopt. If the feature does not exist, it is added and the hash of the feature is returned.

◆ addTransformation()

asio::awaitable< bool > dcn::Registry::addTransformation ( evmc::address  address,
Transformation  transformation,
evmc::address  owner,
std::filesystem::path  source 
)

Adds a transformation to the registry.

Parameters
transformationThe transformation to add.

This function adds a transformation to the registry. The transformation is added to a bucket with its name as the key. If the transformation already exists, the function returns std::nullopt. If the transformation does not exist, it is added and the hash of the transformation is returned.

◆ checkIfSubFeaturesExist()

asio::awaitable< bool > dcn::Registry::checkIfSubFeaturesExist ( const Feature feature) const

Recursively checks if all subfeatures exist in the registry.

Parameters
featureThe feature to check
Returns
true if all subfeatures exist, false otherwise

This function works by iterating over all dimensions of the feature and recursively checking if each subfeature exists in the registry. If at any point any subfeature does not exist, the function returns false.

◆ containsConditionBucket()

asio::awaitable< bool > dcn::Registry::containsConditionBucket ( const std::string &  name) const
protected

Checks if a condition bucket exists in the registry.

Parameters
nameThe name of the condition bucket to check for.
Returns
True if the condition bucket with the given name exists, false otherwise.

◆ containsFeatureBucket()

asio::awaitable< bool > dcn::Registry::containsFeatureBucket ( const std::string &  name) const
protected

Checks if a feature bucket exists in the registry.

Parameters
nameThe name of the feature bucket to check for.
Returns
True if the feature bucket with the given name exists, false otherwise.

◆ containsTransformationBucket()

asio::awaitable< bool > dcn::Registry::containsTransformationBucket ( const std::string &  name) const
protected

Checks if a transformation bucket exists in the registry.

Parameters
nameThe name of the transformation bucket to check for.
Returns
True if the transformation bucket with the given name exists, false otherwise.

◆ getCondition()

asio::awaitable< std::optional< Condition > > dcn::Registry::getCondition ( const std::string &  name,
const evmc::address &  address 
) const

Retrieves a specific condition by name and address.

Parameters
nameThe name of the condition.
addressThe address of the condition.
Returns
An std::optional<Condition> containing the condition if found, or std::nullopt if the condition or address does not exist.

This function searches for a condition in the registry by its name and address. If the condition name or address is not found, it returns std::nullopt.

◆ getFeature()

asio::awaitable< std::optional< Feature > > dcn::Registry::getFeature ( const std::string &  name,
const evmc::address &  address 
) const

Retrieves a specific feature by name and address.

Parameters
nameThe name of the feature.
addressThe address of the feature.
Returns
An std::optional<Feature> containing the feature if found, or std::nullopt if the feature or address does not exist.

This function searches for a feature in the registry by its name and address. If the feature name or address is not found, it returns std::nullopt.

◆ getNewestCondition()

asio::awaitable< std::optional< Condition > > dcn::Registry::getNewestCondition ( const std::string &  name) const

Retrieves the newest condition by name.

Parameters
nameThe name of the condition.
Returns
An std::optional<Condition> containing the condition if found, or std::nullopt if the condition does not exist.

This function searches for the newest condition by name in the registry. If the condition does not exist, it returns std::nullopt.

◆ getNewestFeature()

asio::awaitable< std::optional< Feature > > dcn::Registry::getNewestFeature ( const std::string &  name) const

Retrieves the newest feature by name.

Parameters
nameThe name of the feature.
Returns
An std::optional<Feature> containing the feature if found, or std::nullopt if the feature does not exist.

This function searches for the newest feature by name in the registry. If the feature does not exist, it returns std::nullopt.

◆ getNewestTransformation()

asio::awaitable< std::optional< Transformation > > dcn::Registry::getNewestTransformation ( const std::string &  name) const

Retrieves the newest transformation by name.

Parameters
nameThe name of the transformation.
Returns
An std::optional<Transformation> containing the transformation if found, or std::nullopt if the transformation does not exist.

This function searches for the newest transformation by name in the registry. If the transformation does not exist, it returns std::nullopt.

◆ getOwnedFeatures()

asio::awaitable< absl::flat_hash_set< std::string > > dcn::Registry::getOwnedFeatures ( const evmc::address &  address) const

◆ getOwnedTransformations()

asio::awaitable< absl::flat_hash_set< std::string > > dcn::Registry::getOwnedTransformations ( const evmc::address &  address) const

◆ getTransformation()

asio::awaitable< std::optional< Transformation > > dcn::Registry::getTransformation ( const std::string &  name,
const evmc::address &  address 
) const

Retrieves a specific transformation by name and address.

Parameters
nameThe name of the transformation.
addressThe address of the transformation.
Returns
An std::optional<Transformation> containing the transformation if found, or std::nullopt if the transformation or address does not exist.

This function searches for a transformation in the registry by its name and address. If the transformation name or address is not found, it returns std::nullopt.

◆ isConditionBucketEmpty()

asio::awaitable< bool > dcn::Registry::isConditionBucketEmpty ( const std::string &  name) const
protected

Checks if a condition bucket is empty.

Parameters
nameThe name of the condition bucket.
Returns
true if the condition bucket exists and is empty, false otherwise.

This function first checks if the condition bucket exists in the registry. If it does not exist, the function returns true. If the condition bucket does exist, the function returns true if the bucket is empty and false otherwise.

◆ isFeatureBucketEmpty()

asio::awaitable< bool > dcn::Registry::isFeatureBucketEmpty ( const std::string &  name) const
protected

Checks if a feature bucket is empty.

Parameters
nameThe name of the feature bucket.
Returns
true if the feature bucket exists and is empty, false otherwise.

This function first checks if the feature bucket exists in the registry. If it does not exist, the function returns true. If the feature bucket does exist, the function returns true if the bucket is empty and false otherwise.

◆ isTransformationBucketEmpty()

asio::awaitable< bool > dcn::Registry::isTransformationBucketEmpty ( const std::string &  name) const
protected

Checks if a transformation bucket is empty.

Parameters
nameThe name of the transformation bucket.
Returns
true if the transformation bucket exists and is empty, false otherwise.

This function first checks if the transformation bucket exists in the registry. If it does not exist, the function returns true. If the transformation bucket does exist, the function returns true if the bucket is empty and false otherwise.

◆ operator=()

Registry & dcn::Registry::operator= ( const Registry )
delete

The documentation for this class was generated from the following files: