Leosac  0.8.0
Open Source Access Control
Leosac::ConfigChecker Class Reference

This class is here to help check the validity of the configuration. More...

#include <ConfigChecker.hpp>

+ Collaboration diagram for Leosac::ConfigChecker:

Public Member Functions

void register_object (const std::string &name, const Leosac::Hardware::DeviceClass &type)
 Declare an object on the registry. More...
 
bool has_object (const std::string &name) const
 Check whether or not an object with name name is declared in the registry, no matter its type. More...
 
bool has_object (const std::string &name, const Leosac::Hardware::DeviceClass &type) const
 Check whether or not an object with name name is declared in the registry and if check that its type is type. More...
 
void clear ()
 Clear all informations. More...
 

Private Attributes

std::map< std::string, Leosac::Hardware::DeviceClassobjects_
 
std::mutex mutex_
 

Detailed Description

This class is here to help check the validity of the configuration.

Leosac configuration being text-based, various object (LED, Reader, GPIO) are referenced by name. This is practical because it gives the configuration maintainer some flexibility (especially regarding the Doorman module). However, it is also difficult to detect misconfiguration before running into trouble at runtime.

How does this class help?

The idea is for module declaring object to register them with this class, and for module using (aka talking-to) objects, to check here first.

As a result, this class shall be fully thread safe.

Note
The current behavior is to assert when registering an object twice.

Definition at line 46 of file ConfigChecker.hpp.

Member Function Documentation

◆ clear()

void ConfigChecker::clear ( )

Clear all informations.

This is useful when synchronizing with remote.

Definition at line 48 of file ConfigChecker.cpp.

◆ has_object() [1/2]

bool ConfigChecker::has_object ( const std::string &  name) const

Check whether or not an object with name name is declared in the registry, no matter its type.

Definition at line 34 of file ConfigChecker.cpp.

◆ has_object() [2/2]

bool ConfigChecker::has_object ( const std::string &  name,
const Leosac::Hardware::DeviceClass type 
) const

Check whether or not an object with name name is declared in the registry and if check that its type is type.

Definition at line 40 of file ConfigChecker.cpp.

◆ register_object()

void ConfigChecker::register_object ( const std::string &  name,
const Leosac::Hardware::DeviceClass type 
)

Declare an object on the registry.

Definition at line 25 of file ConfigChecker.cpp.

Member Data Documentation

◆ mutex_

std::mutex Leosac::ConfigChecker::mutex_
mutableprivate

Definition at line 74 of file ConfigChecker.hpp.

◆ objects_

std::map<std::string, Leosac::Hardware::DeviceClass> Leosac::ConfigChecker::objects_
private

Definition at line 73 of file ConfigChecker.hpp.


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