diff options
Diffstat (limited to 'include/gmock/gmock-actions.h')
-rw-r--r-- | include/gmock/gmock-actions.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/include/gmock/gmock-actions.h b/include/gmock/gmock-actions.h index d965e108..007ad9d3 100644 --- a/include/gmock/gmock-actions.h +++ b/include/gmock/gmock-actions.h @@ -268,6 +268,7 @@ class ActionInterface { // Returns true iff this is the DoDefault() action. bool IsDoDefault() const { return is_do_default_; } + private: template <typename Function> friend class internal::MonomorphicDoDefaultActionImpl; @@ -279,6 +280,8 @@ class ActionInterface { // True iff this action is DoDefault(). const bool is_do_default_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionInterface); }; // An Action<F> is a copyable and IMMUTABLE (except by assignment) @@ -325,6 +328,7 @@ class Action { Result Perform(const ArgumentTuple& args) const { return impl_->Perform(args); } + private: template <typename F1, typename F2> friend class internal::ActionAdaptor; @@ -362,6 +366,7 @@ class PolymorphicAction { operator Action<F>() const { return Action<F>(new MonomorphicImpl<F>(impl_)); } + private: template <typename F> class MonomorphicImpl : public ActionInterface<F> { @@ -377,9 +382,13 @@ class PolymorphicAction { private: Impl impl_; + + GTEST_DISALLOW_ASSIGN_(MonomorphicImpl); }; Impl impl_; + + GTEST_DISALLOW_ASSIGN_(PolymorphicAction); }; // Creates an Action from its implementation and returns it. The @@ -416,8 +425,11 @@ class ActionAdaptor : public ActionInterface<F1> { virtual Result Perform(const ArgumentTuple& args) { return impl_->Perform(args); } + private: const internal::linked_ptr<ActionInterface<F2> > impl_; + + GTEST_DISALLOW_ASSIGN_(ActionAdaptor); }; // Implements the polymorphic Return(x) action, which can be used in @@ -470,6 +482,7 @@ class ReturnAction { use_ReturnRef_instead_of_Return_to_return_a_reference); return Action<F>(new Impl<F>(value_)); } + private: // Implements the Return(x) action for a particular function type F. template <typename F> @@ -494,9 +507,13 @@ class ReturnAction { GMOCK_COMPILE_ASSERT_(!internal::is_reference<Result>::value, Result_cannot_be_a_reference_type); Result value_; + + GTEST_DISALLOW_ASSIGN_(Impl); }; R value_; + + GTEST_DISALLOW_ASSIGN_(ReturnAction); }; // Implements the ReturnNull() action. @@ -542,6 +559,7 @@ class ReturnRefAction { use_Return_instead_of_ReturnRef_to_return_a_value); return Action<F>(new Impl<F>(ref_)); } + private: // Implements the ReturnRef(x) action for a particular function type F. template <typename F> @@ -555,11 +573,16 @@ class ReturnRefAction { virtual Result Perform(const ArgumentTuple&) { return ref_; } + private: T& ref_; + + GTEST_DISALLOW_ASSIGN_(Impl); }; T& ref_; + + GTEST_DISALLOW_ASSIGN_(ReturnRefAction); }; // Implements the DoDefault() action for a particular function type F. @@ -611,9 +634,12 @@ class AssignAction { void Perform(const ArgumentTuple& /* args */) const { *ptr_ = value_; } + private: T1* const ptr_; const T2 value_; + + GTEST_DISALLOW_ASSIGN_(AssignAction); }; #if !GTEST_OS_WINDOWS_MOBILE @@ -631,9 +657,12 @@ class SetErrnoAndReturnAction { errno = errno_; return result_; } + private: const int errno_; const T result_; + + GTEST_DISALLOW_ASSIGN_(SetErrnoAndReturnAction); }; #endif // !GTEST_OS_WINDOWS_MOBILE @@ -657,6 +686,8 @@ class SetArgumentPointeeAction { private: const A value_; + + GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction); }; template <size_t N, typename Proto> @@ -675,8 +706,11 @@ class SetArgumentPointeeAction<N, Proto, true> { CompileAssertTypesEqual<void, Result>(); ::std::tr1::get<N>(args)->CopyFrom(*proto_); } + private: const internal::linked_ptr<Proto> proto_; + + GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction); }; // Implements the InvokeWithoutArgs(f) action. The template argument @@ -696,8 +730,11 @@ class InvokeWithoutArgsAction { // compatible with f. template <typename Result, typename ArgumentTuple> Result Perform(const ArgumentTuple&) { return function_impl_(); } + private: FunctionImpl function_impl_; + + GTEST_DISALLOW_ASSIGN_(InvokeWithoutArgsAction); }; // Implements the InvokeWithoutArgs(object_ptr, &Class::Method) action. @@ -711,9 +748,12 @@ class InvokeMethodWithoutArgsAction { Result Perform(const ArgumentTuple&) const { return (obj_ptr_->*method_ptr_)(); } + private: Class* const obj_ptr_; const MethodPtr method_ptr_; + + GTEST_DISALLOW_ASSIGN_(InvokeMethodWithoutArgsAction); }; // Implements the IgnoreResult(action) action. @@ -739,6 +779,7 @@ class IgnoreResultAction { return Action<F>(new Impl<F>(action_)); } + private: template <typename F> class Impl : public ActionInterface<F> { @@ -760,9 +801,13 @@ class IgnoreResultAction { OriginalFunction; const Action<OriginalFunction> action_; + + GTEST_DISALLOW_ASSIGN_(Impl); }; const A action_; + + GTEST_DISALLOW_ASSIGN_(IgnoreResultAction); }; // A ReferenceWrapper<T> object represents a reference to type T, @@ -827,10 +872,14 @@ class DoBothAction { private: const Action<VoidResult> action1_; const Action<F> action2_; + + GTEST_DISALLOW_ASSIGN_(Impl); }; Action1 action1_; Action2 action2_; + + GTEST_DISALLOW_ASSIGN_(DoBothAction); }; } // namespace internal |