00001 #ifndef QPID_AMQP_0_10_COMPLEX_TYPES_H
00002 #define QPID_AMQP_0_10_COMPLEX_TYPES_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "built_in_types.h"
00026 #include <iosfwd>
00027
00028 namespace qpid {
00029 namespace amqp_0_10 {
00030
00031
00032
00033 template <class V, class CV, class H> struct Visitable {
00034 typedef V Visitor;
00035 typedef CV ConstVisitor;
00036 typedef H Holder;
00037
00038 virtual ~Visitable() {}
00039 virtual void accept(Visitor&) = 0;
00040 virtual void accept(ConstVisitor&) const = 0;
00041 };
00042
00043 struct Command;
00044 struct Control;
00045
00046 struct Action {
00047 virtual ~Action() {}
00048 virtual Command* getCommand() { return 0; }
00049 virtual Control* getControl() { return 0; }
00050
00051 virtual const Command* getCommand() const {
00052 return const_cast<Action*>(this)->getCommand();
00053 }
00054 virtual const Control* getControl() const {
00055 return const_cast<Action*>(this)->getControl();
00056 }
00057 static const uint8_t SIZE=0;
00058 static const uint8_t PACK=2;
00059 };
00060
00061 struct CommandVisitor;
00062 struct ConstCommandVisitor;
00063 struct CommandHolder;
00064 struct Command
00065 : public Action,
00066 public Visitable<CommandVisitor, ConstCommandVisitor, CommandHolder>
00067 {
00068 using Action::getCommand;
00069 Command* getCommand() { return this; }
00070 uint8_t getCode() const;
00071 uint8_t getClassCode() const;
00072 const char* getName() const;
00073 const char* getClassName() const;
00074 };
00075 std::ostream& operator<<(std::ostream&, const Command&);
00076
00077 struct ControlVisitor;
00078 struct ConstControlVisitor;
00079 struct ControlHolder;
00080 struct Control
00081 : public Action,
00082 public Visitable<ControlVisitor, ConstControlVisitor, ControlHolder>
00083 {
00084 using Action::getControl;
00085 Control* getControl() { return this; }
00086 uint8_t getCode() const;
00087 uint8_t getClassCode() const;
00088 const char* getName() const;
00089 const char* getClassName() const;
00090 };
00091 std::ostream& operator<<(std::ostream&, const Control&);
00092
00093 struct StructVisitor;
00094 struct ConstStructVisitor;
00095 struct StructHolder;
00096 struct Struct
00097 : public Visitable<StructVisitor, ConstStructVisitor, StructHolder>
00098 {
00099 uint8_t getCode() const;
00100 uint8_t getPack() const;
00101 uint8_t getSize() const;
00102 uint8_t getClassCode() const;
00103 };
00104 std::ostream& operator<<(std::ostream&, const Struct&);
00105
00106 template <SegmentType E> struct ActionType;
00107 template <> struct ActionType<CONTROL> { typedef Control type; };
00108 template <> struct ActionType<COMMAND> { typedef Command type; };
00109
00110 }}
00111
00112 #endif