1 /*
2 * Copyright 2006 Sony Computer Entertainment Inc.
3 *
4 * Licensed under the MIT Open Source License, for details please see license.txt or the website
5 * http://www.opensource.org/licenses/mit-license.php
6 *
7 */
8
9 #include <dae.h>
10 #include <dae/daeDom.h>
11 #include <dom/domAccessor.h>
12 #include <dae/daeMetaCMPolicy.h>
13 #include <dae/daeMetaSequence.h>
14 #include <dae/daeMetaChoice.h>
15 #include <dae/daeMetaGroup.h>
16 #include <dae/daeMetaAny.h>
17 #include <dae/daeMetaElementAttribute.h>
18
19 daeElementRef
create(DAE & dae)20 domAccessor::create(DAE& dae)
21 {
22 domAccessorRef ref = new domAccessor(dae);
23 return ref;
24 }
25
26
27 daeMetaElement *
registerElement(DAE & dae)28 domAccessor::registerElement(DAE& dae)
29 {
30 daeMetaElement* meta = dae.getMeta(ID());
31 if ( meta != NULL ) return meta;
32
33 meta = new daeMetaElement(dae);
34 dae.setMeta(ID(), *meta);
35 meta->setName( "accessor" );
36 meta->registerClass(domAccessor::create);
37
38 daeMetaCMPolicy *cm = NULL;
39 daeMetaElementAttribute *mea = NULL;
40 cm = new daeMetaSequence( meta, cm, 0, 1, 1 );
41
42 mea = new daeMetaElementArrayAttribute( meta, cm, 0, 0, -1 );
43 mea->setName( "param" );
44 mea->setOffset( daeOffsetOf(domAccessor,elemParam_array) );
45 mea->setElementType( domParam::registerElement(dae) );
46 cm->appendChild( mea );
47
48 cm->setMaxOrdinal( 0 );
49 meta->setCMRoot( cm );
50
51 // Add attribute: count
52 {
53 daeMetaAttribute *ma = new daeMetaAttribute;
54 ma->setName( "count" );
55 ma->setType( dae.getAtomicTypes().get("Uint"));
56 ma->setOffset( daeOffsetOf( domAccessor , attrCount ));
57 ma->setContainer( meta );
58 ma->setIsRequired( true );
59
60 meta->appendAttribute(ma);
61 }
62
63 // Add attribute: offset
64 {
65 daeMetaAttribute *ma = new daeMetaAttribute;
66 ma->setName( "offset" );
67 ma->setType( dae.getAtomicTypes().get("Uint"));
68 ma->setOffset( daeOffsetOf( domAccessor , attrOffset ));
69 ma->setContainer( meta );
70 ma->setDefaultString( "0");
71
72 meta->appendAttribute(ma);
73 }
74
75 // Add attribute: source
76 {
77 daeMetaAttribute *ma = new daeMetaAttribute;
78 ma->setName( "source" );
79 ma->setType( dae.getAtomicTypes().get("xsAnyURI"));
80 ma->setOffset( daeOffsetOf( domAccessor , attrSource ));
81 ma->setContainer( meta );
82
83 meta->appendAttribute(ma);
84 }
85
86 // Add attribute: stride
87 {
88 daeMetaAttribute *ma = new daeMetaAttribute;
89 ma->setName( "stride" );
90 ma->setType( dae.getAtomicTypes().get("Uint"));
91 ma->setOffset( daeOffsetOf( domAccessor , attrStride ));
92 ma->setContainer( meta );
93 ma->setDefaultString( "1");
94
95 meta->appendAttribute(ma);
96 }
97
98 meta->setElementSize(sizeof(domAccessor));
99 meta->validate();
100
101 return meta;
102 }
103
104