Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Stroika::Foundation::Common::ReadOnlyProperty< T > Class Template Reference

#include <Property.h>

Inheritance diagram for Stroika::Foundation::Common::ReadOnlyProperty< T >:
Stroika::Foundation::Common::Property< forward_list< PropertyReadEventHandler > & > Stroika::Foundation::Common::Property< forward_list< PropertyChangedEventHandler > & > Stroika::Foundation::Common::Property< Stroika::Foundation::Containers::Mapping< Stroika::Foundation::Characters::String, Stroika::Foundation::Characters::String > > Stroika::Foundation::Common::Property< Stroika::Foundation::Containers::Collection< Stroika::Foundation::IO::Network::HTTP::Cookie > > Stroika::Foundation::Common::Property< optional< ContentEncodings > > Stroika::Foundation::Common::Property< optional< Stroika::Foundation::Characters::String > > Stroika::Foundation::Common::Property< optional< Stroika::Foundation::Containers::Set< Stroika::Foundation::Characters::String > > > Stroika::Foundation::Common::Property< optional< Stroika::Foundation::IO::Network::HTTP::CacheControl > > Stroika::Foundation::Common::Property< optional< ConnectionValue > > Stroika::Foundation::Common::Property< optional< uint64_t > > Stroika::Foundation::Common::Property< optional< Stroika::Foundation::DataExchange::InternetMediaType > > Stroika::Foundation::Common::Property< optional< Time::DateTime > > Stroika::Foundation::Common::Property< Stroika::Foundation::IO::Network::HTTP::CookieList > Stroika::Foundation::Common::Property< optional< Stroika::Foundation::IO::Network::HTTP::ETag > > Stroika::Foundation::Common::Property< optional< Stroika::Foundation::IO::Network::HTTP::IfNoneMatch > > Stroika::Foundation::Common::Property< optional< Stroika::Foundation::IO::Network::HTTP::KeepAlive > > Stroika::Foundation::Common::Property< optional< Stroika::Foundation::IO::Network::URI > > Stroika::Foundation::Common::Property< optional< TransferEncodings > > Stroika::Foundation::Common::Property< Stroika::Foundation::Characters::String > Stroika::Foundation::Common::Property< Stroika::Foundation::IO::Network::URI > Stroika::Foundation::Common::Property< Stroika::Foundation::IO::Network::HTTP::Headers & > Stroika::Foundation::Common::Property< Status > Stroika::Foundation::Common::Property< tuple< Status, optional< Stroika::Foundation::Characters::String > > > Stroika::Foundation::Common::Property< Stroika::Foundation::Time::Duration > Stroika::Foundation::Common::Property< Stroika::Foundation::Containers::Set< Stroika::Frameworks::SystemPerformance::Instrument > > Stroika::Foundation::Common::Property< Stroika::Foundation::Containers::Collection< Stroika::Foundation::Execution::Function > > Stroika::Foundation::Common::Property< Stroika::Foundation::Containers::Collection< Stroika::Frameworks::SystemPerformance::CaptureSet > > Stroika::Foundation::Common::Property< shared_ptr< Stroika::Frameworks::SystemPerformance::Instrument::ICaptureContext > > Stroika::Foundation::Common::Property< Stroika::Foundation::Containers::Sequence< Stroika::Frameworks::WebServer::Interceptor > > Stroika::Foundation::Common::Property< optional< Stroika::Frameworks::WebServer::Interceptor > > Stroika::Foundation::Common::Property< bool > Stroika::Foundation::Common::Property< optional< size_t > > Stroika::Foundation::Common::Property< optional< HTTP::ContentEncodings > > Stroika::Foundation::Common::Property< Characters::CodePage > Stroika::Foundation::Common::Property< T >

Public Member Functions

 ReadOnlyProperty ()=delete
 
nonvirtual T Get () const
 
nonvirtual operator const T () const
 
nonvirtual const T operator() () const
 

Detailed Description

template<typename T>
class Stroika::Foundation::Common::ReadOnlyProperty< T >

Implement C#-like syntax for read-only properties (syntactically like data members but backed by a getter function)

Note
Typically not used - use Property
ANYHOW - see @Property for design overview
We allow T to be of REFERENCE type for ReadOnlyProperties. Not sure its a good idea to be returning a const T& from a property, but it works/is allowed (for now).

Note - unlike with functions - you cannot overload properties, making one return const T& and one return T&

Note
Thread-Safety SAME AS T/GETTER - all methods have exactly the thread safety of the underlying GETTER

Definition at line 128 of file Property.h.

Constructor & Destructor Documentation

◆ ReadOnlyProperty()

template<typename T >
Stroika::Foundation::Common::ReadOnlyProperty< T >::ReadOnlyProperty ( )
delete

ReadOnlyProperty are NOT movable, nor copy constructible: the data doesn't logically exist in the property itself, but in its relationship to some parent object; if it were copied, it might be copied TO some place that didn't have an appropriate enclosing object.

Member Function Documentation

◆ Get()

template<typename T >
requires (not IPropertyMutatable<T>)
T Stroika::Foundation::Common::ReadOnlyProperty< T >::Get ( ) const

Returns the value of the given property T (by calling the underlying 'getter' for the property. This is a non-const method if PropertyCommon::kIsMutableType<T>, and otherwise a const method.

Definition at line 24 of file Property.inl.

◆ operator const T()

template<typename T >
requires (not IPropertyMutatable<T>)
Stroika::Foundation::Common::ReadOnlyProperty< T >::operator const T ( ) const

A ReadOnlyProperty can be automatically converted to its underlying base type. Due to how conversion operators work, this won't always be helpful (like with overloading or multiple levels of conversions, for example with optional<int> compare with int property). But when it works (80% of the time) - its helpful.

When it doesn't work, simply throw in '()' - to use the 'operator()' call, or call Get() if you prefer that syntax.

This is a non-const method if PropertyCommon::kIsMutableType<T>, and otherwise a const method.

Definition at line 36 of file Property.inl.

◆ operator()()

template<typename T >
requires (not IPropertyMutatable<T>)
const T Stroika::Foundation::Common::ReadOnlyProperty< T >::operator() ( ) const

This works 100% of the time. Just use the function syntax, and you get back a copy of the desired underlying type.

Example Usage
namespace PredefinedInternetMediaType { const inline Common::VirtualConstant<InternetMediaType> kPNG...
bool checkIsImage1 = PredefinedInternetMediaType::kPNG().IsA (InternetMediaTypes::Wildcards::kImage);

This is a non-const method if PropertyCommon::kIsMutableType<T>, and otherwise a const method.

Definition at line 48 of file Property.inl.


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