Environment.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/core/base/Environment.hpp"

Logger

Interface for system-wide Logger.
All calls to OATPP_DISABLE_LOGV, OATPP_DISABLE_LOGE, OATPP_DISABLE_LOGD should come here.

namespace oatpp { namespace base { 
  class Logger {}
}}

Methods

Return Type Name Summary
[none] ~Logger Virtual Destructor.
void log Log message with priority, tag, message.

Logger::~Logger

Virtual Destructor.

virtual ~Logger() = default

Logger::log

Log message with priority, tag, message.

  • @param priority - priority channel of the message.
  • @param tag - tag of the log message.
  • @param message - message.

virtual void log(v_int32 priority, const std::string& tag, const std::string& message) = 0

Environment

Class to manage application environment.
Manage object counters, manage components, and do system health-checks.

namespace oatpp { namespace base { 
  class Environment {}
}}

Methods

Return Type Name Summary
void init Initialize environment and do basic health-checks.
void destroy De-initialize environment and do basic health-checks.
void incObjects increment counter of objects.
void decObjects decrement counter of objects.
v_counter getObjectsCount Get count of objects currently allocated and stored in the memory.
v_counter getObjectsCreated Get count of objects created for a whole system lifetime.
v_counter getThreadLocalObjectsCount Same as getObjectsCount() but thread_local
v_counter getThreadLocalObjectsCreated Same as getObjectsCreated() but thread_local
void setLogger Set environment logger.
void printCompilationConfig Print debug information of compilation config.
void log Call Logger::log()
void logFormatted Format message and call Logger::log()
void* getComponent Multiple implementations:
  1. Get component object by typeName.
  2. Get component object by typeName and componentName.
v_int64 getMicroTickCount Get ticks count in microseconds.

Environment::init

Initialize environment and do basic health-checks.

static void init()

Environment::destroy

De-initialize environment and do basic health-checks. Check for memory leaks.

static void destroy()

Environment::incObjects

increment counter of objects.

static void incObjects()

Environment::decObjects

decrement counter of objects.

static void decObjects()

Environment::getObjectsCount

Get count of objects currently allocated and stored in the memory.

  • @return

static v_counter getObjectsCount()

Environment::getObjectsCreated

Get count of objects created for a whole system lifetime.

  • @return - count of objects.

static v_counter getObjectsCreated()

Environment::getThreadLocalObjectsCount

Same as getObjectsCount() but thread_local

  • @return - count of objects.

static v_counter getThreadLocalObjectsCount()

Environment::getThreadLocalObjectsCreated

Same as getObjectsCreated() but thread_local

  • @return - count of objects.

static v_counter getThreadLocalObjectsCreated()

Environment::setLogger

Set environment logger.

  • @param logger - pointer to logger.

static void setLogger(Logger* logger)

Environment::printCompilationConfig

Print debug information of compilation config.
Print values for:
- OATPP_DISABLE_ENV_OBJECT_COUNTERS
- OATPP_DISABLE_POOL_ALLOCATIONS
- OATPP_THREAD_HARDWARE_CONCURRENCY
- OATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT
- OATPP_ASYNC_EXECUTOR_THREAD_NUM_DEFAULT

static void printCompilationConfig()

Environment::log

Call Logger::log()

  • @param priority - priority channel of the message.
  • @param tag - tag of the log message.
  • @param message - message.

static void log(v_int32 priority, const std::string& tag, const std::string& message)

Environment::logFormatted

Format message and call Logger::log()
Message is formatted using vsnprintf method.

  • @param priority - priority channel of the message.
  • @param tag - tag of the log message.
  • @param message - message.
  • @param ... - format arguments.

static void logFormatted(v_int32 priority, const std::string& tag, const char* message, ...)

Environment::getComponent

  1. Get component object by typeName.
    • @param typeName - type name of the component.
    • @return - pointer to a component object.
    static void* getComponent(const std::string& typeName)
    
  2. Get component object by typeName and componentName.
    • @param typeName - type name of the component.
    • @param componentName - component qualifier name.
    • @return - pointer to a component object.
    static void* getComponent(const std::string& typeName, const std::string& componentName)
    

Environment::getMicroTickCount

Get ticks count in microseconds.

  • @return - ticks count in microseconds.

static v_int64 getMicroTickCount()

Environment::Component

Class representing system component.

  • @tparam T - component type.

namespace oatpp { namespace base { 
  class Environment {
    template <typename T>
    class Component {}
  };
}}

Methods

Return Type Name Summary
[none] Component Multiple implementations:
  1. Constructor.
  2. Constructor.
[none] ~Component Non-virtual Destructor.
T getObject Get object stored in the component.

Environment::Component::Component

  1. Constructor.
    • @param name - component name.
    • @param object - component object.
    Component(const std::string& name, const T& object)
      : m_type(typeid(T).name())
      , m_name(name)
      , m_object(object)
    
  2. Constructor.
    • @param object - component object.
    Component(const T& object)
      : Component("NoName", object)
    

Environment::Component::~Component

Non-virtual Destructor.

~Component()

Environment::Component::getObject

Get object stored in the component.

  • @return - object.

T getObject()