Fledge
An open source edge computing platform for industrial users
query.h
1 #ifndef _QUERY_H
2 #define _QUERY_H
3 /*
4  * Fledge storage client.
5  *
6  * Copyright (c) 2018 OSisoft, LLC
7  *
8  * Released under the Apache 2.0 Licence
9  *
10  * Author: Mark Riddoch
11  */
12 #include <where.h>
13 #include <aggregate.h>
14 #include <sort.h>
15 #include <join.h>
16 #include <timebucket.h>
17 #include <returns.h>
18 #include <string>
19 #include <vector>
20 
21 
25 class Query {
26  public:
27  Query(Where *where);
28  Query(Aggregate *aggreate, Where *where);
29  Query(Timebucket *timebucket, Where *where);
30  Query(Timebucket *timebucket, Where *where, unsigned int limit);
32  Query(std::vector<Returns *> returns);
33  Query(std::vector<Returns *> returns, Where *where);
34  Query(std::vector<Returns *> returns, Where *where, unsigned int limit);
35  ~Query();
36  void aggregate(Aggregate *aggegate);
37  void group(const std::string& column);
38  void sort(Sort *sort);
39  void limit(unsigned int limit);
40  void timebucket(Timebucket*);
41  void returns(Returns *);
42  void returns(std::vector<Returns *>);
43  void distinct();
44  void join(Join *join);
45  const std::string toJSON() const;
46  private:
47  Query(const Query&); // Disable copy of query
48  Query& operator=(Query const&);
49  Where *m_where;
50  std::vector<Aggregate *> m_aggregates;
51  std::string m_group;
52  std::vector<Sort *> m_sort;
53  unsigned int m_limit;
54  Timebucket* m_timebucket;
55  std::vector<Returns *> m_returns;
56  bool m_distinct;
57  Join *m_join;
58 };
59 #endif
60 
void sort(Sort *sort)
Add a sort operation to an existing query.
Definition: query.cpp:185
Control a returned column.
Definition: returns.h:20
Aggregate clause in a selection of records.
Definition: aggregate.h:18
void distinct()
Add a distinct value modifier to the query.
Definition: query.cpp:256
Timebucket clause in a selection of records.
Definition: timebucket.h:20
Storage layer query container.
Definition: query.h:25
void timebucket(Timebucket *)
Add a timebucket operation to an existing query.
Definition: query.cpp:215
const std::string toJSON() const
Return the JSON payload for a where clause.
Definition: query.cpp:264
void aggregate(Aggregate *aggegate)
Add a aggregate operation to an existing query object.
Definition: query.cpp:175
void limit(unsigned int limit)
Limit the numebr of rows returned by the query.
Definition: query.cpp:205
Query(Where *where)
Construct a query with a simple where clause.
Definition: query.cpp:21
Join clause representation.
Definition: join.h:19
Sort clause in a selection of records.
Definition: sort.h:20
void join(Join *join)
Add a join clause to a query.
Definition: query.cpp:248
void group(const std::string &column)
Add a group operation to a query.
Definition: query.cpp:195
~Query()
Destructor for a query object.
Definition: query.cpp:142
Where clause in a selection of records.
Definition: where.h:31
void returns(Returns *)
Limit the query to return just a single column.
Definition: query.cpp:225