Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tests / Sequence_Unit_Tests / mock_reference.hpp
blob61708824b4c62248cb1906f6e56fe9efb54ee9af
1 #ifndef guard_mock_reference_hpp
2 #define guard_mock_reference_hpp
3 /**
4 * @file
6 * @brief Mock an object reference so we can test the sequences in
7 * isolation.
9 * @author Carlos O'Ryan
11 #include "ace/config-all.h"
13 #include "testing_counters.hpp"
15 #include "tao/Basic_Types.h"
17 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
18 // Forward declare the class a CORBA::release function for it. That
19 // avoids having to introduce CORBA::Object into the tests.
20 // Ideally the T_var and T_out types should accept mock objects
21 // too, but that is too much to bite in the current iteration.
22 class mock_reference;
23 namespace CORBA
25 void release(mock_reference*);
28 class mock_stream;
30 TAO_END_VERSIONED_NAMESPACE_DECL
32 #include "tao/Objref_VarOut_T.h"
34 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
36 typedef mock_reference *mock_reference_ptr;
37 typedef TAO_Objref_Var_T<mock_reference> mock_reference_var;
38 typedef TAO_Objref_Out_T<mock_reference> mock_reference_out;
40 /**
41 * @class mock_reference
43 * @brief Implement a concrete class with the right interface for an
44 * object reference.
46 class mock_reference
48 public:
49 virtual ~mock_reference();
51 typedef mock_reference_var _var_type;
52 typedef mock_reference_out _out_type;
54 static mock_reference * allocate(int id);
55 static mock_reference * _nil();
57 static call_counter duplicate_calls;
58 static mock_reference * _duplicate(mock_reference * rhs);
59 static call_counter release_calls;
60 static void _tao_release(mock_reference * rhs);
61 static call_counter serialize_calls;
62 static call_counter deserialize_calls;
63 static call_counter marshal_calls;
65 inline bool operator==(mock_reference const & rhs) const
67 return id_ == rhs.id_;
70 inline bool operator!=(mock_reference const & rhs) const
72 return !(*this == rhs);
75 inline int id() const
77 return id_;
80 private:
81 mock_reference ();
83 inline mock_reference(int id)
84 : id_(id)
87 private:
88 int id_;
91 CORBA::Boolean operator<< (TAO_OutputCDR &, const mock_reference *);
92 CORBA::Boolean operator>> (TAO_InputCDR &, mock_reference *&);
94 namespace TAO
96 template<>
97 struct Objref_Traits< mock_reference>
99 static mock_reference_ptr duplicate (mock_reference_ptr);
100 static void release (mock_reference_ptr);
101 static mock_reference_ptr nil (void);
102 static CORBA::Boolean marshal (const mock_reference_ptr p, TAO_OutputCDR & cdr);
106 TAO_END_VERSIONED_NAMESPACE_DECL
107 #endif // guard_mock_reference_hpp