| 163 | |
| 164 | |
| 165 | void Stage::prepare(PointTableRef table) |
| 166 | { |
| 167 | // Linearize |
| 168 | std::stack<Stage *> pending; |
| 169 | std::vector<Stage *> stages; |
| 170 | |
| 171 | pending.push(this); |
| 172 | while (pending.size()) |
| 173 | { |
| 174 | Stage *s = pending.top(); |
| 175 | pending.pop(); |
| 176 | stages.push_back(s); |
| 177 | for (Stage *in : s->m_inputs) |
| 178 | pending.push(in); |
| 179 | } |
| 180 | |
| 181 | // Initialize each stage. |
| 182 | for (auto it = stages.rbegin(); it != stages.rend(); it++) |
| 183 | { |
| 184 | Stage *s = *it; |
| 185 | s->m_args.reset(new ProgramArgs); |
| 186 | s->handleOptions(); |
| 187 | s->startLogging(); |
| 188 | s->l_initialize(table); |
| 189 | s->initialize(table); |
| 190 | s->addDimensions(table.layout()); |
| 191 | s->stopLogging(); |
| 192 | } |
| 193 | |
| 194 | // Call prepared() now that all stages are initialized. |
| 195 | for (auto it = stages.rbegin(); it != stages.rend(); it++) |
| 196 | { |
| 197 | Stage *s = *it; |
| 198 | s->startLogging(); |
| 199 | s->l_prepared(table); |
| 200 | s->prepared(table); |
| 201 | s->stopLogging(); |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | |
| 206 | PointViewSet Stage::execute(PointTableRef table) |