$darkmode
fable::schema::Interface Class Referenceabstract

#include <interface.hpp>

Inheritance diagram for fable::schema::Interface:
[legend]

Public Member Functions

virtual Interfaceclone () const =0
 
virtual bool is_variant () const
 
virtual JsonType type () const =0
 
virtual std::string type_string () const =0
 
virtual bool is_required () const =0
 
virtual const std::string & description () const =0
 
virtual void set_description (const std::string &s)=0
 
virtual Json usage () const =0
 
virtual Json json_schema () const =0
 
virtual void validate (const Conf &c) const =0
 
virtual bool is_valid (const Conf &c) const
 
virtual Json to_json () const
 
virtual void to_json (Json &) const =0
 
virtual void from_conf (const Conf &)=0
 
virtual void reset_ptr ()=0
 

Detailed Description

Interface specifies all information for describing a JSON entity.

Schemas are instantiated through one of the many constructors that are defined.

Most constructor definitions make use of one of a set of private template constructors. These private template constructors enable slimmer constructors for all sorts of types later on. In order to differentiate between these constructors and the ones that users should use, the number of parameters and the order of types is sometimes varied.

We could use named constructors, but then you can not use the new operator with the construction or you need to use the copy constructor thereby constructing the schema twice.

When changing this Interface, the following implementors should be updated:

Box fable/schema/interface.hpp Schema fable/schema.hpp Variant fable/schema/variant.hpp FromConfable fable/schema/confable.hpp

Member Function Documentation

◆ clone()

virtual Interface* fable::schema::Interface::clone ( ) const
pure virtual

Return a new instance of the object.

This is implemented by Base and allows us to wrap implementors of Interface with Schema.

Implemented in fable::schema::Base< CRTP >, fable::schema::Base< FactoryPointerless< ControllerConf > >, fable::schema::Base< Factory< T > >, fable::schema::Base< FactoryPointerless< C > >, fable::schema::Base< FromConfable< T > >, fable::schema::Base< Factory< DistributionPtr > >, fable::schema::Base< String >, fable::schema::Base< VehicleSchema >, fable::schema::Base< FactoryPointerless< T > >, fable::schema::Base< Path >, fable::schema::Base< Boolean >, fable::schema::Base< Optional< T, P > >, fable::schema::Base< FromJson< T > >, fable::schema::Base< Const< T, P > >, fable::schema::Base< Array< IncludeConf, IncludeSchema > >, fable::schema::Base< Number< T > >, fable::schema::Base< Enum< T > >, fable::schema::Base< FactoryPointerless< SimulatorConf > >, fable::schema::Base< Map< T, P > >, fable::schema::Base< Duration< T, Period > >, fable::schema::Base< FactoryPointerless< ComponentConf > >, fable::schema::Base< Ignore >, fable::schema::Base< Passthru< P > >, fable::schema::Base< Array< T, P > >, fable::schema::Base< Struct >, fable::schema::Box, fable::Schema, fable::schema::Variant, and fable::schema::CustomDeserializer.

Examples:
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.20.0/fable/include/fable/schema/interface.hpp.
Here is the caller graph for this function:

◆ description()

virtual const std::string& fable::schema::Interface::description ( ) const
pure virtual

◆ from_conf()

virtual void fable::schema::Interface::from_conf ( const Conf )
pure virtual

Apply the input JSON configuration.

This does not validate the input.

Implemented in cloe::VehicleSchema, fable::schema::Factory< T >, fable::schema::Factory< DistributionPtr >, fable::schema::Box, fable::schema::FactoryBase< T, CRTP >, fable::schema::FactoryBase< SimulatorConf, FactoryPointerless< SimulatorConf > >, fable::schema::FactoryBase< C, FactoryPointerless< C > >, fable::schema::FactoryBase< T, Factory< T > >, fable::schema::FactoryBase< T, FactoryPointerless< T > >, fable::schema::FactoryBase< ComponentConf, FactoryPointerless< ComponentConf > >, fable::schema::FactoryBase< DistributionPtr, Factory< DistributionPtr > >, fable::schema::FactoryBase< ControllerConf, FactoryPointerless< ControllerConf > >, fable::Schema, fable::schema::String, fable::schema::Struct, fable::schema::Path, fable::schema::Map< T, P >, fable::schema::Duration< T, Period >, fable::schema::Array< T, P >, fable::schema::Array< IncludeConf, IncludeSchema >, fable::schema::Variant, fable::schema::Optional< T, P >, fable::schema::Number< T >, fable::schema::FromConfable< T, >, fable::schema::Enum< T >, fable::schema::Passthru< P >, fable::schema::Const< T, P >, fable::schema::CustomDeserializer, fable::schema::FromJson< T >, fable::schema::Ignore, and fable::schema::Boolean.

Examples:
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.20.0/fable/include/fable/schema/interface.hpp.
Here is the caller graph for this function:

◆ is_required()

virtual bool fable::schema::Interface::is_required ( ) const
pure virtual

◆ is_valid()

virtual bool fable::schema::Interface::is_valid ( const Conf c) const
inlinevirtual

Return whether the input JSON is valid.

Examples:
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.20.0/fable/include/fable/schema/interface.hpp.
Here is the call graph for this function:

◆ is_variant()

virtual bool fable::schema::Interface::is_variant ( ) const
inlinevirtual

Return whether the accepted input type is a variant.

A variant type is one that is composed of other types, such as the special types: any-of, one-of, and all-of.

Reimplemented in fable::schema::Variant, and fable::schema::Optional< T, P >.

Examples:
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.20.0/fable/include/fable/schema/interface.hpp.
Here is the call graph for this function:

◆ json_schema()

virtual Json fable::schema::Interface::json_schema ( ) const
pure virtual

Return the JSON schema.

Example output:

{ "$schema": "http://json-schema.org/draft-07/schema#", "description": "stand-in no-operation simulator", "properties": { "vehicles": { "description": "list of vehicle names to make available", "items": { "type": "string" }, "type": "array" } }, "title": "nop", "additionalProperties": false, "type": "object" }

See the following links for the specification:

Implemented in cloe::VehicleSchema, fable::schema::Box, fable::Schema, fable::schema::String, fable::schema::FactoryBase< T, CRTP >, fable::schema::FactoryBase< SimulatorConf, FactoryPointerless< SimulatorConf > >, fable::schema::FactoryBase< C, FactoryPointerless< C > >, fable::schema::FactoryBase< T, Factory< T > >, fable::schema::FactoryBase< T, FactoryPointerless< T > >, fable::schema::FactoryBase< ComponentConf, FactoryPointerless< ComponentConf > >, fable::schema::FactoryBase< DistributionPtr, Factory< DistributionPtr > >, fable::schema::FactoryBase< ControllerConf, FactoryPointerless< ControllerConf > >, fable::schema::Struct, fable::schema::Path, fable::schema::Variant, fable::schema::Array< T, P >, fable::schema::Array< IncludeConf, IncludeSchema >, fable::schema::Map< T, P >, fable::schema::Duration< T, Period >, fable::schema::Number< T >, fable::schema::CustomDeserializer, fable::schema::FromConfable< T, >, fable::schema::Passthru< P >, fable::schema::Optional< T, P >, fable::schema::Enum< T >, fable::schema::Const< T, P >, fable::schema::FromJson< T >, fable::schema::Ignore, and fable::schema::Boolean.

Examples:
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.20.0/fable/include/fable/schema/interface.hpp.
Here is the caller graph for this function:

◆ reset_ptr()

virtual void fable::schema::Interface::reset_ptr ( )
pure virtual

Reset the internal pointer to nullptr, protecting against invalid access.

This should be used when a schema is used after the backing data has been deleted.

Implemented in cloe::VehicleSchema, fable::schema::Factory< T >, fable::schema::Factory< DistributionPtr >, fable::schema::Box, fable::schema::FactoryBase< T, CRTP >, fable::schema::FactoryBase< SimulatorConf, FactoryPointerless< SimulatorConf > >, fable::schema::FactoryBase< C, FactoryPointerless< C > >, fable::schema::FactoryBase< T, Factory< T > >, fable::schema::FactoryBase< T, FactoryPointerless< T > >, fable::schema::FactoryBase< ComponentConf, FactoryPointerless< ComponentConf > >, fable::schema::FactoryBase< DistributionPtr, Factory< DistributionPtr > >, fable::schema::FactoryBase< ControllerConf, FactoryPointerless< ControllerConf > >, fable::Schema, fable::schema::String, fable::schema::Struct, fable::schema::Path, fable::schema::Map< T, P >, fable::schema::Array< T, P >, fable::schema::Array< IncludeConf, IncludeSchema >, fable::schema::Duration< T, Period >, fable::schema::Variant, fable::schema::Optional< T, P >, fable::schema::FromConfable< T, >, fable::schema::Enum< T >, fable::schema::Number< T >, fable::schema::Passthru< P >, fable::schema::Const< T, P >, fable::schema::CustomDeserializer, fable::schema::FromJson< T >, fable::schema::Ignore, and fable::schema::Boolean.

Examples:
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.20.0/fable/include/fable/schema/interface.hpp.
Here is the caller graph for this function:

◆ set_description()

virtual void fable::schema::Interface::set_description ( const std::string &  s)
pure virtual

◆ to_json() [1/2]

virtual Json fable::schema::Interface::to_json ( ) const
inlinevirtual

Return the current value of the destination.

Warning: This is NOT an efficient operation, but it can be useful for cases where speed is not important.

Examples:
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.20.0/fable/include/fable/schema/interface.hpp, and /home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.20.0/fable/include/fable/schema/struct.hpp.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_json() [2/2]

◆ type()

virtual JsonType fable::schema::Interface::type ( ) const
pure virtual

Return the JSON type.

If this is a variant type of differing types, then null should be returned. Otherwise, the type remains unique and can be returned. A type that is null is almost always a variant type of some sort, if even only an optional type.

Implemented in fable::schema::Base< CRTP >, fable::schema::Base< FactoryPointerless< ControllerConf > >, fable::schema::Base< Factory< T > >, fable::schema::Base< FactoryPointerless< C > >, fable::schema::Base< FromConfable< T > >, fable::schema::Base< Factory< DistributionPtr > >, fable::schema::Base< String >, fable::schema::Base< VehicleSchema >, fable::schema::Base< FactoryPointerless< T > >, fable::schema::Base< Path >, fable::schema::Base< Boolean >, fable::schema::Base< Optional< T, P > >, fable::schema::Base< FromJson< T > >, fable::schema::Base< Const< T, P > >, fable::schema::Base< Array< IncludeConf, IncludeSchema > >, fable::schema::Base< Number< T > >, fable::schema::Base< Enum< T > >, fable::schema::Base< FactoryPointerless< SimulatorConf > >, fable::schema::Base< Map< T, P > >, fable::schema::Base< Duration< T, Period > >, fable::schema::Base< FactoryPointerless< ComponentConf > >, fable::schema::Base< Ignore >, fable::schema::Base< Passthru< P > >, fable::schema::Base< Array< T, P > >, fable::schema::Base< Struct >, fable::schema::Box, fable::Schema, fable::schema::Variant, and fable::schema::CustomDeserializer.

Examples:
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.20.0/fable/include/fable/schema/interface.hpp.
Here is the caller graph for this function:

◆ type_string()

virtual std::string fable::schema::Interface::type_string ( ) const
pure virtual

Return the type as a string.

The format of the string is:

"[array of] TYPE"

where TYPE is one of: null, object, boolean, float, integer, unsigned, string, and unknown.

Example output:

"object"
"array of boolean"
"array of object"

Implemented in fable::schema::Base< CRTP >, fable::schema::Base< FactoryPointerless< ControllerConf > >, fable::schema::Base< Factory< T > >, fable::schema::Base< FactoryPointerless< C > >, fable::schema::Base< FromConfable< T > >, fable::schema::Base< Factory< DistributionPtr > >, fable::schema::Base< String >, fable::schema::Base< VehicleSchema >, fable::schema::Base< FactoryPointerless< T > >, fable::schema::Base< Path >, fable::schema::Base< Boolean >, fable::schema::Base< Optional< T, P > >, fable::schema::Base< FromJson< T > >, fable::schema::Base< Const< T, P > >, fable::schema::Base< Array< IncludeConf, IncludeSchema > >, fable::schema::Base< Number< T > >, fable::schema::Base< Enum< T > >, fable::schema::Base< FactoryPointerless< SimulatorConf > >, fable::schema::Base< Map< T, P > >, fable::schema::Base< Duration< T, Period > >, fable::schema::Base< FactoryPointerless< ComponentConf > >, fable::schema::Base< Ignore >, fable::schema::Base< Passthru< P > >, fable::schema::Base< Array< T, P > >, fable::schema::Base< Struct >, fable::schema::Box, fable::Schema, fable::schema::Array< T, P >, fable::schema::Array< IncludeConf, IncludeSchema >, fable::schema::Variant, fable::schema::CustomDeserializer, fable::schema::Passthru< P >, and fable::schema::Optional< T, P >.

Examples:
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.20.0/fable/include/fable/schema/interface.hpp.
Here is the caller graph for this function:

◆ usage()

virtual Json fable::schema::Interface::usage ( ) const
pure virtual

Return a compact JSON description of the schema. This is useful for human-readable error output.

Example output:

{ "field1": "boolean! :: lorem ipsum dolor sit amet", "field2": { "field2.1": "integer :: lorem ipsum dolor sit amet" "field2.2": "boolean :: lorem ipsum dolor sit amet" }, "field3": "array of integer :: lorem ipsum dolor sit amet", "field4": [{ "field4.1": "string :: lorem ipsum dolor sit amet" "field4.2": "boolean :: lorem ipsum dolor sit amet" }] }

When describing the schema of a primitive array, we can represent that as a single string. But when the array contains an object, we wrap a single object in an array. This isn't awfully consistent, but it's the best we can do.

Implemented in fable::schema::Base< CRTP >, fable::schema::Base< FactoryPointerless< ControllerConf > >, fable::schema::Base< Factory< T > >, fable::schema::Base< FactoryPointerless< C > >, fable::schema::Base< FromConfable< T > >, fable::schema::Base< Factory< DistributionPtr > >, fable::schema::Base< String >, fable::schema::Base< VehicleSchema >, fable::schema::Base< FactoryPointerless< T > >, fable::schema::Base< Path >, fable::schema::Base< Boolean >, fable::schema::Base< Optional< T, P > >, fable::schema::Base< FromJson< T > >, fable::schema::Base< Const< T, P > >, fable::schema::Base< Array< IncludeConf, IncludeSchema > >, fable::schema::Base< Number< T > >, fable::schema::Base< Enum< T > >, fable::schema::Base< FactoryPointerless< SimulatorConf > >, fable::schema::Base< Map< T, P > >, fable::schema::Base< Duration< T, Period > >, fable::schema::Base< FactoryPointerless< ComponentConf > >, fable::schema::Base< Ignore >, fable::schema::Base< Passthru< P > >, fable::schema::Base< Array< T, P > >, fable::schema::Base< Struct >, fable::schema::Box, fable::Schema, fable::schema::Struct, fable::schema::Variant, and fable::schema::CustomDeserializer.

Examples:
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.20.0/fable/include/fable/schema/interface.hpp.
Here is the caller graph for this function:

◆ validate()

virtual void fable::schema::Interface::validate ( const Conf c) const
pure virtual

Validate the input JSON configuration.

If you don't have a Conf but would like to validate a Json type, then construct a Conf on the fly:

s.validate(Conf{j});

This function is not provided inline to prevent incorrect use.

Implemented in cloe::VehicleSchema, fable::schema::Box, fable::Schema, fable::schema::FactoryBase< T, CRTP >, fable::schema::FactoryBase< SimulatorConf, FactoryPointerless< SimulatorConf > >, fable::schema::FactoryBase< C, FactoryPointerless< C > >, fable::schema::FactoryBase< T, Factory< T > >, fable::schema::FactoryBase< T, FactoryPointerless< T > >, fable::schema::FactoryBase< ComponentConf, FactoryPointerless< ComponentConf > >, fable::schema::FactoryBase< DistributionPtr, Factory< DistributionPtr > >, fable::schema::FactoryBase< ControllerConf, FactoryPointerless< ControllerConf > >, fable::schema::String, fable::schema::Struct, fable::schema::Path, fable::schema::Map< T, P >, fable::schema::Array< T, P >, fable::schema::Array< IncludeConf, IncludeSchema >, fable::schema::Variant, fable::schema::Duration< T, Period >, fable::schema::Number< T >, fable::schema::Optional< T, P >, fable::schema::FromConfable< T, >, fable::schema::CustomDeserializer, fable::schema::Enum< T >, fable::schema::Passthru< P >, fable::schema::Const< T, P >, fable::schema::FromJson< T >, fable::schema::Ignore, and fable::schema::Boolean.

Examples:
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.20.0/fable/include/fable/schema/interface.hpp.
Here is the caller graph for this function:

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