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

          Line data    Source code
       1             : /*! @brief This file have the interface for VarValue class.
       2             :     @file varvalue.h
       3             :     @author Alvaro Denis <denisacostaq@gmail.com>
       4             :     @date 7/13/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 DATAMODEL_VARVALUE_H
      39             : #define DATAMODEL_VARVALUE_H
      40             : 
      41             : #include "src/database-server/data-model/variable.h"
      42             : 
      43             : /**
      44             :  * @brief The VarValue class define a readed value.
      45             :  * @details A read value is always related to a variable, for a better
      46             :  * understanding check out the following MER diagram.
      47             :  * \dot
      48             :     digraph {
      49             :         graph [layout = dot, rankdir = LR]
      50             : 
      51             :         // Box for entities
      52             :         node [shape=none, margin=0]
      53             : 
      54             :         // One-to-many relation (from one, to many)
      55             :         edge [arrowhead=crow, arrowtail=dot, dir=both]
      56             : 
      57             :         label = "MER variable"
      58             : 
      59             :         // Entities
      60             :         Variable [label=<
      61             :             <table border="0" cellborder="1" cellspacing="0" cellpadding="4">
      62             :                 <tr><td bgcolor="darkseagreen">Variable</td></tr>
      63             :                 <tr><td port="id" align="left">id: integer</td></tr>
      64             :                 <tr><td align="left">name: char(50)</td></tr>
      65             :                 <tr><td align="left">color: char(50)</td></tr>
      66             :             </table>
      67             :         >]
      68             : 
      69             :         VariableValue [label=<
      70             :             <table border="0" cellborder="1" cellspacing="0" cellpadding="4">
      71             :                 <tr><td bgcolor="darkseagreen">VariableValue</td></tr>
      72             :                 <tr><td align="left">id: integer</td></tr>
      73             :                 <tr><td align="left">value: double</td></tr>
      74             :                 <tr><td align="left">timestamp: integer</td></tr>
      75             :                 <tr><td port="fk" align="left">variable_id: integer</td></tr>
      76             :             </table>
      77             :         >]
      78             : 
      79             :         // Relationships
      80             :         Variable:id->VariableValue:fk [label="1:*",len=1.00];
      81             :     }
      82             :  * \enddot
      83             :  */
      84        2164 : class VarValue {
      85             :  public:
      86         358 :   VarValue() = default;
      87             :   VarValue(const Variable &variable, double val, std::uint64_t ts);
      88             :   VarValue(Variable &&variable, double &&val, std::uint64_t &&ts);
      89             :   VarValue(VarValue &&var) noexcept;
      90          30 :   VarValue(const VarValue &var) = default;
      91             : 
      92             :   const Variable &variable() const noexcept;
      93             :   void set_vaiable(const Variable &var) noexcept;
      94             :   double val() const noexcept;
      95             :   void set_val(double val) noexcept;
      96             :   std::uint64_t timestamp() const noexcept;
      97             :   void set_timestamp(std::uint64_t ts) noexcept;
      98             :   const std::string &name() const noexcept;
      99             : 
     100          34 :   VarValue DeepCopy() {
     101          34 :     VarValue v{};
     102          34 :     v.val_ = this->val_;
     103          34 :     v.variable_ = this->variable_;
     104          34 :     v.timestamp_ = this->timestamp_;
     105          34 :     return v;
     106             :   }
     107             : 
     108             :  private:
     109             :   Variable variable_;
     110             :   double val_;
     111             :   std::uint64_t timestamp_;
     112             : };
     113             : 
     114             : #endif  // DATAMODEL_VARVALUE_H

Generated by: LCOV version 1.12