/[svn]/libgig/trunk/src/RIFF.cpp
ViewVC logotype

Diff of /libgig/trunk/src/RIFF.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3480 by schoenebeck, Thu Feb 21 20:10:08 2019 UTC revision 3481 by schoenebeck, Fri Feb 22 12:12:50 2019 UTC
# Line 65  namespace RIFF { Line 65  namespace RIFF {
65      }      }
66    
67      /**      /**
68       * Divides this progress task into the requested amount of sub-progress       * Divides this progress task into the requested amount of equal weighted
69       * tasks and returns a vector with those subprogress tasks.       * sub-progress tasks and returns a vector with those subprogress tasks.
70       *       *
71       * @param iSubtasks - total amount sub tasks this task should be subdivided       * @param iSubtasks - total amount sub tasks this task should be subdivided
72       * @returns subtasks       * @returns subtasks
# Line 79  namespace RIFF { Line 79  namespace RIFF {
79              v.push_back(p);              v.push_back(p);
80          }          }
81          return v;          return v;
82        }
83    
84        /**
85         * Divides this progress task into the requested amount of sub-progress
86         * tasks, where each one of those new sub-progress tasks is created with its
87         * requested individual weight / portion, and finally returns a vector
88         * with those new subprogress tasks.
89         *
90         * The amount of subprogresses to be created is determined by this method
91         * by calling @c vSubTaskPortions.size() .
92         *
93         * Example: consider you wanted to create 3 subprogresses where the 1st
94         * subtask should be assigned 10% of the new 3 subprogresses' overall
95         * progress, the 2nd subtask should be assigned 50% of the new 3
96         * subprogresses' overall progress, and the 3rd subtask should be assigned
97         * 40%, then you might call this method like this:
98         * @code
99         * std::vector<progress_t> subprogresses = progress.subdivide({0.1, 0.5, 0.4});
100         * @endcode
101         *
102         * @param vSubTaskPortions - amount and individual weight of subtasks to be
103         *                           created
104         * @returns subtasks
105         */
106        std::vector<progress_t> progress_t::subdivide(std::vector<float> vSubTaskPortions) {
107            float fTotal = 0.f; // usually 1.0, but we sum the portions up below to be sure
108            for (int i = 0; i < vSubTaskPortions.size(); ++i)
109                fTotal += vSubTaskPortions[i];
110    
111            float fLow = 0.f, fHigh = 0.f;
112            std::vector<progress_t> v;
113            for (int i = 0; i < vSubTaskPortions.size(); ++i) {
114                fLow  = fHigh;
115                fHigh = vSubTaskPortions[i];
116                progress_t p;
117                __divide_progress(this, &p, fTotal, fLow, fHigh);
118                v.push_back(p);
119            }
120            return v;
121      }      }
122    
123    

Legend:
Removed from v.3480  
changed lines
  Added in v.3481

  ViewVC Help
Powered by ViewVC