source: branches/hpc34/src/TableTraverse.h@ 2582

Last change on this file since 2582 was 2343, checked in by Takeshi Nakazato, 13 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Patch from Wes.
This is changes intend to compile with llvm c++ and Intel
and those might not affect actual behavior.


  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1//
2// C++ Interface: TableTraverse
3//
4// Description:
5//
6// Copyright: See COPYING file that comes with this distribution
7//
8
9/*
10 * $Id: TableTraverse.h 2343 2011-11-06 14:55:32Z TakeshiNakazato $
11 */
12
13#ifndef ASAP_TABLETRAVERSE_H
14#define ASAP_TABLETRAVERSE_H
15
16#include <casa/aips.h>
17#include <tables/Tables/BaseTable.h>
18#include <tables/Tables/Table.h>
19
20namespace asap {
21
22 class TableVisitor {
23 public:
24 virtual ~TableVisitor() {}
25
26 // This method is called just before the first <src>visit()<src> call.
27 virtual void start() {}
28
29 // <p><src>isFirst</src> is True only when the first visit.</p>
30 // <p><src>recordNo</src> indicates which record is currently visited.
31 // <p><src>nCols</src> indicates a number of columns used to sort records.
32 // <src>nCols</src> is equal to a number of elements of
33 // <src>columnNames</src> argument of <src>traverseTable()</src>
34 // excluding the trailing NULL element.</p>
35 // <p><src>colValues</src> is an array of arrays which contains all
36 // column values for each column.
37 // For example, <src>colValues[0]</src> is an array which contains all
38 // values of the first column.
39 // The order of <src>colValues</src> is same as the one of
40 // <src>columnNames</src> argument of <src>traverseTable()</src>.</p>
41 // <p>Returning False causes stopping iteration,
42 // otherwise iterate over all records.</p>
43 // <p>If <src>visit()</src> throws an exception, the iteration stops and
44 // <src>finish()</src> will not be called.</p>
45 virtual casa::Bool visit(casa::Bool isFirst, casa::uInt recordNo,
46 casa::uInt nCols,
47 void const *const colValues[]) = 0;
48
49 // This method is called immediately after all visits have done.
50 virtual void finish() {}
51 };
52
53 // <src>TypeManager</src> describes a type to handle the type dynamically.
54 class TypeManager {
55 public:
56 virtual ~TypeManager() {}
57 virtual casa::BaseCompare *getComparator() const = 0;
58 virtual size_t sizeOf() const = 0;
59 virtual void *allocArray(size_t size) const = 0;
60 virtual void freeArray(void *array) const = 0;
61 };
62
63 // This template is applicable to the type which can be applied to
64 // <src>casa::ObjCompare&lt;T&gt;</src>.
65 template<class T> class TypeManagerImpl: public TypeManager {
66 public:
67 TypeManagerImpl(){}
68 virtual casa::BaseCompare *getComparator() const {
69 static casa::ObjCompare<T> comparator;
70 return &comparator;
71 }
72 virtual size_t sizeOf() const {
73 return sizeof(T);
74 }
75 virtual void *allocArray(size_t size) const {
76 return new T[size];
77 }
78 virtual void freeArray(void *array) const {
79 delete[] (T*)array;
80 }
81 };
82
83
84 // <p>This function iterates over <src>table</src> with calling
85 // <src>visitor->visit()</src> for each record after calling
86 // <src>visitor->start()</src> and, finally, it calls
87 // <src>visitor->finish()</src>.</p>
88 // <p><src>columnNames</src> should be a NULL terminated array of column
89 // names which will be used to sort records to determine the order of visits.
90 // If <src>doSort</src> is False, <src>columnNames</src> is used only to
91 // specify <src>nCols</src> and <src>colValues</src> arguments for calling
92 // <src>visitor->visit()</src>.</p>
93 // <p><src>typeManagers</src> should be a NULL terminated array of
94 // <src>TypeManager</src> too.
95 // It's number of elements and order of elements should be same as
96 // <src>columnNames</src>.
97 // <src>TypeManagerImpl</src> is useful to create instances of
98 // <src>TypeManager</src>.</p>
99 // <p>If <src>doSort</src> is True, the order of visits is ascending order
100 // for each column. <src>columnNames[0]</src> is a primary sort key and
101 // <src>columnNames[1]</src> is a secondary sort key, ...</p>
102 void traverseTable(const casa::Table &table,
103 const char *const columnNames[],
104 const TypeManager *const typeManagers[],
105 TableVisitor *visitor,
106 casa::Bool doSort = casa::True);
107
108}
109
110#endif
Note: See TracBrowser for help on using the repository browser.