IGNITE-3586: CPP: Made QueryArgument private
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/15c97807 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/15c97807 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/15c97807 Branch: refs/heads/ignite-1192 Commit: 15c97807d9aba529fdd637e3ce5c89d2747f529b Parents: 89eb175 Author: Igor Sapego <isap...@gridgain.com> Authored: Mon Mar 20 15:51:57 2017 +0300 Committer: Igor Sapego <isap...@gridgain.com> Committed: Mon Mar 20 15:51:57 2017 +0300 ---------------------------------------------------------------------- modules/platforms/cpp/core/include/Makefile.am | 2 +- .../include/ignite/cache/query/query_argument.h | 134 ------------------ .../core/include/ignite/cache/query/query_sql.h | 16 ++- .../ignite/cache/query/query_sql_fields.h | 16 ++- .../ignite/impl/cache/query/query_argument.h | 137 +++++++++++++++++++ .../platforms/cpp/core/project/vs/core.vcxproj | 2 +- .../cpp/core/project/vs/core.vcxproj.filters | 6 +- 7 files changed, 160 insertions(+), 153 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/15c97807/modules/platforms/cpp/core/include/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/Makefile.am b/modules/platforms/cpp/core/include/Makefile.am index 650f230..21d3062 100644 --- a/modules/platforms/cpp/core/include/Makefile.am +++ b/modules/platforms/cpp/core/include/Makefile.am @@ -25,6 +25,7 @@ nobase_include_HEADERS = \ ignite/impl/ignite_environment.h \ ignite/impl/ignite_impl.h \ ignite/impl/cache/query/query_fields_row_impl.h \ + ignite/impl/cache/query/query_argument.h \ ignite/impl/cache/query/query_impl.h \ ignite/impl/cache/cache_impl.h \ ignite/impl/cache/cache_entry_processor_holder.h \ @@ -43,7 +44,6 @@ nobase_include_HEADERS = \ ignite/cache/query/query_cursor.h \ ignite/cache/query/query_sql.h \ ignite/cache/query/query.h \ - ignite/cache/query/query_argument.h \ ignite/cache/query/query_sql_fields.h \ ignite/cache/query/query_text.h \ ignite/cache/cache.h \ http://git-wip-us.apache.org/repos/asf/ignite/blob/15c97807/modules/platforms/cpp/core/include/ignite/cache/query/query_argument.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_argument.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_argument.h deleted file mode 100644 index 65578ce..0000000 --- a/modules/platforms/cpp/core/include/ignite/cache/query/query_argument.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Declares ignite::cache::query::QueryArgument class template and - * ignite::cache::query::QueryArgumentBase interface. - */ - -#ifndef _IGNITE_CACHE_QUERY_QUERY_ARGUMENT -#define _IGNITE_CACHE_QUERY_QUERY_ARGUMENT - -#include "ignite/binary/binary_raw_writer.h" - -namespace ignite -{ - namespace cache - { - namespace query - { - /** - * Base class for all query arguments. - */ - class QueryArgumentBase - { - public: - /** - * Destructor. - */ - virtual ~QueryArgumentBase() - { - // No-op. - } - - /** - * Copy argument. - * - * @return Copy of this argument instance. - */ - virtual QueryArgumentBase* Copy() const = 0; - - /** - * Write argument using provided writer. - * - * @param writer Writer to use to write this argument. - */ - virtual void Write(ignite::binary::BinaryRawWriter& writer) = 0; - }; - - /** - * Query argument class template. - * - * Template argument type should be copy-constructable and - * assignable. Also BinaryType class template should be specialized - * for this type. - */ - template<typename T> - class QueryArgument : public QueryArgumentBase - { - public: - /** - * Constructor. - * - * @param val Value. - */ - QueryArgument(const T& val) : - val(val) - { - // No-op. - } - - /** - * Copy constructor. - * - * @param other Other instance. - */ - QueryArgument(const QueryArgument& other) : - val(other.val) - { - // No-op. - } - - /** - * Assignment operator. - * - * @param other Other instance. - * @return *this. - */ - QueryArgument& operator=(const QueryArgument& other) - { - if (this != &other) - val = other.val; - - return *this; - } - - virtual ~QueryArgument() - { - // No-op. - } - - virtual QueryArgumentBase* Copy() const - { - return new QueryArgument(val); - } - - virtual void Write(ignite::binary::BinaryRawWriter& writer) - { - writer.WriteObject<T>(val); - } - - private: - /** Value. */ - T val; - }; - } - } -} - -#endif //_IGNITE_CACHE_QUERY_QUERY_ARGUMENT \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/15c97807/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h index 0ec5d5f..289d70a 100644 --- a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h +++ b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h @@ -27,8 +27,8 @@ #include <string> #include <vector> -#include "ignite/cache/query/query_argument.h" -#include "ignite/binary/binary_raw_writer.h" +#include <ignite/impl/cache/query/query_argument.h> +#include <ignite/binary/binary_raw_writer.h> namespace ignite { @@ -74,7 +74,7 @@ namespace ignite { args.reserve(other.args.size()); - typedef std::vector<QueryArgumentBase*>::const_iterator Iter; + typedef std::vector<impl::cache::query::QueryArgumentBase*>::const_iterator Iter; for (Iter i = other.args.begin(); i != other.args.end(); ++i) args.push_back((*i)->Copy()); @@ -102,7 +102,7 @@ namespace ignite */ ~SqlQuery() { - typedef std::vector<QueryArgumentBase*>::const_iterator Iter; + typedef std::vector<impl::cache::query::QueryArgumentBase*>::const_iterator Iter; for (Iter it = args.begin(); it != args.end(); ++it) delete *it; @@ -241,7 +241,7 @@ namespace ignite template<typename T> void AddArgument(const T& arg) { - args.push_back(new QueryArgument<T>(arg)); + args.push_back(new impl::cache::query::QueryArgument<T>(arg)); } /** @@ -258,7 +258,9 @@ namespace ignite writer.WriteInt32(static_cast<int32_t>(args.size())); - for (std::vector<QueryArgumentBase*>::const_iterator it = args.begin(); it != args.end(); ++it) + std::vector<impl::cache::query::QueryArgumentBase*>::const_iterator it; + + for (it = args.begin(); it != args.end(); ++it) (*it)->Write(writer); writer.WriteBool(distributedJoins); @@ -281,7 +283,7 @@ namespace ignite bool distributedJoins; /** Arguments. */ - std::vector<QueryArgumentBase*> args; + std::vector<impl::cache::query::QueryArgumentBase*> args; }; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/15c97807/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h index 10dd6ab..7c09d85 100644 --- a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h +++ b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h @@ -27,8 +27,8 @@ #include <string> #include <vector> -#include "ignite/cache/query/query_argument.h" -#include "ignite/binary/binary_raw_writer.h" +#include <ignite/impl/cache/query/query_argument.h> +#include <ignite/binary/binary_raw_writer.h> namespace ignite { @@ -90,7 +90,7 @@ namespace ignite { args.reserve(other.args.size()); - typedef std::vector<QueryArgumentBase*>::const_iterator Iter; + typedef std::vector<impl::cache::query::QueryArgumentBase*>::const_iterator Iter; for (Iter i = other.args.begin(); i != other.args.end(); ++i) args.push_back((*i)->Copy()); @@ -118,7 +118,7 @@ namespace ignite */ ~SqlFieldsQuery() { - typedef std::vector<QueryArgumentBase*>::const_iterator Iter; + typedef std::vector<impl::cache::query::QueryArgumentBase*>::const_iterator Iter; for (Iter it = args.begin(); it != args.end(); ++it) delete *it; @@ -264,7 +264,7 @@ namespace ignite template<typename T> void AddArgument(const T& arg) { - args.push_back(new QueryArgument<T>(arg)); + args.push_back(new impl::cache::query::QueryArgument<T>(arg)); } /** @@ -280,7 +280,9 @@ namespace ignite writer.WriteInt32(static_cast<int32_t>(args.size())); - for (std::vector<QueryArgumentBase*>::const_iterator it = args.begin(); it != args.end(); ++it) + std::vector<impl::cache::query::QueryArgumentBase*>::const_iterator it; + + for (it = args.begin(); it != args.end(); ++it) (*it)->Write(writer); writer.WriteBool(distributedJoins); @@ -304,7 +306,7 @@ namespace ignite bool enforceJoinOrder; /** Arguments. */ - std::vector<QueryArgumentBase*> args; + std::vector<impl::cache::query::QueryArgumentBase*> args; }; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/15c97807/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_argument.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_argument.h b/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_argument.h new file mode 100644 index 0000000..f2f55bc --- /dev/null +++ b/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_argument.h @@ -0,0 +1,137 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Declares ignite::cache::query::QueryArgument class template and + * ignite::cache::query::QueryArgumentBase interface. + */ + +#ifndef _IGNITE_IMPL_CACHE_QUERY_QUERY_ARGUMENT +#define _IGNITE_IMPL_CACHE_QUERY_QUERY_ARGUMENT + +#include <ignite/binary/binary_raw_writer.h> + +namespace ignite +{ + namespace impl + { + namespace cache + { + namespace query + { + /** + * Base class for all query arguments. + */ + class QueryArgumentBase + { + public: + /** + * Destructor. + */ + virtual ~QueryArgumentBase() + { + // No-op. + } + + /** + * Copy argument. + * + * @return Copy of this argument instance. + */ + virtual QueryArgumentBase* Copy() const = 0; + + /** + * Write argument using provided writer. + * + * @param writer Writer to use to write this argument. + */ + virtual void Write(ignite::binary::BinaryRawWriter& writer) = 0; + }; + + /** + * Query argument class template. + * + * Template argument type should be copy-constructable and + * assignable. Also BinaryType class template should be specialized + * for this type. + */ + template<typename T> + class QueryArgument : public QueryArgumentBase + { + public: + /** + * Constructor. + * + * @param val Value. + */ + QueryArgument(const T& val) : + val(val) + { + // No-op. + } + + /** + * Copy constructor. + * + * @param other Other instance. + */ + QueryArgument(const QueryArgument& other) : + val(other.val) + { + // No-op. + } + + /** + * Assignment operator. + * + * @param other Other instance. + * @return *this. + */ + QueryArgument& operator=(const QueryArgument& other) + { + if (this != &other) + val = other.val; + + return *this; + } + + virtual ~QueryArgument() + { + // No-op. + } + + virtual QueryArgumentBase* Copy() const + { + return new QueryArgument(val); + } + + virtual void Write(ignite::binary::BinaryRawWriter& writer) + { + writer.WriteObject<T>(val); + } + + private: + /** Value. */ + T val; + }; + } + } + } +} + +#endif //_IGNITE_IMPL_CACHE_QUERY_QUERY_ARGUMENT \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/15c97807/modules/platforms/cpp/core/project/vs/core.vcxproj ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/project/vs/core.vcxproj b/modules/platforms/cpp/core/project/vs/core.vcxproj index 9a5a80b..b490887 100644 --- a/modules/platforms/cpp/core/project/vs/core.vcxproj +++ b/modules/platforms/cpp/core/project/vs/core.vcxproj @@ -200,7 +200,6 @@ <ClInclude Include="..\..\include\ignite\cache\query\continuous\continuous_query_handle.h" /> <ClInclude Include="..\..\include\ignite\cache\mutable_cache_entry.h" /> <ClInclude Include="..\..\include\ignite\cache\query\query.h" /> - <ClInclude Include="..\..\include\ignite\cache\query\query_argument.h" /> <ClInclude Include="..\..\include\ignite\cache\query\query_cursor.h" /> <ClInclude Include="..\..\include\ignite\cache\query\query_fields_cursor.h" /> <ClInclude Include="..\..\include\ignite\cache\query\query_fields_row.h" /> @@ -215,6 +214,7 @@ <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_updater_impl.h" /> <ClInclude Include="..\..\include\ignite\impl\cache\cache_entry_processor_holder.h" /> <ClInclude Include="..\..\include\ignite\impl\cache\cache_impl.h" /> + <ClInclude Include="..\..\include\ignite\impl\cache\query\query_argument.h" /> <ClInclude Include="..\..\include\ignite\impl\cache\query\query_batch.h" /> <ClInclude Include="..\..\include\ignite\impl\cache\query\continuous\continuous_query_handle_impl.h" /> <ClInclude Include="..\..\include\ignite\impl\cache\query\continuous\continuous_query_impl.h" /> http://git-wip-us.apache.org/repos/asf/ignite/blob/15c97807/modules/platforms/cpp/core/project/vs/core.vcxproj.filters ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/project/vs/core.vcxproj.filters b/modules/platforms/cpp/core/project/vs/core.vcxproj.filters index fc58633..b75b3b2 100644 --- a/modules/platforms/cpp/core/project/vs/core.vcxproj.filters +++ b/modules/platforms/cpp/core/project/vs/core.vcxproj.filters @@ -87,9 +87,6 @@ <ClInclude Include="..\..\include\ignite\impl\cache\query\query_impl.h"> <Filter>Code\impl\cache\query</Filter> </ClInclude> - <ClInclude Include="..\..\include\ignite\cache\query\query_argument.h"> - <Filter>Code\cache\query</Filter> - </ClInclude> <ClInclude Include="..\..\include\ignite\cache\query\query_cursor.h"> <Filter>Code\cache\query</Filter> </ClInclude> @@ -192,6 +189,9 @@ <ClInclude Include="..\..\include\ignite\ignite_binding_context.h"> <Filter>Code</Filter> </ClInclude> + <ClInclude Include="..\..\include\ignite\impl\cache\query\query_argument.h"> + <Filter>Code\impl\cache\query</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <Filter Include="Code">