# Provider.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/core/provider/Provider.hpp"

# Provider

Abstract resource provider.

  • @tparam T - resource class.

namespace oatpp { namespace provider { 
  template <class T>
  class Provider {}
}}

# Methods

Return Type Name Summary
[none] Provider Multiple implementations:
  1. Default constructor.
  2. Constructor.
[none] ~Provider Virtual destructor.
const std::unordered_map<oatpp::data::share::StringKeyLabelCI, oatpp::data::share::StringKeyLabel>& getProperties Some optional properties that user might want to know.
data::share::StringKeyLabel getProperty Get optional property
std::shared_ptr<T> get Get resource.
async::CoroutineStarterForResult<const std::shared_ptr<T>&> getAsync Get resource in Async manner.
void invalidate Invalidate resource that was previously created by this provider.
void stop Stop provider and free associated resources.

# Provider::Provider

  1. Default constructor.
    Provider() = default
    
  2. Constructor.
    • @param properties
    Provider(const std::unordered_map<data::share::StringKeyLabelCI, data::share::StringKeyLabel>& properties)
      : m_properties(properties)
    

# Provider::~Provider

Virtual destructor.

virtual ~Provider() = default

# Provider::getProperties

Some optional properties that user might want to know.
Note: All properties are optional and user should not rely on this.

const std::unordered_map<oatpp::data::share::StringKeyLabelCI, oatpp::data::share::StringKeyLabel>& getProperties() const

# Provider::getProperty

Get optional property

data::share::StringKeyLabel getProperty(const oatpp::String& key) const

# Provider::get

Get resource.

  • @return - resource.

virtual std::shared_ptr<T> get() = 0

# Provider::getAsync

Get resource in Async manner.

  • @return - oatpp::async::CoroutineStarterForResult of T.

virtual async::CoroutineStarterForResult<const std::shared_ptr<T>&> getAsync() = 0

# Provider::invalidate

Invalidate resource that was previously created by this provider.
Use-case: if provider is pool based - you can signal that this resource should not be reused anymore.

  • @param resource

virtual void invalidate(const std::shared_ptr<T>& resource) = 0

# Provider::stop

Stop provider and free associated resources.

virtual void stop() = 0