A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
QueryOutput.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * *
3  * Copyright 2018 Rice University *
4  * *
5  * Licensed under the Apache License, Version 2.0 (the "License"); *
6  * you may not use this file except in compliance with the License. *
7  * You may obtain a copy of the License at *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14  * See the License for the specific language governing permissions and *
15  * limitations under the License. *
16  * *
17  *****************************************************************************/
18 
19 #ifndef QUERY_OUTPUT_H
20 #define QUERY_OUTPUT_H
21 
22 #include "Query.h"
23 #include "OutputIterator.h"
24 #include "TypeName.h"
25 #include "SetScan.h"
26 
27 // PRELOAD %QueryOutput <Nothing>%
28 
29 namespace pdb {
30 
31 template <class OutType>
32 class QueryOutput : public QueryBase {
33 
34 public:
36 
37  QueryOutput(std::string& dbName, std::string& setName) {
38  this->setSetName(setName);
39  this->setdbName(dbName);
40  myType = getTypeName<OutType>();
41  }
42 
44  myType = getTypeName<OutType>();
45  }
46 
47  QueryOutput(std::string dbName, std::string setName, Handle<QueryBase> input) {
48  this->setSetName(setName);
49  this->setDBName(dbName);
50  myType = getTypeName<OutType>();
51  this->setInput(input);
52  }
53 
55 
56  virtual std::string getIthInputType(int i) override {
57  if (i != 0) {
58  return "Bad index";
59  }
60  return myType;
61  }
62 
63  virtual std::string getOutputType() override {
64  return "";
65  }
66 
67  virtual int getNumInputs() override {
68  return 1;
69  }
70 
71  virtual std::string getQueryType() override {
72  return "localoutput";
73  }
74 
75 
76  void match(function<void(QueryBase&)> forSelection,
77  function<void(QueryBase&)> forSet,
78  function<void(QueryBase&)> forQueryOutput) override {
79  forQueryOutput(*this);
80  };
81 
82 private:
83  // records the output type
84  String myType;
85 };
86 }
87 
88 #endif
#define ENABLE_DEEP_COPY
Definition: DeepCopy.h:52
void setSetName(std::string toMe)
Definition: QueryBase.h:89
virtual std::string getOutputType() override
Definition: QueryOutput.h:63
bool setInput(Handle< QueryBase > toMe)
Definition: QueryBase.h:114
virtual std::string getQueryType() override
Definition: QueryOutput.h:71
virtual std::string getIthInputType(int i) override
Definition: QueryOutput.h:56
ENABLE_DEEP_COPY QueryOutput(std::string &dbName, std::string &setName)
Definition: QueryOutput.h:37
void setDBName(std::string toMe)
Definition: QueryBase.h:80
void match(function< void(QueryBase &)> forSelection, function< void(QueryBase &)> forSet, function< void(QueryBase &)> forQueryOutput) override
Definition: QueryOutput.h:76
QueryOutput(std::string dbName, std::string setName, Handle< QueryBase > input)
Definition: QueryOutput.h:47
virtual int getNumInputs() override
Definition: QueryOutput.h:67