diff --git a/src/lib/iter-stack.hpp b/src/lib/iter-stack.hpp index d4e239e95..e6fa35015 100644 --- a/src/lib/iter-stack.hpp +++ b/src/lib/iter-stack.hpp @@ -50,6 +50,7 @@ #include "lib/error.hpp" #include "lib/iter-adapter.hpp" +#include "lib/nocopy.hpp" #include "lib/util.hpp" #include @@ -57,7 +58,6 @@ namespace lib { - namespace { using util::unConst; diff --git a/src/lib/nocopy.hpp b/src/lib/nocopy.hpp new file mode 100644 index 000000000..3f8fc8b36 --- /dev/null +++ b/src/lib/nocopy.hpp @@ -0,0 +1,59 @@ +/* + NOCOPY.hpp - some flavours of non-copyable entities + + Copyright (C) Lumiera.org + 2012, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + + +#ifndef LIB_NOCOPY_H +#define LIB_NOCOPY_H + +#include + + + +namespace util { + + /** + * any copy and copy construction prohibited + */ + class no_copy + : boost::noncopyable + { }; + + /** + * classes inheriting from this mixin + * may be created by copy-construction, + * but any copy-assignment is prohibited. + * @note especially this allows returning + * by-value from a builder function, + * while prohibiting any further copy + */ + class no_copy_by_client + { + protected: + ~no_copy_by_client() {} + no_copy_by_client() {} + no_copy_by_client (no_copy_by_client const&) {} + no_copy_by_client const& + operator=(no_copy_by_client const&) { return *this; } + }; + +} // namespace util +#endif /*LIB_NOCOPY_H*/ diff --git a/src/proc/mobject/session/query-resolver.hpp b/src/proc/mobject/session/query-resolver.hpp index c09ee9d9d..43a290549 100644 --- a/src/proc/mobject/session/query-resolver.hpp +++ b/src/proc/mobject/session/query-resolver.hpp @@ -29,6 +29,7 @@ #include "lib/bool-checkable.hpp" #include "lib/typed-counter.hpp" #include "lib/iter-adapter.hpp" +#include "lib/nocopy.hpp" #include "lib/util.hpp" #include @@ -52,15 +53,6 @@ namespace session { using std::tr1::function; using std::string; - class no_copy_by_client - { - protected: - ~no_copy_by_client() {} - no_copy_by_client() {} - no_copy_by_client (no_copy_by_client const&) {} - no_copy_by_client const& - operator=(no_copy_by_client const&) { return *this; } - }; class Goal; class Resolution; @@ -77,7 +69,7 @@ namespace session { * Query ABC */ class Goal - : no_copy_by_client + : util::no_copy_by_client { public: virtual ~Goal() ;