Qpid Management Framework  0.24
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Query.h
Go to the documentation of this file.
1 #ifndef _QmfEngineQuery_
2 #define _QmfEngineQuery_
3 
4 /*
5  * Licensed to the Apache Software Foundation (ASF) under one
6  * or more contributor license agreements. See the NOTICE file
7  * distributed with this work for additional information
8  * regarding copyright ownership. The ASF licenses this file
9  * to you under the Apache License, Version 2.0 (the
10  * "License"); you may not use this file except in compliance
11  * with the License. You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing,
16  * software distributed under the License is distributed on an
17  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18  * KIND, either express or implied. See the License for the
19  * specific language governing permissions and limitations
20  * under the License.
21  */
22 
23 #include <qmf/engine/ObjectId.h>
24 #include <qmf/engine/Value.h>
25 
26 namespace qmf {
27 namespace engine {
28 
29  class Object;
30  struct QueryElementImpl;
31  struct QueryImpl;
32  struct QueryExpressionImpl;
33  class SchemaClassKey;
34 
35  enum ValueOper {
36  O_EQ = 1,
37  O_NE = 2,
38  O_LT = 3,
39  O_LE = 4,
40  O_GT = 5,
41  O_GE = 6,
44  O_PRESENT = 9,
46  };
47 
48  struct QueryOperand {
49  virtual ~QueryOperand() {}
50  virtual bool evaluate(const Object* object) const = 0;
51  };
52 
53  struct QueryElement : public QueryOperand {
54  QueryElement(const char* attrName, const Value* value, ValueOper oper);
55  QueryElement(QueryElementImpl* impl);
56  virtual ~QueryElement();
57  bool evaluate(const Object* object) const;
58 
59  QueryElementImpl* impl;
60  };
61 
62  enum ExprOper {
63  E_NOT = 1,
64  E_AND = 2,
65  E_OR = 3,
66  E_XOR = 4
67  };
68 
69  struct QueryExpression : public QueryOperand {
70  QueryExpression(ExprOper oper, const QueryOperand* operand1, const QueryOperand* operand2);
71  QueryExpression(QueryExpressionImpl* impl);
72  virtual ~QueryExpression();
73  bool evaluate(const Object* object) const;
74 
75  QueryExpressionImpl* impl;
76  };
77 
78  class Query {
79  public:
80  Query(const char* className, const char* packageName);
81  Query(const SchemaClassKey* key);
82  Query(const ObjectId* oid);
83  Query(const Query& from);
84  ~Query();
85 
86  void setSelect(const QueryOperand* criterion);
87  void setLimit(uint32_t maxResults);
88  void setOrderBy(const char* attrName, bool decreasing);
89 
90  const char* getPackage() const;
91  const char* getClass() const;
92  const ObjectId* getObjectId() const;
93 
94  bool haveSelect() const;
95  bool haveLimit() const;
96  bool haveOrderBy() const;
97  const QueryOperand* getSelect() const;
98  uint32_t getLimit() const;
99  const char* getOrderBy() const;
100  bool getDecreasing() const;
101 
102  private:
103  friend struct QueryImpl;
104  friend class BrokerProxyImpl;
105  Query(QueryImpl* impl);
106  QueryImpl* impl;
107  };
108 }
109 }
110 
111 #endif
112