/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/cpp/src/qpid/amqp_0_10/complex_types.h

00001 #ifndef QPID_AMQP_0_10_COMPLEX_TYPES_H
00002 #define QPID_AMQP_0_10_COMPLEX_TYPES_H
00003 
00004 /*
00005  *
00006  * Licensed to the Apache Software Foundation (ASF) under one
00007  * or more contributor license agreements.  See the NOTICE file
00008  * distributed with this work for additional information
00009  * regarding copyright ownership.  The ASF licenses this file
00010  * to you under the Apache License, Version 2.0 (the
00011  * "License"); you may not use this file except in compliance
00012  * with the License.  You may obtain a copy of the License at
00013  * 
00014  *   http://www.apache.org/licenses/LICENSE-2.0
00015  * 
00016  * Unless required by applicable law or agreed to in writing,
00017  * software distributed under the License is distributed on an
00018  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00019  * KIND, either express or implied.  See the License for the
00020  * specific language governing permissions and limitations
00021  * under the License.
00022  *
00023  */
00024 
00025 #include "built_in_types.h"
00026 #include <iosfwd>
00027 
00028 namespace qpid {
00029 namespace amqp_0_10 {
00030 
00031 // Base classes for complex types.
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 {  // Base for commands & controls
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 }} // namespace qpid::amqp_0_10
00111 
00112 #endif  

Generated on Thu Apr 10 11:08:17 2008 for Qpid by  doxygen 1.4.7