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 | |
Registry & | operator= (const Registry &)=delete |
~Registry ()=default | |
asio::awaitable< bool > | addFeature (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< bool > | addTransformation (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< bool > | addCondition (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< bool > | checkIfSubFeaturesExist (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< bool > | containsFeatureBucket (const std::string &name) const |
Checks if a feature bucket exists in the registry. | |
asio::awaitable< bool > | containsTransformationBucket (const std::string &name) const |
Checks if a transformation bucket exists in the registry. | |
asio::awaitable< bool > | containsConditionBucket (const std::string &name) const |
Checks if a condition bucket exists in the registry. | |
asio::awaitable< bool > | isFeatureBucketEmpty (const std::string &name) const |
Checks if a feature bucket is empty. | |
asio::awaitable< bool > | isTransformationBucketEmpty (const std::string &name) const |
Checks if a transformation bucket is empty. | |
asio::awaitable< bool > | isConditionBucketEmpty (const std::string &name) const |
Checks if a condition bucket is empty. | |
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.
|
delete |
dcn::Registry::Registry | ( | asio::io_context & | io_context | ) |
|
default |
asio::awaitable< bool > dcn::Registry::addCondition | ( | evmc::address | address, |
Condition | condition, | ||
std::filesystem::path | source | ||
) |
Adds a condition to the registry.
condition | The 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.
asio::awaitable< bool > dcn::Registry::addFeature | ( | evmc::address | address, |
Feature | feature, | ||
evmc::address | owner, | ||
std::filesystem::path | source | ||
) |
Adds a feature to the registry.
feature | The 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.
asio::awaitable< bool > dcn::Registry::addTransformation | ( | evmc::address | address, |
Transformation | transformation, | ||
evmc::address | owner, | ||
std::filesystem::path | source | ||
) |
Adds a transformation to the registry.
transformation | The 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.
Recursively checks if all subfeatures exist in the registry.
feature | The feature to check |
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.
|
protected |
Checks if a condition bucket exists in the registry.
name | The name of the condition bucket to check for. |
|
protected |
Checks if a feature bucket exists in the registry.
name | The name of the feature bucket to check for. |
|
protected |
Checks if a transformation bucket exists in the registry.
name | The name of the transformation bucket to check for. |
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.
name | The name of the condition. |
address | The address of the condition. |
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
.
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.
name | The name of the feature. |
address | The address of the feature. |
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
.
asio::awaitable< std::optional< Condition > > dcn::Registry::getNewestCondition | ( | const std::string & | name | ) | const |
Retrieves the newest condition by name.
name | The name of the condition. |
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
.
asio::awaitable< std::optional< Feature > > dcn::Registry::getNewestFeature | ( | const std::string & | name | ) | const |
Retrieves the newest feature by name.
name | The name of the feature. |
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
.
asio::awaitable< std::optional< Transformation > > dcn::Registry::getNewestTransformation | ( | const std::string & | name | ) | const |
Retrieves the newest transformation by name.
name | The name of the transformation. |
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
.
asio::awaitable< absl::flat_hash_set< std::string > > dcn::Registry::getOwnedFeatures | ( | const evmc::address & | address | ) | const |
asio::awaitable< absl::flat_hash_set< std::string > > dcn::Registry::getOwnedTransformations | ( | const evmc::address & | address | ) | const |
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.
name | The name of the transformation. |
address | The address of the transformation. |
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
.
|
protected |
Checks if a condition bucket is empty.
name | The name of the condition bucket. |
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.
|
protected |
Checks if a feature bucket is empty.
name | The name of the feature bucket. |
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.
|
protected |
Checks if a transformation bucket is empty.
name | The name of the transformation bucket. |
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.