Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
qmf/engine/Query.h
Go to the documentation of this file.
00001 #ifndef _QmfEngineQuery_
00002 #define _QmfEngineQuery_
00003 
00004 /*
00005  * Licensed to the Apache Software Foundation (ASF) under one
00006  * or more contributor license agreements.  See the NOTICE file
00007  * distributed with this work for additional information
00008  * regarding copyright ownership.  The ASF licenses this file
00009  * to you under the Apache License, Version 2.0 (the
00010  * "License"); you may not use this file except in compliance
00011  * with the License.  You may obtain a copy of the License at
00012  * 
00013  *   http://www.apache.org/licenses/LICENSE-2.0
00014  * 
00015  * Unless required by applicable law or agreed to in writing,
00016  * software distributed under the License is distributed on an
00017  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00018  * KIND, either express or implied.  See the License for the
00019  * specific language governing permissions and limitations
00020  * under the License.
00021  */
00022 
00023 #include <qmf/engine/ObjectId.h>
00024 #include <qmf/engine/Value.h>
00025 
00026 namespace qmf {
00027 namespace engine {
00028 
00029     class Object;
00030     struct QueryElementImpl;
00031     struct QueryImpl;
00032     struct QueryExpressionImpl;
00033     class  SchemaClassKey;
00034 
00035     enum ValueOper {
00036         O_EQ = 1,
00037         O_NE = 2,
00038         O_LT = 3,
00039         O_LE = 4,
00040         O_GT = 5,
00041         O_GE = 6,
00042         O_RE_MATCH = 7,
00043         O_RE_NOMATCH = 8,
00044         O_PRESENT = 9,
00045         O_NOT_PRESENT = 10
00046     };
00047 
00048     struct QueryOperand {
00049         virtual ~QueryOperand() {}
00050         virtual bool evaluate(const Object* object) const = 0;
00051     };
00052 
00053     struct QueryElement : public QueryOperand {
00054         QueryElement(const char* attrName, const Value* value, ValueOper oper);
00055         QueryElement(QueryElementImpl* impl);
00056         virtual ~QueryElement();
00057         bool evaluate(const Object* object) const;
00058 
00059         QueryElementImpl* impl;
00060     };
00061 
00062     enum ExprOper {
00063         E_NOT = 1,
00064         E_AND = 2,
00065         E_OR  = 3,
00066         E_XOR = 4
00067     };
00068 
00069     struct QueryExpression : public QueryOperand {
00070         QueryExpression(ExprOper oper, const QueryOperand* operand1, const QueryOperand* operand2);
00071         QueryExpression(QueryExpressionImpl* impl);
00072         virtual ~QueryExpression();
00073         bool evaluate(const Object* object) const;
00074         
00075         QueryExpressionImpl* impl;
00076     };
00077 
00078     class Query {
00079     public:
00080         Query(const char* className, const char* packageName);
00081         Query(const SchemaClassKey* key);
00082         Query(const ObjectId* oid);
00083         Query(const Query& from);
00084         ~Query();
00085 
00086         void setSelect(const QueryOperand* criterion);
00087         void setLimit(uint32_t maxResults);
00088         void setOrderBy(const char* attrName, bool decreasing);
00089 
00090         const char* getPackage() const;
00091         const char* getClass() const;
00092         const ObjectId* getObjectId() const;
00093 
00094         bool haveSelect() const;
00095         bool haveLimit() const;
00096         bool haveOrderBy() const;
00097         const QueryOperand* getSelect() const;
00098         uint32_t getLimit() const;
00099         const char* getOrderBy() const;
00100         bool getDecreasing() const;
00101 
00102     private:
00103         friend struct QueryImpl;
00104         friend class BrokerProxyImpl;
00105         Query(QueryImpl* impl);
00106         QueryImpl* impl;
00107     };
00108 }
00109 }
00110 
00111 #endif
00112 

Qpid C++ API Reference
Generated on Mon Aug 22 2011 for Qpid C++ Client API by doxygen 1.7.4