<commit_before>/** @file Value.h 
  *  Copyright (c) 2016 Ozbotics 
  *  Distributed under the MIT license (see LICENSE)
  */ 
#ifndef _VALUE_H
  #define _VALUE_H

#include <Arduino.h>

 /**
  *  ValueBase class. 
  *  The Base of all Value<T> classes
  */
class ValueBase {
  public:
   /**
    * render the value as a character string
    * @param buf the char buffer
    * @return nothing
    */  
    virtual void getValueString(char * buf)=0;
};


 /**
  *  Value<T> class template. 
 */
template <class T>
class Value : public ValueBase {
  protected:
    T _value;                 /**< protected variable _value. The current value. */ 
    T _oldValue;              /**< protected variable _value. The previous value. */ 
    byte _displayLength;      /**< protected variable _displayLength. The total width of the output string. */ 
    byte _displayDecimals;    /**< protected variable _displayDecimals. The number of decimal places. */ 
    unsigned int _divideBy;   /**< protected variable _divideBy. Divide the value by this amount, eg; 60000 to convert milliseconds to minutes. */ 

  public:
  /**
    * constructor
    * @param displayLength The total width of the output string.
    * @param displayDecimals The number of decimal places.
    * @param divideBy Divide the value by this amount, eg; 60000 to convert milliseconds to minutes.
    */  
    Value<T>(byte displayLength=0, byte displayDecimals=0, unsigned int divideBy=1) :  _displayLength(displayLength), _displayDecimals(displayDecimals), _divideBy(divideBy), _value( T() ), _oldValue( T() ), ValueBase() { }

   /**
    * render the value as a character string
    * @param buf the char buffer
    * @return nothing
    */  
    virtual void getValueString(char * buf);
    
   /**
    * return the value in its native type
    * @return the current value
    */  
    virtual T getValue();
    
   /**
    * set the value
    * @param value the new value
    * @return nothing
    */  
    virtual void setValue(T value) { 
      _value = value; 
    }

   /**
    * set the displayLength
    * @param displayLength the new displayLength
    * @return nothing
    */  
    void setDisplayLength(byte displayLength) {
      _displayLength = displayLength;
    }
    
   /**
    * set the displayDecimals
    * @param displayDecimals the new displayDecimals
    * @return nothing
    */  
    void setDisplayDecimals(byte displayDecimals) {
      _displayDecimals = displayDecimals;
      }

   /**
    * set the divideBy
    * @param divideBy the new divideBy
    * @return nothing
    */  
    void setDivideBy(byte divideBy) {
      _divideBy = divideBy;
    }

   /**
    * equals operator
    * @param other the other Value object to be compared
    * @return true if this and other Value are equal
    */  
    bool operator==(Value<T>& other) {
      return (this->getValue() == other.getValue());
    }
    

   /**
    * not-equal operator
    * @param other the other Value object to be compared
    * @return true if this and other Value are not equal
    */  
    bool operator!=(Value<T>& other) {
      return (this->getValue() != other.getValue());
    }

   /**<commit_msg>Fixed bug in Value::setDivideBy(), type had not been upgraded to unsigned int<commit_after>/** @file Value.h 
  *  Copyright (c) 2016 Ozbotics 
  *  Distributed under the MIT license (see LICENSE)
  */ 
#ifndef _VALUE_H
  #define _VALUE_H

#include <Arduino.h>

 /**
  *  ValueBase class. 
  *  The Base of all Value<T> classes
  */
class ValueBase {
  public:
   /**
    * render the value as a character string
    * @param buf the char buffer
    * @return nothing
    */  
    virtual void getValueString(char * buf)=0;
};


 /**
  *  Value<T> class template. 
 */
template <class T>
class Value : public ValueBase {
  protected:
    T _value;                 /**< protected variable _value. The current value. */ 
    T _oldValue;              /**< protected variable _value. The previous value. */ 
    byte _displayLength;      /**< protected variable _displayLength. The total width of the output string. */ 
    byte _displayDecimals;    /**< protected variable _displayDecimals. The number of decimal places. */ 
    unsigned int _divideBy;   /**< protected variable _divideBy. Divide the value by this amount, eg; 60000 to convert milliseconds to minutes. */ 

  public:
  /**
    * constructor
    * @param displayLength The total width of the output string.
    * @param displayDecimals The number of decimal places.
    * @param divideBy Divide the value by this amount, eg; 60000 to convert milliseconds to minutes.
    */  
    Value<T>(byte displayLength=0, byte displayDecimals=0, unsigned int divideBy=1) :  _displayLength(displayLength), _displayDecimals(displayDecimals), _divideBy(divideBy), _value( T() ), _oldValue( T() ), ValueBase() { }

   /**
    * render the value as a character string
    * @param buf the char buffer
    * @return nothing
    */  
    virtual void getValueString(char * buf);
    
   /**
    * return the value in its native type
    * @return the current value
    */  
    virtual T getValue();
    
   /**
    * set the value
    * @param value the new value
    * @return nothing
    */  
    virtual void setValue(T value) { 
      _value = value; 
    }

   /**
    * set the displayLength
    * @param displayLength the new displayLength
    * @return nothing
    */  
    void setDisplayLength(byte displayLength) {
      _displayLength = displayLength;
    }
    
   /**
    * set the displayDecimals
    * @param displayDecimals the new displayDecimals
    * @return nothing
    */  
    void setDisplayDecimals(byte displayDecimals) {
      _displayDecimals = displayDecimals;
      }

   /**
    * set the divideBy
    * @param divideBy the new divideBy
    * @return nothing
    */  
    void setDivideBy(unsigned int divideBy) {
      _divideBy = divideBy;
    }

   /**
    * equals operator
    * @param other the other Value object to be compared
    * @return true if this and other Value are equal
    */  
    bool operator==(Value<T>& other) {
      return (this->getValue() == other.getValue());
    }
    

   /**
    * not-equal operator
    * @param other the other Value object to be compared
    * @return true if this and other Value are not equal
    */  
    bool operator!=(Value<T>& other) {
      return (this->getValue() != other.getValue());
    }

   /**
{'fraction_non_alphanumeric': 0.10006244146113019, 'fraction_numerical': 0.00561973150171714, 'mean_word_length': 2.472628726287263, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3530512', 'n_tokens_mistral': 1916, 'n_tokens_neox': 1813, 'n_words': 634}