Browse Source

Adds documentation deployment make target, additional values relating to
leading objects

Caleb Fangmeier 7 years ago
parent
commit
8be6413ed7
2 changed files with 19 additions and 5 deletions
  1. 10 0
      api.hpp
  2. 9 5
      value.hpp

+ 10 - 0
api.hpp

@@ -164,6 +164,16 @@ namespace fv{
         return pair<T1,T2>(lookup<T1>(name1), lookup<T2>(name2), alias);
         return pair<T1,T2>(lookup<T1>(name1), lookup<T2>(name2), alias);
     }
     }
 
 
+    template <typename T>
+    decltype(auto)
+    reduce(Function<T(std::vector<T>)>& fn, Value<std::vector<T>>* v, const std::string& alias=""){
+        typedef T type;
+        const std::string& name = Reduce<T>::fmt_name(fn, v);
+        if (check_exists<type>(name))
+            return lookup<type>(name);
+        else
+            return (Value<type>*)new Reduce<T>(fn, v, alias);
+    }
 
 
     template <typename T>
     template <typename T>
     decltype(auto)
     decltype(auto)

+ 9 - 5
value.hpp

@@ -950,19 +950,23 @@ class TupFilter : public DerivedValue<std::vector<std::tuple<ArgTypes...>>>{
 template <typename T>
 template <typename T>
 class Reduce : public DerivedValue<T>{
 class Reduce : public DerivedValue<T>{
     private:
     private:
-        Function<T(std::vector<T>)>& reduce;
+        Function<T(std::vector<T>)>& reduce_fn;
 
 
         void update_value(){
         void update_value(){
-            this->value = reduce(v->get_value());
+            this->value = reduce_fn(v->get_value());
         }
         }
 
 
     protected:
     protected:
         Value<std::vector<T> >* v;
         Value<std::vector<T> >* v;
 
 
     public:
     public:
-        Reduce(Function<T(std::vector<T>)>& reduce, Value<std::vector<T> >* v, const std::string alias)
-          :DerivedValue<T>("reduceWith("+reduce.get_name()+":"+v->get_name()+")", alias),
-           reduce(reduce), v(v) { }
+        static std::string fmt_name(Function<T(std::vector<T>)>& reduce_fn, Value<std::vector<T>>* v){
+            return "reduce("+reduce_fn.get_name()+":"+v->get_name()+")";
+        }
+
+        Reduce(Function<T(std::vector<T>)>& reduce_fn, Value<std::vector<T> >* v, const std::string alias)
+          :DerivedValue<T>(fmt_name(reduce_fn, v), alias),
+           reduce_fn(reduce_fn), v(v) { }
 };
 };
 
 
 /**
 /**