SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LinAlgEngine.h
Go to the documentation of this file.
1 //
2 // For more information, please see: http://software.sci.utah.edu
3 //
4 // The MIT License
5 //
6 // Copyright (c) 2009 Scientific Computing and Imaging Institute,
7 // University of Utah.
8 //
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 // DEALINGS IN THE SOFTWARE.
27 //
28 
29 #ifndef CORE_PARSER_LINALGENGINE_H
30 #define CORE_PARSER_LINALGENGINE_H 1
31 
32 #include <Core/Util/ProgressReporter.h>
33 #include <Core/Datatypes/FieldInformation.h>
34 
35 
38 #include <Core/Parser/Parser.h>
39 
40 // Include files needed for Windows
41 #include <Core/Parser/share.h>
42 
43 namespace SCIRun {
44 
46 {
47  public:
48  // Classes for storing data on output variables
49 
50  class OutputMatrix {
51  public:
52  std::string array_name_;
53  std::string matrix_name_;
55  };
56 
57  public:
58  // CALLS TO THIS CLASS SHOULD BE MADE IN THE ORDER
59  // THAT THE FUNCTIONS ARE GIVEN HERE
60 
61  // Make sure it starts with a clean definition file
62  NewLinAlgEngine() { pr_ = &(def_pr_); clear(); }
63 
64  // Setup a progress reporter
65  void set_progress_reporter(ProgressReporter* pr) { pr_ = pr; }
66 
67  // Generate input matrices
68  bool add_input_matrix(std::string name,
69  MatrixHandle& matrix);
70 
71  // Setup a matrix for output
72  bool add_output_matrix(std::string name);
73 
74  // Setup the expression
75  bool add_expressions(std::string& expressions);
76 
77  // Run the expressions in parallel
78  bool run();
79 
80  // Extract handles to the results
81  bool get_matrix(std::string name, MatrixHandle& matrix);
82 
83  // Clean up the engine
84  void clear();
85 
86  private:
87  ProgressReporter def_pr_;
88  // Progress reporter for reporting error
89  ProgressReporter* pr_;
90 
91  // Parser program : the structure of the expressions and simple reduction
92  // of the expressions to simple function calls
93  ParserProgramHandle pprogram_;
94  // Wrapper around the function calls, this piece actually executes the code
95  LinAlgProgramHandle mprogram_;
96 
97  // Expression to evaluate before the main expression
98  // This one is to extract the variables from the data sources
99  // This reduces the amount of actual functions we need to implement
100  std::string pre_expression_;
101  // The user defined expression
102  std::string expression_;
103  // Expression to get the data back into the data sinks
104  std::string post_expression_;
105 
106  // Data that needs to be stored as it is needed before and after the parser is
107  // done. An output needs to be set before the parser, otherwise it is optimized
108  // away, but the type is only know when the parser has validated and optimized
109  // the expression tree
110 
111  std::vector<OutputMatrix> matrixdata_;
112 };
113 
114 }
115 
116 #endif
LockingHandle< Matrix< double > > MatrixHandle
Definition: MatrixFwd.h:55
Handle< LinAlgProgram > LinAlgProgramHandle
Definition: LinAlgInterpreter.h:61
Definition: Parser.h:680
Definition: LinAlgEngine.h:50
#define SCISHARE
Definition: share.h:39
void set_progress_reporter(ProgressReporter *pr)
Definition: LinAlgEngine.h:65
MatrixHandle matrix_
Definition: LinAlgEngine.h:54
std::string matrix_name_
Definition: LinAlgEngine.h:53
const char * name[]
Definition: BoostGraphExampleTests.cc:87
boost::shared_ptr< ParserProgram > ParserProgramHandle
Definition: Parser.h:70
NewLinAlgEngine()
Definition: LinAlgEngine.h:62
Definition: LinAlgEngine.h:45
Definition: LinAlgInterpreter.h:291
std::string array_name_
Definition: LinAlgEngine.h:52