Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

sequence.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 #ifndef AKAXISO2_FRAMEWORK_SEQUENCE_H__
00003 #define AKAXISO2_FRAMEWORK_SEQUENCE_H__
00004 
00010 #include <akaxiso2/framework/simpletype.h>
00011 #include <akaxiso2/framework/attribute.h>
00012 #include <akaxiso2/framework/memberdef.h>
00013 #include <akaxiso2/framework/closure.h>
00014 #include <akaxiso2/framework/model_check.h>
00015 
00016 namespace aka2 {
00017 
00018   template<class L>
00019   class sequence_op_dispatcher : public sequence_op {
00020   public:
00021     virtual schematype_id get_schematype() const { return sequence_id; }
00022     virtual std::string get_typename() const { return L::get_xmltype(); }
00024     virtual bool equals(const void *lhs, const void *rhs) const {
00025       return L::equals(lhs, rhs);
00026     }
00027 
00028     virtual void construct(void *e) const {  L::construct(e); }
00029     virtual void copy_construct(void *e, const void *src) const { L::copy_construct(e, src); }
00030     virtual void destruct(void *e) const { L::destruct(e); }
00031     virtual size_t class_size() const { return L::class_size(); }
00032 
00034     virtual const attribute_types *get_attribute_types() const {
00035       return &L::attribute_types_;
00036     }
00038     virtual const member_types &get_member_types() const {
00039       return L::member_types_;
00040     }
00041     virtual const attribute_type *get_anyattr_type() const { return L::get_anyattr_type(); }
00042   };
00043 
00044 
00045   template<class L, class T>
00046   struct sequence_statics {
00047     static member_types member_types_;
00048     static sequence_op_dispatcher<L> dispatcher_;
00049   };
00050 
00051   template<class L, class T>
00052   member_types sequence_statics<L, T>::member_types_;
00053 
00054   template<class L, class T>
00055   sequence_op_dispatcher<L> sequence_statics<L, T>::dispatcher_;
00056 
00057 
00070   template<class T, class L=xiso::leaf<T> >
00071   class sequence : public attributes<L, T>,
00072                    public sequence_statics<L, T>,
00073                    public memberdef<L, T> {
00074   public:
00075     typedef T value_type;
00076 
00077     virtual ~sequence(){}
00078 
00079     static member_type* register_membertype(const member_type &mtype) {
00080       L::member_types_.push_back(mtype);
00081       return &L::member_types_.back();
00082     }
00083 
00084     static void initialize() {
00085       if (!system_type_registry().add(L()))
00086         return;
00087       L::member_types_.clear();
00088       L::attribute_types_.clear();
00089       L l; l.model();
00090       check_emptiable(L::member_types_);
00091     }
00092 
00093     static void uninitialize() {
00094       L::member_types_.clear();
00095       L::attribute_types_.clear();
00096     }
00097 
00098 
00099     static void construct(void *e) {
00100       new (e) T();
00101       sequence_construct(e, L::dispatcher_);
00102     }
00103     static void copy_construct(void *e, const void *src) {
00104       new (e) T(*static_cast<const T*>(src));
00105     }
00106     static size_t class_size() { return sizeof(T); }
00107     static void destruct(void *elm) { static_cast<T*>(elm)->~T(); }
00108 
00109     static bool equals(const void *lhs, const void *rhs) {
00110       return sequence_equals(lhs, rhs, L::dispatcher_);
00111     }
00112 
00113     static element_op* get_attribute_dispatcher() { return &L::dispatcher_; }
00114     static default_op* create_default_op() { return 0; }
00115 
00122     static void enclose(const std::string &tagname) {
00123       member_type mtype(new null_getter(), enclose_op::op_, false);
00124       mtype.set_name(qname(tagname));
00125       L::register_membertype(mtype);
00126     }
00127 
00134     static void disclose(const std::string &tagname) {
00135       member_type mtype(new null_getter(), disclose_op::op_, false);
00136       mtype.set_name(qname(tagname));
00137       L::register_membertype(mtype);
00138     }
00139   };
00140 
00141 } // namespace aka2
00142 
00143 #endif

Generated on Sun Dec 19 22:58:57 2004 for akaxiso2 by doxygen1.2.18