source: trunk/Lucide/SOURCE/plugins/ludoc/luinode.cpp @ 35

Last change on this file since 35 was 35, checked in by Eugene Romanenko, 15 years ago

added licence block to source files

File size: 5.2 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: CDDL 1.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the COMMON DEVELOPMENT AND
5 * DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6 * this file except in compliance with the License. You may obtain a copy of
7 * the License at http://www.sun.com/cddl/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Initial Developer of the Original Code is
15 * Eugene Romanenko, netlabs.org.
16 * Portions created by the Initial Developer are Copyright (C) 2006
17 * the Initial Developer. All Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 * Alternatively, the contents of this file may be used under the terms of
22 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
23 * in which case the provisions of the LGPL are applicable instead of those
24 * above. If you wish to allow use of your version of this file only under the
25 * terms of the LGPL, and not to allow others to use your version of this file
26 * under the terms of the CDDL, indicate your decision by deleting the
27 * provisions above and replace them with the notice and other provisions
28 * required by the LGPL. If you do not delete the provisions above, a recipient
29 * may use your version of this file under the terms of any one of the CDDL
30 * or the LGPL.
31 *
32 * ***** END LICENSE BLOCK ***** */
33
34
35
36/*
37 *  This file was generated by the SOM Compiler.
38 *  Generated using:
39 *     SOM incremental update: 2.24
40 */
41
42
43/*
44 *  This file was generated by the SOM Compiler and Emitter Framework.
45 *  Generated using template emitter:
46 *      SOM Emitter emitxtm: 2.23.1.9
47 */
48
49#ifndef SOM_Module_luinode_Source
50#define SOM_Module_luinode_Source
51#endif
52#define LuIndexNode_Class_Source
53
54#include <string.h>
55#include <vector>
56using namespace std;
57
58#include "luinode.xih"
59
60
61
62static char *newstrdup( const char *s )
63{
64    if ( s == NULL ) {
65        return NULL;
66    }
67    char *temp = new char[ strlen( s ) + 1 ];
68    strcpy( temp, s );
69    return temp;
70}
71
72
73typedef vector<LuIndexNode *> NodeList;
74
75
76struct LuINodeData
77{
78    LuLink link;
79    NodeList *nodes;
80    int index;
81
82    LuINodeData( LuLink *l );
83    ~LuINodeData();
84};
85
86LuINodeData::LuINodeData( LuLink *l )
87{
88    memset( &link, 0, sizeof( LuLink ) );
89    if ( l != NULL )
90    {
91        link.title = newstrdup( l->title );
92        link.uri = newstrdup( l->uri );
93        link.type = l->type;
94        link.page = l->page;
95    }
96
97    nodes = new NodeList;
98
99    index = 0;
100}
101
102LuINodeData::~LuINodeData()
103{
104    delete link.title;
105    delete link.uri;
106
107    for ( int i = 0; i < nodes->size(); i++ ) {
108        delete (*nodes)[i];
109    }
110    delete nodes;
111}
112
113
114SOM_Scope void SOMLINK LuIndexNodeInit(LuIndexNode *somSelf,
115                                        Environment *ev, somInitCtrl* ctrl,
116                                       LuLink* link)
117{
118    LuIndexNodeData *somThis;
119    somInitCtrl globalCtrl;
120    somBooleanVector myMask;
121    LuIndexNode_BeginInitializer_LuIndexNodeInit;
122
123    LuIndexNode_Init_SOMObject_somDefaultInit(somSelf, ctrl);
124
125    // local LuIndexNode initialization code added by programmer
126    LuINodeData *d = new LuINodeData( link );
127    somThis->data = d;
128}
129
130
131SOM_Scope void  SOMLINK addChild(LuIndexNode *somSelf,  Environment *ev,
132                                 LuIndexNode* node)
133{
134    LuIndexNodeData *somThis = LuIndexNodeGetData(somSelf);
135    LuINodeData *d = (LuINodeData *)somThis->data;
136    d->nodes->push_back( node );
137}
138
139
140SOM_Scope LuIndexNode*  SOMLINK getFirstChild(LuIndexNode *somSelf,
141                                               Environment *ev)
142{
143    LuIndexNodeData *somThis = LuIndexNodeGetData(somSelf);
144    LuINodeData *d = (LuINodeData *)somThis->data;
145    d->index = 0;
146    if ( d->nodes->size() == 0 ) {
147        return NULL;
148    }
149    return (*(d->nodes))[ d->index++ ];
150}
151
152
153SOM_Scope LuIndexNode*  SOMLINK getNextChild(LuIndexNode *somSelf,
154                                              Environment *ev)
155{
156    LuIndexNodeData *somThis = LuIndexNodeGetData(somSelf);
157    LuINodeData *d = (LuINodeData *)somThis->data;
158    if ( d->index >= d->nodes->size() ) {
159        return NULL;
160    }
161    return (*(d->nodes))[ d->index++ ];
162}
163
164
165SOM_Scope LuLink*  SOMLINK getLink(LuIndexNode *somSelf,  Environment *ev)
166{
167    LuIndexNodeData *somThis = LuIndexNodeGetData(somSelf);
168    LuINodeData *d = (LuINodeData *)somThis->data;
169    return &(d->link);
170}
171
172
173SOM_Scope void SOMLINK somDestruct(LuIndexNode *somSelf, octet doFree,
174                                   som3DestructCtrl* ctrl)
175{
176    LuIndexNodeData *somThis;
177    somDestructCtrl globalCtrl;
178    somBooleanVector myMask;
179    LuIndexNode_BeginDestructor;
180
181    // local LuIndexNode deinitialization code begin
182    LuINodeData *d = (LuINodeData *)somThis->data;
183    //somPrintf( "LuIndexNode destructor, title %s\n", d->link.title );
184    delete d;
185    // local LuIndexNode deinitialization code end
186
187    LuIndexNode_EndDestructor;
188}
189
190
Note: See TracBrowser for help on using the repository browser.