lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 203d1b5 2/6: Refactor


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 203d1b5 2/6: Refactor
Date: Wed, 8 Feb 2017 09:15:40 -0500 (EST)

branch: master
commit 203d1b5f9c5d211656ebca9004700b7dd42b807c
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Refactor
    
    See:
      http://lists.nongnu.org/archive/html/lmi/2017-02/msg00027.html
    for this and the next commit or two.
---
 input_sequence.cpp | 18 ++++++++++++++----
 input_sequence.hpp |  4 ++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/input_sequence.cpp b/input_sequence.cpp
index 101fa26..6817aa7 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -49,6 +49,16 @@ ValueInterval::ValueInterval()
     ,insane           (false)
 {}
 
+void ValueInterval::value(double d)
+{
+    value_number = d;
+}
+
+void ValueInterval::value(std::string const& s)
+{
+    value_keyword = s;
+}
+
 SequenceParser::SequenceParser
     (std::string const&              input_expression
     ,int                             a_years_to_maturity
@@ -807,7 +817,7 @@ InputSequence::InputSequence(std::vector<double> const& v)
     double current_value = prior_value;
 
     intervals_.push_back(dummy);
-    intervals_.back().value_number = current_value;
+    intervals_.back().value(current_value);
 
     for(auto const& vi : v)
         {
@@ -820,7 +830,7 @@ InputSequence::InputSequence(std::vector<double> const& v)
             {
             int value_change_duration = intervals_.back().end_duration;
             intervals_.push_back(dummy);
-            intervals_.back().value_number = current_value;
+            intervals_.back().value(current_value);
             intervals_.back().begin_duration = value_change_duration;
             intervals_.back().end_duration = ++value_change_duration;
             prior_value = current_value;
@@ -840,7 +850,7 @@ InputSequence::InputSequence(std::vector<std::string> 
const& v)
     std::string current_value = prior_value;
 
     intervals_.push_back(dummy);
-    intervals_.back().value_keyword = current_value;
+    intervals_.back().value(current_value);
 
     for(auto const& vi : v)
         {
@@ -853,7 +863,7 @@ InputSequence::InputSequence(std::vector<std::string> 
const& v)
             {
             int value_change_duration = intervals_.back().end_duration;
             intervals_.push_back(dummy);
-            intervals_.back().value_keyword = current_value;
+            intervals_.back().value(current_value);
             intervals_.back().begin_duration = value_change_duration;
             intervals_.back().end_duration = ++value_change_duration;
             prior_value = current_value;
diff --git a/input_sequence.hpp b/input_sequence.hpp
index 34b6349..aa93bdd 100644
--- a/input_sequence.hpp
+++ b/input_sequence.hpp
@@ -158,6 +158,10 @@ struct ValueInterval
 {
     ValueInterval();
 
+    // Should this struct become a class because these members have been added?
+    void value(double);
+    void value(std::string const&);
+
     double        value_number;
     std::string   value_keyword;
     bool          value_is_keyword;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]