LCOV - code coverage report
Current view: top level - data-access - idataaccess.h (source / functions) Hit Total Coverage
Test: Code coverage report for DAQs. Lines: 2 2 100.0 %
Date: 2021-05-07 16:58:01 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /*! @brief This file have the interface for IDataAccess class.
       2             :     @file idataaccess.h
       3             :     @author Alvaro Denis <denisacostaq@gmail.com>
       4             :     @date 6/23/2019
       5             : 
       6             :     @copyright
       7             :     @attention <h1><center><strong>COPYRIGHT &copy; 2019 </strong>
       8             :     [<strong>denisacostaq</strong>][denisacostaq-URL].
       9             :     All rights reserved.</center></h1>
      10             :     @attention This file is part of [<strong>DAQs</strong>][DAQs-URL].
      11             : 
      12             :     Redistribution and use in source and binary forms, with or without
      13             :     modification, are permitted provided that the following conditions
      14             :     are met:
      15             :     - 1. Redistributions of source code must retain the above copyright
      16             :       notice, this list of conditions and the following disclaimer.
      17             :     - 2. Redistributions in binary form must reproduce the above copyright
      18             :       notice, this list of conditions and the following disclaimer in the
      19             :       documentation and/or other materials provided with the distribution.
      20             :     - 3. Neither the name of the University nor the names of its contributors
      21             :       may be used to endorse or promote products derived from this software
      22             :       without specific prior written permission.
      23             : 
      24             :     THIS PRODUCT IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
      25             :     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      26             :     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      27             :     ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
      28             :     DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
      29             :     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
      30             :     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
      31             :     ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      32             :     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
      33             :     THIS PRODUCT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      34             : 
      35             :     [denisacostaq-URL]: https://about.me/denisacostaq "Alvaro Denis Acosta"
      36             :     [DAQs-URL]: https://github.com/denisacostaq/DAQs "DAQs"
      37             :  */
      38             : #ifndef DATABASESERVER_IDATAACCESS_H
      39             : #define DATABASESERVER_IDATAACCESS_H
      40             : 
      41             : #include <chrono>
      42             : #include <functional>
      43             : #include <string>
      44             : #include <tuple>
      45             : #include <vector>
      46             : 
      47             : #include "src/database-server/data-model/variable.h"
      48             : #include "src/database-server/data-model/varvalue.h"
      49             : 
      50             : /**
      51             :  * @brief The IDataAccess interface is like a proxy for the data layer
      52             :  * @details This class can filter request or data, for example check for
      53             :  * authorization or data compression.
      54             :  */
      55             : class IDataAccess {
      56             :  public:
      57             :   enum class Err { Ok, Failed, InvalidArgument };
      58             : 
      59          28 :   IDataAccess() noexcept = default;
      60          28 :   virtual ~IDataAccess() = default;
      61             :   IDataAccess(const IDataAccess&) = delete;
      62             :   IDataAccess& operator=(const IDataAccess&) = delete;
      63             :   IDataAccess(IDataAccess&&) = default;
      64             :   IDataAccess& operator=(IDataAccess&&) = default;
      65             : 
      66             :   /**
      67             :    * @brief add_variable add a new variable.
      68             :    * @param var variable info.
      69             :    * @return Ok on success.
      70             :    * @sa IDataSource::add_variable
      71             :    */
      72             :   virtual Err add_variable(const Variable& var) noexcept = 0;
      73             : 
      74             :   /**
      75             :    * @brief add_variable_value add a new variable value related to a variable.
      76             :    * @param var add a variable value.
      77             :    * @return Ok on success.
      78             :    * @sa IDataSource::add_variable_value
      79             :    */
      80             :   virtual Err add_variable_value(const VarValue& var) noexcept = 0;
      81             : 
      82             :   /**
      83             :    * @brief fetch_variables get all variables.
      84             :    * @return a vector with the variables.
      85             :    * @sa IDataSource::add_variable
      86             :    */
      87             :   virtual std::tuple<std::vector<Variable>, Err> fetch_variables() noexcept = 0;
      88             : 
      89             :   /**
      90             :    * @brief fetch_variable_values get values for a variable.
      91             :    * @param var_name variable name.
      92             :    * @param max_len max result len (for data compression for example).
      93             :    * @return a vector with the variable values.
      94             :    * @sa IDataSource::fetch_variable_values
      95             :    */
      96             :   virtual std::tuple<std::vector<VarValue>, Err> fetch_variable_values(
      97             :       const std::string& var_name,
      98             :       size_t max_len = std::numeric_limits<size_t>::infinity()) noexcept = 0;
      99             : 
     100             :   /**
     101             :    * @brief fetch_variable_values get values for a variable in a date range.
     102             :    * @param var_name variable name.
     103             :    * @param start_date start date of the period.
     104             :    * @param end_date end date of the period.
     105             :    * @param max_len max result len (for data compression for example).
     106             :    * @return a vector with the variable values.
     107             :    * @sa IDataSource::fetch_variable_values
     108             :    */
     109             :   virtual std::tuple<std::vector<VarValue>, Err> fetch_variable_values(
     110             :       const std::string& var_name,
     111             :       const std::chrono::system_clock::time_point& start_date,
     112             :       const std::chrono::system_clock::time_point& end_date,
     113             :       size_t max_len = std::numeric_limits<size_t>::infinity()) noexcept = 0;
     114             : };
     115             : 
     116             : #endif  // DATABASESERVER_IDATAACCESS_H

Generated by: LCOV version 1.12