GenerateAtts.h 101 KB
Newer Older
hrchilds's avatar
hrchilds committed
1
2
/*****************************************************************************
*
brugger's avatar
 
brugger committed
3
* Copyright (c) 2000 - 2008, Lawrence Livermore National Security, LLC
hrchilds's avatar
hrchilds committed
4
* Produced at the Lawrence Livermore National Laboratory
brugger's avatar
 
brugger committed
5
* LLNL-CODE-400142
hrchilds's avatar
hrchilds committed
6
7
* All rights reserved.
*
brugger's avatar
 
brugger committed
8
* This file is  part of VisIt. For  details, see https://visit.llnl.gov/.  The
hrchilds's avatar
hrchilds committed
9
10
11
12
13
14
15
16
17
18
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution  and  use  in  source  and  binary  forms,  with  or  without
* modification, are permitted provided that the following conditions are met:
*
*  - Redistributions of  source code must  retain the above  copyright notice,
*    this list of conditions and the disclaimer below.
*  - Redistributions in binary form must reproduce the above copyright notice,
*    this  list of  conditions  and  the  disclaimer (as noted below)  in  the
brugger's avatar
 
brugger committed
19
20
21
*    documentation and/or other materials provided with the distribution.
*  - Neither the name of  the LLNS/LLNL nor the names of  its contributors may
*    be used to endorse or promote products derived from this software without
hrchilds's avatar
hrchilds committed
22
23
24
25
26
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR  IMPLIED WARRANTIES, INCLUDING,  BUT NOT  LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND  FITNESS FOR A PARTICULAR  PURPOSE
brugger's avatar
 
brugger committed
27
28
29
* ARE  DISCLAIMED. IN  NO EVENT  SHALL LAWRENCE  LIVERMORE NATIONAL  SECURITY,
* LLC, THE  U.S.  DEPARTMENT OF  ENERGY  OR  CONTRIBUTORS BE  LIABLE  FOR  ANY
* DIRECT,  INDIRECT,   INCIDENTAL,   SPECIAL,   EXEMPLARY,  OR   CONSEQUENTIAL
hrchilds's avatar
hrchilds committed
30
31
32
33
34
35
36
37
38
* DAMAGES (INCLUDING, BUT NOT  LIMITED TO, PROCUREMENT OF  SUBSTITUTE GOODS OR
* SERVICES; LOSS OF  USE, DATA, OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER
* CAUSED  AND  ON  ANY  THEORY  OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT
* LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY  WAY
* OUT OF THE  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/

hrchilds's avatar
hrchilds committed
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef GENERATE_ATTS_H
#define GENERATE_ATTS_H

#include <vector>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <sys/types.h>
#include <time.h>
#include "Field.h"

using std::vector;

whitlocb's avatar
whitlocb committed
52
53
#define GENERATOR_NAME "xml2atts"

hrchilds's avatar
hrchilds committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// ****************************************************************************
//  File:  GenerateAtts
//
//  Purpose:
//    Contains a set of classes which override the default implementation
//    to create an attribute subject.
//
//  Note: This file overrides --
//    FieldFactory
//    Field
//    Attribute
//    Enum
//    Plugin
//
//  Programmer:  Jeremy Meredith
//  Creation:    August 28, 2001
//
//  Modifications:
//    Jeremy Meredith, Wed Feb  6 16:51:14 PST 2002
//    Removed some of the source Initializer routines since the SetDefault
//    routines should work just fine when an initializer is needed for these.
//
//    Jeremy Meredith, Fri Apr 19 15:25:46 PDT 2002
//    Added constants, includes, and a codefile.  Made the HasFunction,
//    PrintFunction, DeleteFunction all check to make sure we are trying
//    to override a builtin function.  Made use of the prefix/postfix
//    additional code from the codefile.  Made use of overridden functions
//    in more places.
//
//    Jeremy Meredith, Wed May  8 15:26:37 PDT 2002
//    Added ability to have non-persistent objects.
//    Made enums work like enums, not just static ints.
//    Added some methods needed for keyframing.
//
//    Brad Whitlock, Tue May 14 10:23:57 PDT 2002
//    Added support for exporting symbols.
//
//    Kathleen Bonnell, Fri Jun 28 09:32:26 PDT 2002 
//    Implemented SetDefault for IntVector, DoubleVector, and StringVector.
//
//    Jeremy Meredith, Sat Aug  3 11:58:40 PDT 2002
//    Allowed attributes without fields.
//
//    Jeremy Meredith, Wed Aug 14 17:30:09 PDT 2002
//    Fixed a bug where an "int i;" was missing from some functions.
//
//    Jeremy Meredith, Tue Aug 27 14:32:50 PDT 2002
//    Added mfiles, dbtype, and libs.  Allowed NULL atts.
//
//    Jeremy Meredith, Thu Oct 17 15:58:29 PDT 2002
//    Added some enhancements for the XML editor.
//
//    Jeremy Meredith, Sun Nov 17 17:41:12 PST 2002
//    Fixed a compiler warning on the SGIs.
//
//    Sean Ahern, Mon Nov 18 14:43:14 PST 2002
//    Added widget files.
//
//    Brad Whitlock, Mon Nov 18 14:46:41 PST 2002
//    Ported to Windows.
//
//    Jeremy Meredith, Fri Jan 17 10:01:08 PST 2003
//    Made it handle AGs with multiple AG vectors.
//
//    Brad Whitlock, Mon Feb 10 13:19:36 PST 2003
//    I made it generate static methods to convert enums to and from strings.
//
//    Brad Whitlock, Thu Mar 13 12:36:58 PDT 2003
//    I added another argument to the Plugin constructor.
//
//    Brad Whitlock, Tue May 20 08:50:48 PDT 2003
//    I changed the code generation for the CreateNode method so it writes out
//    only the fields that differ from the default values for the class. I also
//    made the generated code have fewer unneeded variables.
//
hrchilds's avatar
hrchilds committed
129
130
131
//    Brad Whitlock, Tue Jul 15 13:22:36 PST 2003
//    I added range checking for enums so reading from config files is safer.
//
hrchilds's avatar
hrchilds committed
132
133
134
//    Brad Whitlock, Wed Jul 23 11:17:25 PDT 2003
//    I added code to generate a NewInstance method.
//
hrchilds's avatar
hrchilds committed
135
136
137
138
//    Jeremy Meredith, Tue Sep 23 16:17:41 PDT 2003
//    Changed haswriter to be a bool.
//    Made attributes with multiple vector fields use a single counter.
//
hrchilds's avatar
hrchilds committed
139
140
141
142
//    Brad Whitlock, Thu Oct 9 11:47:28 PDT 2003
//    I changed the code generation so that colors are always added to the
//    DataNode in CreateNode.
//
hrchilds's avatar
hrchilds committed
143
144
145
//    Jeremy Meredith, Wed Nov  5 13:28:03 PST 2003
//    Added ability to disable plugins by default.
//
hrchilds's avatar
hrchilds committed
146
147
148
//    Brad Whitlock, Wed Dec 17 11:55:11 PDT 2003
//    I changed the generated code so CreateNode has three args.
//
hrchilds's avatar
hrchilds committed
149
150
151
//    Jeremy Meredith, Wed Jul  7 17:08:03 PDT 2004
//    Allow for mdserver-specific code in a plugin's source files.
//
hrchilds's avatar
hrchilds committed
152
153
154
155
//    Jeremy Meredith, Wed Sep  1 12:38:10 PDT 2004
//    Removed AttVector's header SetXXX method prototype.
//    Honor non-member user-defined functions.
//
hrchilds's avatar
hrchilds committed
156
157
158
//    Brad Whitlock, Wed Dec 8 15:48:10 PST 2004
//    Added support for variable names as a type.
//
hrchilds's avatar
hrchilds committed
159
160
161
//    Jeremy Meredith, Mon Apr  4 16:45:55 PDT 2005
//    Fixed capitalization for the att-vector helper methods.
//
hrchilds's avatar
hrchilds committed
162
163
164
//    Hank Childs, Tue May 24 09:54:36 PDT 2005
//    Added new argument to constructor for hasoptions.
//
hrchilds's avatar
hrchilds committed
165
166
167
168
//    Kathleen Bonnell, Mon Feb  6 16:23:30 PST 2006 
//    Allow assignment operator and 'SetProperty' methods from codefile to 
//    replace default generated methods. 
//
hrchilds's avatar
hrchilds committed
169
170
171
//    Hank Childs, Thu Jun  8 16:52:47 PDT 2006
//    Added copyright.
//
hrchilds's avatar
hrchilds committed
172
173
174
//    Cyrus Harrison, Wed Mar  7 09:47:13 PST 2007
//    Allow for engine-specific code in a plugin's source files
//
hrchilds's avatar
hrchilds committed
175
176
177
178
//    Brad Whitlock, Thu Mar 1 16:06:53 PST 2007
//    Added support for some AVT enums and for public/protected/private members.
//    I also changed the names of the generated access methods for attVectors.
//
179
180
181
182
//    Hank Childs, Tue Aug 28 14:46:34 PDT 2007
//    Print out a warning if someone declares a builtin function that is
//    being ignored.
//
whitlocb's avatar
whitlocb committed
183
184
185
//    Brad Whitlock, Fri Dec 14 14:13:02 PST 2007
//    Add case identifiers for fields.
//
186
187
188
189
//    Brad Whitlock, Fri Feb 15 15:01:39 PST 2008
//    Added some tests that should prevent source from being flagged as an
//    error in Klockwork.
//
whitlocb's avatar
whitlocb committed
190
191
192
193
//    Brad Whitlock, Thu Feb 28 14:10:04 PST 2008
//    Added generatorName and made it use HasCode,PrintCode instead of 
//    accessing the code file directly.
//
194
195
196
//    Jeremy Meredith, Thu Aug  7 14:34:01 EDT 2008
//    Reorder constructor initializers to be the correct order.
//
hrchilds's avatar
hrchilds committed
197
198
199
200
201
202
203
// ****************************************************************************

// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------

class AttsGeneratorField : public virtual Field
{
whitlocb's avatar
whitlocb committed
204
205
  protected:
    QString generatorName;
hrchilds's avatar
hrchilds committed
206
207
  public:
    AttsGeneratorField(const QString &t, const QString &n, const QString &l)
whitlocb's avatar
whitlocb committed
208
209
210
211
        : Field(t,n,l), generatorName(GENERATOR_NAME)
    {
    }
    QString GetCPPNameW(int w, bool subtypename=false, const QString &classname="")
hrchilds's avatar
hrchilds committed
212
213
214
215
216
217
218
219
220
221
222
223
    {
        QString s = GetCPPName(subtypename,classname);
        for (int i=w - s.length(); i>0; i--)
            s += " ";
        return s;
    }
    virtual bool CanHaveConst() { return false; }
    virtual QString GetAttributeGroupID() = 0;
    virtual QString DataNodeConversion()
    {
        return "BadType";
    }
whitlocb's avatar
whitlocb committed
224
225
226
227
    virtual QString FieldID() const
    {
        return QString("ID_") + name;
    }
hrchilds's avatar
hrchilds committed
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
    virtual void AddAttributeIncludes(UniqueStringList &sl) const
    {
    }
    virtual void WriteHeaderForwardDeclarations(ostream &h) { }
    virtual void AddSystemIncludes(UniqueStringList &sl) { }
    virtual void WriteHeaderSelectFunction(ostream &h)
    {
        if (CanHaveConst())
        {
            h << "    void Select" << Name << "();" << endl;
        }
    }
    virtual void WriteHeaderSetFunction(ostream &h)
    {
        h << "    void Set"<<Name<<"(";
        if (CanHaveConst())
            h << "const ";
        h << GetCPPName(true) << " ";
        if (isArray) 
            h << "*";
        else if (CanHaveConst())
            h << "&";
        h << name << "_);" << endl;
    }
    virtual void WriteHeaderGetFunction(ostream &h, int w)
    {
        if (isArray)
        {
            h << "    const " << GetCPPNameW(w) << " *Get" << Name << "() const;" << endl;
            h << "          " << GetCPPNameW(w) << " *Get" << Name << "();" << endl;
        }
        else if (CanHaveConst())
        {
            h << "    const " << GetCPPNameW(w) << " &Get" << Name << "() const;" << endl;
            h << "          " << GetCPPNameW(w) << " &Get" << Name << "();" << endl;
        }
        else
            h << "    " << GetCPPNameW(w,true) << " Get" << Name << "() const;" << endl;
    }
    virtual void WriteHeaderAGVectorProto(ostream &h) { }
    virtual void WriteHeaderSoloAGVectorProto(ostream &h) { }
    virtual void WriteHeaderAttribute(ostream &h, int w)
    {
        h << "    " << GetCPPNameW(w) << " " << name;
        if (isArray)
            h << "[" << length << "]";
        h << ";" << endl;
    }
    // ------------------------------------------------------------------------
    virtual void WriteSourceIncludes(ostream &c)
    {
    }
    virtual void WriteSourceInitializer(ostream &c)
    {
    }
    virtual bool RequiresSourceInitializer() const
    {
        return false;
    }
    virtual void WriteSourceSetFunction(ostream &c, const QString &classname)
    {
        // Write prototype.
        c << "void" << endl;
        c << classname << "::Set" << Name << "(";
        if (CanHaveConst())
            c << "const ";
        c << GetCPPName(true,classname) << " ";
        if (isArray)
            c << "*";
        else if (CanHaveConst())
            c << "&";
        c << name << "_)" << endl;

        // Write function body
        c << "{" << endl;
whitlocb's avatar
whitlocb committed
303
304
305
306
307
308
309

        QString codeName(QString("Set")+Name);
        if(HasCode(codeName, 0, generatorName))
        {
            PrintCode(c, codeName, 0, generatorName);
            c << endl;
        }
hrchilds's avatar
hrchilds committed
310
311
312
313

        if (!isArray)
        {
            c << "    " << name << " = " << name << "_;" << endl;
whitlocb's avatar
whitlocb committed
314
            c << "    Select(" << FieldID() << ", "
hrchilds's avatar
hrchilds committed
315
316
317
318
319
320
321
322
323
324
325
326
327
328
              << "(void *)&" << name << ");" << endl;
        }
        else
        {
            if (length < 5)
            {
                for(int i = 0; i < length; ++i)
                    c << "    " << name << "[" << i << "] = " << name << "_[" << i << "];"<< endl;
            }
            else
            {
                c << "    for(int i = 0; i < " << length << "; ++i)" << endl;
                c << "        " << name << "[i] = " << name << "_[i];"<< endl;
            }
whitlocb's avatar
whitlocb committed
329
            c << "    Select(" << FieldID() << ", (void *)" << name << ", " << length << ");" << endl;
hrchilds's avatar
hrchilds committed
330
331
        }

whitlocb's avatar
whitlocb committed
332
333
334
335
336
        if(HasCode(codeName, 1, generatorName))
        {
            PrintCode(c, codeName, 1, generatorName);
            c << endl;
        }
hrchilds's avatar
hrchilds committed
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399

        c << "}" << endl;
        c << endl;
    }
    virtual void WriteSourceGetFunction(ostream &c, const QString &classname, bool doConst)
    {
        if (isArray)
        {
            if (doConst)
            {
                c << "const " << GetCPPName() << " *" << endl << classname << "::Get"
                  << Name << "() const" << endl;
            }
            else
            {
                c << GetCPPName() << " *" << endl << classname << "::Get"
                  << Name << "()" << endl;
            }
        }
        else if (CanHaveConst())
        {
            if (doConst)
            {
                c << "const " << GetCPPName() << " &" << endl << classname
                  << "::Get" << Name << "() const" << endl;
            }
            else
            {
                c << GetCPPName() << " &" << endl << classname << "::Get"
                  << Name << "()" << endl;
            }
        }
        else
        {
            c << GetCPPName(true,classname) << endl << classname << "::Get"
              << Name << "() const" << endl;
        }

        // Function body
        c << "{" << endl;
        if (type == "attArray")
        {
            cerr << "EEEEEERRRRRRRRROOOOOOORRRRRRR" << endl;
        }
        else
        {
            if (type == "enum")
                c << "    return " << GetCPPName(true) << "(" << name << ");" << endl;
            else
                c << "    return " << name << ";" << endl;
        }
        c << "}" << endl;
        c << endl;
    }
    virtual void WriteSourceSelectFunction(ostream &c, const QString &classname)
    {
        if (! CanHaveConst())
            return;

        c << "void" << endl << classname << "::Select" << Name << "()" << endl;
        c << "{" << endl;
        if (isArray)
        {
whitlocb's avatar
whitlocb committed
400
            c << "    Select(" << FieldID() << ", (void *)"
hrchilds's avatar
hrchilds committed
401
402
403
404
              << name << ", " << length  << ");";
        }
        else
        {
whitlocb's avatar
whitlocb committed
405
            c << "    Select(" << FieldID() << ", (void *)&"
hrchilds's avatar
hrchilds committed
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
              << name << ");";
        }
        c << endl << "}" << endl << endl;
    }
    virtual void WriteSourceAGVectorFunctions(ostream &c, const QString &classname, const QString &purpose)
    {
    }
    virtual void WriteSourceSoloAGVectorFunctions(ostream &c, const QString &classname, const QString &purpose)
    {
    }
    virtual void WriteSourceSetDefault(ostream &c) = 0;
    virtual void WriteSourceCopyCode(ostream &c)
    {
        if (isArray)
        {
            if (length < 4)
            {
                for(int i = 0; i < length; ++i)
                {
                    c << "    " << name << "[" << i << "] = "
                      << "obj." << name << "[" << i << "];" << endl;
                }
            }
            else
            {
431
                c << "    for(int i = 0; i < " << length << "; ++i)" << endl;
hrchilds's avatar
hrchilds committed
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
                c << "        " << name << "[i] = " 
                  <<     "obj." << name << "[i];" << endl;
            }
            c << endl;
        }
        else
        {
            c << "    " << name << " = obj." << name << ";" << endl;
        }
    }
    virtual void WriteSourceDestructor(ostream &c)
    {
    }
    virtual void WriteSourceSetFromNode(ostream &c)
    {
        c << "    if((node = searchNode->GetNode(\"" << name
          << "\")) != 0)" << endl;
        c << "        Set" << Name << "(";
        c << "node->" << DataNodeConversion() << "());" << endl;
    }
    virtual void WriteSourceSubAttributeGroupSingle(ostream &c)
    {
    }
    virtual void WriteSourceSubAttributeGroup(ostream &c)
    {
    }
    virtual void WriteSourceComparisonPrecalc(ostream &c, const QString &indent)
    {
        if (isArray)
        {
            c << indent << "// Compare the " << name << " arrays." << endl;
            c << indent << "bool " << name << "_equal = true;" << endl; 
464
            c << indent << "for(int i = 0; i < " << length << " && "
hrchilds's avatar
hrchilds committed
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
              << name << "_equal; ++i)" << endl;
            c << indent << "    " << name << "_equal = ("
              << name << "[i] == obj." << name
              << "[i]);" << endl << endl;
        }
    }
    virtual void WriteSourceComparison(ostream &c)
    {
        if (isArray)
            c << name << "_equal";
        else
        {
            c << "(" << name << " == obj." << name << ")";
        }
    }
hrchilds's avatar
hrchilds committed
480
    virtual QString GetFieldType() const { return type; }
hrchilds's avatar
hrchilds committed
481
482
483
484
485
486
487
488
489
};

//
// ------------------------------------ Int -----------------------------------
//
class AttsGeneratorInt : public virtual Int , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorInt(const QString &n, const QString &l)
490
        : Field("int",n,l), Int(n,l), AttsGeneratorField("int",n,l) { }
hrchilds's avatar
hrchilds committed
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
    virtual QString GetAttributeGroupID()
    {
        return "i";
    }
    virtual QString DataNodeConversion()
    {
        return "AsInt";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        c << "    " << name << " = " << val << ";" << endl;
    }
};

//
// -------------------------------- IntArray --------------------------------
//
class AttsGeneratorIntArray : public virtual IntArray , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorIntArray(const QString &s, const QString &n, const QString &l)
512
        : Field("intArray",n,l), IntArray(s,n,l), AttsGeneratorField("intArray",n,l) { }
hrchilds's avatar
hrchilds committed
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "I";
    }
    virtual QString DataNodeConversion()
    {
        return "AsIntArray";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        for (int i=0; i<length; i++)
            c << "    " << name << "["<<i<<"] = " << val[i] << ";" << endl;
    }
};


//
// -------------------------------- IntVector --------------------------------
//
class AttsGeneratorIntVector : public virtual IntVector , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorIntVector(const QString &n, const QString &l)
537
        : Field("intVector",n,l), IntVector(n,l), AttsGeneratorField("intVector",n,l) { }
hrchilds's avatar
hrchilds committed
538
539
540
541
542
543
544
545
546
547
548
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "i*";
    }
    virtual QString DataNodeConversion()
    {
        return "AsIntVector";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
549
        for (size_t i=0; i < val.size(); i++)
hrchilds's avatar
hrchilds committed
550
551
552
553
554
555
556
557
558
559
560
561
            c << "    " << name << ".push_back(" << val[i] << ");" << endl;
    }
};


// 
// ----------------------------------- Bool -----------------------------------
//
class AttsGeneratorBool : public virtual Bool , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorBool(const QString &n, const QString &l)
562
        : Field("bool",n,l), Bool(n,l), AttsGeneratorField("bool",n,l) { }
hrchilds's avatar
hrchilds committed
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
    virtual QString GetAttributeGroupID()
    {
        return "b";
    }
    virtual QString DataNodeConversion()
    {
        return "AsBool";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        c << "    " << name << " = " << (val ? "true" : "false") << ";" << endl;
    }
};


//
// ----------------------------------- Float ----------------------------------
//
class AttsGeneratorFloat : public virtual Float , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorFloat(const QString &n, const QString &l)
585
        : Field("float",n,l), Float(n,l), AttsGeneratorField("float",n,l) { }
hrchilds's avatar
hrchilds committed
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
    virtual QString GetAttributeGroupID()
    {
        return "f";
    }
    virtual QString DataNodeConversion()
    {
        return "AsFloat";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        c << "    " << name << " = " << val << ";" << endl;
    }
};


//
// -------------------------------- FloatArray -------------------------------
//
class AttsGeneratorFloatArray : public virtual FloatArray , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorFloatArray(const QString &s, const QString &n, const QString &l)
608
        : Field("floatArray",n,l), FloatArray(s,n,l), AttsGeneratorField("floatArray",n,l) { }
hrchilds's avatar
hrchilds committed
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "F";
    }
    virtual QString DataNodeConversion()
    {
        return "AsFloatArray";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        for (int i=0; i<length; i++)
            c << "    " << name << "["<<i<<"] = " << val[i] << ";" << endl;
    }
};


//
// ---------------------------------- Double ----------------------------------
//
class AttsGeneratorDouble : public virtual Double , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorDouble(const QString &n, const QString &l)
633
        : Field("double",n,l), Double(n,l), AttsGeneratorField("double",n,l) { }
hrchilds's avatar
hrchilds committed
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
    virtual QString GetAttributeGroupID()
    {
        return "d";
    }
    virtual QString DataNodeConversion()
    {
        return "AsDouble";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        c << "    " << name << " = " << val << ";" << endl;
    }
};


//
// -------------------------------- DoubleArray -------------------------------
//
class AttsGeneratorDoubleArray : public virtual DoubleArray , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorDoubleArray(const QString &s, const QString &n, const QString &l)
656
        : Field("doubleArray",n,l), DoubleArray(s,n,l), AttsGeneratorField("doubleArray",n,l) { }
hrchilds's avatar
hrchilds committed
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "D";
    }
    virtual QString DataNodeConversion()
    {
        return "AsDoubleArray";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        for (int i=0; i<length; i++)
            c << "    " << name << "["<<i<<"] = " << val[i] << ";" << endl;
    }
};


//
// ------------------------------- DoubleVector -------------------------------
//
class AttsGeneratorDoubleVector : public virtual DoubleVector , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorDoubleVector(const QString &n, const QString &l)
681
        : Field("doubleVector",n,l), DoubleVector(n,l), AttsGeneratorField("doubleVector",n,l) { }
hrchilds's avatar
hrchilds committed
682
683
684
685
686
687
688
689
690
691
692
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "d*";
    }
    virtual QString DataNodeConversion()
    {
        return "AsDoubleVector";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
693
        for (size_t i=0; i < val.size(); i++)
hrchilds's avatar
hrchilds committed
694
695
696
697
698
699
700
701
702
703
704
705
            c << "    " << name << ".push_back(" << val[i] << ");" << endl;
    }
};


//
// ----------------------------------- UChar ----------------------------------
//
class AttsGeneratorUChar : public virtual UChar , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorUChar(const QString &n, const QString &l)
706
        : Field("uchar",n,l), UChar(n,l), AttsGeneratorField("uchar",n,l) { }
hrchilds's avatar
hrchilds committed
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
    virtual QString GetAttributeGroupID()
    {
        return "u";
    }
    virtual QString DataNodeConversion()
    {
        return "AsUnsignedChar";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        c << "    " << name << " = " << int(val) << ";" << endl;
    }
};


//
// -------------------------------- UCharArray --------------------------------
//
class AttsGeneratorUCharArray : public virtual UCharArray , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorUCharArray(const QString &s, const QString &n, const QString &l)
729
        : Field("ucharArray",n,l), UCharArray(s,n,l), AttsGeneratorField("ucharArray",n,l) { }
hrchilds's avatar
hrchilds committed
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "U";
    }
    virtual QString DataNodeConversion()
    {
        return "AsUnsignedCharArray";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        for (int i=0; i<length; i++)
            c << "    " << name << "["<<i<<"] = " << int(val[i]) << ";" << endl;
    }
};


//
// ------------------------------- unsignedCharVector -------------------------------
//
class AttsGeneratorUCharVector : public virtual UCharVector , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorUCharVector(const QString &n, const QString &l)
754
        : Field("ucharVector",n,l), UCharVector(n,l), AttsGeneratorField("ucharVector",n,l) { }
hrchilds's avatar
hrchilds committed
755
756
757
758
759
760
761
762
763
764
765
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "u*";
    }
    virtual QString DataNodeConversion()
    {
        return "AsUnsignedCharVector";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
766
        for (size_t i=0; i < val.size(); i++)
hrchilds's avatar
hrchilds committed
767
768
769
770
771
772
773
774
775
776
777
778
            c << "    " << name << ".push_back(" << val[i] << ");" << endl;
    }
};


//
// ---------------------------------- String ----------------------------------
//
class AttsGeneratorString : public virtual String , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorString(const QString &n, const QString &l)
779
        : Field("string",n,l), String(n,l), AttsGeneratorField("string",n,l) { }
hrchilds's avatar
hrchilds committed
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
    virtual bool CanHaveConst() { return true; }
    virtual void AddSystemIncludes(UniqueStringList &sl) 
    { 
        sl.AddString("#include <string>\n");
    }
    virtual QString GetAttributeGroupID()
    {
        return "s";
    }
    virtual QString DataNodeConversion()
    {
        return "AsString";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        c << "    " << name << " = \"" << val << "\";" << endl;
    }
};


//
// ------------------------------- StringVector -------------------------------
//
class AttsGeneratorStringVector : public virtual StringVector , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorStringVector(const QString &n, const QString &l)
807
        : Field("stringVector",n,l), StringVector(n,l), AttsGeneratorField("stringVector",n,l) { }
hrchilds's avatar
hrchilds committed
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
    virtual bool CanHaveConst() { return true; }
    virtual void AddSystemIncludes(UniqueStringList &sl) 
    { 
        sl.AddString("#include <string>\n");
    }
    virtual QString GetAttributeGroupID()
    {
        return "s*";
    }
    virtual QString DataNodeConversion()
    {
        return "AsStringVector";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
823
        for (size_t i=0; i < val.size(); i++)
hrchilds's avatar
hrchilds committed
824
825
826
827
828
829
830
831
832
833
834
835
        c << "    " << name << ".push_back(" << "\"" << val[i].latin1() << "\");" << endl;
    }
};


//
// -------------------------------- ColorTable --------------------------------
//
class AttsGeneratorColorTable : public virtual ColorTable , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorColorTable(const QString &n, const QString &l)
836
        : Field("colortable",n,l), ColorTable(n,l), AttsGeneratorField("colortable",n,l) { }
hrchilds's avatar
hrchilds committed
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
    virtual bool CanHaveConst() { return true; }
    virtual void AddSystemIncludes(UniqueStringList &sl) 
    { 
        sl.AddString("#include <string>\n");
    }
    virtual QString GetAttributeGroupID()
    {
        return "s";
    }
    virtual QString DataNodeConversion()
    {
        return "AsString";
    }
    virtual bool RequiresSourceInitializer() const
    {
        return true;
    }
    virtual void WriteSourceInitializer(ostream &c)
    {
        if(valueSet)
            c << name << "(\""<<val<<"\")";
        else
            c << name << "(\"hot\")";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
    }
};


//
// ----------------------------------- Color ----------------------------------
//
class AttsGeneratorColor : public virtual Color , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorColor(const QString &n, const QString &l)
874
        : Field("color",n,l), Color(n,l), AttsGeneratorField("color",n,l) { }
hrchilds's avatar
hrchilds committed
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
    virtual bool CanHaveConst() { return true; }
    virtual void AddAttributeIncludes(UniqueStringList &sl) const
    {
        sl.AddString("#include <ColorAttribute.h>\n");
    }
    virtual QString GetAttributeGroupID()
    {
        return "a";
    }
    virtual bool RequiresSourceInitializer() const
    {
        return true;
    }
    virtual void WriteSourceInitializer(ostream &c)
    {
        if(valueSet)
        {
            if(val[3] == 255)
                c << name << "(" << int(val[0]) << ", " << int(val[1]) << ", "
                                 << int(val[2]) << ")";
            else
                c << name << "(" << int(val[0]) << ", " << int(val[1]) << ", "
                                 << int(val[2]) << ", " << int(val[3]) << ")";
        }
        else
            c << name << "()";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
    }
    virtual void WriteSourceSetFromNode(ostream &c)
    {
        c << "    if((node = searchNode->GetNode(\"" << name
          << "\")) != 0)" << endl;
        c << "        " << name << ".SetFromNode(node);" << endl;
    }
};


//
// --------------------------------- LineStyle --------------------------------
//
class AttsGeneratorLineStyle : public virtual LineStyle , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorLineStyle(const QString &n, const QString &l)
921
        : Field("linestyle",n,l), LineStyle(n,l), AttsGeneratorField("linestyle",n,l) { }
hrchilds's avatar
hrchilds committed
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
    virtual QString GetAttributeGroupID()
    {
        return "i";
    }
    virtual QString DataNodeConversion()
    {
        return "AsInt";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        c << "    " << name << " = " << val << ";" << endl;
    }
};


//
// --------------------------------- LineWidth --------------------------------
//
class AttsGeneratorLineWidth : public virtual LineWidth , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorLineWidth(const QString &n, const QString &l)
944
        : Field("linewidth",n,l), LineWidth(n,l), AttsGeneratorField("linewidth",n,l) { }
hrchilds's avatar
hrchilds committed
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
    virtual QString GetAttributeGroupID()
    {
        return "i";
    }
    virtual QString DataNodeConversion()
    {
        return "AsInt";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        c << "    " << name << " = " << val << ";" << endl;
    }
};


//
// --------------------------------- Opacity ----------------------------------
//
class AttsGeneratorOpacity : public virtual Opacity , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorOpacity(const QString &n, const QString &l)
967
        : Field("opacity",n,l), Opacity(n,l), AttsGeneratorField("opacity",n,l) { }
hrchilds's avatar
hrchilds committed
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
    virtual QString GetAttributeGroupID()
    {
        return "d";
    }
    virtual QString DataNodeConversion()
    {
        return "AsDouble";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        c << "    " << name << " = " << val << ";" << endl;
    }
};


hrchilds's avatar
hrchilds committed
983
984
985
986
987
988
989
//
// -------------------------------- VariableName --------------------------------
//
class AttsGeneratorVariableName : public virtual VariableName , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorVariableName(const QString &n, const QString &l)
990
991
992
        : Field("variablename",n,l), VariableName(n,l),
          AttsGeneratorField("variablename",n,l)
           { }
hrchilds's avatar
hrchilds committed
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
    virtual bool CanHaveConst() { return true; }
    virtual void AddSystemIncludes(UniqueStringList &sl) 
    { 
        sl.AddString("#include <string>\n");
    }
    virtual QString GetAttributeGroupID()
    {
        return "s";
    }
    virtual QString DataNodeConversion()
    {
        return "AsString";
    }
    virtual bool RequiresSourceInitializer() const
    {
        return true;
    }
    virtual void WriteSourceInitializer(ostream &c)
    {
        if(valueSet)
            c << name << "(\""<<val<<"\")";
        else
            c << name << "(\"default\")";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
    }
};


hrchilds's avatar
hrchilds committed
1023
1024
1025
1026
1027
1028
1029
//
// ------------------------------------ Att -----------------------------------
//
class AttsGeneratorAtt : public virtual Att , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorAtt(const QString &t, const QString &n, const QString &l)
1030
        : Field("att",n,l), Att(t,n,l), AttsGeneratorField("att",n,l) { }
hrchilds's avatar
hrchilds committed
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
    virtual bool CanHaveConst() { return true; }
    virtual void AddAttributeIncludes(UniqueStringList &sl) const
    {
        QString tmp;
        tmp.sprintf("#include <%s.h>\n", attType.latin1());
        sl.AddString(tmp.latin1());
    }
    virtual QString GetAttributeGroupID()
    {
        return "a";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
    }
    virtual void WriteSourceSetFromNode(ostream &c)
    {
        c << "    if((node = searchNode->GetNode(\"" << name
          << "\")) != 0)" << endl;
        c << "        " << name << ".SetFromNode(node);" << endl;
    }
};


//
// --------------------------------- AttVector --------------------------------
//
class AttsGeneratorAttVector : public virtual AttVector , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorAttVector(const QString &t, const QString &n, const QString &l)
1061
        : Field("attVector",n,l), AttVector(t,n,l), AttsGeneratorField("attVector",n,l) { }
hrchilds's avatar
hrchilds committed
1062
1063
1064
1065
1066
1067
1068
    virtual bool CanHaveConst() { return true; }
    virtual void WriteHeaderForwardDeclarations(ostream &h)
    {
        h << "class " << attType << ";" << endl;
    }
    virtual void WriteHeaderAGVectorProto(ostream &h)
    {
hrchilds's avatar
hrchilds committed
1069
        QString plural("");
hrchilds's avatar
hrchilds committed
1070
        if(Name.right(1) != "s")
hrchilds's avatar
hrchilds committed
1071
1072
1073
1074
1075
1076
1077
1078
            plural = "s";

        h << "    void Add" << Name << "(const " << attType << " &);" << endl;
        h << "    void Clear" << Name << plural << "();" << endl;
        h << "    void Remove" << Name << "(int i);" << endl;
        h << "    int  GetNum" << Name << plural << "() const;" << endl;
        h << "    " << attType << " &Get" << Name << "(int i);" << endl;
        h << "    const " << attType << " &Get" << Name << "(int i) const;" << endl;
hrchilds's avatar
hrchilds committed
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
        h << endl;
    }
    virtual void WriteHeaderSoloAGVectorProto(ostream &h)
    {
        h << "    " << attType << " &operator [] (int i);" << endl;
        h << "    const " << attType << " &operator [] (int i) const;" << endl;
        h << endl;
    }
    virtual void WriteSourceIncludes(ostream &c)
    {
        c << "#include <"<<attType<<".h>" << endl;
    }
    virtual QString GetAttributeGroupID()
    {
        return "a*";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
    }
hrchilds's avatar
hrchilds committed
1098
1099
1100
1101
1102
    virtual void WriteHeaderSetFunction(ostream &h)
    {
        // Disabled the header method because the .C implementation (below)
        // does not output anything.
    }
hrchilds's avatar
hrchilds committed
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
    virtual void WriteSourceSetFunction(ostream &c, const QString &classname)
    {
        /*
        if (codeFile && codeFile->code.count(QString("Set")+Name) && !codeFile->code[QString("Set")+Name].first.isNull())
            c << codeFile->code[QString("Set")+Name].first;

        if (codeFile && codeFile->code.count(QString("Set")+Name) && !codeFile->code[QString("Set")+Name].second.isNull())
            c << codeFile->code[QString("Set")+Name].second;
        */
    }
    virtual void WriteSourceCopyCode(ostream &c)
    {
        c << "    // *** Copy the " << name << " field ***" << endl;
        c << "    // Delete the AttributeGroup objects and clear the vector." << endl;
        c << "    for(pos = " << name << ".begin(); pos != "
          << name << ".end(); ++pos)" << endl;
        c << "        delete *pos;" << endl;
        c << "    " << name << ".clear();" << endl;
        c << "    if(obj." << name << ".size() > 0)" << endl;
        c << "        " << name << ".reserve(obj." << name << ".size());" << endl;
        c << "    // Duplicate the " << name << " from obj." << endl;
        c << "    for(pos = obj." << name << ".begin(); pos != obj." << name << ".end(); ++pos)" << endl;
        c << "    {" << endl;
        c << "        " << attType << " *old" << attType << " = (" << attType << " *)(*pos);" << endl;
        c << "        " << attType << " *new" << attType << " = new " << attType << "(*old" << attType << ");" << endl;
        c << "        " << name << ".push_back(new" << attType << ");" << endl;
        c << "    }" << endl << endl;
    }
    virtual void WriteSourceDestructor(ostream &c)
    {
        c << "    // Destroy the " << name << " field." << endl;
        c << "    for(pos = " << name << ".begin();"
          << " pos != " << name << ".end(); ++pos)" << endl;
        c << "        delete *pos;" << endl;
    }
    virtual void WriteSourceSetFromNode(ostream &c)
    {
hrchilds's avatar
hrchilds committed
1140
        QString plural("");
hrchilds's avatar
hrchilds committed
1141
        if(Name.right(1) != "s")
hrchilds's avatar
hrchilds committed
1142
1143
            plural = "s";

hrchilds's avatar
hrchilds committed
1144
        c << "    // Clear all the " << attType << "s." << endl;
hrchilds's avatar
hrchilds committed
1145
        c << "    Clear" << Name << plural << "();" << endl;
hrchilds's avatar
hrchilds committed
1146
1147
1148
1149
1150
        c << endl;
        c << "    // Go through all of the children and construct a new" << endl;
        c << "    // " << attType << " for each one of them." << endl;
                  
        c << "    children = searchNode->GetChildren();" << endl;
1151
        c << "    if(children != 0)" << endl;
hrchilds's avatar
hrchilds committed
1152
        c << "    {" << endl;
1153
        c << "        for(int i = 0; i < searchNode->GetNumChildren(); ++i)" << endl;
hrchilds's avatar
hrchilds committed
1154
        c << "        {" << endl;
1155
1156
1157
1158
1159
1160
        c << "            if(children[i]->GetKey() == std::string(\"" << attType << "\"))" << endl;
        c << "            {" << endl;
        c << "                " << attType << " temp;" << endl;
        c << "                temp.SetFromNode(children[i]);" << endl;
        c << "                Add" << Name << "(temp);" << endl;
        c << "            }" << endl;
hrchilds's avatar
hrchilds committed
1161
1162
1163
1164
1165
1166
1167
        c << "        }" << endl;
        c << "    }" << endl << endl;
    }
    virtual void WriteSourceAGVectorFunctions(ostream &c, const QString &classname, const QString &purpose)
    {
        QString methodName;
        QString s = attType;
hrchilds's avatar
hrchilds committed
1168
        QString plural("");
hrchilds's avatar
hrchilds committed
1169
        if(Name.right(1) != "s")
hrchilds's avatar
hrchilds committed
1170
            plural = "s";
hrchilds's avatar
hrchilds committed
1171
1172
1173

        // Write the Add method.
        methodName = "Add";
hrchilds's avatar
hrchilds committed
1174
        methodName += Name;
whitlocb's avatar
whitlocb committed
1175
        WriteMethodComment(c, classname, methodName, purpose, generatorName);
hrchilds's avatar
hrchilds committed
1176
1177
1178
1179
1180
1181
1182
        c << "void" << endl;
        c << classname << "::" << methodName << "(const " << s << " &obj)" << endl;
        c << "{" << endl;
        c << "    " << s << " *new" << s << " = new " << s << "(obj);" << endl;
        c << "    " << name << ".push_back(new" << s << ");" << endl;
        c << endl;
        c << "    // Indicate that things have changed by selecting it." << endl;
whitlocb's avatar
whitlocb committed
1183
        c << "    Select(" << FieldID() << ", (void *)&" << name << ");" << endl;
hrchilds's avatar
hrchilds committed
1184
1185
1186
1187
        c << "}" << endl << endl;

        // Write the Clear method
        methodName = "Clear";
hrchilds's avatar
hrchilds committed
1188
        methodName += Name + plural;
whitlocb's avatar
whitlocb committed
1189
        WriteMethodComment(c, classname, methodName, purpose, generatorName);
hrchilds's avatar
hrchilds committed
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
        c << "void" << endl;
        c << classname << "::" << methodName << "()" << endl;
        c << "{" << endl;
        c << "    AttributeGroupVector::iterator pos;" << endl;
        c << endl;
        c << "    for(pos = " << name << ".begin(); pos != " << name << ".end(); ++pos)" << endl;
        c << "        delete *pos;" << endl;
        c << "    " << name << ".clear();" << endl;
        c << endl;
        c << "    // Indicate that things have changed by selecting the list." << endl;
whitlocb's avatar
whitlocb committed
1200
        c << "    Select(" << FieldID() << ", (void *)&" << name << ");" << endl;
hrchilds's avatar
hrchilds committed
1201
1202
1203
1204
        c << "}" << endl << endl;

        // Write the Remove method
        methodName = "Remove";
hrchilds's avatar
hrchilds committed
1205
        methodName += Name;
whitlocb's avatar
whitlocb committed
1206
        WriteMethodComment(c, classname, methodName, purpose, generatorName);
hrchilds's avatar
hrchilds committed
1207
1208
1209
1210
1211
1212
1213
        c << "void" << endl;
        c << classname << "::" << methodName << "(int index)" << endl;
        c << "{" << endl;
        c << "    AttributeGroupVector::iterator pos = " << name << ".begin();" << endl;
        c << endl;
        c << "    // Iterate through the vector \"index\" times. " << endl;
        c << "    for(int i = 0; i < index; ++i)" << endl;
1214
        c << "        if(pos != " << name << ".end()) ++pos;" << endl;
hrchilds's avatar
hrchilds committed
1215
1216
1217
1218
1219
1220
1221
1222
1223
        c << endl;
        c << "    // If pos is still a valid iterator, remove that element." << endl;
        c << "    if(pos != " << name << ".end())" << endl;
        c << "    {" << endl;
        c << "        delete *pos;" << endl;
        c << "        " << name << ".erase(pos);" << endl;
        c << "    }" << endl;
        c << endl;
        c << "    // Indicate that things have changed by selecting the list." << endl;
whitlocb's avatar
whitlocb committed
1224
        c << "    Select(" << FieldID() << ", (void *)&" << name << ");" << endl;
hrchilds's avatar
hrchilds committed
1225
1226
1227
1228
        c << "}" << endl << endl;

        // Write the GetNum method
        methodName = "GetNum";
hrchilds's avatar
hrchilds committed
1229
        methodName += Name + plural;
whitlocb's avatar
whitlocb committed
1230
        WriteMethodComment(c, classname, methodName, purpose, generatorName);
hrchilds's avatar
hrchilds committed
1231
1232
1233
1234
1235
1236
1237
1238
        c << "int" << endl;
        c << classname << "::" << methodName << "() const" << endl;
        c << "{" << endl;
        c << "    return " << name << ".size();" << endl;
        c << "}" << endl << endl;

        // Write the Get method
        methodName = "Get";
hrchilds's avatar
hrchilds committed
1239
        methodName += Name;
whitlocb's avatar
whitlocb committed
1240
        WriteMethodComment(c, classname, methodName, purpose, generatorName);
hrchilds's avatar
hrchilds committed
1241
1242
1243
1244
1245
1246
1247
1248
        c << s << " &" << endl;
        c << classname << "::" << methodName << "(int i)" << endl;
        c << "{" << endl;
        c << "    return *((" << s << " *)" << name << "[i]);" << endl;
        c << "}" << endl << endl;

        // Write the const Get method
        methodName = "Get";
hrchilds's avatar
hrchilds committed
1249
        methodName += Name;
whitlocb's avatar
whitlocb committed
1250
        WriteMethodComment(c, classname, methodName, purpose, generatorName);
hrchilds's avatar
hrchilds committed
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
        c << "const " << s << " &" << endl;
        c << classname << "::" << methodName << "(int i) const" << endl;
        c << "{" << endl;
        c << "    return *((" << s << " *)" << name << "[i]);" << endl;
        c << "}" << endl << endl;
    }
    virtual void WriteSourceSoloAGVectorFunctions(ostream &c, const QString &classname, const QString &purpose)
    {
        QString methodName;
        QString s = attType;

        // Write the non-const [] operator
        methodName = "operator []";
whitlocb's avatar
whitlocb committed
1264
        WriteMethodComment(c, classname, methodName, purpose, generatorName);
hrchilds's avatar
hrchilds committed
1265
1266
1267
1268
1269
1270
1271
        c << s << " &" << endl;
        c << classname << "::" << methodName << " (int i)" << endl;
        c << "{" << endl;
        c << "    return *((" << s << " *)" << name << "[i]);" << endl;
        c << "}" << endl << endl;

        // Write the const [] operator
whitlocb's avatar
whitlocb committed
1272
        WriteMethodComment(c, classname, methodName, purpose, generatorName);
hrchilds's avatar
hrchilds committed
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
        c << "const " << s << " &" << endl;
        c << classname << "::" << methodName << " (int i) const" << endl;
        c << "{" << endl;
        c << "    return *((" << s << " *)" << name << "[i]);" << endl;
        c << "}" << endl << endl;
    }
    virtual void WriteSourceSubAttributeGroupSingle(ostream &c)
    {
        c << "    return new " << attType << ";" << endl;
    }
    virtual void WriteSourceSubAttributeGroup(ostream &c)
    {
whitlocb's avatar
whitlocb committed
1285
        c << "    case " << FieldID() << ":" << endl;
hrchilds's avatar
hrchilds committed
1286
1287
1288
1289
1290
1291
1292
1293
        c << "        retval = new " << attType << ";" << endl;
        c << "        break;" << endl;
    }
    virtual void WriteSourceComparisonPrecalc(ostream &c, const QString &indent)
    {
        QString s = attType;
        c << indent << "bool " << name << "_equal = (obj." << name 
          << ".size() == " << name << ".size());" << endl;
1294
        c << indent << "for(size_t i = 0; (i < " << name
hrchilds's avatar
hrchilds committed
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
          << ".size()) && " << name << "_equal; ++i)" << endl;
        c << indent << "{" << endl;
        c << indent << "    // Make references to " << s
          << " from AttributeGroup *." << endl;
        c << indent << "    const " << s << " &" << name
          << "1 = *((const " << s << " *)(" << name << "[i]));" << endl;
        c << indent << "    const " << s << " &" << name
          << "2 = *((const " << s << " *)(obj." << name << "[i]));" << endl;
        c << indent << "    " << name << "_equal = ("
          << name << "1 == " << name << "2);" << endl;
        c << indent << "}" << endl << endl;
    }
    virtual void WriteSourceComparison(ostream &c)
    {
        c << name << "_equal";
    }
};


//
// ----------------------------------- Enum -----------------------------------
//
class AttsGeneratorEnum : public virtual Enum , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorEnum(const QString &t, const QString &n, const QString &l)
1321
        : Field("enum",n,l), Enum(t,n,l), AttsGeneratorField("enum",n,l) { }
hrchilds's avatar
hrchilds committed
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
    virtual QString GetAttributeGroupID()
    {
        return "i";
    }
    virtual QString DataNodeConversion()
    {
        return "AsInt";
    }

    virtual void AddSystemIncludes(UniqueStringList &sl) 
    { 
        sl.AddString("#include <string>\n");
    }

    virtual void WriteSourceSetDefault(ostream &c)
    {
        c << "    " << name << " = " <<enumType->values[val] << ";" << endl;
    }
    virtual void WriteSourceSetFromNode(ostream &c)
    {
        c << "    if((node = searchNode->GetNode(\"" << name
          << "\")) != 0)" << endl;
        c << "    {" << endl;
        c << "        // Allow enums to be int or string in the config file" << endl;
        c << "        if(node->GetNodeType() == INT_NODE)" << endl;
hrchilds's avatar
hrchilds committed
1347
1348
1349
1350
1351
        c << "        {" << endl;
        c << "            int ival = node->AsInt();" << endl;
        c << "            if(ival >= 0 && ival < " << enumType->values.size() << ")" << endl;
        c << "                Set" << Name << "(" << GetCPPName(true) << "(ival));" << endl;
        c << "        }" << endl;
hrchilds's avatar
hrchilds committed
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
        c << "        else if(node->GetNodeType() == STRING_NODE)" << endl;
        c << "        {" << endl;
        c << "            " << GetCPPName(true) << " value;" << endl;
        c << "            if(" << GetCPPName(true) << "_FromString(node->AsString(), value))" << endl;
        c << "                Set" << Name << "(value);" << endl;
        c << "        }" << endl;
        c << "    }" << endl;
    }
};


hrchilds's avatar
hrchilds committed
1363
1364
1365
1366
1367
1368
1369
//
// --------------------------------- ScaleMode --------------------------------
//
class AttsGeneratorScaleMode : public virtual ScaleMode , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorScaleMode(const QString &n, const QString &l)
1370
        : Field("scalemode",n,l), ScaleMode(n,l), AttsGeneratorField("scalemode",n,l) { }
hrchilds's avatar
hrchilds committed
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
    virtual QString GetAttributeGroupID()
    {
        return "i";
    }
    virtual QString DataNodeConversion()
    {
        return "AsInt";
    }
    virtual void WriteSourceSetDefault(ostream &c)
    {
        c << "    " << name << " = " << val << ";" << endl;
    }
};


hrchilds's avatar
hrchilds committed
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
#define AVT_GENERATOR_METHODS \
    virtual void AddSystemIncludes(UniqueStringList &sl) \
    { \
        sl.AddString("#include <avtTypes.h>\n");\
    }\
    virtual QString GetAttributeGroupID()\
    {\
        return "i";\
    }\
    virtual QString DataNodeConversion()\
    {\
        return "AsInt";\
    }\
    virtual void WriteSourceSetDefault(ostream &c)\
    {\
        c << "    " << name << " = ";\
        int nsym = 0;\
        const char **sym = GetSymbols(nsym);\
        if(val >= 0 && val < nsym)\
            c << sym[val];\
        else\
            c << val;\
        c << ";" << endl;\
    }\
    virtual QString GetFieldType() const { return "int"; }

//
// ----------------------------------- avtCentering -----------------------------------
//
1415
class AttsGeneratoravtCentering : public virtual avtCenteringField, public virtual AttsGeneratorField
hrchilds's avatar
hrchilds committed
1416
1417
1418
{
  public:
    AttsGeneratoravtCentering(const QString &n, const QString &l)
1419
        : Field("avtCentering",n,l), avtCenteringField(n,l), AttsGeneratorField("avtCentering",n,l)
hrchilds's avatar
hrchilds committed
1420
1421
1422
1423
1424
1425
1426
    { }
    AVT_GENERATOR_METHODS
};

//
// ----------------------------------- avtGhostType -----------------------------------
//
1427
class AttsGeneratoravtGhostType : public virtual avtGhostTypeField, public virtual AttsGeneratorField
hrchilds's avatar
hrchilds committed
1428
1429
1430
{
  public:
    AttsGeneratoravtGhostType(const QString &n, const QString &l)
1431
        : Field("avtGhostType",n,l), avtGhostTypeField(n,l), AttsGeneratorField("avtGhostType",n,l)
hrchilds's avatar
hrchilds committed
1432
1433
1434
1435
1436
1437
1438
    { }
    AVT_GENERATOR_METHODS
};

//
// ----------------------------------- avtSubsetType -----------------------------------
//
1439
class AttsGeneratoravtSubsetType : public virtual avtSubsetTypeField, public virtual AttsGeneratorField
hrchilds's avatar
hrchilds committed
1440
1441
1442
{
  public:
    AttsGeneratoravtSubsetType(const QString &n, const QString &l)
1443
        : Field("int",n,l), avtSubsetTypeField(n,l), AttsGeneratorField("int",n,l)
hrchilds's avatar
hrchilds committed
1444
1445
1446
1447
1448
1449
1450
    { }
    AVT_GENERATOR_METHODS
};

//
// ----------------------------------- avtVarType -----------------------------------
//
1451
class AttsGeneratoravtVarType : public virtual avtVarTypeField, public virtual AttsGeneratorField
hrchilds's avatar
hrchilds committed
1452
1453
1454
{
  public:
    AttsGeneratoravtVarType(const QString &n, const QString &l)
1455
        : Field("avtVarTypeField",n,l), avtVarTypeField(n,l), AttsGeneratorField("avtVarType",n,l)
hrchilds's avatar
hrchilds committed
1456
1457
1458
1459
1460
1461
1462
    { }
    AVT_GENERATOR_METHODS
};

//
// ----------------------------------- avtMeshType -----------------------------------
//
1463
class AttsGeneratoravtMeshType : public virtual avtMeshTypeField, public virtual AttsGeneratorField
hrchilds's avatar
hrchilds committed
1464
1465
1466
{
  public:
    AttsGeneratoravtMeshType(const QString &n, const QString &l)
1467
        : Field("avtMeshTypeField",n,l), avtMeshTypeField(n,l), AttsGeneratorField("avtMeshType",n,l)
hrchilds's avatar
hrchilds committed
1468
1469
1470
1471
1472
1473
1474
    { }
    AVT_GENERATOR_METHODS
};

//
// ----------------------------------- avtExtentType -----------------------------------
//
1475
class AttsGeneratoravtExtentType : public virtual avtExtentTypeField, public virtual AttsGeneratorField
hrchilds's avatar
hrchilds committed
1476
1477
1478
{
  public:
    AttsGeneratoravtExtentType(const QString &n, const QString &l)
1479
        : Field("avtExtentType",n,l), avtExtentTypeField(n,l), AttsGeneratorField("avtExentType",n,l)
hrchilds's avatar
hrchilds committed
1480
1481
1482
1483
1484
1485
1486
    { }
    AVT_GENERATOR_METHODS
};

//
// ----------------------------------- avtMeshCoordType -----------------------------------
//
1487
class AttsGeneratoravtMeshCoordType : public virtual avtMeshCoordTypeField, public virtual AttsGeneratorField
hrchilds's avatar
hrchilds committed
1488
1489
1490
{
  public:
    AttsGeneratoravtMeshCoordType(const QString &n, const QString &l)
1491
        : Field("avtMeshCoordType",n,l), avtMeshCoordTypeField(n,l), AttsGeneratorField("avtMeshCoordType",n,l)
hrchilds's avatar
hrchilds committed
1492
1493
1494
1495
1496
1497
1498
    { }
    AVT_GENERATOR_METHODS
};

//
// ----------------------------------- LoadBalanceScheme -----------------------------------
//
1499
class AttsGeneratorLoadBalanceScheme : public virtual LoadBalanceSchemeField, public virtual AttsGeneratorField
hrchilds's avatar
hrchilds committed
1500
1501
1502
{
  public:
    AttsGeneratorLoadBalanceScheme(const QString &n, const QString &l)
1503
        : Field("LoadBalanceScheme",n,l), LoadBalanceSchemeField(n,l), AttsGeneratorField("LoadBalanceScheme",n,l)
hrchilds's avatar
hrchilds committed
1504
1505
1506
1507
    { }
    AVT_GENERATOR_METHODS
};

hrchilds's avatar
hrchilds committed
1508
// ----------------------------------------------------------------------------
hrchilds's avatar
hrchilds committed
1509
1510
1511
1512
// Modifications:
//    Brad Whitlock, Wed Dec 8 15:47:03 PST 2004
//    Added support for variable names.
//
hrchilds's avatar
hrchilds committed
1513
1514
1515
//    Brad Whitlock, Thu Mar 1 14:17:10 PST 2007
//    Added support for various avt enums.
//
hrchilds's avatar
hrchilds committed
1516
1517
1518
//    Kathleen Bonnell, Thu Mar 22 16:58:23 PDT 2007 
//    Added scalemode.
//
hrchilds's avatar
hrchilds committed
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
// ----------------------------------------------------------------------------
class AttsFieldFactory
{
  public:
    static AttsGeneratorField *createField(const QString &name,
                                           const QString &type,
                                           const QString &subtype,
                                           const QString &length,
                                           const QString &label)
    {
        AttsGeneratorField *f = NULL;
        if      (type.isNull())          throw QString().sprintf("Field %s was specified with no type.",name.latin1());
        else if (type == "int")          f = new AttsGeneratorInt(name,label);
        else if (type == "intArray")     f = new AttsGeneratorIntArray(length,name,label);
        else if (type == "intVector")    f = new AttsGeneratorIntVector(name,label);
        else if (type == "bool")         f = new AttsGeneratorBool(name,label);
        else if (type == "float")        f = new AttsGeneratorFloat(name,label);
        else if (type == "floatArray")   f = new AttsGeneratorFloatArray(length,name,label);
        else if (type == "double")       f = new AttsGeneratorDouble(name,label);
        else if (type == "doubleArray")  f = new AttsGeneratorDoubleArray(length,name,label);
        else if (type == "doubleVector") f = new AttsGeneratorDoubleVector(name,label);
        else if (type == "uchar")        f = new AttsGeneratorUChar(name,label);
        else if (type == "ucharArray")   f = new AttsGeneratorUCharArray(length,name,label);
        else if (type == "ucharVector")  f = new AttsGeneratorUCharVector(name,label);
        else if (type == "string")       f = new AttsGeneratorString(name,label);
        else if (type == "stringVector") f = new AttsGeneratorStringVector(name,label);
        else if (type == "colortable")   f = new AttsGeneratorColorTable(name,label);
        else if (type == "color")        f = new AttsGeneratorColor(name,label);
        else if (type == "opacity")      f = new AttsGeneratorOpacity(name,label);
        else if (type == "linestyle")    f = new AttsGeneratorLineStyle(name,label);
        else if (type == "linewidth")    f = new AttsGeneratorLineWidth(name,label);
hrchilds's avatar
hrchilds committed
1550
        else if (type == "variablename") f = new AttsGeneratorVariableName(name,label);
hrchilds's avatar
hrchilds committed
1551
1552
1553
        else if (type == "att")          f = new AttsGeneratorAtt(subtype,name,label);
        else if (type == "attVector")    f = new AttsGeneratorAttVector(subtype,name,label);
        else if (type == "enum")         f = new AttsGeneratorEnum(subtype, name, label);
hrchilds's avatar
hrchilds committed
1554
        else if (type == "scalemode")    f = new AttsGeneratorScaleMode(name,label);
hrchilds's avatar
hrchilds committed
1555

hrchilds's avatar
hrchilds committed
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
        // Special built-in AVT enums
        else if (type == "avtCentering")      f = new AttsGeneratoravtCentering(name, label);
        else if (type == "avtVarType")        f = new AttsGeneratoravtVarType(name, label);
        else if (type == "avtSubsetType")     f = new AttsGeneratoravtSubsetType(name, label);
        else if (type == "avtExtentType")     f = new AttsGeneratoravtExtentType(name, label);
        else if (type == "avtMeshType")       f = new AttsGeneratoravtMeshType(name, label);
        else if (type == "avtGhostType")      f = new AttsGeneratoravtGhostType(name, label);
        else if (type == "avtMeshCoordType")  f = new AttsGeneratoravtMeshCoordType(name, label);
        else if (type == "LoadBalanceScheme") f = new AttsGeneratorLoadBalanceScheme(name, label);

hrchilds's avatar
hrchilds committed
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
        if (!f)
            throw QString().sprintf("AttsFieldFactory: unknown type for field %s: %s",name.latin1(),type.latin1());

        return f;
    }
};

// ----------------------------------------------------------------------------
// Modifications:
//   Brad Whitlock, Tue May 14 10:30:51 PDT 2002
//   Added export support.
//
hrchilds's avatar
hrchilds committed
1578
1579
1580
//   Mark C. Miller, Tue Oct 26 16:18:21 PDT 2004
//   Changed operator = to return & to class & check for assignment to self
//
hrchilds's avatar
hrchilds committed
1581
1582
1583
1584
1585
1586
1587
//   Brad Whitlock, Wed Mar 7 15:57:54 PST 2007
//   Added ability to turn off keyframing methods.
//
//   Jeremy Meredith, Tue Mar 13 15:17:14 EDT 2007
//   Made non-member constants written before the class, and don't add
//   whitespace for empty constant defs (like #defines in the header file).
//
1588
1589
1590
//   Hank Childs, Thu Jan 10 14:33:30 PST 2008
//   Added filenames, specifiedFilenames.
//
whitlocb's avatar
whitlocb committed
1591
1592
1593
//   Brad Whitlock, Thu Feb 28 12:03:30 PDT 2008
//   Made it use a base class so it can inherit some methods.
//
1594
1595
//   Mark C. Miller, Tue Mar 18 20:56:47 PDT 2008
//   Made it write field id enum regardless of only public fields
hrchilds's avatar
hrchilds committed
1596
// ----------------------------------------------------------------------------
whitlocb's avatar
whitlocb committed
1597
1598
1599
#include <GeneratorBase.h>

class AttsGeneratorAttribute : public GeneratorBase
hrchilds's avatar
hrchilds committed
1600
1601
1602
1603
1604
1605
{
  public:
    vector<AttsGeneratorField*> fields;
  public:
    AttsGeneratorAttribute(const QString &n, const QString &p, const QString &f,
                           const QString &e, const QString &ei)
whitlocb's avatar
whitlocb committed
1606
        : GeneratorBase(n,p,f,e,ei, GENERATOR_NAME), fields()
hrchilds's avatar
hrchilds committed
1607
1608
    {
    }
whitlocb's avatar
whitlocb committed
1609
1610

    virtual ~AttsGeneratorAttribute()
hrchilds's avatar
hrchilds committed
1611
    {
1612
        for (size_t i = 0; i < fields.size(); ++i)
whitlocb's avatar
whitlocb committed
1613
1614
            delete fields[i];
        fields.clear();
hrchilds's avatar
hrchilds committed
1615
    }
whitlocb's avatar
whitlocb committed
1616
1617

    virtual void Print(ostream &out)
hrchilds's avatar
hrchilds committed
1618
1619
1620
1621
    {
        out << "    Attribute: " << name << " (" << purpose << ")" << endl;
        out << "        exportAPI=" << exportAPI << endl;
        out << "        exportInclude=" << exportInclude << endl;
1622
        for (size_t i=0; i<fields.size(); i++)
hrchilds's avatar
hrchilds committed
1623
            fields[i]->Print(out);
1624
        for (size_t i=0; i<includes.size(); i++)
whitlocb's avatar
whitlocb committed
1625
            includes[i]->Print(out, generatorName);
1626
        for (size_t i=0; i<functions.size(); i++)
whitlocb's avatar
whitlocb committed
1627
            functions[i]->Print(out, generatorName);
1628
        for (size_t i=0; i<constants.size(); i++)
whitlocb's avatar
whitlocb committed
1629
            constants[i]->Print(out, generatorName);
hrchilds's avatar
hrchilds committed
1630
1631
1632
1633
1634
1635
    }

    // ------------------------------------------------------------------------
    // ------------------------------------------------------------------------
    void WriteHeader(ostream &h)
    {
hrchilds's avatar
hrchilds committed
1636
        h << copyright_str.c_str() << endl;
hrchilds's avatar
hrchilds committed
1637
1638
1639
1640
1641
1642
1643
1644
1645
        h << "#ifndef " << name.upper() << "_H" << endl;
        h << "#define " << name.upper() << "_H" << endl;
        if(!exportInclude.isEmpty())
            h << "#include <" << exportInclude << ">" << endl;
        WriteHeaderSystemIncludes(h);
        h << "#include <AttributeSubject.h>" << endl;
        WriteHeaderForwardDeclarations(h);
        WriteHeaderAttributeIncludes(h);
        // write user header includes
1646
        for (size_t i=0; i<includes.size(); i++)
hrchilds's avatar
hrchilds committed
1647
        {
whitlocb's avatar
whitlocb committed
1648
1649
            if (includes[i]->destination=="header" &&
                includes[i]->target == generatorName)
hrchilds's avatar
hrchilds committed
1650
1651
1652
1653
1654
1655
1656
1657
1658
            {
                if (includes[i]->quoted == true)
                    h << "#include \"" << includes[i]->include << "\"" << endl;
                else
                    h << "#include <"  << includes[i]->include << ">"  << endl;
            }
        }

        h << endl;
hrchilds's avatar
hrchilds committed
1659
1660

        // write non-member constants
1661
        for (size_t i=0; i<constants.size(); i++)
hrchilds's avatar
hrchilds committed
1662
        {
whitlocb's avatar
whitlocb committed
1663
            if (! constants[i]->member && constants[i]->target == generatorName)
hrchilds's avatar
hrchilds committed
1664
1665
1666
                h << constants[i]->decl << endl;
        }

whitlocb's avatar
whitlocb committed
1667
        WriteClassComment(h, purpose);
hrchilds's avatar
hrchilds committed
1668
1669
1670
1671
1672
1673
        if(exportAPI.isEmpty())
            h << "class " << name << " : public AttributeSubject" << endl;
        else
            h << "class " << exportAPI << " " << name << " : public AttributeSubject" << endl;
        h << "{" << endl;
        h << "public:" << endl;