SpatialOps
NeboCond.h
1 /* This file was generated by fulmar version 0.9.2. */
2 
3 /*
4  * Copyright (c) 2014-2017 The University of Utah
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
25 #ifndef NEBO_COND_H
26  #define NEBO_COND_H
27 
28  namespace SpatialOps {
29  struct NeboNil {
30  #ifdef ENABLE_THREADS
31  NeboNil typedef ResizeType;
32  #endif
33  /* ENABLE_THREADS */
34 
35  NeboNil typedef SeqWalkType;
36 
37  #ifdef __CUDACC__
38  NeboNil typedef GPUWalkType;
39  #endif
40  /* __CUDACC__ */
41 
42  NeboNil() {}
43 
44  template<typename FieldType>
45  struct Convert { NeboNil typedef Result; };
46 
47  template<typename FieldType>
48  inline NeboNil convert(void) const { return NeboNil(); }
49  };
50 
51  template<typename CurrentMode,
52  typename Test,
53  typename Expr,
54  typename FieldType>
55  struct NeboClause;
56  template<typename Test, typename Expr, typename FieldType>
57  struct NeboClause<Initial, Test, Expr, FieldType> {
58  public:
59  FieldType typedef field_type;
60 
61  NeboClause<SeqWalk,
62  typename Test::SeqWalkType,
63  typename Expr::SeqWalkType,
64  FieldType> typedef SeqWalkType;
65 
66  #ifdef ENABLE_THREADS
67  NeboClause<Resize,
68  typename Test::ResizeType,
69  typename Expr::ResizeType,
70  FieldType> typedef ResizeType;
71  #endif
72  /* ENABLE_THREADS */
73 
74  #ifdef __CUDACC__
75  NeboClause<GPUWalk,
76  typename Test::GPUWalkType,
77  typename Expr::GPUWalkType,
78  FieldType> typedef GPUWalkType;
79  #endif
80  /* __CUDACC__ */
81 
82  NeboClause(Test const & t, Expr const & e)
83  : test_(t), expr_(e)
84  {}
85 
86  inline GhostData ghosts_with_bc(void) const {
87  return min(test_.ghosts_with_bc(), expr_.ghosts_with_bc());
88  }
89 
90  inline GhostData ghosts_without_bc(void) const {
91  return min(test_.ghosts_without_bc(), expr_.ghosts_without_bc());
92  }
93 
94  inline bool has_extents(void) const {
95  return test_.has_extents() || expr_.has_extents();
96  }
97 
98  inline IntVec extents(void) const {
99  #ifndef NDEBUG
100  if(test_.has_extents() && expr_.has_extents()) {
101  assert(test_.extents() == expr_.extents());
102  }
103  #endif
104  /* NDEBUG */;
105 
106  return (test_.has_extents() ? test_.extents() : expr_.extents());
107  }
108 
109  inline IntVec has_bc(BCSide const bcSide) const {
110  return test_.has_bc() || expr_.has_bc(bcSide);
111  }
112 
113  inline SeqWalkType init(IntVec const & extents,
114  GhostData const & ghosts,
115  IntVec const & hasBC) const {
116  return SeqWalkType(test_.init(extents, ghosts, hasBC),
117  expr_.init(extents, ghosts, hasBC));
118  }
119 
120  #ifdef ENABLE_THREADS
121  inline ResizeType resize(void) const {
122  return ResizeType(test_.resize(), expr_.resize());
123  }
124  #endif
125  /* ENABLE_THREADS */
126 
127  #ifdef __CUDACC__
128  inline bool cpu_ready(void) const {
129  return test_.cpu_ready() && expr_.cpu_ready();
130  }
131 
132  inline bool gpu_ready(int const deviceIndex) const {
133  return test_.gpu_ready(deviceIndex) && expr_.gpu_ready(deviceIndex);
134  }
135 
136  inline GPUWalkType gpu_init(IntVec const & extents,
137  GhostData const & ghosts,
138  IntVec const & hasBC,
139  int const deviceIndex,
140  cudaStream_t const & lhsStream) const {
141  return GPUWalkType(test_.gpu_init(extents,
142  ghosts,
143  hasBC,
144  deviceIndex,
145  lhsStream),
146  expr_.gpu_init(extents,
147  ghosts,
148  hasBC,
149  deviceIndex,
150  lhsStream));
151  }
152 
153  inline void stream_wait_event(cudaEvent_t const & event) const {
154  test_.stream_wait_event(event);
155 
156  expr_.stream_wait_event(event);
157  }
158 
159  #ifdef NEBO_GPU_TEST
160  inline void gpu_prep(int const deviceIndex) const {
161  test_.gpu_prep(deviceIndex);
162 
163  expr_.gpu_prep(deviceIndex);
164  }
165  #endif
166  /* NEBO_GPU_TEST */
167  #endif
168  /* __CUDACC__ */
169 
170  private:
171  Test const test_;
172 
173  Expr const expr_;
174  };
175  #ifdef ENABLE_THREADS
176  template<typename Test, typename Expr, typename FieldType>
177  struct NeboClause<Resize, Test, Expr, FieldType> {
178  public:
179  FieldType typedef field_type;
180 
181  NeboClause<SeqWalk,
182  typename Test::SeqWalkType,
183  typename Expr::SeqWalkType,
184  FieldType> typedef SeqWalkType;
185 
186  NeboClause(Test const & test, Expr const & expr)
187  : test_(test), expr_(expr)
188  {}
189 
190  inline SeqWalkType init(IntVec const & extents,
191  GhostData const & ghosts,
192  IntVec const & hasBC) const {
193  return SeqWalkType(test_.init(extents, ghosts, hasBC),
194  expr_.init(extents, ghosts, hasBC));
195  }
196 
197  private:
198  Test const test_;
199 
200  Expr const expr_;
201  }
202  #endif
203  /* ENABLE_THREADS */;
204  template<typename Test, typename Expr, typename FieldType>
205  struct NeboClause<SeqWalk, Test, Expr, FieldType> {
206  public:
207  FieldType typedef field_type;
208 
209  typename field_type::value_type typedef value_type;
210 
211  NeboClause(Test const & test, Expr const & expr)
212  : test_(test), expr_(expr)
213  {}
214 
215  template<typename OptionalArgT>
216  inline value_type eval(int const x, int const y, int const z) const {
217  return expr_.template eval<OptionalArgT>(x, y, z);
218  }
219 
220  template<typename OptionalArgT>
221  inline bool check(int const x, int const y, int const z) const {
222  return test_.template eval<OptionalArgT>(x, y, z);
223  }
224 
225  private:
226  Test test_;
227 
228  Expr expr_;
229  };
230  #ifdef __CUDACC__
231  template<typename Test, typename Expr, typename FieldType>
232  struct NeboClause<GPUWalk, Test, Expr, FieldType> {
233  public:
234  FieldType typedef field_type;
235 
236  typename field_type::value_type typedef value_type;
237 
238  NeboClause(Test const & test, Expr const & expr)
239  : test_(test), expr_(expr)
240  {}
241 
242  template<typename OptionalArgT>
243  __device__ inline value_type eval(int const x,
244  int const y,
245  int const z) const {
246  return expr_.template eval<OptionalArgT>(x, y, z);
247  }
248 
249  template<typename OptionalArgT>
250  __device__ inline bool check(int const x, int const y, int const z) const {
251  return test_.template eval<OptionalArgT>(x, y, z);
252  }
253 
254  private:
255  Test test_;
256 
257  Expr expr_;
258  }
259  #endif
260  /* __CUDACC__ */;
261 
262  template<typename CurrentMode,
263  typename ClauseType,
264  typename Otherwise,
265  typename FieldType>
266  struct NeboCond;
267  template<typename ClauseType, typename Otherwise, typename FieldType>
268  struct NeboCond<Initial, ClauseType, Otherwise, FieldType> {
269  public:
270  FieldType typedef field_type;
271 
272  NeboCond<SeqWalk,
273  typename ClauseType::SeqWalkType,
274  typename Otherwise::SeqWalkType,
275  FieldType> typedef SeqWalkType;
276 
277  #ifdef ENABLE_THREADS
278  NeboCond<Resize,
279  typename ClauseType::ResizeType,
280  typename Otherwise::ResizeType,
281  FieldType> typedef ResizeType;
282  #endif
283  /* ENABLE_THREADS */
284 
285  #ifdef __CUDACC__
286  NeboCond<GPUWalk,
287  typename ClauseType::GPUWalkType,
288  typename Otherwise::GPUWalkType,
289  FieldType> typedef GPUWalkType;
290  #endif
291  /* __CUDACC__ */
292 
293  NeboCond(ClauseType const & c, Otherwise const & e)
294  : clause_(c), otherwise_(e)
295  {}
296 
297  inline GhostData ghosts_with_bc(void) const {
298  return min(clause_.ghosts_with_bc(), otherwise_.ghosts_with_bc());
299  }
300 
301  inline GhostData ghosts_without_bc(void) const {
302  return min(clause_.ghosts_without_bc(), otherwise_.ghosts_without_bc());
303  }
304 
305  inline bool has_extents(void) const {
306  return clause_.has_extents() || otherwise_.has_extents();
307  }
308 
309  inline IntVec extents(void) const {
310  #ifndef NDEBUG
311  if(clause_.has_extents() && otherwise_.has_extents()) {
312  assert(clause_.extents() == otherwise_.extents());
313  }
314  #endif
315  /* NDEBUG */;
316 
317  return (clause_.has_extents() ? clause_.extents() : otherwise_.extents());
318  }
319 
320  inline IntVec has_bc(BCSide const bcSide) const {
321  return clause_.has_bc() || otherwise_.has_bc(bcSide);
322  }
323 
324  inline SeqWalkType init(IntVec const & extents,
325  GhostData const & ghosts,
326  IntVec const & hasBC) const {
327  return SeqWalkType(clause_.init(extents, ghosts, hasBC),
328  otherwise_.init(extents, ghosts, hasBC));
329  }
330 
331  #ifdef ENABLE_THREADS
332  inline ResizeType resize(void) const {
333  return ResizeType(clause_.resize(), otherwise_.resize());
334  }
335  #endif
336  /* ENABLE_THREADS */
337 
338  #ifdef __CUDACC__
339  inline bool cpu_ready(void) const {
340  return clause_.cpu_ready() && otherwise_.cpu_ready();
341  }
342 
343  inline bool gpu_ready(int const deviceIndex) const {
344  return clause_.gpu_ready(deviceIndex) && otherwise_.gpu_ready(deviceIndex);
345  }
346 
347  inline GPUWalkType gpu_init(IntVec const & extents,
348  GhostData const & ghosts,
349  IntVec const & hasBC,
350  int const deviceIndex,
351  cudaStream_t const & lhsStream) const {
352  return GPUWalkType(clause_.gpu_init(extents,
353  ghosts,
354  hasBC,
355  deviceIndex,
356  lhsStream),
357  otherwise_.gpu_init(extents,
358  ghosts,
359  hasBC,
360  deviceIndex,
361  lhsStream));
362  }
363 
364  inline void stream_wait_event(cudaEvent_t const & event) const {
365  clause_.stream_wait_event(event);
366 
367  otherwise_.stream_wait_event(event);
368  }
369 
370  #ifdef NEBO_GPU_TEST
371  inline void gpu_prep(int const deviceIndex) const {
372  clause_.gpu_prep(deviceIndex);
373 
374  otherwise_.gpu_prep(deviceIndex);
375  }
376  #endif
377  /* NEBO_GPU_TEST */
378  #endif
379  /* __CUDACC__ */
380 
381  inline ClauseType const & clause(void) const { return clause_; }
382 
383  inline Otherwise const & otherwise(void) const { return otherwise_; }
384 
385  private:
386  ClauseType const clause_;
387 
388  Otherwise const otherwise_;
389  };
390  #ifdef ENABLE_THREADS
391  template<typename ClauseType, typename Otherwise, typename FieldType>
392  struct NeboCond<Resize, ClauseType, Otherwise, FieldType> {
393  public:
394  FieldType typedef field_type;
395 
396  NeboCond<SeqWalk,
397  typename ClauseType::SeqWalkType,
398  typename Otherwise::SeqWalkType,
399  FieldType> typedef SeqWalkType;
400 
401  NeboCond(ClauseType const & clause, Otherwise const & otherwise)
402  : clause_(clause), otherwise_(otherwise)
403  {}
404 
405  inline SeqWalkType init(IntVec const & extents,
406  GhostData const & ghosts,
407  IntVec const & hasBC) const {
408  return SeqWalkType(clause_.init(extents, ghosts, hasBC),
409  otherwise_.init(extents, ghosts, hasBC));
410  }
411 
412  private:
413  ClauseType const clause_;
414 
415  Otherwise const otherwise_;
416  }
417  #endif
418  /* ENABLE_THREADS */;
419  template<typename ClauseType, typename Otherwise, typename FieldType>
420  struct NeboCond<SeqWalk, ClauseType, Otherwise, FieldType> {
421  public:
422  FieldType typedef field_type;
423 
424  typename field_type::value_type typedef value_type;
425 
426  NeboCond(ClauseType const & clause, Otherwise const & otherwise)
427  : clause_(clause), otherwise_(otherwise)
428  {}
429 
430  template<typename OptionalArgT>
431  inline value_type eval(int const x, int const y, int const z) const {
432  return (clause_.template check<OptionalArgT>(x, y, z) ? clause_.template
433  eval<OptionalArgT>(x,
434  y,
435  z)
436  : otherwise_.template eval<OptionalArgT>(x, y, z));
437  }
438 
439  private:
440  ClauseType clause_;
441 
442  Otherwise otherwise_;
443  };
444  #ifdef __CUDACC__
445  template<typename ClauseType, typename Otherwise, typename FieldType>
446  struct NeboCond<GPUWalk, ClauseType, Otherwise, FieldType> {
447  public:
448  FieldType typedef field_type;
449 
450  typename field_type::value_type typedef value_type;
451 
452  NeboCond(ClauseType const & clause, Otherwise const & otherwise)
453  : clause_(clause), otherwise_(otherwise)
454  {}
455 
456  template<typename OptionalArgT>
457  __device__ inline value_type eval(int const x,
458  int const y,
459  int const z) const {
460  return (clause_.template check<OptionalArgT>(x, y, z) ? clause_.template
461  eval<OptionalArgT>(x,
462  y,
463  z)
464  : otherwise_.template eval<OptionalArgT>(x, y, z));
465  }
466 
467  private:
468  ClauseType clause_;
469 
470  Otherwise otherwise_;
471  }
472  #endif
473  /* __CUDACC__ */;
474 
475  template<typename CurrentMode, typename Test, typename Expr, typename T>
477  template<typename Test, typename Expr, typename T>
478  struct NeboSingleValueClause<Initial, Test, Expr, T> {
479  public:
481  field_type;
482 
483  NeboSingleValueClause<SeqWalk,
484  typename Test::SeqWalkType,
485  typename Expr::SeqWalkType,
486  T> typedef SeqWalkType;
487 
488  #ifdef ENABLE_THREADS
489  NeboSingleValueClause<Resize,
490  typename Test::ResizeType,
491  typename Expr::ResizeType,
492  T> typedef ResizeType;
493  #endif
494  /* ENABLE_THREADS */
495 
496  #ifdef __CUDACC__
497  NeboSingleValueClause<GPUWalk,
498  typename Test::GPUWalkType,
499  typename Expr::GPUWalkType,
500  T> typedef GPUWalkType;
501  #endif
502  /* __CUDACC__ */
503 
504  NeboSingleValueClause(Test const & t, Expr const & e)
505  : test_(t), expr_(e)
506  {}
507 
508  inline GhostData ghosts_with_bc(void) const {
509  return GhostData(GHOST_MAX);
510  }
511 
512  inline GhostData ghosts_without_bc(void) const {
513  return GhostData(GHOST_MAX);
514  }
515 
516  inline bool has_extents(void) const { return false; }
517 
518  inline IntVec extents(void) const { return IntVec(0, 0, 0); }
519 
520  inline IntVec has_bc(BCSide const bcSide) const {
521  return IntVec(0, 0, 0);
522  }
523 
524  inline SeqWalkType init(IntVec const & extents,
525  GhostData const & ghosts,
526  IntVec const & hasBC) const {
527  return SeqWalkType(test_.init(extents, ghosts, hasBC),
528  expr_.init(extents, ghosts, hasBC));
529  }
530 
531  #ifdef ENABLE_THREADS
532  inline ResizeType resize(void) const {
533  return ResizeType(test_.resize(), expr_.resize());
534  }
535  #endif
536  /* ENABLE_THREADS */
537 
538  #ifdef __CUDACC__
539  inline bool cpu_ready(void) const {
540  return test_.cpu_ready() && expr_.cpu_ready();
541  }
542 
543  inline bool gpu_ready(int const deviceIndex) const {
544  return test_.gpu_ready(deviceIndex) && expr_.gpu_ready(deviceIndex);
545  }
546 
547  inline GPUWalkType gpu_init(IntVec const & extents,
548  GhostData const & ghosts,
549  IntVec const & hasBC,
550  int const deviceIndex,
551  cudaStream_t const & lhsStream) const {
552  return GPUWalkType(test_.gpu_init(extents,
553  ghosts,
554  hasBC,
555  deviceIndex,
556  lhsStream),
557  expr_.gpu_init(extents,
558  ghosts,
559  hasBC,
560  deviceIndex,
561  lhsStream));
562  }
563 
564  inline void stream_wait_event(cudaEvent_t const & event) const {
565  test_.stream_wait_event(event);
566 
567  expr_.stream_wait_event(event);
568  }
569 
570  #ifdef NEBO_GPU_TEST
571  inline void gpu_prep(int const deviceIndex) const {
572  test_.gpu_prep(deviceIndex);
573 
574  expr_.gpu_prep(deviceIndex);
575  }
576  #endif
577  /* NEBO_GPU_TEST */
578  #endif
579  /* __CUDACC__ */
580 
581  template<typename FieldType>
582  struct Convert {
584 
585  static inline Result convert(Test const & t, Expr const & e) {
586  return Result(t, e);
587  }
588  };
589 
590  inline Test const & test(void) const { return test_; }
591 
592  inline Expr const & expr(void) const { return expr_; }
593 
594  private:
595  Test const test_;
596 
597  Expr const expr_;
598  };
599  #ifdef ENABLE_THREADS
600  template<typename Test, typename Expr, typename T>
601  struct NeboSingleValueClause<Resize, Test, Expr, T> {
602  public:
604  field_type;
605 
606  NeboSingleValueClause<SeqWalk,
607  typename Test::SeqWalkType,
608  typename Expr::SeqWalkType,
609  T> typedef SeqWalkType;
610 
611  NeboSingleValueClause(Test const & test, Expr const & expr)
612  : test_(test), expr_(expr)
613  {}
614 
615  inline SeqWalkType init(IntVec const & extents,
616  GhostData const & ghosts,
617  IntVec const & hasBC) const {
618  return SeqWalkType(test_.init(extents, ghosts, hasBC),
619  expr_.init(extents, ghosts, hasBC));
620  }
621 
622  private:
623  Test const test_;
624 
625  Expr const expr_;
626  }
627  #endif
628  /* ENABLE_THREADS */;
629  template<typename Test, typename Expr, typename T>
630  struct NeboSingleValueClause<SeqWalk, Test, Expr, T> {
631  public:
633  field_type;
634 
635  typename field_type::value_type typedef value_type;
636 
637  NeboSingleValueClause(Test const & test, Expr const & expr)
638  : test_(test), expr_(expr)
639  {}
640 
641  template<typename OptionalArgT>
642  inline value_type eval(int const x, int const y, int const z) const {
643  return expr_.template eval<OptionalArgT>(x, y, z);
644  }
645 
646  template<typename OptionalArgT>
647  inline bool check(int const x, int const y, int const z) const {
648  return test_.template eval<OptionalArgT>(x, y, z);
649  }
650 
651  private:
652  Test test_;
653 
654  Expr expr_;
655  };
656  #ifdef __CUDACC__
657  template<typename Test, typename Expr, typename T>
658  struct NeboSingleValueClause<GPUWalk, Test, Expr, T> {
659  public:
661  field_type;
662 
663  typename field_type::value_type typedef value_type;
664 
665  NeboSingleValueClause(Test const & test, Expr const & expr)
666  : test_(test), expr_(expr)
667  {}
668 
669  template<typename OptionalArgT>
670  __device__ inline value_type eval(int const x,
671  int const y,
672  int const z) const {
673  return expr_.template eval<OptionalArgT>(x, y, z);
674  }
675 
676  template<typename OptionalArgT>
677  __device__ inline bool check(int const x, int const y, int const z) const {
678  return test_.template eval<OptionalArgT>(x, y, z);
679  }
680 
681  private:
682  Test test_;
683 
684  Expr expr_;
685  }
686  #endif
687  /* __CUDACC__ */;
688 
689  template<typename CurrentMode,
690  typename ClauseType,
691  typename Otherwise,
692  typename T>
694  template<typename ClauseType, typename Otherwise, typename T>
695  struct NeboSingleValueCond<Initial, ClauseType, Otherwise, T> {
696  public:
698  field_type;
699 
700  NeboSingleValueCond<SeqWalk,
701  typename ClauseType::SeqWalkType,
702  typename Otherwise::SeqWalkType,
703  T> typedef SeqWalkType;
704 
705  #ifdef ENABLE_THREADS
706  NeboSingleValueCond<Resize,
707  typename ClauseType::ResizeType,
708  typename Otherwise::ResizeType,
709  T> typedef ResizeType;
710  #endif
711  /* ENABLE_THREADS */
712 
713  #ifdef __CUDACC__
714  NeboSingleValueCond<GPUWalk,
715  typename ClauseType::GPUWalkType,
716  typename Otherwise::GPUWalkType,
717  T> typedef GPUWalkType;
718  #endif
719  /* __CUDACC__ */
720 
721  NeboSingleValueCond(ClauseType const & c, Otherwise const & e)
722  : clause_(c), otherwise_(e)
723  {}
724 
725  inline GhostData ghosts_with_bc(void) const {
726  return GhostData(GHOST_MAX);
727  }
728 
729  inline GhostData ghosts_without_bc(void) const {
730  return GhostData(GHOST_MAX);
731  }
732 
733  inline bool has_extents(void) const { return false; }
734 
735  inline IntVec extents(void) const { return IntVec(0, 0, 0); }
736 
737  inline IntVec has_bc(BCSide const bcSide) const {
738  return IntVec(0, 0, 0);
739  }
740 
741  inline SeqWalkType init(IntVec const & extents,
742  GhostData const & ghosts,
743  IntVec const & hasBC) const {
744  return SeqWalkType(clause_.init(extents, ghosts, hasBC),
745  otherwise_.init(extents, ghosts, hasBC));
746  }
747 
748  #ifdef ENABLE_THREADS
749  inline ResizeType resize(void) const {
750  return ResizeType(clause_.resize(), otherwise_.resize());
751  }
752  #endif
753  /* ENABLE_THREADS */
754 
755  #ifdef __CUDACC__
756  inline bool cpu_ready(void) const {
757  return clause_.cpu_ready() && otherwise_.cpu_ready();
758  }
759 
760  inline bool gpu_ready(int const deviceIndex) const {
761  return clause_.gpu_ready(deviceIndex) && otherwise_.gpu_ready(deviceIndex);
762  }
763 
764  inline GPUWalkType gpu_init(IntVec const & extents,
765  GhostData const & ghosts,
766  IntVec const & hasBC,
767  int const deviceIndex,
768  cudaStream_t const & lhsStream) const {
769  return GPUWalkType(clause_.gpu_init(extents,
770  ghosts,
771  hasBC,
772  deviceIndex,
773  lhsStream),
774  otherwise_.gpu_init(extents,
775  ghosts,
776  hasBC,
777  deviceIndex,
778  lhsStream));
779  }
780 
781  inline void stream_wait_event(cudaEvent_t const & event) const {
782  clause_.stream_wait_event(event);
783 
784  otherwise_.stream_wait_event(event);
785  }
786 
787  #ifdef NEBO_GPU_TEST
788  inline void gpu_prep(int const deviceIndex) const {
789  clause_.gpu_prep(deviceIndex);
790 
791  otherwise_.gpu_prep(deviceIndex);
792  }
793  #endif
794  /* NEBO_GPU_TEST */
795  #endif
796  /* __CUDACC__ */
797 
798  template<typename FieldType>
799  struct Convert {
800  typename ClauseType::template Convert<FieldType> typedef
801  ConvertingClause;
802 
803  typename ConvertingClause::Result typedef ConvertedClause;
804 
805  typename Otherwise::template Convert<FieldType>::Result typedef
806  ConvertedClauses;
807 
809  typedef Result;
810 
811  static inline Result convert(ClauseType const & c,
812  Otherwise const & o) {
813  return Result(ConvertingClause::convert(c.test(), c.expr()),
814  o.template convert<FieldType>());
815  }
816  };
817 
818  template<typename FieldType>
819  inline typename Convert<FieldType>::Result convert(void) const {
820  return Convert<FieldType>::convert(clause(), otherwise());
821  }
822 
823  inline ClauseType const & clause(void) const { return clause_; }
824 
825  inline Otherwise const & otherwise(void) const { return otherwise_; }
826 
827  private:
828  ClauseType const clause_;
829 
830  Otherwise const otherwise_;
831  };
832  #ifdef ENABLE_THREADS
833  template<typename ClauseType, typename Otherwise, typename T>
834  struct NeboSingleValueCond<Resize, ClauseType, Otherwise, T> {
835  public:
837  field_type;
838 
839  NeboSingleValueCond<SeqWalk,
840  typename ClauseType::SeqWalkType,
841  typename Otherwise::SeqWalkType,
842  T> typedef SeqWalkType;
843 
844  NeboSingleValueCond(ClauseType const & clause,
845  Otherwise const & otherwise)
846  : clause_(clause), otherwise_(otherwise)
847  {}
848 
849  inline SeqWalkType init(IntVec const & extents,
850  GhostData const & ghosts,
851  IntVec const & hasBC) const {
852  return SeqWalkType(clause_.init(extents, ghosts, hasBC),
853  otherwise_.init(extents, ghosts, hasBC));
854  }
855 
856  private:
857  ClauseType const clause_;
858 
859  Otherwise const otherwise_;
860  }
861  #endif
862  /* ENABLE_THREADS */;
863  template<typename ClauseType, typename Otherwise, typename T>
864  struct NeboSingleValueCond<SeqWalk, ClauseType, Otherwise, T> {
865  public:
867  field_type;
868 
869  typename field_type::value_type typedef value_type;
870 
871  NeboSingleValueCond(ClauseType const & clause,
872  Otherwise const & otherwise)
873  : clause_(clause), otherwise_(otherwise)
874  {}
875 
876  template<typename OptionalArgT>
877  inline value_type eval(int const x, int const y, int const z) const {
878  return (clause_.template check<OptionalArgT>(x, y, z) ? clause_.template
879  eval<OptionalArgT>(x,
880  y,
881  z)
882  : otherwise_.template eval<OptionalArgT>(x, y, z));
883  }
884 
885  private:
886  ClauseType clause_;
887 
888  Otherwise otherwise_;
889  };
890  #ifdef __CUDACC__
891  template<typename ClauseType, typename Otherwise, typename T>
892  struct NeboSingleValueCond<GPUWalk, ClauseType, Otherwise, T> {
893  public:
895  field_type;
896 
897  typename field_type::value_type typedef value_type;
898 
899  NeboSingleValueCond(ClauseType const & clause,
900  Otherwise const & otherwise)
901  : clause_(clause), otherwise_(otherwise)
902  {}
903 
904  template<typename OptionalArgT>
905  __device__ inline value_type eval(int const x,
906  int const y,
907  int const z) const {
908  return (clause_.template check<OptionalArgT>(x, y, z) ? clause_.template
909  eval<OptionalArgT>(x,
910  y,
911  z)
912  : otherwise_.template eval<OptionalArgT>(x, y, z));
913  }
914 
915  private:
916  ClauseType clause_;
917 
918  Otherwise otherwise_;
919  }
920  #endif
921  /* __CUDACC__ */;
922 
924  public:
925  NeboSimpleClause(bool const & b, double const & d)
926  : b_(b), d_(d)
927  {}
928 
929  inline bool check(void) const { return b_; }
930 
931  inline double eval(void) const { return d_; }
932 
933  template<typename FieldType>
934  struct FullConvert {
935  NeboScalar<Initial, bool> typedef Boolean;
936 
938 
940 
941  static inline result full_convert(bool const b,
942  typename FieldType::value_type
943  const d) {
944  return result(Boolean(b), Scalar(d));
945  }
946  };
947 
948  template<typename T>
949  struct SingleConvert {
950  NeboScalar<Initial, bool> typedef Boolean;
951 
952  NeboScalar<Initial, T> typedef Scalar;
953 
955 
956  static inline result single_convert(bool const b, T const d) {
957  return result(Boolean(b), Scalar(d));
958  }
959  };
960 
961  private:
962  bool const b_;
963 
964  double const d_;
965  };
966 
968  public:
969  NeboSimpleFinalClause(double const d)
970  : d_(d)
971  {}
972 
973  inline double eval(void) const { return d_; }
974 
975  private:
976  double const d_;
977  };
978 
979  template<typename Otherwise>
980  struct NeboSimpleCond {
981  public:
982  NeboSimpleCond(NeboSimpleClause const & c, Otherwise const & otherwise)
983  : c_(c), otherwise_(otherwise)
984  {}
985 
986  inline double eval(void) const {
987  return (c_.check() ? c_.eval() : otherwise_.eval());
988  }
989 
990  template<typename FieldType>
991  struct FullConvert {
992  NeboSimpleClause::template FullConvert<FieldType> typedef
993  ConvertingClause;
994 
995  typename ConvertingClause::result typedef ConvertedClause;
996 
997  typename Otherwise::template FullConvert<FieldType>::result typedef
998  ConvertedClauses;
999 
1001  typedef result;
1002 
1003  static inline result full_convert(NeboSimpleClause const & c,
1004  Otherwise const & o) {
1005  return result(ConvertingClause::full_convert(c.check(), c.eval()),
1006  o.template full_convert<FieldType>());
1007  }
1008  };
1009 
1010  template<typename FieldType>
1011  inline typename FullConvert<FieldType>::result full_convert(void) const {
1012  return FullConvert<FieldType>::full_convert(clause(), otherwise());
1013  }
1014 
1015  template<typename T>
1016  struct SingleConvert {
1017  NeboSimpleClause::template SingleConvert<T> typedef
1018  ConvertingClause;
1019 
1020  typename ConvertingClause::result typedef ConvertedClause;
1021 
1022  typename Otherwise::template SingleConvert<T>::result typedef
1023  ConvertedClauses;
1024 
1026  typedef result;
1027 
1028  static inline result single_convert(NeboSimpleClause const & c,
1029  Otherwise const & o) {
1030  return result(ConvertingClause::single_convert(c.check(), c.eval()),
1031  o.template single_convert<T>());
1032  }
1033  };
1034 
1035  template<typename T>
1036  inline typename SingleConvert<T>::result single_convert(void) const {
1037  return SingleConvert<T>::single_convert(clause(), otherwise());
1038  }
1039 
1040  inline NeboSimpleClause const & clause(void) const { return c_; }
1041 
1042  inline Otherwise const & otherwise(void) const { return otherwise_; }
1043 
1044  private:
1045  NeboSimpleClause const c_;
1046 
1047  Otherwise const otherwise_;
1048  };
1049 
1050  template<>
1052  public:
1053  NeboSimpleCond(NeboSimpleClause const & c, NeboNil const & nil)
1054  : c_(c)
1055  {}
1056 
1057  template<typename FieldType>
1058  struct FullConvert {
1059  NeboSimpleClause::template FullConvert<FieldType> typedef
1060  ConvertingClause;
1061 
1062  typename ConvertingClause::result typedef ConvertedClause;
1063 
1064  NeboNil typedef ConvertedClauses;
1065 
1067  typedef result;
1068 
1069  static inline result full_convert(NeboSimpleClause const & c) {
1070  return result(ConvertingClause::full_convert(c.check(), c.eval()),
1071  NeboNil());
1072  }
1073  };
1074 
1075  template<typename FieldType>
1076  inline typename FullConvert<FieldType>::result full_convert(void) const {
1077  return FullConvert<FieldType>::full_convert(clause());
1078  }
1079 
1080  template<typename T>
1081  struct SingleConvert {
1082  NeboSimpleClause::template SingleConvert<T> typedef
1083  ConvertingClause;
1084 
1085  typename ConvertingClause::result typedef ConvertedClause;
1086 
1087  NeboNil typedef ConvertedClauses;
1088 
1090  typedef result;
1091 
1092  static inline result single_convert(NeboSimpleClause const & c) {
1093  return result(ConvertingClause::single_convert(c.check(), c.eval()),
1094  NeboNil());
1095  }
1096  };
1097 
1098  template<typename T>
1099  inline typename SingleConvert<T>::result single_convert(void) const {
1100  return SingleConvert<T>::single_convert(clause());
1101  }
1102 
1103  inline NeboSimpleClause const & clause(void) const { return c_; }
1104 
1105  inline NeboNil otherwise(void) const { return NeboNil(); }
1106 
1107  private:
1108  NeboSimpleClause const c_;
1109  };
1110 
1111  template<typename Clauses>
1112  struct CondBuilder;
1113 
1114  template<typename ClauseType, typename Otherwise, typename FieldType>
1115  struct CondBuilder<NeboCond<Initial, ClauseType, Otherwise, FieldType> > {
1116  public:
1118 
1119  private:
1120  template<typename Remaining, typename PreceedingResult>
1121  struct ReverseClausesRecursive;
1122 
1123  template<typename PreceedingResult>
1124  struct ReverseClausesRecursive<NeboNil, PreceedingResult> {
1125  PreceedingResult typedef Result;
1126 
1127  static inline Result reverse(NeboNil const & nil,
1128  PreceedingResult const & r) {
1129  return r;
1130  }
1131  };
1132 
1133  template<typename Next, typename Following, typename PreceedingResult>
1134  struct ReverseClausesRecursive<NeboCond<Initial,
1135  Next,
1136  Following,
1137  FieldType>,
1138  PreceedingResult> {
1140 
1142  NewResult;
1143 
1144  ReverseClausesRecursive<Following, NewResult> typedef InternalCall;
1145 
1146  typename InternalCall::Result typedef Result;
1147 
1148  static inline Result reverse(Remaining const & l,
1149  PreceedingResult const & r) {
1150  return InternalCall::reverse(l.otherwise(),
1151  NewResult(l.clause(), r));
1152  }
1153  };
1154 
1155  Clauses const clauses_;
1156 
1157  public:
1159  & cs)
1160  : clauses_(cs)
1161  {}
1162 
1163  template<typename Final>
1164  struct ReverseClauses;
1165 
1166  template<typename Final>
1167  struct ReverseClauses {
1168  ReverseClausesRecursive<Clauses, Final> typedef InternalCall;
1169 
1170  typename InternalCall::Result typedef Result;
1171 
1172  static inline Result reverse(Clauses const & cs, Final const & f) {
1173  return InternalCall::reverse(cs, f);
1174  }
1175  };
1176 
1177  template<typename Final>
1178  inline typename ReverseClauses<Final>::Result reverse(Final const & f) {
1179  ReverseClauses<Final> typedef InternalCall;
1180 
1181  return InternalCall::reverse(clauses_, f);
1182  }
1183 
1184  /* full X final X double */
1185  inline NeboExpression<typename ReverseClauses<NeboScalar<Initial,
1186  typename
1187  FieldType::
1188  value_type> >::
1189  Result,
1190  FieldType> operator ()(double const d) {
1192 
1193  typename ReverseClauses<Scalar>::Result typedef ReversedClauses;
1194 
1195  NeboExpression<ReversedClauses, FieldType> typedef ReturnType;
1196 
1197  return ReturnType(reverse(Scalar(d)));
1198  }
1199 
1200  /* full X final X single-field */
1201  inline NeboExpression<typename ReverseClauses<NeboConstSingleValueField<Initial,
1202  typename
1203  FieldType::
1204  value_type>
1205  >::Result,
1206  FieldType> operator ()(SpatialOps::SpatialField<SpatialOps::
1207  SingleValue,
1208  typename
1209  FieldType::
1210  value_type>
1211  const & f) {
1213  typedef Field;
1214 
1215  typename ReverseClauses<Field>::Result typedef ReversedClauses;
1216 
1217  NeboExpression<ReversedClauses, FieldType> typedef ReturnType;
1218 
1219  return ReturnType(reverse(Field(f)));
1220  }
1221 
1222  /* full X final X single-expr */
1223  template<typename Expr>
1225  FieldType> operator ()(NeboSingleValueExpression<Expr,
1226  typename
1227  FieldType::
1228  value_type>
1229  const & e) {
1230  typename ReverseClauses<Expr>::Result typedef ReversedClauses;
1231 
1232  NeboExpression<ReversedClauses, FieldType> typedef ReturnType;
1233 
1234  return ReturnType(reverse(e.expr()));
1235  }
1236 
1237  /* full X final X field */
1238  inline NeboExpression<typename ReverseClauses<NeboConstField<Initial,
1239  FieldType>
1240  >::Result,
1241  FieldType> operator ()(FieldType const & f) {
1242  NeboConstField<Initial, FieldType> typedef Field;
1243 
1244  typename ReverseClauses<Field>::Result typedef ReversedClauses;
1245 
1246  NeboExpression<ReversedClauses, FieldType> typedef ReturnType;
1247 
1248  return ReturnType(reverse(Field(f)));
1249  }
1250 
1251  /* full X final X expr */
1252  template<typename Expr>
1254  FieldType> operator ()(NeboExpression<Expr,
1255  FieldType>
1256  const & e) {
1257  typename ReverseClauses<Expr>::Result typedef ReversedClauses;
1258 
1259  NeboExpression<ReversedClauses, FieldType> typedef ReturnType;
1260 
1261  return ReturnType(reverse(e.expr()));
1262  }
1263 
1264  /* full X bool X double */
1265  inline CondBuilder<NeboCond<Initial,
1266  NeboClause<Initial,
1268  NeboScalar<Initial,
1269  typename FieldType::
1270  value_type>,
1271  FieldType>,
1272  Clauses,
1273  FieldType> > operator ()(bool const b,
1274  double const d) {
1275  NeboScalar<Initial, bool> typedef Boolean;
1276 
1278 
1280 
1282 
1283  CondBuilder<Cond> typedef ReturnType;
1284 
1285  return ReturnType(Cond(Clause(Boolean(b), Scalar(d)), clauses_));
1286  }
1287 
1288  /* full X bool X single-field */
1289  inline CondBuilder<NeboCond<Initial,
1290  NeboClause<Initial,
1291  NeboScalar<Initial, bool>,
1292  NeboConstSingleValueField<Initial,
1293  typename
1294  FieldType::
1295  value_type>,
1296  FieldType>,
1297  Clauses,
1298  FieldType> > operator ()(bool const b,
1299  SpatialOps::
1301  SingleValue,
1302  typename
1303  FieldType::
1304  value_type>
1305  const & f) {
1306  NeboScalar<Initial, bool> typedef Boolean;
1307 
1309  typedef Field;
1310 
1312 
1314 
1315  CondBuilder<Cond> typedef ReturnType;
1316 
1317  return ReturnType(Cond(Clause(Boolean(b), Field(f)), clauses_));
1318  }
1319 
1320  /* full X bool X single-expr */
1321  template<typename Expr>
1322  inline CondBuilder<NeboCond<Initial,
1323  NeboClause<Initial,
1324  NeboScalar<Initial, bool>,
1325  Expr,
1326  FieldType>,
1327  Clauses,
1328  FieldType> > operator ()(bool const b,
1330  typename
1331  FieldType::
1332  value_type>
1333  const & e) {
1334  NeboScalar<Initial, bool> typedef Boolean;
1335 
1337 
1339 
1340  CondBuilder<Cond> typedef ReturnType;
1341 
1342  return ReturnType(Cond(Clause(Boolean(b), e.expr()), clauses_));
1343  }
1344 
1345  /* full X bool X field */
1346  inline CondBuilder<NeboCond<Initial,
1347  NeboClause<Initial,
1348  NeboScalar<Initial, bool>,
1349  NeboConstField<Initial,
1350  FieldType>,
1351  FieldType>,
1352  Clauses,
1353  FieldType> > operator ()(bool const b,
1354  FieldType const &
1355  f) {
1356  NeboScalar<Initial, bool> typedef Boolean;
1357 
1358  NeboConstField<Initial, FieldType> typedef Field;
1359 
1361 
1363 
1364  CondBuilder<Cond> typedef ReturnType;
1365 
1366  return ReturnType(Cond(Clause(Boolean(b), Field(f)), clauses_));
1367  }
1368 
1369  /* full X bool X expr */
1370  template<typename Expr>
1371  inline CondBuilder<NeboCond<Initial,
1372  NeboClause<Initial,
1373  NeboScalar<Initial, bool>,
1374  Expr,
1375  FieldType>,
1376  Clauses,
1377  FieldType> > operator ()(bool const b,
1378  NeboExpression<Expr,
1379  FieldType>
1380  const & e) {
1381  NeboScalar<Initial, bool> typedef Boolean;
1382 
1384 
1386 
1387  CondBuilder<Cond> typedef ReturnType;
1388 
1389  return ReturnType(Cond(Clause(Boolean(b), e.expr()), clauses_));
1390  }
1391 
1392  /* full X single-expr X double */
1393  template<typename BoolExpr>
1394  inline CondBuilder<NeboCond<Initial,
1395  NeboClause<Initial,
1396  BoolExpr,
1397  NeboScalar<Initial,
1398  typename FieldType::
1399  value_type>,
1400  FieldType>,
1401  Clauses,
1402  FieldType> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
1403  typename
1404  FieldType::
1405  value_type>
1406  const & nb,
1407  double const d) {
1409 
1411 
1413 
1414  CondBuilder<Cond> typedef ReturnType;
1415 
1416  return ReturnType(Cond(Clause(nb.expr(), Scalar(d)), clauses_));
1417  }
1418 
1419  /* full X single-expr X single-field */
1420  template<typename BoolExpr>
1421  inline CondBuilder<NeboCond<Initial,
1422  NeboClause<Initial,
1423  BoolExpr,
1424  NeboConstSingleValueField<Initial,
1425  typename
1426  FieldType::
1427  value_type>,
1428  FieldType>,
1429  Clauses,
1430  FieldType> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
1431  typename
1432  FieldType::
1433  value_type>
1434  const & nb,
1435  SpatialOps::
1437  SingleValue,
1438  typename
1439  FieldType::
1440  value_type>
1441  const & f) {
1443  typedef Field;
1444 
1446 
1448 
1449  CondBuilder<Cond> typedef ReturnType;
1450 
1451  return ReturnType(Cond(Clause(nb.expr(), Field(f)), clauses_));
1452  }
1453 
1454  /* full X single-expr X single-expr */
1455  template<typename BoolExpr, typename Expr>
1456  inline CondBuilder<NeboCond<Initial,
1457  NeboClause<Initial,
1458  BoolExpr,
1459  Expr,
1460  FieldType>,
1461  Clauses,
1462  FieldType> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
1463  typename
1464  FieldType::
1465  value_type>
1466  const & nb,
1468  typename
1469  FieldType::
1470  value_type>
1471  const & e) {
1473 
1475 
1476  CondBuilder<Cond> typedef ReturnType;
1477 
1478  return ReturnType(Cond(Clause(nb.expr(), e.expr()), clauses_));
1479  }
1480 
1481  /* full X single-expr X field */
1482  template<typename BoolExpr>
1483  inline CondBuilder<NeboCond<Initial,
1484  NeboClause<Initial,
1485  BoolExpr,
1486  NeboConstField<Initial,
1487  FieldType>,
1488  FieldType>,
1489  Clauses,
1490  FieldType> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
1491  typename
1492  FieldType::
1493  value_type>
1494  const & nb,
1495  FieldType const
1496  & f) {
1497  NeboConstField<Initial, FieldType> typedef Field;
1498 
1500 
1502 
1503  CondBuilder<Cond> typedef ReturnType;
1504 
1505  return ReturnType(Cond(Clause(nb.expr(), Field(f)), clauses_));
1506  }
1507 
1508  /* full X single-expr X expr */
1509  template<typename BoolExpr, typename Expr>
1510  inline CondBuilder<NeboCond<Initial,
1511  NeboClause<Initial,
1512  BoolExpr,
1513  Expr,
1514  FieldType>,
1515  Clauses,
1516  FieldType> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
1517  typename
1518  FieldType::
1519  value_type>
1520  const & nb,
1521  NeboExpression<Expr,
1522  FieldType>
1523  const & e) {
1525 
1527 
1528  CondBuilder<Cond> typedef ReturnType;
1529 
1530  return ReturnType(Cond(Clause(nb.expr(), e.expr()), clauses_));
1531  }
1532 
1533  /* full X expr X double */
1534  template<typename BoolExpr>
1535  inline CondBuilder<NeboCond<Initial,
1536  NeboClause<Initial,
1537  BoolExpr,
1538  NeboScalar<Initial,
1539  typename FieldType::
1540  value_type>,
1541  FieldType>,
1542  Clauses,
1543  FieldType> > operator ()(NeboBooleanExpression<BoolExpr,
1544  FieldType>
1545  const & nb,
1546  double const d) {
1548 
1550 
1552 
1553  CondBuilder<Cond> typedef ReturnType;
1554 
1555  return ReturnType(Cond(Clause(nb.expr(), Scalar(d)), clauses_));
1556  }
1557 
1558  /* full X expr X single-field */
1559  template<typename BoolExpr>
1560  inline CondBuilder<NeboCond<Initial,
1561  NeboClause<Initial,
1562  BoolExpr,
1563  NeboConstSingleValueField<Initial,
1564  typename
1565  FieldType::
1566  value_type>,
1567  FieldType>,
1568  Clauses,
1569  FieldType> > operator ()(NeboBooleanExpression<BoolExpr,
1570  FieldType>
1571  const & nb,
1572  SpatialOps::
1574  SingleValue,
1575  typename
1576  FieldType::
1577  value_type>
1578  const & f) {
1580  typedef Field;
1581 
1583 
1585 
1586  CondBuilder<Cond> typedef ReturnType;
1587 
1588  return ReturnType(Cond(Clause(nb.expr(), Field(f)), clauses_));
1589  }
1590 
1591  /* full X expr X single-expr */
1592  template<typename BoolExpr, typename Expr>
1593  inline CondBuilder<NeboCond<Initial,
1594  NeboClause<Initial,
1595  BoolExpr,
1596  Expr,
1597  FieldType>,
1598  Clauses,
1599  FieldType> > operator ()(NeboBooleanExpression<BoolExpr,
1600  FieldType>
1601  const & nb,
1603  typename
1604  FieldType::
1605  value_type>
1606  const & e) {
1608 
1610 
1611  CondBuilder<Cond> typedef ReturnType;
1612 
1613  return ReturnType(Cond(Clause(nb.expr(), e.expr()), clauses_));
1614  }
1615 
1616  /* full X expr X field */
1617  template<typename BoolExpr>
1618  inline CondBuilder<NeboCond<Initial,
1619  NeboClause<Initial,
1620  BoolExpr,
1621  NeboConstField<Initial,
1622  FieldType>,
1623  FieldType>,
1624  Clauses,
1625  FieldType> > operator ()(NeboBooleanExpression<BoolExpr,
1626  FieldType>
1627  const & nb,
1628  FieldType const
1629  & f) {
1630  NeboConstField<Initial, FieldType> typedef Field;
1631 
1633 
1635 
1636  CondBuilder<Cond> typedef ReturnType;
1637 
1638  return ReturnType(Cond(Clause(nb.expr(), Field(f)), clauses_));
1639  }
1640 
1641  /* full X expr X expr */
1642  template<typename BoolExpr, typename Expr>
1643  inline CondBuilder<NeboCond<Initial,
1644  NeboClause<Initial,
1645  BoolExpr,
1646  Expr,
1647  FieldType>,
1648  Clauses,
1649  FieldType> > operator ()(NeboBooleanExpression<BoolExpr,
1650  FieldType>
1651  const & nb,
1652  NeboExpression<Expr,
1653  FieldType>
1654  const & e) {
1656 
1658 
1659  CondBuilder<Cond> typedef ReturnType;
1660 
1661  return ReturnType(Cond(Clause(nb.expr(), e.expr()), clauses_));
1662  }
1663 
1664  /* full X mask X double */
1665  inline CondBuilder<NeboCond<Initial,
1666  NeboClause<Initial,
1668  NeboScalar<Initial,
1669  typename FieldType::
1670  value_type>,
1671  FieldType>,
1672  Clauses,
1673  FieldType> > operator ()(SpatialMask<FieldType>
1674  const & mask,
1675  double const d) {
1676  NeboMask<Initial, FieldType> typedef Mask;
1677 
1679 
1681 
1683 
1684  CondBuilder<Cond> typedef ReturnType;
1685 
1686  return ReturnType(Cond(Clause(Mask(mask), Scalar(d)), clauses_));
1687  }
1688 
1689  /* full X mask X single-field */
1690  inline CondBuilder<NeboCond<Initial,
1691  NeboClause<Initial,
1692  NeboMask<Initial, FieldType>,
1693  NeboConstSingleValueField<Initial,
1694  typename
1695  FieldType::
1696  value_type>,
1697  FieldType>,
1698  Clauses,
1699  FieldType> > operator ()(SpatialMask<FieldType>
1700  const & mask,
1701  SpatialOps::
1703  SingleValue,
1704  typename
1705  FieldType::
1706  value_type>
1707  const & f) {
1708  NeboMask<Initial, FieldType> typedef Mask;
1709 
1711  typedef Field;
1712 
1714 
1716 
1717  CondBuilder<Cond> typedef ReturnType;
1718 
1719  return ReturnType(Cond(Clause(Mask(mask), Field(f)), clauses_));
1720  }
1721 
1722  /* full X mask X single-expr */
1723  template<typename Expr>
1724  inline CondBuilder<NeboCond<Initial,
1725  NeboClause<Initial,
1726  NeboMask<Initial, FieldType>,
1727  Expr,
1728  FieldType>,
1729  Clauses,
1730  FieldType> > operator ()(SpatialMask<FieldType>
1731  const & mask,
1733  typename
1734  FieldType::
1735  value_type>
1736  const & e) {
1737  NeboMask<Initial, FieldType> typedef Mask;
1738 
1740 
1742 
1743  CondBuilder<Cond> typedef ReturnType;
1744 
1745  return ReturnType(Cond(Clause(Mask(mask), e.expr()), clauses_));
1746  }
1747 
1748  /* full X mask X field */
1749  inline CondBuilder<NeboCond<Initial,
1750  NeboClause<Initial,
1751  NeboMask<Initial, FieldType>,
1752  NeboConstField<Initial,
1753  FieldType>,
1754  FieldType>,
1755  Clauses,
1756  FieldType> > operator ()(SpatialMask<FieldType>
1757  const & mask,
1758  FieldType const &
1759  f) {
1760  NeboMask<Initial, FieldType> typedef Mask;
1761 
1762  NeboConstField<Initial, FieldType> typedef Field;
1763 
1765 
1767 
1768  CondBuilder<Cond> typedef ReturnType;
1769 
1770  return ReturnType(Cond(Clause(Mask(mask), Field(f)), clauses_));
1771  }
1772 
1773  /* full X mask X expr */
1774  template<typename Expr>
1775  inline CondBuilder<NeboCond<Initial,
1776  NeboClause<Initial,
1777  NeboMask<Initial, FieldType>,
1778  Expr,
1779  FieldType>,
1780  Clauses,
1781  FieldType> > operator ()(SpatialMask<FieldType>
1782  const & mask,
1783  NeboExpression<Expr,
1784  FieldType>
1785  const & e) {
1786  NeboMask<Initial, FieldType> typedef Mask;
1787 
1789 
1791 
1792  CondBuilder<Cond> typedef ReturnType;
1793 
1794  return ReturnType(Cond(Clause(Mask(mask), e.expr()), clauses_));
1795  }
1796  };
1797 
1798  template<typename ClauseType, typename Otherwise, typename T>
1799  struct CondBuilder<NeboSingleValueCond<Initial, ClauseType, Otherwise, T>
1800  > {
1801  public:
1803  Clauses;
1804 
1805  private:
1806  template<typename Remaining, typename PreceedingResult>
1807  struct ReverseClausesRecursive;
1808 
1809  template<typename PreceedingResult>
1810  struct ReverseClausesRecursive<NeboNil, PreceedingResult> {
1811  PreceedingResult typedef Result;
1812 
1813  static inline Result reverse(NeboNil const & nil,
1814  PreceedingResult const & r) {
1815  return r;
1816  }
1817  };
1818 
1819  template<typename Next, typename Following, typename PreceedingResult>
1820  struct ReverseClausesRecursive<NeboSingleValueCond<Initial,
1821  Next,
1822  Following,
1823  T>,
1824  PreceedingResult> {
1826 
1828  NewResult;
1829 
1830  ReverseClausesRecursive<Following, NewResult> typedef InternalCall;
1831 
1832  typename InternalCall::Result typedef Result;
1833 
1834  static inline Result reverse(Remaining const & l,
1835  PreceedingResult const & r) {
1836  return InternalCall::reverse(l.otherwise(),
1837  NewResult(l.clause(), r));
1838  }
1839  };
1840 
1841  Clauses const clauses_;
1842 
1843  public:
1845  const & cs)
1846  : clauses_(cs)
1847  {}
1848 
1849  template<typename Final>
1850  struct ReverseClauses;
1851 
1852  template<typename Final>
1853  struct ReverseClauses {
1854  ReverseClausesRecursive<Clauses, Final> typedef InternalCall;
1855 
1856  typename InternalCall::Result typedef Result;
1857 
1858  static inline Result reverse(Clauses const & cs, Final const & f) {
1859  return InternalCall::reverse(cs, f);
1860  }
1861  };
1862 
1863  template<typename Final>
1864  inline typename ReverseClauses<Final>::Result reverse(Final const & f) {
1865  ReverseClauses<Final> typedef InternalCall;
1866 
1867  return InternalCall::reverse(clauses_, f);
1868  }
1869 
1870  /* single X final X double */
1871  inline NeboSingleValueExpression<typename ReverseClauses<NeboScalar<Initial,
1872  T>
1873  >::Result,
1874  T> operator ()(double const d) {
1875  NeboScalar<Initial, T> typedef Scalar;
1876 
1877  typename ReverseClauses<Scalar>::Result typedef ReversedClauses;
1878 
1880 
1881  return ReturnType(reverse(Scalar(d)));
1882  }
1883 
1884  /* single X final X single-field */
1885  inline NeboSingleValueExpression<typename ReverseClauses<NeboConstSingleValueField<Initial,
1886  T>
1887  >::Result,
1888  T> operator ()(SpatialOps::
1890  SingleValue,
1891  T> const
1892  & f) {
1894 
1895  typename ReverseClauses<Field>::Result typedef ReversedClauses;
1896 
1898 
1899  return ReturnType(reverse(Field(f)));
1900  }
1901 
1902  /* single X final X single-expr */
1903  template<typename Expr>
1905  Result,
1906  T> operator ()(NeboSingleValueExpression<Expr,
1907  T>
1908  const & e) {
1909  typename ReverseClauses<Expr>::Result typedef ReversedClauses;
1910 
1912 
1913  return ReturnType(reverse(e.expr()));
1914  }
1915 
1916  /* single X final X field */
1917  template<typename FieldType>
1918  inline NeboExpression<typename ReverseClauses<NeboConstField<Initial,
1919  typename
1920  NeboFieldCheck<typename
1921  FieldType::
1922  field_type,
1923  FieldType>::
1924  Result> >::
1925  Result,
1926  typename NeboFieldCheck<typename FieldType::
1927  field_type,
1928  FieldType>::Result>
1929  operator ()(FieldType const & f) {
1930  NeboConstField<Initial, FieldType> typedef Field;
1931 
1932  typename ReverseClauses<Field>::Result typedef ReversedClauses;
1933 
1934  NeboExpression<ReversedClauses, FieldType> typedef ReturnType;
1935 
1936  return ReturnType(reverse(Field(f)));
1937  }
1938 
1939  /* single X final X expr */
1940  template<typename Expr, typename FieldType>
1942  typename NeboFieldCheck<typename FieldType::
1943  field_type,
1944  FieldType>::Result>
1945  operator ()(NeboExpression<Expr, FieldType> const & e) {
1946  typename ReverseClauses<Expr>::Result typedef ReversedClauses;
1947 
1948  NeboExpression<ReversedClauses, FieldType> typedef ReturnType;
1949 
1950  return ReturnType(reverse(e.expr()));
1951  }
1952 
1953  /* single X bool X double */
1954  inline CondBuilder<NeboSingleValueCond<Initial,
1955  NeboSingleValueClause<Initial,
1956  NeboScalar<Initial,
1957  bool>,
1958  NeboScalar<Initial,
1959  T>,
1960  T>,
1961  Clauses,
1962  T> > operator ()(bool const b,
1963  double const d) {
1964  NeboScalar<Initial, bool> typedef Boolean;
1965 
1966  NeboScalar<Initial, T> typedef Scalar;
1967 
1969 
1971 
1972  CondBuilder<Cond> typedef ReturnType;
1973 
1974  return ReturnType(Cond(Clause(Boolean(b), Scalar(d)), clauses_));
1975  }
1976 
1977  /* single X bool X single-field */
1978  inline CondBuilder<NeboSingleValueCond<Initial,
1979  NeboSingleValueClause<Initial,
1980  NeboScalar<Initial,
1981  bool>,
1982  NeboConstSingleValueField<Initial,
1983  T>,
1984  T>,
1985  Clauses,
1986  T> > operator ()(bool const b,
1987  SpatialOps::
1989  SingleValue,
1990  T>
1991  const & f) {
1992  NeboScalar<Initial, bool> typedef Boolean;
1993 
1995 
1997 
1999 
2000  CondBuilder<Cond> typedef ReturnType;
2001 
2002  return ReturnType(Cond(Clause(Boolean(b), Field(f)), clauses_));
2003  }
2004 
2005  /* single X bool X single-expr */
2006  template<typename Expr>
2007  inline CondBuilder<NeboSingleValueCond<Initial,
2008  NeboSingleValueClause<Initial,
2009  NeboScalar<Initial,
2010  bool>,
2011  Expr,
2012  T>,
2013  Clauses,
2014  T> > operator ()(bool const b,
2016  T>
2017  const & e) {
2018  NeboScalar<Initial, bool> typedef Boolean;
2019 
2021 
2023 
2024  CondBuilder<Cond> typedef ReturnType;
2025 
2026  return ReturnType(Cond(Clause(Boolean(b), e.expr()), clauses_));
2027  }
2028 
2029  /* single X bool X field */
2030  template<typename FieldType>
2031  inline CondBuilder<NeboCond<Initial,
2032  NeboClause<Initial,
2033  NeboScalar<Initial, bool>,
2034  NeboConstField<Initial,
2035  typename
2036  NeboFieldCheck<typename
2037  FieldType::
2038  field_type,
2039  FieldType>::
2040  Result>,
2041  typename NeboFieldCheck<typename
2042  FieldType::
2043  field_type,
2044  FieldType>::
2045  Result>,
2046  typename Clauses::template Convert<typename
2047  NeboFieldCheck<typename
2048  FieldType::
2049  field_type,
2050  FieldType>::
2051  Result>::
2052  Result,
2053  typename NeboFieldCheck<typename
2054  FieldType::
2055  field_type,
2056  FieldType>::
2057  Result> > operator ()(bool const b,
2058  FieldType const & f) {
2059  NeboScalar<Initial, bool> typedef Boolean;
2060 
2061  NeboConstField<Initial, FieldType> typedef Field;
2062 
2064 
2065  typename Clauses::template Convert<FieldType>::Result typedef
2066  ConvertedClauses;
2067 
2069  Cond;
2070 
2071  CondBuilder<Cond> typedef ReturnType;
2072 
2073  return ReturnType(Cond(Clause(Boolean(b), Field(f)),
2074  clauses_.template convert<FieldType>()));
2075  }
2076 
2077  /* single X bool X expr */
2078  template<typename Expr, typename FieldType>
2079  inline CondBuilder<NeboCond<Initial,
2080  NeboClause<Initial,
2081  NeboScalar<Initial, bool>,
2082  Expr,
2083  typename NeboFieldCheck<typename
2084  FieldType::
2085  field_type,
2086  FieldType>::
2087  Result>,
2088  typename Clauses::template Convert<typename
2089  NeboFieldCheck<typename
2090  FieldType::
2091  field_type,
2092  FieldType>::
2093  Result>::
2094  Result,
2095  typename NeboFieldCheck<typename
2096  FieldType::
2097  field_type,
2098  FieldType>::
2099  Result> > operator ()(bool const b,
2100  NeboExpression<Expr,
2101  FieldType>
2102  const & e) {
2103  NeboScalar<Initial, bool> typedef Boolean;
2104 
2106 
2107  typename Clauses::template Convert<FieldType>::Result typedef
2108  ConvertedClauses;
2109 
2111  Cond;
2112 
2113  CondBuilder<Cond> typedef ReturnType;
2114 
2115  return ReturnType(Cond(Clause(Boolean(b), e.expr()),
2116  clauses_.template convert<FieldType>()));
2117  }
2118 
2119  /* single X single-expr X double */
2120  template<typename BoolExpr>
2121  inline CondBuilder<NeboSingleValueCond<Initial,
2122  NeboSingleValueClause<Initial,
2123  BoolExpr,
2124  NeboScalar<Initial,
2125  T>,
2126  T>,
2127  Clauses,
2128  T> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
2129  T>
2130  const & nb,
2131  double const
2132  d) {
2133  NeboScalar<Initial, T> typedef Scalar;
2134 
2136 
2138 
2139  CondBuilder<Cond> typedef ReturnType;
2140 
2141  return ReturnType(Cond(Clause(nb.expr(), Scalar(d)), clauses_));
2142  }
2143 
2144  /* single X single-expr X single-field */
2145  template<typename BoolExpr>
2146  inline CondBuilder<NeboSingleValueCond<Initial,
2147  NeboSingleValueClause<Initial,
2148  BoolExpr,
2149  NeboConstSingleValueField<Initial,
2150  T>,
2151  T>,
2152  Clauses,
2153  T> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
2154  T>
2155  const & nb,
2156  SpatialOps::
2158  SingleValue,
2159  T>
2160  const & f) {
2162 
2164 
2166 
2167  CondBuilder<Cond> typedef ReturnType;
2168 
2169  return ReturnType(Cond(Clause(nb.expr(), Field(f)), clauses_));
2170  }
2171 
2172  /* single X single-expr X single-expr */
2173  template<typename BoolExpr, typename Expr>
2174  inline CondBuilder<NeboSingleValueCond<Initial,
2175  NeboSingleValueClause<Initial,
2176  BoolExpr,
2177  Expr,
2178  T>,
2179  Clauses,
2180  T> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
2181  T>
2182  const & nb,
2184  T>
2185  const & e) {
2187 
2189 
2190  CondBuilder<Cond> typedef ReturnType;
2191 
2192  return ReturnType(Cond(Clause(nb.expr(), e.expr()), clauses_));
2193  }
2194 
2195  /* single X single-expr X field */
2196  template<typename BoolExpr, typename FieldType>
2197  inline CondBuilder<NeboCond<Initial,
2198  NeboClause<Initial,
2199  BoolExpr,
2200  NeboConstField<Initial,
2201  typename
2202  NeboFieldCheck<typename
2203  FieldType::
2204  field_type,
2205  FieldType>::
2206  Result>,
2207  typename NeboFieldCheck<typename
2208  FieldType::
2209  field_type,
2210  FieldType>::
2211  Result>,
2212  typename Clauses::template Convert<typename
2213  NeboFieldCheck<typename
2214  FieldType::
2215  field_type,
2216  FieldType>::
2217  Result>::
2218  Result,
2219  typename NeboFieldCheck<typename
2220  FieldType::
2221  field_type,
2222  FieldType>::
2223  Result> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
2224  typename
2225  FieldType::
2226  value_type>
2227  const & nb,
2228  FieldType const & f) {
2229  NeboConstField<Initial, FieldType> typedef Field;
2230 
2232 
2233  typename Clauses::template Convert<FieldType>::Result typedef
2234  ConvertedClauses;
2235 
2237  Cond;
2238 
2239  CondBuilder<Cond> typedef ReturnType;
2240 
2241  return ReturnType(Cond(Clause(nb.expr(), Field(f)),
2242  clauses_.template convert<FieldType>()));
2243  }
2244 
2245  /* single X single-expr X expr */
2246  template<typename BoolExpr, typename Expr, typename FieldType>
2247  inline CondBuilder<NeboCond<Initial,
2248  NeboClause<Initial,
2249  BoolExpr,
2250  Expr,
2251  typename NeboFieldCheck<typename
2252  FieldType::
2253  field_type,
2254  FieldType>::
2255  Result>,
2256  typename Clauses::template Convert<typename
2257  NeboFieldCheck<typename
2258  FieldType::
2259  field_type,
2260  FieldType>::
2261  Result>::
2262  Result,
2263  typename NeboFieldCheck<typename
2264  FieldType::
2265  field_type,
2266  FieldType>::
2267  Result> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
2268  typename
2269  FieldType::
2270  value_type>
2271  const & nb,
2272  NeboExpression<Expr,
2273  FieldType>
2274  const & e) {
2276 
2277  typename Clauses::template Convert<FieldType>::Result typedef
2278  ConvertedClauses;
2279 
2281  Cond;
2282 
2283  CondBuilder<Cond> typedef ReturnType;
2284 
2285  return ReturnType(Cond(Clause(nb.expr(), e.expr()),
2286  clauses_.template convert<FieldType>()));
2287  }
2288 
2289  /* single X expr X double */
2290  template<typename BoolExpr, typename FieldType>
2291  inline CondBuilder<NeboCond<Initial,
2292  NeboClause<Initial,
2293  BoolExpr,
2294  NeboScalar<Initial,
2295  typename
2296  NeboFieldCheck<typename
2297  FieldType::
2298  field_type,
2299  FieldType>::
2300  Result::value_type>,
2301  typename NeboFieldCheck<typename
2302  FieldType::
2303  field_type,
2304  FieldType>::
2305  Result>,
2306  typename Clauses::template Convert<typename
2307  NeboFieldCheck<typename
2308  FieldType::
2309  field_type,
2310  FieldType>::
2311  Result>::
2312  Result,
2313  typename NeboFieldCheck<typename
2314  FieldType::
2315  field_type,
2316  FieldType>::
2317  Result> > operator ()(NeboBooleanExpression<BoolExpr,
2318  FieldType>
2319  const & nb,
2320  double const d) {
2322 
2324 
2325  typename Clauses::template Convert<FieldType>::Result typedef
2326  ConvertedClauses;
2327 
2329  Cond;
2330 
2331  CondBuilder<Cond> typedef ReturnType;
2332 
2333  return ReturnType(Cond(Clause(nb.expr(), Scalar(d)),
2334  clauses_.template convert<FieldType>()));
2335  }
2336 
2337  /* single X expr X single-field */
2338  template<typename BoolExpr, typename FieldType>
2339  inline CondBuilder<NeboCond<Initial,
2340  NeboClause<Initial,
2341  BoolExpr,
2342  NeboConstSingleValueField<Initial,
2343  typename
2344  NeboFieldCheck<typename
2345  FieldType::
2346  field_type,
2347  FieldType>::
2348  Result::
2349  value_type>,
2350  typename NeboFieldCheck<typename
2351  FieldType::
2352  field_type,
2353  FieldType>::
2354  Result>,
2355  typename Clauses::template Convert<typename
2356  NeboFieldCheck<typename
2357  FieldType::
2358  field_type,
2359  FieldType>::
2360  Result>::
2361  Result,
2362  typename NeboFieldCheck<typename
2363  FieldType::
2364  field_type,
2365  FieldType>::
2366  Result> > operator ()(NeboBooleanExpression<BoolExpr,
2367  FieldType>
2368  const & nb,
2369  SpatialOps::
2371  SingleValue,
2372  typename
2373  FieldType::
2374  value_type>
2375  const & f) {
2377  typedef Field;
2378 
2380 
2381  typename Clauses::template Convert<FieldType>::Result typedef
2382  ConvertedClauses;
2383 
2385  Cond;
2386 
2387  CondBuilder<Cond> typedef ReturnType;
2388 
2389  return ReturnType(Cond(Clause(nb.expr(), Field(f)),
2390  clauses_.template convert<FieldType>()));
2391  }
2392 
2393  /* single X expr X single-expr */
2394  template<typename BoolExpr, typename Expr, typename FieldType>
2395  inline CondBuilder<NeboCond<Initial,
2396  NeboClause<Initial,
2397  BoolExpr,
2398  Expr,
2399  typename NeboFieldCheck<typename
2400  FieldType::
2401  field_type,
2402  FieldType>::
2403  Result>,
2404  typename Clauses::template Convert<typename
2405  NeboFieldCheck<typename
2406  FieldType::
2407  field_type,
2408  FieldType>::
2409  Result>::
2410  Result,
2411  typename NeboFieldCheck<typename
2412  FieldType::
2413  field_type,
2414  FieldType>::
2415  Result> > operator ()(NeboBooleanExpression<BoolExpr,
2416  FieldType>
2417  const & nb,
2419  typename
2420  FieldType::
2421  value_type>
2422  const & e) {
2424 
2425  typename Clauses::template Convert<FieldType>::Result typedef
2426  ConvertedClauses;
2427 
2429  Cond;
2430 
2431  CondBuilder<Cond> typedef ReturnType;
2432 
2433  return ReturnType(Cond(Clause(nb.expr(), e.expr()),
2434  clauses_.template convert<FieldType>()));
2435  }
2436 
2437  /* single X expr X field */
2438  template<typename BoolExpr, typename FieldType>
2439  inline CondBuilder<NeboCond<Initial,
2440  NeboClause<Initial,
2441  BoolExpr,
2442  NeboConstField<Initial,
2443  typename
2444  NeboFieldCheck<typename
2445  FieldType::
2446  field_type,
2447  FieldType>::
2448  Result>,
2449  typename NeboFieldCheck<typename
2450  FieldType::
2451  field_type,
2452  FieldType>::
2453  Result>,
2454  typename Clauses::template Convert<typename
2455  NeboFieldCheck<typename
2456  FieldType::
2457  field_type,
2458  FieldType>::
2459  Result>::
2460  Result,
2461  typename NeboFieldCheck<typename
2462  FieldType::
2463  field_type,
2464  FieldType>::
2465  Result> > operator ()(NeboBooleanExpression<BoolExpr,
2466  FieldType>
2467  const & nb,
2468  FieldType const & f) {
2469  NeboConstField<Initial, FieldType> typedef Field;
2470 
2472 
2473  typename Clauses::template Convert<FieldType>::Result typedef
2474  ConvertedClauses;
2475 
2477  Cond;
2478 
2479  CondBuilder<Cond> typedef ReturnType;
2480 
2481  return ReturnType(Cond(Clause(nb.expr(), Field(f)),
2482  clauses_.template convert<FieldType>()));
2483  }
2484 
2485  /* single X expr X expr */
2486  template<typename BoolExpr, typename Expr, typename FieldType>
2487  inline CondBuilder<NeboCond<Initial,
2488  NeboClause<Initial,
2489  BoolExpr,
2490  Expr,
2491  typename NeboFieldCheck<typename
2492  FieldType::
2493  field_type,
2494  FieldType>::
2495  Result>,
2496  typename Clauses::template Convert<typename
2497  NeboFieldCheck<typename
2498  FieldType::
2499  field_type,
2500  FieldType>::
2501  Result>::
2502  Result,
2503  typename NeboFieldCheck<typename
2504  FieldType::
2505  field_type,
2506  FieldType>::
2507  Result> > operator ()(NeboBooleanExpression<BoolExpr,
2508  FieldType>
2509  const & nb,
2510  NeboExpression<Expr,
2511  FieldType>
2512  const & e) {
2514 
2515  typename Clauses::template Convert<FieldType>::Result typedef
2516  ConvertedClauses;
2517 
2519  Cond;
2520 
2521  CondBuilder<Cond> typedef ReturnType;
2522 
2523  return ReturnType(Cond(Clause(nb.expr(), e.expr()),
2524  clauses_.template convert<FieldType>()));
2525  }
2526 
2527  /* single X mask X double */
2528  template<typename FieldType>
2529  inline CondBuilder<NeboCond<Initial,
2530  NeboClause<Initial,
2531  NeboMask<Initial,
2532  typename
2533  NeboFieldCheck<typename
2534  FieldType::
2535  field_type,
2536  FieldType>::
2537  Result>,
2538  NeboScalar<Initial,
2539  typename
2540  NeboFieldCheck<typename
2541  FieldType::
2542  field_type,
2543  FieldType>::
2544  Result::value_type>,
2545  typename NeboFieldCheck<typename
2546  FieldType::
2547  field_type,
2548  FieldType>::
2549  Result>,
2550  typename Clauses::template Convert<typename
2551  NeboFieldCheck<typename
2552  FieldType::
2553  field_type,
2554  FieldType>::
2555  Result>::
2556  Result,
2557  typename NeboFieldCheck<typename
2558  FieldType::
2559  field_type,
2560  FieldType>::
2561  Result> > operator ()(SpatialMask<FieldType>
2562  const & mask,
2563  double const d) {
2564  NeboMask<Initial, FieldType> typedef Mask;
2565 
2567 
2569 
2570  typename Clauses::template Convert<FieldType>::Result typedef
2571  ConvertedClauses;
2572 
2574  Cond;
2575 
2576  CondBuilder<Cond> typedef ReturnType;
2577 
2578  return ReturnType(Cond(Clause(Mask(mask), Scalar(d)),
2579  clauses_.template convert<FieldType>()));
2580  }
2581 
2582  /* single X mask X single-field */
2583  template<typename FieldType>
2584  inline CondBuilder<NeboCond<Initial,
2585  NeboClause<Initial,
2586  NeboMask<Initial,
2587  typename
2588  NeboFieldCheck<typename
2589  FieldType::
2590  field_type,
2591  FieldType>::
2592  Result>,
2593  NeboConstSingleValueField<Initial,
2594  typename
2595  NeboFieldCheck<typename
2596  FieldType::
2597  field_type,
2598  FieldType>::
2599  Result::
2600  value_type>,
2601  typename NeboFieldCheck<typename
2602  FieldType::
2603  field_type,
2604  FieldType>::
2605  Result>,
2606  typename Clauses::template Convert<typename
2607  NeboFieldCheck<typename
2608  FieldType::
2609  field_type,
2610  FieldType>::
2611  Result>::
2612  Result,
2613  typename NeboFieldCheck<typename
2614  FieldType::
2615  field_type,
2616  FieldType>::
2617  Result> > operator ()(SpatialMask<FieldType>
2618  const & mask,
2619  SpatialOps::
2621  SingleValue,
2622  typename
2623  FieldType::
2624  value_type>
2625  const & f) {
2626  NeboMask<Initial, FieldType> typedef Mask;
2627 
2629  typedef Field;
2630 
2632 
2633  typename Clauses::template Convert<FieldType>::Result typedef
2634  ConvertedClauses;
2635 
2637  Cond;
2638 
2639  CondBuilder<Cond> typedef ReturnType;
2640 
2641  return ReturnType(Cond(Clause(Mask(mask), Field(f)),
2642  clauses_.template convert<FieldType>()));
2643  }
2644 
2645  /* single X mask X single-expr */
2646  template<typename Expr, typename FieldType>
2647  inline CondBuilder<NeboCond<Initial,
2648  NeboClause<Initial,
2649  NeboMask<Initial,
2650  typename
2651  NeboFieldCheck<typename
2652  FieldType::
2653  field_type,
2654  FieldType>::
2655  Result>,
2656  Expr,
2657  typename NeboFieldCheck<typename
2658  FieldType::
2659  field_type,
2660  FieldType>::
2661  Result>,
2662  typename Clauses::template Convert<typename
2663  NeboFieldCheck<typename
2664  FieldType::
2665  field_type,
2666  FieldType>::
2667  Result>::
2668  Result,
2669  typename NeboFieldCheck<typename
2670  FieldType::
2671  field_type,
2672  FieldType>::
2673  Result> > operator ()(SpatialMask<FieldType>
2674  const & mask,
2676  typename
2677  FieldType::
2678  value_type>
2679  const & e) {
2680  NeboMask<Initial, FieldType> typedef Mask;
2681 
2683 
2684  typename Clauses::template Convert<FieldType>::Result typedef
2685  ConvertedClauses;
2686 
2688  Cond;
2689 
2690  CondBuilder<Cond> typedef ReturnType;
2691 
2692  return ReturnType(Cond(Clause(Mask(mask), e.expr()),
2693  clauses_.template convert<FieldType>()));
2694  }
2695 
2696  /* single X mask X field */
2697  template<typename FieldType>
2698  inline CondBuilder<NeboCond<Initial,
2699  NeboClause<Initial,
2700  NeboMask<Initial,
2701  typename
2702  NeboFieldCheck<typename
2703  FieldType::
2704  field_type,
2705  FieldType>::
2706  Result>,
2707  NeboConstField<Initial,
2708  typename
2709  NeboFieldCheck<typename
2710  FieldType::
2711  field_type,
2712  FieldType>::
2713  Result>,
2714  typename NeboFieldCheck<typename
2715  FieldType::
2716  field_type,
2717  FieldType>::
2718  Result>,
2719  typename Clauses::template Convert<typename
2720  NeboFieldCheck<typename
2721  FieldType::
2722  field_type,
2723  FieldType>::
2724  Result>::
2725  Result,
2726  typename NeboFieldCheck<typename
2727  FieldType::
2728  field_type,
2729  FieldType>::
2730  Result> > operator ()(SpatialMask<FieldType>
2731  const & mask,
2732  FieldType const & f) {
2733  NeboMask<Initial, FieldType> typedef Mask;
2734 
2735  NeboConstField<Initial, FieldType> typedef Field;
2736 
2738 
2739  typename Clauses::template Convert<FieldType>::Result typedef
2740  ConvertedClauses;
2741 
2743  Cond;
2744 
2745  CondBuilder<Cond> typedef ReturnType;
2746 
2747  return ReturnType(Cond(Clause(Mask(mask), Field(f)),
2748  clauses_.template convert<FieldType>()));
2749  }
2750 
2751  /* single X mask X expr */
2752  template<typename Expr, typename FieldType>
2753  inline CondBuilder<NeboCond<Initial,
2754  NeboClause<Initial,
2755  NeboMask<Initial,
2756  typename
2757  NeboFieldCheck<typename
2758  FieldType::
2759  field_type,
2760  FieldType>::
2761  Result>,
2762  Expr,
2763  typename NeboFieldCheck<typename
2764  FieldType::
2765  field_type,
2766  FieldType>::
2767  Result>,
2768  typename Clauses::template Convert<typename
2769  NeboFieldCheck<typename
2770  FieldType::
2771  field_type,
2772  FieldType>::
2773  Result>::
2774  Result,
2775  typename NeboFieldCheck<typename
2776  FieldType::
2777  field_type,
2778  FieldType>::
2779  Result> > operator ()(SpatialMask<FieldType>
2780  const & mask,
2781  NeboExpression<Expr,
2782  FieldType>
2783  const & e) {
2784  NeboMask<Initial, FieldType> typedef Mask;
2785 
2787 
2788  typename Clauses::template Convert<FieldType>::Result typedef
2789  ConvertedClauses;
2790 
2792  Cond;
2793 
2794  CondBuilder<Cond> typedef ReturnType;
2795 
2796  return ReturnType(Cond(Clause(Mask(mask), e.expr()),
2797  clauses_.template convert<FieldType>()));
2798  }
2799  };
2800 
2801  template<typename Otherwise>
2802  struct CondBuilder<NeboSimpleCond<Otherwise> > {
2803  public:
2804  NeboSimpleCond<Otherwise> typedef Clauses;
2805 
2806  private:
2807  template<typename Remaining, typename PreceedingResult>
2808  struct ReverseClausesRecursive;
2809 
2810  template<typename PreceedingResult>
2811  struct ReverseClausesRecursive<NeboNil, PreceedingResult> {
2812  PreceedingResult typedef Result;
2813 
2814  static inline Result reverse(NeboNil const & nil,
2815  PreceedingResult const & r) {
2816  return r;
2817  }
2818  };
2819 
2820  template<typename Following, typename PreceedingResult>
2821  struct ReverseClausesRecursive<NeboSimpleCond<Following>,
2822  PreceedingResult> {
2823  NeboSimpleCond<Following> typedef Remaining;
2824 
2825  NeboSimpleCond<PreceedingResult> typedef NewResult;
2826 
2827  ReverseClausesRecursive<Following, NewResult> typedef InternalCall;
2828 
2829  typename InternalCall::Result typedef Result;
2830 
2831  static inline Result reverse(Remaining const & l,
2832  PreceedingResult const & r) {
2833  return InternalCall::reverse(l.otherwise(),
2834  NewResult(l.clause(), r));
2835  }
2836  };
2837 
2838  Clauses const clauses_;
2839 
2840  public:
2842  : clauses_(cs)
2843  {}
2844 
2845  template<typename Final>
2846  struct ReverseClauses;
2847 
2848  template<typename Final>
2849  struct ReverseClauses {
2850  ReverseClausesRecursive<Clauses, Final> typedef InternalCall;
2851 
2852  typename InternalCall::Result typedef Result;
2853 
2854  static inline Result reverse(Clauses const & cs, Final const & f) {
2855  return InternalCall::reverse(cs, f);
2856  }
2857  };
2858 
2859  template<typename Final>
2860  inline typename ReverseClauses<Final>::Result reverse(Final const & f) {
2861  ReverseClauses<Final> typedef InternalCall;
2862 
2863  return InternalCall::reverse(clauses_, f);
2864  }
2865 
2866  /* simple X final X double */
2867  inline double operator ()(double const d) {
2868  return reverse(NeboSimpleFinalClause(d)).eval();
2869  }
2870 
2871  /* simple X final X single-field */
2872  template<typename T>
2873  inline NeboSingleValueExpression<typename CondBuilder<typename
2874  Clauses::
2875  template
2876  SingleConvert<T>::
2877  result>::
2878  template ReverseClauses<NeboConstSingleValueField<Initial,
2879  T>
2880  >::Result,
2881  T> operator ()(SpatialOps::
2883  SingleValue,
2884  T> const
2885  & f) {
2887 
2888  typename Clauses::template SingleConvert<T>::result typedef
2889  ConvertedClauses;
2890 
2891  CondBuilder<ConvertedClauses> typedef NewBuilder;
2892 
2893  typename NewBuilder::template ReverseClauses<Field>::Result
2894  typedef ReversedClauses;
2895 
2897 
2898  return ReturnType(NewBuilder(clauses_.template single_convert<T>()).reverse(Field(f)));
2899  }
2900 
2901  /* simple X final X single-expr */
2902  template<typename Expr, typename T>
2903  inline NeboSingleValueExpression<typename CondBuilder<typename
2904  Clauses::
2905  template
2906  SingleConvert<T>::
2907  result>::
2908  template ReverseClauses<Expr>::
2909  Result,
2910  T> operator ()(NeboSingleValueExpression<Expr,
2911  T>
2912  const & e) {
2913  typename Clauses::template SingleConvert<T>::result typedef
2914  ConvertedClauses;
2915 
2916  CondBuilder<ConvertedClauses> typedef NewBuilder;
2917 
2918  typename NewBuilder::template ReverseClauses<Expr>::Result typedef
2919  ReversedClauses;
2920 
2922 
2923  return ReturnType(NewBuilder(clauses_.template single_convert<T>()).reverse(e.expr()));
2924  }
2925 
2926  /* simple X final X field */
2927  template<typename FieldType>
2928  inline NeboExpression<typename CondBuilder<typename Clauses::template
2929  FullConvert<typename
2930  NeboFieldCheck<typename
2931  FieldType::
2932  field_type,
2933  FieldType>::
2934  Result>::
2935  result>::template
2936  ReverseClauses<NeboConstField<Initial,
2937  typename
2938  NeboFieldCheck<typename
2939  FieldType::
2940  field_type,
2941  FieldType>::
2942  Result> >::Result,
2943  typename NeboFieldCheck<typename FieldType::
2944  field_type,
2945  FieldType>::Result>
2946  operator ()(FieldType const & f) {
2947  NeboConstField<Initial, FieldType> typedef Field;
2948 
2949  typename Clauses::template FullConvert<FieldType>::result typedef
2950  ConvertedClauses;
2951 
2952  CondBuilder<ConvertedClauses> typedef NewBuilder;
2953 
2954  typename NewBuilder::template ReverseClauses<Field>::Result
2955  typedef ReversedClauses;
2956 
2957  NeboExpression<ReversedClauses, FieldType> typedef ReturnType;
2958 
2959  return ReturnType(NewBuilder(clauses_.template full_convert<FieldType>()).reverse(Field(f)));
2960  }
2961 
2962  /* simple X final X expr */
2963  template<typename Expr, typename FieldType>
2964  inline NeboExpression<typename CondBuilder<typename Clauses::template
2965  FullConvert<typename
2966  NeboFieldCheck<typename
2967  FieldType::
2968  field_type,
2969  FieldType>::
2970  Result>::
2971  result>::template
2972  ReverseClauses<Expr>::Result,
2973  typename NeboFieldCheck<typename FieldType::
2974  field_type,
2975  FieldType>::Result>
2976  operator ()(NeboExpression<Expr, FieldType> const & e) {
2977  typename Clauses::template FullConvert<FieldType>::result typedef
2978  ConvertedClauses;
2979 
2980  CondBuilder<ConvertedClauses> typedef NewBuilder;
2981 
2982  typename NewBuilder::template ReverseClauses<Expr>::Result typedef
2983  ReversedClauses;
2984 
2985  NeboExpression<ReversedClauses, FieldType> typedef ReturnType;
2986 
2987  return ReturnType(NewBuilder(clauses_.template full_convert<FieldType>()).reverse(e.expr()));
2988  }
2989 
2990  /* simple X bool X double */
2991  inline CondBuilder<NeboSimpleCond<Clauses> > operator ()(bool const b,
2992  double const
2993  d) {
2994  NeboSimpleCond<Clauses> typedef Cond;
2995 
2996  CondBuilder<Cond> typedef ReturnType;
2997 
2998  return ReturnType(Cond(NeboSimpleClause(b, d), clauses_));
2999  }
3000 
3001  /* simple X bool X single-field */
3002  template<typename T>
3003  inline CondBuilder<NeboSingleValueCond<Initial,
3004  NeboSingleValueClause<Initial,
3005  NeboScalar<Initial,
3006  bool>,
3007  NeboConstSingleValueField<Initial,
3008  T>,
3009  T>,
3010  typename Clauses::template
3011  SingleConvert<T>::result,
3012  T> > operator ()(bool const b,
3013  SpatialOps::
3015  SingleValue,
3016  T>
3017  const & f) {
3018  NeboScalar<Initial, bool> typedef Boolean;
3019 
3021 
3023 
3024  typename Clauses::template SingleConvert<T>::result typedef
3025  ConvertedClauses;
3026 
3028  Cond;
3029 
3030  CondBuilder<Cond> typedef ReturnType;
3031 
3032  return ReturnType(Cond(Clause(Boolean(b), Field(f)),
3033  clauses_.template single_convert<T>()));
3034  }
3035 
3036  /* simple X bool X single-expr */
3037  template<typename Expr, typename T>
3038  inline CondBuilder<NeboSingleValueCond<Initial,
3039  NeboSingleValueClause<Initial,
3040  NeboScalar<Initial,
3041  bool>,
3042  Expr,
3043  T>,
3044  typename Clauses::template
3045  SingleConvert<T>::result,
3046  T> > operator ()(bool const b,
3048  T>
3049  const & e) {
3050  NeboScalar<Initial, bool> typedef Boolean;
3051 
3053 
3054  typename Clauses::template SingleConvert<T>::result typedef
3055  ConvertedClauses;
3056 
3058  Cond;
3059 
3060  CondBuilder<Cond> typedef ReturnType;
3061 
3062  return ReturnType(Cond(Clause(Boolean(b), e.expr()),
3063  clauses_.template single_convert<T>()));
3064  }
3065 
3066  /* simple X bool X field */
3067  template<typename FieldType>
3068  inline CondBuilder<NeboCond<Initial,
3069  NeboClause<Initial,
3070  NeboScalar<Initial, bool>,
3071  NeboConstField<Initial,
3072  typename
3073  NeboFieldCheck<typename
3074  FieldType::
3075  field_type,
3076  FieldType>::
3077  Result>,
3078  typename NeboFieldCheck<typename
3079  FieldType::
3080  field_type,
3081  FieldType>::
3082  Result>,
3083  typename Clauses::template FullConvert<typename
3084  NeboFieldCheck<typename
3085  FieldType::
3086  field_type,
3087  FieldType>::
3088  Result>::
3089  result,
3090  typename NeboFieldCheck<typename
3091  FieldType::
3092  field_type,
3093  FieldType>::
3094  Result> > operator ()(bool const b,
3095  FieldType const & f) {
3096  NeboScalar<Initial, bool> typedef Boolean;
3097 
3098  NeboConstField<Initial, FieldType> typedef Field;
3099 
3101 
3102  typename Clauses::template FullConvert<FieldType>::result typedef
3103  ConvertedClauses;
3104 
3106  Cond;
3107 
3108  CondBuilder<Cond> typedef ReturnType;
3109 
3110  return ReturnType(Cond(Clause(Boolean(b), Field(f)),
3111  clauses_.template full_convert<FieldType>()));
3112  }
3113 
3114  /* simple X bool X expr */
3115  template<typename Expr, typename FieldType>
3116  inline CondBuilder<NeboCond<Initial,
3117  NeboClause<Initial,
3118  NeboScalar<Initial, bool>,
3119  Expr,
3120  typename NeboFieldCheck<typename
3121  FieldType::
3122  field_type,
3123  FieldType>::
3124  Result>,
3125  typename Clauses::template FullConvert<typename
3126  NeboFieldCheck<typename
3127  FieldType::
3128  field_type,
3129  FieldType>::
3130  Result>::
3131  result,
3132  typename NeboFieldCheck<typename
3133  FieldType::
3134  field_type,
3135  FieldType>::
3136  Result> > operator ()(bool const b,
3137  NeboExpression<Expr,
3138  FieldType>
3139  const & e) {
3140  NeboScalar<Initial, bool> typedef Boolean;
3141 
3143 
3144  typename Clauses::template FullConvert<FieldType>::result typedef
3145  ConvertedClauses;
3146 
3148  Cond;
3149 
3150  CondBuilder<Cond> typedef ReturnType;
3151 
3152  return ReturnType(Cond(Clause(Boolean(b), e.expr()),
3153  clauses_.template full_convert<FieldType>()));
3154  }
3155 
3156  /* simple X single-expr X double */
3157  template<typename BoolExpr, typename T>
3158  inline CondBuilder<NeboSingleValueCond<Initial,
3159  NeboSingleValueClause<Initial,
3160  BoolExpr,
3161  NeboScalar<Initial,
3162  T>,
3163  T>,
3164  typename Clauses::template
3165  SingleConvert<T>::result,
3166  T> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
3167  T>
3168  const & nb,
3169  double const
3170  d) {
3171  NeboScalar<Initial, T> typedef Scalar;
3172 
3174 
3175  typename Clauses::template SingleConvert<T>::result typedef
3176  ConvertedClauses;
3177 
3179  Cond;
3180 
3181  CondBuilder<Cond> typedef ReturnType;
3182 
3183  return ReturnType(Cond(Clause(nb.expr(), Scalar(d)),
3184  clauses_.template single_convert<T>()));
3185  }
3186 
3187  /* simple X single-expr X single-field */
3188  template<typename BoolExpr, typename T>
3189  inline CondBuilder<NeboSingleValueCond<Initial,
3190  NeboSingleValueClause<Initial,
3191  BoolExpr,
3192  NeboConstSingleValueField<Initial,
3193  T>,
3194  T>,
3195  typename Clauses::template
3196  SingleConvert<T>::result,
3197  T> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
3198  T>
3199  const & nb,
3200  SpatialOps::
3202  SingleValue,
3203  T>
3204  const & f) {
3206 
3208 
3209  typename Clauses::template SingleConvert<T>::result typedef
3210  ConvertedClauses;
3211 
3213  Cond;
3214 
3215  CondBuilder<Cond> typedef ReturnType;
3216 
3217  return ReturnType(Cond(Clause(nb.expr(), Field(f)),
3218  clauses_.template single_convert<T>()));
3219  }
3220 
3221  /* simple X single-expr X single-expr */
3222  template<typename BoolExpr, typename Expr, typename T>
3223  inline CondBuilder<NeboSingleValueCond<Initial,
3224  NeboSingleValueClause<Initial,
3225  BoolExpr,
3226  Expr,
3227  T>,
3228  typename Clauses::template
3229  SingleConvert<T>::result,
3230  T> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
3231  T>
3232  const & nb,
3234  T>
3235  const & e) {
3237 
3238  typename Clauses::template SingleConvert<T>::result typedef
3239  ConvertedClauses;
3240 
3242  Cond;
3243 
3244  CondBuilder<Cond> typedef ReturnType;
3245 
3246  return ReturnType(Cond(Clause(nb.expr(), e.expr()),
3247  clauses_.template single_convert<T>()));
3248  }
3249 
3250  /* simple X single-expr X field */
3251  template<typename BoolExpr, typename FieldType>
3252  inline CondBuilder<NeboCond<Initial,
3253  NeboClause<Initial,
3254  BoolExpr,
3255  NeboConstField<Initial,
3256  typename
3257  NeboFieldCheck<typename
3258  FieldType::
3259  field_type,
3260  FieldType>::
3261  Result>,
3262  typename NeboFieldCheck<typename
3263  FieldType::
3264  field_type,
3265  FieldType>::
3266  Result>,
3267  typename Clauses::template FullConvert<typename
3268  NeboFieldCheck<typename
3269  FieldType::
3270  field_type,
3271  FieldType>::
3272  Result>::
3273  result,
3274  typename NeboFieldCheck<typename
3275  FieldType::
3276  field_type,
3277  FieldType>::
3278  Result> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
3279  typename
3280  FieldType::
3281  value_type>
3282  const & nb,
3283  FieldType const & f) {
3284  NeboConstField<Initial, FieldType> typedef Field;
3285 
3287 
3288  typename Clauses::template FullConvert<FieldType>::result typedef
3289  ConvertedClauses;
3290 
3292  Cond;
3293 
3294  CondBuilder<Cond> typedef ReturnType;
3295 
3296  return ReturnType(Cond(Clause(nb.expr(), Field(f)),
3297  clauses_.template full_convert<FieldType>()));
3298  }
3299 
3300  /* simple X single-expr X expr */
3301  template<typename BoolExpr, typename Expr, typename FieldType>
3302  inline CondBuilder<NeboCond<Initial,
3303  NeboClause<Initial,
3304  BoolExpr,
3305  Expr,
3306  typename NeboFieldCheck<typename
3307  FieldType::
3308  field_type,
3309  FieldType>::
3310  Result>,
3311  typename Clauses::template FullConvert<typename
3312  NeboFieldCheck<typename
3313  FieldType::
3314  field_type,
3315  FieldType>::
3316  Result>::
3317  result,
3318  typename NeboFieldCheck<typename
3319  FieldType::
3320  field_type,
3321  FieldType>::
3322  Result> > operator ()(NeboBooleanSingleValueExpression<BoolExpr,
3323  typename
3324  FieldType::
3325  value_type>
3326  const & nb,
3327  NeboExpression<Expr,
3328  FieldType>
3329  const & e) {
3331 
3332  typename Clauses::template FullConvert<FieldType>::result typedef
3333  ConvertedClauses;
3334 
3336  Cond;
3337 
3338  CondBuilder<Cond> typedef ReturnType;
3339 
3340  return ReturnType(Cond(Clause(nb.expr(), e.expr()),
3341  clauses_.template full_convert<FieldType>()));
3342  }
3343 
3344  /* simple X expr X double */
3345  template<typename BoolExpr, typename FieldType>
3346  inline CondBuilder<NeboCond<Initial,
3347  NeboClause<Initial,
3348  BoolExpr,
3349  NeboScalar<Initial,
3350  typename
3351  NeboFieldCheck<typename
3352  FieldType::
3353  field_type,
3354  FieldType>::
3355  Result::value_type>,
3356  typename NeboFieldCheck<typename
3357  FieldType::
3358  field_type,
3359  FieldType>::
3360  Result>,
3361  typename Clauses::template FullConvert<typename
3362  NeboFieldCheck<typename
3363  FieldType::
3364  field_type,
3365  FieldType>::
3366  Result>::
3367  result,
3368  typename NeboFieldCheck<typename
3369  FieldType::
3370  field_type,
3371  FieldType>::
3372  Result> > operator ()(NeboBooleanExpression<BoolExpr,
3373  FieldType>
3374  const & nb,
3375  double const d) {
3377 
3379 
3380  typename Clauses::template FullConvert<FieldType>::result typedef
3381  ConvertedClauses;
3382 
3384  Cond;
3385 
3386  CondBuilder<Cond> typedef ReturnType;
3387 
3388  return ReturnType(Cond(Clause(nb.expr(), Scalar(d)),
3389  clauses_.template full_convert<FieldType>()));
3390  }
3391 
3392  /* simple X expr X single-field */
3393  template<typename BoolExpr, typename FieldType>
3394  inline CondBuilder<NeboCond<Initial,
3395  NeboClause<Initial,
3396  BoolExpr,
3397  NeboConstSingleValueField<Initial,
3398  typename
3399  NeboFieldCheck<typename
3400  FieldType::
3401  field_type,
3402  FieldType>::
3403  Result::
3404  value_type>,
3405  typename NeboFieldCheck<typename
3406  FieldType::
3407  field_type,
3408  FieldType>::
3409  Result>,
3410  typename Clauses::template FullConvert<typename
3411  NeboFieldCheck<typename
3412  FieldType::
3413  field_type,
3414  FieldType>::
3415  Result>::
3416  result,
3417  typename NeboFieldCheck<typename
3418  FieldType::
3419  field_type,
3420  FieldType>::
3421  Result> > operator ()(NeboBooleanExpression<BoolExpr,
3422  FieldType>
3423  const & nb,
3424  SpatialOps::
3426  SingleValue,
3427  typename
3428  FieldType::
3429  value_type>
3430  const & f) {
3432  typedef Field;
3433 
3435 
3436  typename Clauses::template FullConvert<FieldType>::result typedef
3437  ConvertedClauses;
3438 
3440  Cond;
3441 
3442  CondBuilder<Cond> typedef ReturnType;
3443 
3444  return ReturnType(Cond(Clause(nb.expr(), Field(f)),
3445  clauses_.template full_convert<FieldType>()));
3446  }
3447 
3448  /* simple X expr X single-expr */
3449  template<typename BoolExpr, typename Expr, typename FieldType>
3450  inline CondBuilder<NeboCond<Initial,
3451  NeboClause<Initial,
3452  BoolExpr,
3453  Expr,
3454  typename NeboFieldCheck<typename
3455  FieldType::
3456  field_type,
3457  FieldType>::
3458  Result>,
3459  typename Clauses::template FullConvert<typename
3460  NeboFieldCheck<typename
3461  FieldType::
3462  field_type,
3463  FieldType>::
3464  Result>::
3465  result,
3466  typename NeboFieldCheck<typename
3467  FieldType::
3468  field_type,
3469  FieldType>::
3470  Result> > operator ()(NeboBooleanExpression<BoolExpr,
3471  FieldType>
3472  const & nb,
3474  typename
3475  FieldType::
3476  value_type>
3477  const & e) {
3479 
3480  typename Clauses::template FullConvert<FieldType>::result typedef
3481  ConvertedClauses;
3482 
3484  Cond;
3485 
3486  CondBuilder<Cond> typedef ReturnType;
3487 
3488  return ReturnType(Cond(Clause(nb.expr(), e.expr()),
3489  clauses_.template full_convert<FieldType>()));
3490  }
3491 
3492  /* simple X expr X field */
3493  template<typename BoolExpr, typename FieldType>
3494  inline CondBuilder<NeboCond<Initial,
3495  NeboClause<Initial,
3496  BoolExpr,
3497  NeboConstField<Initial,
3498  typename
3499  NeboFieldCheck<typename
3500  FieldType::
3501  field_type,
3502  FieldType>::
3503  Result>,
3504  typename NeboFieldCheck<typename
3505  FieldType::
3506  field_type,
3507  FieldType>::
3508  Result>,
3509  typename Clauses::template FullConvert<typename
3510  NeboFieldCheck<typename
3511  FieldType::
3512  field_type,
3513  FieldType>::
3514  Result>::
3515  result,
3516  typename NeboFieldCheck<typename
3517  FieldType::
3518  field_type,
3519  FieldType>::
3520  Result> > operator ()(NeboBooleanExpression<BoolExpr,
3521  FieldType>
3522  const & nb,
3523  FieldType const & f) {
3524  NeboConstField<Initial, FieldType> typedef Field;
3525 
3527 
3528  typename Clauses::template FullConvert<FieldType>::result typedef
3529  ConvertedClauses;
3530 
3532  Cond;
3533 
3534  CondBuilder<Cond> typedef ReturnType;
3535 
3536  return ReturnType(Cond(Clause(nb.expr(), Field(f)),
3537  clauses_.template full_convert<FieldType>()));
3538  }
3539 
3540  /* simple X expr X expr */
3541  template<typename BoolExpr, typename Expr, typename FieldType>
3542  inline CondBuilder<NeboCond<Initial,
3543  NeboClause<Initial,
3544  BoolExpr,
3545  Expr,
3546  typename NeboFieldCheck<typename
3547  FieldType::
3548  field_type,
3549  FieldType>::
3550  Result>,
3551  typename Clauses::template FullConvert<typename
3552  NeboFieldCheck<typename
3553  FieldType::
3554  field_type,
3555  FieldType>::
3556  Result>::
3557  result,
3558  typename NeboFieldCheck<typename
3559  FieldType::
3560  field_type,
3561  FieldType>::
3562  Result> > operator ()(NeboBooleanExpression<BoolExpr,
3563  FieldType>
3564  const & nb,
3565  NeboExpression<Expr,
3566  FieldType>
3567  const & e) {
3569 
3570  typename Clauses::template FullConvert<FieldType>::result typedef
3571  ConvertedClauses;
3572 
3574  Cond;
3575 
3576  CondBuilder<Cond> typedef ReturnType;
3577 
3578  return ReturnType(Cond(Clause(nb.expr(), e.expr()),
3579  clauses_.template full_convert<FieldType>()));
3580  }
3581 
3582  /* simple X mask X double */
3583  template<typename FieldType>
3584  inline CondBuilder<NeboCond<Initial,
3585  NeboClause<Initial,
3586  NeboMask<Initial,
3587  typename
3588  NeboFieldCheck<typename
3589  FieldType::
3590  field_type,
3591  FieldType>::
3592  Result>,
3593  NeboScalar<Initial,
3594  typename
3595  NeboFieldCheck<typename
3596  FieldType::
3597  field_type,
3598  FieldType>::
3599  Result::value_type>,
3600  typename NeboFieldCheck<typename
3601  FieldType::
3602  field_type,
3603  FieldType>::
3604  Result>,
3605  typename Clauses::template FullConvert<typename
3606  NeboFieldCheck<typename
3607  FieldType::
3608  field_type,
3609  FieldType>::
3610  Result>::
3611  result,
3612  typename NeboFieldCheck<typename
3613  FieldType::
3614  field_type,
3615  FieldType>::
3616  Result> > operator ()(SpatialMask<FieldType>
3617  const & mask,
3618  double const d) {
3619  NeboMask<Initial, FieldType> typedef Mask;
3620 
3622 
3624 
3625  typename Clauses::template FullConvert<FieldType>::result typedef
3626  ConvertedClauses;
3627 
3629  Cond;
3630 
3631  CondBuilder<Cond> typedef ReturnType;
3632 
3633  return ReturnType(Cond(Clause(Mask(mask), Scalar(d)),
3634  clauses_.template full_convert<FieldType>()));
3635  }
3636 
3637  /* simple X mask X single-field */
3638  template<typename FieldType>
3639  inline CondBuilder<NeboCond<Initial,
3640  NeboClause<Initial,
3641  NeboMask<Initial,
3642  typename
3643  NeboFieldCheck<typename
3644  FieldType::
3645  field_type,
3646  FieldType>::
3647  Result>,
3648  NeboConstSingleValueField<Initial,
3649  typename
3650  NeboFieldCheck<typename
3651  FieldType::
3652  field_type,
3653  FieldType>::
3654  Result::
3655  value_type>,
3656  typename NeboFieldCheck<typename
3657  FieldType::
3658  field_type,
3659  FieldType>::
3660  Result>,
3661  typename Clauses::template FullConvert<typename
3662  NeboFieldCheck<typename
3663  FieldType::
3664  field_type,
3665  FieldType>::
3666  Result>::
3667  result,
3668  typename NeboFieldCheck<typename
3669  FieldType::
3670  field_type,
3671  FieldType>::
3672  Result> > operator ()(SpatialMask<FieldType>
3673  const & mask,
3674  SpatialOps::
3676  SingleValue,
3677  typename
3678  FieldType::
3679  value_type>
3680  const & f) {
3681  NeboMask<Initial, FieldType> typedef Mask;
3682 
3684  typedef Field;
3685 
3687 
3688  typename Clauses::template FullConvert<FieldType>::result typedef
3689  ConvertedClauses;
3690 
3692  Cond;
3693 
3694  CondBuilder<Cond> typedef ReturnType;
3695 
3696  return ReturnType(Cond(Clause(Mask(mask), Field(f)),
3697  clauses_.template full_convert<FieldType>()));
3698  }
3699 
3700  /* simple X mask X single-expr */
3701  template<typename Expr, typename FieldType>
3702  inline CondBuilder<NeboCond<Initial,
3703  NeboClause<Initial,
3704  NeboMask<Initial,
3705  typename
3706  NeboFieldCheck<typename
3707  FieldType::
3708  field_type,
3709  FieldType>::
3710  Result>,
3711  Expr,
3712  typename NeboFieldCheck<typename
3713  FieldType::
3714  field_type,
3715  FieldType>::
3716  Result>,
3717  typename Clauses::template FullConvert<typename
3718  NeboFieldCheck<typename
3719  FieldType::
3720  field_type,
3721  FieldType>::
3722  Result>::
3723  result,
3724  typename NeboFieldCheck<typename
3725  FieldType::
3726  field_type,
3727  FieldType>::
3728  Result> > operator ()(SpatialMask<FieldType>
3729  const & mask,
3731  typename
3732  FieldType::
3733  value_type>
3734  const & e) {
3735  NeboMask<Initial, FieldType> typedef Mask;
3736 
3738 
3739  typename Clauses::template FullConvert<FieldType>::result typedef
3740  ConvertedClauses;
3741 
3743  Cond;
3744 
3745  CondBuilder<Cond> typedef ReturnType;
3746 
3747  return ReturnType(Cond(Clause(Mask(mask), e.expr()),
3748  clauses_.template full_convert<FieldType>()));
3749  }
3750 
3751  /* simple X mask X field */
3752  template<typename FieldType>
3753  inline CondBuilder<NeboCond<Initial,
3754  NeboClause<Initial,
3755  NeboMask<Initial,
3756  typename
3757  NeboFieldCheck<typename
3758  FieldType::
3759  field_type,
3760  FieldType>::
3761  Result>,
3762  NeboConstField<Initial,
3763  typename
3764  NeboFieldCheck<typename
3765  FieldType::
3766  field_type,
3767  FieldType>::
3768  Result>,
3769  typename NeboFieldCheck<typename
3770  FieldType::
3771  field_type,
3772  FieldType>::
3773  Result>,
3774  typename Clauses::template FullConvert<typename
3775  NeboFieldCheck<typename
3776  FieldType::
3777  field_type,
3778  FieldType>::
3779  Result>::
3780  result,
3781  typename NeboFieldCheck<typename
3782  FieldType::
3783  field_type,
3784  FieldType>::
3785  Result> > operator ()(SpatialMask<FieldType>
3786  const & mask,
3787  FieldType const & f) {
3788  NeboMask<Initial, FieldType> typedef Mask;
3789 
3790  NeboConstField<Initial, FieldType> typedef Field;
3791 
3793 
3794  typename Clauses::template FullConvert<FieldType>::result typedef
3795  ConvertedClauses;
3796 
3798  Cond;
3799 
3800  CondBuilder<Cond> typedef ReturnType;
3801 
3802  return ReturnType(Cond(Clause(Mask(mask), Field(f)),
3803  clauses_.template full_convert<FieldType>()));
3804  }
3805 
3806  /* simple X mask X expr */
3807  template<typename Expr, typename FieldType>
3808  inline CondBuilder<NeboCond<Initial,
3809  NeboClause<Initial,
3810  NeboMask<Initial,
3811  typename
3812  NeboFieldCheck<typename
3813  FieldType::
3814  field_type,
3815  FieldType>::
3816  Result>,
3817  Expr,
3818  typename NeboFieldCheck<typename
3819  FieldType::
3820  field_type,
3821  FieldType>::
3822  Result>,
3823  typename Clauses::template FullConvert<typename
3824  NeboFieldCheck<typename
3825  FieldType::
3826  field_type,
3827  FieldType>::
3828  Result>::
3829  result,
3830  typename NeboFieldCheck<typename
3831  FieldType::
3832  field_type,
3833  FieldType>::
3834  Result> > operator ()(SpatialMask<FieldType>
3835  const & mask,
3836  NeboExpression<Expr,
3837  FieldType>
3838  const & e) {
3839  NeboMask<Initial, FieldType> typedef Mask;
3840 
3842 
3843  typename Clauses::template FullConvert<FieldType>::result typedef
3844  ConvertedClauses;
3845 
3847  Cond;
3848 
3849  CondBuilder<Cond> typedef ReturnType;
3850 
3851  return ReturnType(Cond(Clause(Mask(mask), e.expr()),
3852  clauses_.template full_convert<FieldType>()));
3853  }
3854  };
3855 
3856  template<>
3857  struct CondBuilder<NeboNil> {
3858  public:
3859  CondBuilder() {}
3860  };
3861 
3862  /* none X final X double */
3863  inline double cond(double const d) { return d; };
3864 
3865  /* none X final X single-field */
3866  template<typename T>
3870 
3871  NeboSingleValueExpression<Field, T> typedef ReturnType;
3872 
3873  return ReturnType(Field(f));
3874  };
3875 
3876  /* none X final X single-expr */
3877  template<typename Expr, typename T>
3879  T>
3880  const & e) { return e; };
3881 
3882  /* none X final X field */
3883  template<typename FieldType>
3884  inline NeboExpression<NeboConstField<Initial,
3885  typename NeboFieldCheck<typename
3886  FieldType::
3887  field_type,
3888  FieldType>::
3889  Result>,
3890  typename NeboFieldCheck<typename FieldType::
3891  field_type,
3892  FieldType>::Result> cond(FieldType
3893  const
3894  &
3895  f) {
3896  NeboConstField<Initial, FieldType> typedef Field;
3897 
3898  NeboExpression<Field, FieldType> typedef ReturnType;
3899 
3900  return ReturnType(Field(f));
3901  };
3902 
3903  /* none X final X expr */
3904  template<typename Expr, typename FieldType>
3905  inline NeboExpression<Expr,
3906  typename NeboFieldCheck<typename FieldType::
3907  field_type,
3908  FieldType>::Result> cond(NeboExpression<Expr,
3909  FieldType>
3910  const
3911  &
3912  e) {
3913  return e;
3914  };
3915 
3916  /* none X bool X double */
3917  inline CondBuilder<NeboSimpleCond<NeboNil> > cond(bool const b,
3918  double const d) {
3919  NeboSimpleCond<NeboNil> typedef Cond;
3920 
3921  CondBuilder<Cond> typedef ReturnType;
3922 
3923  return ReturnType(Cond(NeboSimpleClause(b, d), NeboNil()));
3924  };
3925 
3926  /* none X bool X single-field */
3927  template<typename T>
3928  inline CondBuilder<NeboSingleValueCond<Initial,
3929  NeboSingleValueClause<Initial,
3930  NeboScalar<Initial,
3931  bool>,
3932  NeboConstSingleValueField<Initial,
3933  T>,
3934  T>,
3935  NeboNil,
3936  T> > cond(bool const b,
3938  SingleValue,
3939  T>
3940  const & f) {
3941  NeboScalar<Initial, bool> typedef Boolean;
3942 
3944 
3946 
3948 
3949  CondBuilder<Cond> typedef ReturnType;
3950 
3951  return ReturnType(Cond(Clause(Boolean(b), Field(f)), NeboNil()));
3952  };
3953 
3954  /* none X bool X single-expr */
3955  template<typename Expr, typename T>
3956  inline CondBuilder<NeboSingleValueCond<Initial,
3957  NeboSingleValueClause<Initial,
3958  NeboScalar<Initial,
3959  bool>,
3960  Expr,
3961  T>,
3962  NeboNil,
3963  T> > cond(bool const b,
3965  T>
3966  const & e) {
3967  NeboScalar<Initial, bool> typedef Boolean;
3968 
3970 
3972 
3973  CondBuilder<Cond> typedef ReturnType;
3974 
3975  return ReturnType(Cond(Clause(Boolean(b), e.expr()), NeboNil()));
3976  };
3977 
3978  /* none X bool X field */
3979  template<typename FieldType>
3980  inline CondBuilder<NeboCond<Initial,
3981  NeboClause<Initial,
3982  NeboScalar<Initial, bool>,
3983  NeboConstField<Initial,
3984  typename
3985  NeboFieldCheck<typename
3986  FieldType::
3987  field_type,
3988  FieldType>::
3989  Result>,
3990  typename NeboFieldCheck<typename
3991  FieldType::
3992  field_type,
3993  FieldType>::
3994  Result>,
3995  NeboNil,
3996  typename NeboFieldCheck<typename FieldType::
3997  field_type,
3998  FieldType>::Result> >
3999  cond(bool const b, FieldType const & f) {
4000  NeboScalar<Initial, bool> typedef Boolean;
4001 
4002  NeboConstField<Initial, FieldType> typedef Field;
4003 
4005 
4007 
4008  CondBuilder<Cond> typedef ReturnType;
4009 
4010  return ReturnType(Cond(Clause(Boolean(b), Field(f)), NeboNil()));
4011  };
4012 
4013  /* none X bool X expr */
4014  template<typename Expr, typename FieldType>
4015  inline CondBuilder<NeboCond<Initial,
4016  NeboClause<Initial,
4017  NeboScalar<Initial, bool>,
4018  Expr,
4019  typename NeboFieldCheck<typename
4020  FieldType::
4021  field_type,
4022  FieldType>::
4023  Result>,
4024  NeboNil,
4025  typename NeboFieldCheck<typename FieldType::
4026  field_type,
4027  FieldType>::Result> >
4028  cond(bool const b, NeboExpression<Expr, FieldType> const & e) {
4029  NeboScalar<Initial, bool> typedef Boolean;
4030 
4032 
4034 
4035  CondBuilder<Cond> typedef ReturnType;
4036 
4037  return ReturnType(Cond(Clause(Boolean(b), e.expr()), NeboNil()));
4038  };
4039 
4040  /* none X single-expr X double */
4041  template<typename BoolExpr, typename T>
4042  inline CondBuilder<NeboSingleValueCond<Initial,
4043  NeboSingleValueClause<Initial,
4044  BoolExpr,
4045  NeboScalar<Initial,
4046  T>,
4047  T>,
4048  NeboNil,
4049  T> > cond(NeboBooleanSingleValueExpression<BoolExpr,
4050  T>
4051  const & nb,
4052  double const d) {
4053  NeboScalar<Initial, T> typedef Scalar;
4054 
4056 
4058 
4059  CondBuilder<Cond> typedef ReturnType;
4060 
4061  return ReturnType(Cond(Clause(nb.expr(), Scalar(d)), NeboNil()));
4062  };
4063 
4064  /* none X single-expr X single-field */
4065  template<typename BoolExpr, typename T>
4066  inline CondBuilder<NeboSingleValueCond<Initial,
4067  NeboSingleValueClause<Initial,
4068  BoolExpr,
4069  NeboConstSingleValueField<Initial,
4070  T>,
4071  T>,
4072  NeboNil,
4073  T> > cond(NeboBooleanSingleValueExpression<BoolExpr,
4074  T>
4075  const & nb,
4077  SingleValue,
4078  T>
4079  const & f) {
4081 
4083 
4085 
4086  CondBuilder<Cond> typedef ReturnType;
4087 
4088  return ReturnType(Cond(Clause(nb.expr(), Field(f)), NeboNil()));
4089  };
4090 
4091  /* none X single-expr X single-expr */
4092  template<typename BoolExpr, typename Expr, typename T>
4093  inline CondBuilder<NeboSingleValueCond<Initial,
4094  NeboSingleValueClause<Initial,
4095  BoolExpr,
4096  Expr,
4097  T>,
4098  NeboNil,
4099  T> > cond(NeboBooleanSingleValueExpression<BoolExpr,
4100  T>
4101  const & nb,
4103  T>
4104  const & e) {
4106 
4108 
4109  CondBuilder<Cond> typedef ReturnType;
4110 
4111  return ReturnType(Cond(Clause(nb.expr(), e.expr()), NeboNil()));
4112  };
4113 
4114  /* none X single-expr X field */
4115  template<typename BoolExpr, typename FieldType>
4116  inline CondBuilder<NeboCond<Initial,
4117  NeboClause<Initial,
4118  BoolExpr,
4119  NeboConstField<Initial,
4120  typename
4121  NeboFieldCheck<typename
4122  FieldType::
4123  field_type,
4124  FieldType>::
4125  Result>,
4126  typename NeboFieldCheck<typename
4127  FieldType::
4128  field_type,
4129  FieldType>::
4130  Result>,
4131  NeboNil,
4132  typename NeboFieldCheck<typename FieldType::
4133  field_type,
4134  FieldType>::Result> >
4135  cond(NeboBooleanSingleValueExpression<BoolExpr,
4136  typename FieldType::value_type>
4137  const & nb,
4138  FieldType const & f) {
4139  NeboConstField<Initial, FieldType> typedef Field;
4140 
4142 
4144 
4145  CondBuilder<Cond> typedef ReturnType;
4146 
4147  return ReturnType(Cond(Clause(nb.expr(), Field(f)), NeboNil()));
4148  };
4149 
4150  /* none X single-expr X expr */
4151  template<typename BoolExpr, typename Expr, typename FieldType>
4152  inline CondBuilder<NeboCond<Initial,
4153  NeboClause<Initial,
4154  BoolExpr,
4155  Expr,
4156  typename NeboFieldCheck<typename
4157  FieldType::
4158  field_type,
4159  FieldType>::
4160  Result>,
4161  NeboNil,
4162  typename NeboFieldCheck<typename FieldType::
4163  field_type,
4164  FieldType>::Result> >
4165  cond(NeboBooleanSingleValueExpression<BoolExpr,
4166  typename FieldType::value_type>
4167  const & nb,
4168  NeboExpression<Expr, FieldType> const & e) {
4170 
4172 
4173  CondBuilder<Cond> typedef ReturnType;
4174 
4175  return ReturnType(Cond(Clause(nb.expr(), e.expr()), NeboNil()));
4176  };
4177 
4178  /* none X expr X double */
4179  template<typename BoolExpr, typename FieldType>
4180  inline CondBuilder<NeboCond<Initial,
4181  NeboClause<Initial,
4182  BoolExpr,
4183  NeboScalar<Initial,
4184  typename NeboFieldCheck<typename
4185  FieldType::
4186  field_type,
4187  FieldType>::
4188  Result::value_type>,
4189  typename NeboFieldCheck<typename
4190  FieldType::
4191  field_type,
4192  FieldType>::
4193  Result>,
4194  NeboNil,
4195  typename NeboFieldCheck<typename FieldType::
4196  field_type,
4197  FieldType>::Result> >
4199  double const d) {
4201 
4203 
4205 
4206  CondBuilder<Cond> typedef ReturnType;
4207 
4208  return ReturnType(Cond(Clause(nb.expr(), Scalar(d)), NeboNil()));
4209  };
4210 
4211  /* none X expr X single-field */
4212  template<typename BoolExpr, typename FieldType>
4213  inline CondBuilder<NeboCond<Initial,
4214  NeboClause<Initial,
4215  BoolExpr,
4216  NeboConstSingleValueField<Initial,
4217  typename
4218  NeboFieldCheck<typename
4219  FieldType::
4220  field_type,
4221  FieldType>::
4222  Result::
4223  value_type>,
4224  typename NeboFieldCheck<typename
4225  FieldType::
4226  field_type,
4227  FieldType>::
4228  Result>,
4229  NeboNil,
4230  typename NeboFieldCheck<typename FieldType::
4231  field_type,
4232  FieldType>::Result> >
4235  typename FieldType::value_type> const & f) {
4237  typedef Field;
4238 
4240 
4242 
4243  CondBuilder<Cond> typedef ReturnType;
4244 
4245  return ReturnType(Cond(Clause(nb.expr(), Field(f)), NeboNil()));
4246  };
4247 
4248  /* none X expr X single-expr */
4249  template<typename BoolExpr, typename Expr, typename FieldType>
4250  inline CondBuilder<NeboCond<Initial,
4251  NeboClause<Initial,
4252  BoolExpr,
4253  Expr,
4254  typename NeboFieldCheck<typename
4255  FieldType::
4256  field_type,
4257  FieldType>::
4258  Result>,
4259  NeboNil,
4260  typename NeboFieldCheck<typename FieldType::
4261  field_type,
4262  FieldType>::Result> >
4265  const & e) {
4267 
4269 
4270  CondBuilder<Cond> typedef ReturnType;
4271 
4272  return ReturnType(Cond(Clause(nb.expr(), e.expr()), NeboNil()));
4273  };
4274 
4275  /* none X expr X field */
4276  template<typename BoolExpr, typename FieldType>
4277  inline CondBuilder<NeboCond<Initial,
4278  NeboClause<Initial,
4279  BoolExpr,
4280  NeboConstField<Initial,
4281  typename
4282  NeboFieldCheck<typename
4283  FieldType::
4284  field_type,
4285  FieldType>::
4286  Result>,
4287  typename NeboFieldCheck<typename
4288  FieldType::
4289  field_type,
4290  FieldType>::
4291  Result>,
4292  NeboNil,
4293  typename NeboFieldCheck<typename FieldType::
4294  field_type,
4295  FieldType>::Result> >
4297  FieldType const & f) {
4298  NeboConstField<Initial, FieldType> typedef Field;
4299 
4301 
4303 
4304  CondBuilder<Cond> typedef ReturnType;
4305 
4306  return ReturnType(Cond(Clause(nb.expr(), Field(f)), NeboNil()));
4307  };
4308 
4309  /* none X expr X expr */
4310  template<typename BoolExpr, typename Expr, typename FieldType>
4311  inline CondBuilder<NeboCond<Initial,
4312  NeboClause<Initial,
4313  BoolExpr,
4314  Expr,
4315  typename NeboFieldCheck<typename
4316  FieldType::
4317  field_type,
4318  FieldType>::
4319  Result>,
4320  NeboNil,
4321  typename NeboFieldCheck<typename FieldType::
4322  field_type,
4323  FieldType>::Result> >
4325  NeboExpression<Expr, FieldType> const & e) {
4327 
4329 
4330  CondBuilder<Cond> typedef ReturnType;
4331 
4332  return ReturnType(Cond(Clause(nb.expr(), e.expr()), NeboNil()));
4333  };
4334 
4335  /* none X mask X double */
4336  template<typename FieldType>
4337  inline CondBuilder<NeboCond<Initial,
4338  NeboClause<Initial,
4339  NeboMask<Initial,
4340  typename NeboFieldCheck<typename
4341  FieldType::
4342  field_type,
4343  FieldType>::
4344  Result>,
4345  NeboScalar<Initial,
4346  typename NeboFieldCheck<typename
4347  FieldType::
4348  field_type,
4349  FieldType>::
4350  Result::value_type>,
4351  typename NeboFieldCheck<typename
4352  FieldType::
4353  field_type,
4354  FieldType>::
4355  Result>,
4356  NeboNil,
4357  typename NeboFieldCheck<typename FieldType::
4358  field_type,
4359  FieldType>::Result> >
4360  cond(SpatialMask<FieldType> const & mask, double const d) {
4361  NeboMask<Initial, FieldType> typedef Mask;
4362 
4364 
4366 
4368 
4369  CondBuilder<Cond> typedef ReturnType;
4370 
4371  return ReturnType(Cond(Clause(Mask(mask), Scalar(d)), NeboNil()));
4372  };
4373 
4374  /* none X mask X single-field */
4375  template<typename FieldType>
4376  inline CondBuilder<NeboCond<Initial,
4377  NeboClause<Initial,
4378  NeboMask<Initial,
4379  typename NeboFieldCheck<typename
4380  FieldType::
4381  field_type,
4382  FieldType>::
4383  Result>,
4384  NeboConstSingleValueField<Initial,
4385  typename
4386  NeboFieldCheck<typename
4387  FieldType::
4388  field_type,
4389  FieldType>::
4390  Result::
4391  value_type>,
4392  typename NeboFieldCheck<typename
4393  FieldType::
4394  field_type,
4395  FieldType>::
4396  Result>,
4397  NeboNil,
4398  typename NeboFieldCheck<typename FieldType::
4399  field_type,
4400  FieldType>::Result> >
4401  cond(SpatialMask<FieldType> const & mask,
4403  typename FieldType::value_type> const & f) {
4404  NeboMask<Initial, FieldType> typedef Mask;
4405 
4407  typedef Field;
4408 
4410 
4412 
4413  CondBuilder<Cond> typedef ReturnType;
4414 
4415  return ReturnType(Cond(Clause(Mask(mask), Field(f)), NeboNil()));
4416  };
4417 
4418  /* none X mask X single-expr */
4419  template<typename Expr, typename FieldType>
4420  inline CondBuilder<NeboCond<Initial,
4421  NeboClause<Initial,
4422  NeboMask<Initial,
4423  typename NeboFieldCheck<typename
4424  FieldType::
4425  field_type,
4426  FieldType>::
4427  Result>,
4428  Expr,
4429  typename NeboFieldCheck<typename
4430  FieldType::
4431  field_type,
4432  FieldType>::
4433  Result>,
4434  NeboNil,
4435  typename NeboFieldCheck<typename FieldType::
4436  field_type,
4437  FieldType>::Result> >
4438  cond(SpatialMask<FieldType> const & mask,
4440  const & e) {
4441  NeboMask<Initial, FieldType> typedef Mask;
4442 
4444 
4446 
4447  CondBuilder<Cond> typedef ReturnType;
4448 
4449  return ReturnType(Cond(Clause(Mask(mask), e.expr()), NeboNil()));
4450  };
4451 
4452  /* none X mask X field */
4453  template<typename FieldType>
4454  inline CondBuilder<NeboCond<Initial,
4455  NeboClause<Initial,
4456  NeboMask<Initial,
4457  typename NeboFieldCheck<typename
4458  FieldType::
4459  field_type,
4460  FieldType>::
4461  Result>,
4462  NeboConstField<Initial,
4463  typename
4464  NeboFieldCheck<typename
4465  FieldType::
4466  field_type,
4467  FieldType>::
4468  Result>,
4469  typename NeboFieldCheck<typename
4470  FieldType::
4471  field_type,
4472  FieldType>::
4473  Result>,
4474  NeboNil,
4475  typename NeboFieldCheck<typename FieldType::
4476  field_type,
4477  FieldType>::Result> >
4478  cond(SpatialMask<FieldType> const & mask, FieldType const & f) {
4479  NeboMask<Initial, FieldType> typedef Mask;
4480 
4481  NeboConstField<Initial, FieldType> typedef Field;
4482 
4484 
4486 
4487  CondBuilder<Cond> typedef ReturnType;
4488 
4489  return ReturnType(Cond(Clause(Mask(mask), Field(f)), NeboNil()));
4490  };
4491 
4492  /* none X mask X expr */
4493  template<typename Expr, typename FieldType>
4494  inline CondBuilder<NeboCond<Initial,
4495  NeboClause<Initial,
4496  NeboMask<Initial,
4497  typename NeboFieldCheck<typename
4498  FieldType::
4499  field_type,
4500  FieldType>::
4501  Result>,
4502  Expr,
4503  typename NeboFieldCheck<typename
4504  FieldType::
4505  field_type,
4506  FieldType>::
4507  Result>,
4508  NeboNil,
4509  typename NeboFieldCheck<typename FieldType::
4510  field_type,
4511  FieldType>::Result> >
4512  cond(SpatialMask<FieldType> const & mask,
4513  NeboExpression<Expr, FieldType> const & e) {
4514  NeboMask<Initial, FieldType> typedef Mask;
4515 
4517 
4519 
4520  CondBuilder<Cond> typedef ReturnType;
4521 
4522  return ReturnType(Cond(Clause(Mask(mask), e.expr()), NeboNil()));
4523  };
4524 
4525  #define nebo_cond cond//;
4526  } /* SpatialOps */
4527 
4528 #endif
4529 /* NEBO_COND_H */
Type traits for a single value field.
Abstracts a mask.
Definition: SpatialMask.h:70
Holds information about the number of ghost cells on each side of the domain.
Definition: GhostData.h:54
BCSide
Allows identification of whether we are setting the BC on the right or left side when using an operat...