GenerateAtts.h 112 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2
/*****************************************************************************
*
bonnell's avatar
bonnell committed
3
* Copyright (c) 2000 - 2015, 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-442911
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
#ifndef GENERATE_ATTS_H
#define GENERATE_ATTS_H
whitlocb's avatar
whitlocb committed
41
#include <QTextStream>
hrchilds's avatar
hrchilds committed
42 43 44 45 46 47 48 49 50

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

51

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.
//
197 198 199 200 201
//    Jeremy Meredith, Thu Mar 25 14:13:10 EDT 2010
//    For att vectors, if we don't get any new contents, then don't
//    clear the old vector.  This mirrors the behavior for other
//    types of fields.
//
202 203 204
//    Brad Whitlock, Fri Dec 10 16:09:42 PST 2010
//    I made protected members generate Set/Get methods like public members.
//
205 206 207
//    Kathleen Biagas, Thu Aug 25 14:21:58 MST 2011
//    Allow fields in a persistent state object to be non-persistent.
//
208 209 210
//    Kathleen Biagas, Tue Mar  1 11:01:51 PST 2011
//    Added Generator for MapNode type.
//
211 212 213 214 215
//    Kathleen Biagas, Tue Jun 18 10:28:36 PDT 2013
//    Added logic to forego switch statements on GetField* calls that have
//    no fields, as in the case of derived or place-holder atts that define
//    no new fields beyond what the base class has defined.
//
hrchilds's avatar
hrchilds committed
216 217 218 219 220 221 222
// ****************************************************************************

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

class AttsGeneratorField : public virtual Field
{
whitlocb's avatar
whitlocb committed
223 224
  protected:
    QString generatorName;
hrchilds's avatar
hrchilds committed
225 226
  public:
    AttsGeneratorField(const QString &t, const QString &n, const QString &l)
whitlocb's avatar
whitlocb committed
227 228 229 230
        : Field(t,n,l), generatorName(GENERATOR_NAME)
    {
    }
    QString GetCPPNameW(int w, bool subtypename=false, const QString &classname="")
hrchilds's avatar
hrchilds committed
231 232 233 234 235 236 237 238 239 240 241 242
    {
        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
243 244 245 246
    virtual QString FieldID() const
    {
        return QString("ID_") + name;
    }
hrchilds's avatar
hrchilds committed
247 248 249
    virtual void AddAttributeIncludes(UniqueStringList &sl) const
    {
    }
whitlocb's avatar
whitlocb committed
250
    virtual void WriteHeaderForwardDeclarations(QTextStream &h) { }
hrchilds's avatar
hrchilds committed
251
    virtual void AddSystemIncludes(UniqueStringList &sl) { }
whitlocb's avatar
whitlocb committed
252
    virtual void WriteHeaderSelectFunction(QTextStream &h)
hrchilds's avatar
hrchilds committed
253 254 255
    {
        if (CanHaveConst())
        {
whitlocb's avatar
whitlocb committed
256
            h << "    void Select" << Name << "();" << Endl;
hrchilds's avatar
hrchilds committed
257 258
        }
    }
whitlocb's avatar
whitlocb committed
259
    virtual void WriteHeaderSetFunction(QTextStream &h)
hrchilds's avatar
hrchilds committed
260 261 262 263 264 265 266 267 268
    {
        h << "    void Set"<<Name<<"(";
        if (CanHaveConst())
            h << "const ";
        h << GetCPPName(true) << " ";
        if (isArray) 
            h << "*";
        else if (CanHaveConst())
            h << "&";
whitlocb's avatar
whitlocb committed
269
        h << name << "_);" << Endl;
hrchilds's avatar
hrchilds committed
270
    }
whitlocb's avatar
whitlocb committed
271
    virtual void WriteHeaderGetFunction(QTextStream &h, int w)
hrchilds's avatar
hrchilds committed
272 273 274
    {
        if (isArray)
        {
whitlocb's avatar
whitlocb committed
275 276
            h << "    const " << GetCPPNameW(w) << " *Get" << Name << "() const;" << Endl;
            h << "          " << GetCPPNameW(w) << " *Get" << Name << "();" << Endl;
hrchilds's avatar
hrchilds committed
277 278 279
        }
        else if (CanHaveConst())
        {
whitlocb's avatar
whitlocb committed
280 281
            h << "    const " << GetCPPNameW(w) << " &Get" << Name << "() const;" << Endl;
            h << "          " << GetCPPNameW(w) << " &Get" << Name << "();" << Endl;
hrchilds's avatar
hrchilds committed
282 283
        }
        else
whitlocb's avatar
whitlocb committed
284
            h << "    " << GetCPPNameW(w,true) << " Get" << Name << "() const;" << Endl;
hrchilds's avatar
hrchilds committed
285
    }
whitlocb's avatar
whitlocb committed
286 287 288
    virtual void WriteHeaderAGVectorProto(QTextStream &h) { }
    virtual void WriteHeaderSoloAGVectorProto(QTextStream &h) { }
    virtual void WriteHeaderAttribute(QTextStream &h, int w)
hrchilds's avatar
hrchilds committed
289 290 291 292
    {
        h << "    " << GetCPPNameW(w) << " " << name;
        if (isArray)
            h << "[" << length << "]";
whitlocb's avatar
whitlocb committed
293
        h << ";" << Endl;
hrchilds's avatar
hrchilds committed
294 295
    }
    // ------------------------------------------------------------------------
whitlocb's avatar
whitlocb committed
296
    virtual void WriteSourceIncludes(QTextStream &c)
hrchilds's avatar
hrchilds committed
297 298
    {
    }
whitlocb's avatar
whitlocb committed
299
    virtual void WriteSourceInitializer(QTextStream &c)
hrchilds's avatar
hrchilds committed
300 301 302 303 304 305
    {
    }
    virtual bool RequiresSourceInitializer() const
    {
        return false;
    }
whitlocb's avatar
whitlocb committed
306
    virtual void WriteSourceSetFunction(QTextStream &c, const QString &classname)
hrchilds's avatar
hrchilds committed
307 308
    {
        // Write prototype.
whitlocb's avatar
whitlocb committed
309
        c << "void" << Endl;
hrchilds's avatar
hrchilds committed
310 311 312 313 314 315 316 317
        c << classname << "::Set" << Name << "(";
        if (CanHaveConst())
            c << "const ";
        c << GetCPPName(true,classname) << " ";
        if (isArray)
            c << "*";
        else if (CanHaveConst())
            c << "&";
whitlocb's avatar
whitlocb committed
318
        c << name << "_)" << Endl;
hrchilds's avatar
hrchilds committed
319 320

        // Write function body
whitlocb's avatar
whitlocb committed
321
        c << "{" << Endl;
whitlocb's avatar
whitlocb committed
322 323 324 325 326

        QString codeName(QString("Set")+Name);
        if(HasCode(codeName, 0, generatorName))
        {
            PrintCode(c, codeName, 0, generatorName);
whitlocb's avatar
whitlocb committed
327
            c << Endl;
whitlocb's avatar
whitlocb committed
328
        }
hrchilds's avatar
hrchilds committed
329 330 331

        if (!isArray)
        {
whitlocb's avatar
whitlocb committed
332
            c << "    " << name << " = " << name << "_;" << Endl;
whitlocb's avatar
whitlocb committed
333
            c << "    Select(" << FieldID() << ", "
whitlocb's avatar
whitlocb committed
334
              << "(void *)&" << name << ");" << Endl;
hrchilds's avatar
hrchilds committed
335 336 337 338 339 340
        }
        else
        {
            if (length < 5)
            {
                for(int i = 0; i < length; ++i)
whitlocb's avatar
whitlocb committed
341
                    c << "    " << name << "[" << i << "] = " << name << "_[" << i << "];"<< Endl;
hrchilds's avatar
hrchilds committed
342 343 344
            }
            else
            {
whitlocb's avatar
whitlocb committed
345 346
                c << "    for(int i = 0; i < " << length << "; ++i)" << Endl;
                c << "        " << name << "[i] = " << name << "_[i];"<< Endl;
hrchilds's avatar
hrchilds committed
347
            }
whitlocb's avatar
whitlocb committed
348
            c << "    Select(" << FieldID() << ", (void *)" << name << ", " << length << ");" << Endl;
hrchilds's avatar
hrchilds committed
349 350
        }

whitlocb's avatar
whitlocb committed
351 352 353
        if(HasCode(codeName, 1, generatorName))
        {
            PrintCode(c, codeName, 1, generatorName);
whitlocb's avatar
whitlocb committed
354
            c << Endl;
whitlocb's avatar
whitlocb committed
355
        }
hrchilds's avatar
hrchilds committed
356

whitlocb's avatar
whitlocb committed
357 358
        c << "}" << Endl;
        c << Endl;
hrchilds's avatar
hrchilds committed
359
    }
whitlocb's avatar
whitlocb committed
360
    virtual void WriteSourceGetFunction(QTextStream &c, const QString &classname, bool doConst)
hrchilds's avatar
hrchilds committed
361 362 363 364 365
    {
        if (isArray)
        {
            if (doConst)
            {
whitlocb's avatar
whitlocb committed
366 367
                c << "const " << GetCPPName() << " *" << Endl << classname << "::Get"
                  << Name << "() const" << Endl;
hrchilds's avatar
hrchilds committed
368 369 370
            }
            else
            {
whitlocb's avatar
whitlocb committed
371 372
                c << GetCPPName() << " *" << Endl << classname << "::Get"
                  << Name << "()" << Endl;
hrchilds's avatar
hrchilds committed
373 374 375 376 377 378
            }
        }
        else if (CanHaveConst())
        {
            if (doConst)
            {
whitlocb's avatar
whitlocb committed
379 380
                c << "const " << GetCPPName() << " &" << Endl << classname
                  << "::Get" << Name << "() const" << Endl;
hrchilds's avatar
hrchilds committed
381 382 383
            }
            else
            {
whitlocb's avatar
whitlocb committed
384 385
                c << GetCPPName() << " &" << Endl << classname << "::Get"
                  << Name << "()" << Endl;
hrchilds's avatar
hrchilds committed
386 387 388 389
            }
        }
        else
        {
whitlocb's avatar
whitlocb committed
390 391
            c << GetCPPName(true,classname) << Endl << classname << "::Get"
              << Name << "() const" << Endl;
hrchilds's avatar
hrchilds committed
392 393 394
        }

        // Function body
whitlocb's avatar
whitlocb committed
395
        c << "{" << Endl;
hrchilds's avatar
hrchilds committed
396 397
        if (type == "attArray")
        {
whitlocb's avatar
whitlocb committed
398
            cErr << "EEEEEERRRRRRRRROOOOOOORRRRRRR" << Endl;
hrchilds's avatar
hrchilds committed
399 400 401 402
        }
        else
        {
            if (type == "enum")
whitlocb's avatar
whitlocb committed
403
                c << "    return " << GetCPPName(true) << "(" << name << ");" << Endl;
hrchilds's avatar
hrchilds committed
404
            else
whitlocb's avatar
whitlocb committed
405
                c << "    return " << name << ";" << Endl;
hrchilds's avatar
hrchilds committed
406
        }
whitlocb's avatar
whitlocb committed
407 408
        c << "}" << Endl;
        c << Endl;
hrchilds's avatar
hrchilds committed
409
    }
whitlocb's avatar
whitlocb committed
410
    virtual void WriteSourceSelectFunction(QTextStream &c, const QString &classname)
hrchilds's avatar
hrchilds committed
411 412 413 414
    {
        if (! CanHaveConst())
            return;

whitlocb's avatar
whitlocb committed
415 416
        c << "void" << Endl << classname << "::Select" << Name << "()" << Endl;
        c << "{" << Endl;
hrchilds's avatar
hrchilds committed
417 418
        if (isArray)
        {
whitlocb's avatar
whitlocb committed
419
            c << "    Select(" << FieldID() << ", (void *)"
hrchilds's avatar
hrchilds committed
420 421 422 423
              << name << ", " << length  << ");";
        }
        else
        {
whitlocb's avatar
whitlocb committed
424
            c << "    Select(" << FieldID() << ", (void *)&"
hrchilds's avatar
hrchilds committed
425 426
              << name << ");";
        }
whitlocb's avatar
whitlocb committed
427
        c << Endl << "}" << Endl << Endl;
hrchilds's avatar
hrchilds committed
428
    }
whitlocb's avatar
whitlocb committed
429
    virtual void WriteSourceAGVectorFunctions(QTextStream &c, const QString &classname, const QString &purpose)
hrchilds's avatar
hrchilds committed
430 431
    {
    }
whitlocb's avatar
whitlocb committed
432
    virtual void WriteSourceSoloAGVectorFunctions(QTextStream &c, const QString &classname, const QString &purpose)
hrchilds's avatar
hrchilds committed
433 434
    {
    }
whitlocb's avatar
whitlocb committed
435 436
    virtual void WriteSourceSetDefault(QTextStream &c) = 0;
    virtual void WriteSourceCopyCode(QTextStream &c)
hrchilds's avatar
hrchilds committed
437 438 439 440 441 442 443 444
    {
        if (isArray)
        {
            if (length < 4)
            {
                for(int i = 0; i < length; ++i)
                {
                    c << "    " << name << "[" << i << "] = "
whitlocb's avatar
whitlocb committed
445
                      << "obj." << name << "[" << i << "];" << Endl;
hrchilds's avatar
hrchilds committed
446 447 448 449
                }
            }
            else
            {
whitlocb's avatar
whitlocb committed
450
                c << "    for(int i = 0; i < " << length << "; ++i)" << Endl;
hrchilds's avatar
hrchilds committed
451
                c << "        " << name << "[i] = " 
whitlocb's avatar
whitlocb committed
452
                  <<     "obj." << name << "[i];" << Endl;
hrchilds's avatar
hrchilds committed
453
            }
whitlocb's avatar
whitlocb committed
454
            c << Endl;
hrchilds's avatar
hrchilds committed
455 456 457
        }
        else
        {
whitlocb's avatar
whitlocb committed
458
            c << "    " << name << " = obj." << name << ";" << Endl;
hrchilds's avatar
hrchilds committed
459 460
        }
    }
whitlocb's avatar
whitlocb committed
461
    virtual void WriteSourceDestructor(QTextStream &c)
hrchilds's avatar
hrchilds committed
462 463
    {
    }
whitlocb's avatar
whitlocb committed
464
    virtual void WriteSourceSetFromNode(QTextStream &c)
hrchilds's avatar
hrchilds committed
465 466
    {
        c << "    if((node = searchNode->GetNode(\"" << name
whitlocb's avatar
whitlocb committed
467
          << "\")) != 0)" << Endl;
hrchilds's avatar
hrchilds committed
468
        c << "        Set" << Name << "(";
whitlocb's avatar
whitlocb committed
469
        c << "node->" << DataNodeConversion() << "());" << Endl;
hrchilds's avatar
hrchilds committed
470
    }
whitlocb's avatar
whitlocb committed
471
    virtual void WriteSourceSubAttributeGroupSingle(QTextStream &c)
hrchilds's avatar
hrchilds committed
472 473
    {
    }
whitlocb's avatar
whitlocb committed
474
    virtual void WriteSourceSubAttributeGroup(QTextStream &c)
hrchilds's avatar
hrchilds committed
475 476
    {
    }
whitlocb's avatar
whitlocb committed
477
    virtual void WriteSourceComparisonPrecalc(QTextStream &c, const QString &indent)
hrchilds's avatar
hrchilds committed
478 479 480
    {
        if (isArray)
        {
whitlocb's avatar
whitlocb committed
481 482
            c << indent << "// Compare the " << name << " arrays." << Endl;
            c << indent << "bool " << name << "_equal = true;" << Endl; 
483
            c << indent << "for(int i = 0; i < " << length << " && "
whitlocb's avatar
whitlocb committed
484
              << name << "_equal; ++i)" << Endl;
hrchilds's avatar
hrchilds committed
485 486
            c << indent << "    " << name << "_equal = ("
              << name << "[i] == obj." << name
whitlocb's avatar
whitlocb committed
487
              << "[i]);" << Endl << Endl;
hrchilds's avatar
hrchilds committed
488 489
        }
    }
whitlocb's avatar
whitlocb committed
490
    virtual void WriteSourceComparison(QTextStream &c)
hrchilds's avatar
hrchilds committed
491 492 493 494 495 496 497 498
    {
        if (isArray)
            c << name << "_equal";
        else
        {
            c << "(" << name << " == obj." << name << ")";
        }
    }
hrchilds's avatar
hrchilds committed
499
    virtual QString GetFieldType() const { return type; }
hrchilds's avatar
hrchilds committed
500 501 502 503 504 505 506 507 508
};

//
// ------------------------------------ Int -----------------------------------
//
class AttsGeneratorInt : public virtual Int , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorInt(const QString &n, const QString &l)
509
        : Field("int",n,l), Int(n,l), AttsGeneratorField("int",n,l) { }
hrchilds's avatar
hrchilds committed
510 511 512 513 514 515 516 517
    virtual QString GetAttributeGroupID()
    {
        return "i";
    }
    virtual QString DataNodeConversion()
    {
        return "AsInt";
    }
whitlocb's avatar
whitlocb committed
518
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
519
    {
whitlocb's avatar
whitlocb committed
520
        c << "    " << name << " = " << val << ";" << Endl;
hrchilds's avatar
hrchilds committed
521 522 523 524 525 526 527 528 529 530
    }
};

//
// -------------------------------- IntArray --------------------------------
//
class AttsGeneratorIntArray : public virtual IntArray , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorIntArray(const QString &s, const QString &n, const QString &l)
531
        : Field("intArray",n,l), IntArray(s,n,l), AttsGeneratorField("intArray",n,l) { }
hrchilds's avatar
hrchilds committed
532 533 534 535 536 537 538 539 540
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "I";
    }
    virtual QString DataNodeConversion()
    {
        return "AsIntArray";
    }
whitlocb's avatar
whitlocb committed
541
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
542 543
    {
        for (int i=0; i<length; i++)
whitlocb's avatar
whitlocb committed
544
            c << "    " << name << "["<<i<<"] = " << val[i] << ";" << Endl;
hrchilds's avatar
hrchilds committed
545 546 547 548 549 550 551 552 553 554 555
    }
};


//
// -------------------------------- IntVector --------------------------------
//
class AttsGeneratorIntVector : public virtual IntVector , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorIntVector(const QString &n, const QString &l)
556
        : Field("intVector",n,l), IntVector(n,l), AttsGeneratorField("intVector",n,l) { }
hrchilds's avatar
hrchilds committed
557 558 559 560 561 562 563 564 565
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "i*";
    }
    virtual QString DataNodeConversion()
    {
        return "AsIntVector";
    }
whitlocb's avatar
whitlocb committed
566
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
567
    {
568
        for (size_t i=0; i < val.size(); i++)
whitlocb's avatar
whitlocb committed
569
            c << "    " << name << ".push_back(" << val[i] << ");" << Endl;
hrchilds's avatar
hrchilds committed
570 571 572 573 574 575 576 577 578 579 580
    }
};


// 
// ----------------------------------- Bool -----------------------------------
//
class AttsGeneratorBool : public virtual Bool , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorBool(const QString &n, const QString &l)
581
        : Field("bool",n,l), Bool(n,l), AttsGeneratorField("bool",n,l) { }
hrchilds's avatar
hrchilds committed
582 583 584 585 586 587 588 589
    virtual QString GetAttributeGroupID()
    {
        return "b";
    }
    virtual QString DataNodeConversion()
    {
        return "AsBool";
    }
whitlocb's avatar
whitlocb committed
590
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
591
    {
whitlocb's avatar
whitlocb committed
592
        c << "    " << name << " = " << (val ? "true" : "false") << ";" << Endl;
hrchilds's avatar
hrchilds committed
593 594 595 596 597 598 599 600 601 602 603
    }
};


//
// ----------------------------------- Float ----------------------------------
//
class AttsGeneratorFloat : public virtual Float , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorFloat(const QString &n, const QString &l)
604
        : Field("float",n,l), Float(n,l), AttsGeneratorField("float",n,l) { }
hrchilds's avatar
hrchilds committed
605 606 607 608 609 610 611 612
    virtual QString GetAttributeGroupID()
    {
        return "f";
    }
    virtual QString DataNodeConversion()
    {
        return "AsFloat";
    }
whitlocb's avatar
whitlocb committed
613
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
614
    {
whitlocb's avatar
whitlocb committed
615
        c << "    " << name << " = " << val << ";" << Endl;
hrchilds's avatar
hrchilds committed
616 617 618 619 620 621 622 623 624 625 626
    }
};


//
// -------------------------------- FloatArray -------------------------------
//
class AttsGeneratorFloatArray : public virtual FloatArray , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorFloatArray(const QString &s, const QString &n, const QString &l)
627
        : Field("floatArray",n,l), FloatArray(s,n,l), AttsGeneratorField("floatArray",n,l) { }
hrchilds's avatar
hrchilds committed
628 629 630 631 632 633 634 635 636
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "F";
    }
    virtual QString DataNodeConversion()
    {
        return "AsFloatArray";
    }
whitlocb's avatar
whitlocb committed
637
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
638 639
    {
        for (int i=0; i<length; i++)
whitlocb's avatar
whitlocb committed
640
            c << "    " << name << "["<<i<<"] = " << val[i] << ";" << Endl;
hrchilds's avatar
hrchilds committed
641 642 643 644
    }
};


645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669
//
// ------------------------------- FloatVector -------------------------------
//
class AttsGeneratorFloatVector : public virtual FloatVector , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorFloatVector(const QString &n, const QString &l)
        : Field("floatVector",n,l), FloatVector(n,l), AttsGeneratorField("floatVector",n,l) { }
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "f*";
    }
    virtual QString DataNodeConversion()
    {
        return "AsFloatVector";
    }
    virtual void WriteSourceSetDefault(QTextStream &c)
    {
        for (size_t i=0; i < val.size(); i++)
            c << "    " << name << ".push_back(" << val[i] << ");" << Endl;
    }
};


hrchilds's avatar
hrchilds committed
670 671 672 673 674 675 676
//
// ---------------------------------- Double ----------------------------------
//
class AttsGeneratorDouble : public virtual Double , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorDouble(const QString &n, const QString &l)
677
        : Field("double",n,l), Double(n,l), AttsGeneratorField("double",n,l) { }
hrchilds's avatar
hrchilds committed
678 679 680 681 682 683 684 685
    virtual QString GetAttributeGroupID()
    {
        return "d";
    }
    virtual QString DataNodeConversion()
    {
        return "AsDouble";
    }
whitlocb's avatar
whitlocb committed
686
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
687
    {
whitlocb's avatar
whitlocb committed
688
        c << "    " << name << " = " << val << ";" << Endl;
hrchilds's avatar
hrchilds committed
689 690 691 692 693 694 695 696 697 698 699
    }
};


//
// -------------------------------- DoubleArray -------------------------------
//
class AttsGeneratorDoubleArray : public virtual DoubleArray , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorDoubleArray(const QString &s, const QString &n, const QString &l)
700
        : Field("doubleArray",n,l), DoubleArray(s,n,l), AttsGeneratorField("doubleArray",n,l) { }
hrchilds's avatar
hrchilds committed
701 702 703 704 705 706 707 708 709
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "D";
    }
    virtual QString DataNodeConversion()
    {
        return "AsDoubleArray";
    }
whitlocb's avatar
whitlocb committed
710
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
711 712
    {
        for (int i=0; i<length; i++)
whitlocb's avatar
whitlocb committed
713
            c << "    " << name << "["<<i<<"] = " << val[i] << ";" << Endl;
hrchilds's avatar
hrchilds committed
714 715 716 717 718 719 720 721 722 723 724
    }
};


//
// ------------------------------- DoubleVector -------------------------------
//
class AttsGeneratorDoubleVector : public virtual DoubleVector , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorDoubleVector(const QString &n, const QString &l)
725
        : Field("doubleVector",n,l), DoubleVector(n,l), AttsGeneratorField("doubleVector",n,l) { }
hrchilds's avatar
hrchilds committed
726 727 728 729 730 731 732 733 734
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "d*";
    }
    virtual QString DataNodeConversion()
    {
        return "AsDoubleVector";
    }
whitlocb's avatar
whitlocb committed
735
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
736
    {
737
        for (size_t i=0; i < val.size(); i++)
whitlocb's avatar
whitlocb committed
738
            c << "    " << name << ".push_back(" << val[i] << ");" << Endl;
hrchilds's avatar
hrchilds committed
739 740 741 742 743 744 745 746 747 748 749
    }
};


//
// ----------------------------------- UChar ----------------------------------
//
class AttsGeneratorUChar : public virtual UChar , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorUChar(const QString &n, const QString &l)
750
        : Field("uchar",n,l), UChar(n,l), AttsGeneratorField("uchar",n,l) { }
hrchilds's avatar
hrchilds committed
751 752 753 754 755 756 757 758
    virtual QString GetAttributeGroupID()
    {
        return "u";
    }
    virtual QString DataNodeConversion()
    {
        return "AsUnsignedChar";
    }
whitlocb's avatar
whitlocb committed
759
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
760
    {
whitlocb's avatar
whitlocb committed
761
        c << "    " << name << " = " << int(val) << ";" << Endl;
hrchilds's avatar
hrchilds committed
762 763 764 765 766 767 768 769 770 771 772
    }
};


//
// -------------------------------- UCharArray --------------------------------
//
class AttsGeneratorUCharArray : public virtual UCharArray , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorUCharArray(const QString &s, const QString &n, const QString &l)
773
        : Field("ucharArray",n,l), UCharArray(s,n,l), AttsGeneratorField("ucharArray",n,l) { }
hrchilds's avatar
hrchilds committed
774 775 776 777 778 779 780 781 782
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "U";
    }
    virtual QString DataNodeConversion()
    {
        return "AsUnsignedCharArray";
    }
whitlocb's avatar
whitlocb committed
783
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
784 785
    {
        for (int i=0; i<length; i++)
whitlocb's avatar
whitlocb committed
786
            c << "    " << name << "["<<i<<"] = " << int(val[i]) << ";" << Endl;
hrchilds's avatar
hrchilds committed
787 788 789 790 791 792 793 794 795 796 797
    }
};


//
// ------------------------------- unsignedCharVector -------------------------------
//
class AttsGeneratorUCharVector : public virtual UCharVector , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorUCharVector(const QString &n, const QString &l)
798
        : Field("ucharVector",n,l), UCharVector(n,l), AttsGeneratorField("ucharVector",n,l) { }
hrchilds's avatar
hrchilds committed
799 800 801 802 803 804 805 806 807
    virtual bool CanHaveConst() { return true; }
    virtual QString GetAttributeGroupID()
    {
        return "u*";
    }
    virtual QString DataNodeConversion()
    {
        return "AsUnsignedCharVector";
    }
whitlocb's avatar
whitlocb committed
808
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
809
    {
810
        for (size_t i=0; i < val.size(); i++)
whitlocb's avatar
whitlocb committed
811
            c << "    " << name << ".push_back(" << val[i] << ");" << Endl;
hrchilds's avatar
hrchilds committed
812 813 814 815 816 817 818 819 820 821 822
    }
};


//
// ---------------------------------- String ----------------------------------
//
class AttsGeneratorString : public virtual String , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorString(const QString &n, const QString &l)
823
        : Field("string",n,l), String(n,l), AttsGeneratorField("string",n,l) { }
hrchilds's avatar
hrchilds committed
824 825 826 827 828 829 830 831 832 833 834 835 836
    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";
    }
whitlocb's avatar
whitlocb committed
837
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
838
    {
whitlocb's avatar
whitlocb committed
839
        c << "    " << name << " = \"" << val << "\";" << Endl;
hrchilds's avatar
hrchilds committed
840 841 842 843 844 845 846 847 848 849 850
    }
};


//
// ------------------------------- StringVector -------------------------------
//
class AttsGeneratorStringVector : public virtual StringVector , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorStringVector(const QString &n, const QString &l)
851
        : Field("stringVector",n,l), StringVector(n,l), AttsGeneratorField("stringVector",n,l) { }
hrchilds's avatar
hrchilds committed
852 853 854 855 856 857 858 859 860 861 862 863 864
    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";
    }
whitlocb's avatar
whitlocb committed
865
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
866
    {
867
        for (size_t i=0; i < val.size(); i++)
whitlocb's avatar
whitlocb committed
868
        c << "    " << name << ".push_back(" << "\"" << val[i] << "\");" << Endl;
hrchilds's avatar
hrchilds committed
869 870 871 872 873 874 875 876 877 878 879
    }
};


//
// -------------------------------- ColorTable --------------------------------
//
class AttsGeneratorColorTable : public virtual ColorTable , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorColorTable(const QString &n, const QString &l)
880
        : Field("colortable",n,l), ColorTable(n,l), AttsGeneratorField("colortable",n,l) { }
hrchilds's avatar
hrchilds committed
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897
    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;
    }
whitlocb's avatar
whitlocb committed
898
    virtual void WriteSourceInitializer(QTextStream &c)
hrchilds's avatar
hrchilds committed
899 900 901 902 903 904
    {
        if(valueSet)
            c << name << "(\""<<val<<"\")";
        else
            c << name << "(\"hot\")";
    }
whitlocb's avatar
whitlocb committed
905
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
906 907 908 909 910 911 912 913 914 915 916 917
    {
    }
};


//
// ----------------------------------- Color ----------------------------------
//
class AttsGeneratorColor : public virtual Color , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorColor(const QString &n, const QString &l)
918
        : Field("color",n,l), Color(n,l), AttsGeneratorField("color",n,l) { }
hrchilds's avatar
hrchilds committed
919 920 921 922 923 924 925 926 927 928 929 930 931
    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;
    }
whitlocb's avatar
whitlocb committed
932
    virtual void WriteSourceInitializer(QTextStream &c)
hrchilds's avatar
hrchilds committed
933 934 935 936 937 938 939 940 941 942 943 944 945
    {
        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 << "()";
    }
whitlocb's avatar
whitlocb committed
946
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
947 948
    {
    }
whitlocb's avatar
whitlocb committed
949
    virtual void WriteSourceSetFromNode(QTextStream &c)
hrchilds's avatar
hrchilds committed
950 951
    {
        c << "    if((node = searchNode->GetNode(\"" << name
whitlocb's avatar
whitlocb committed
952 953
          << "\")) != 0)" << Endl;
        c << "        " << name << ".SetFromNode(node);" << Endl;
hrchilds's avatar
hrchilds committed
954 955 956 957 958 959 960 961 962 963 964
    }
};


//
// --------------------------------- LineStyle --------------------------------
//
class AttsGeneratorLineStyle : public virtual LineStyle , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorLineStyle(const QString &n, const QString &l)
965
        : Field("linestyle",n,l), LineStyle(n,l), AttsGeneratorField("linestyle",n,l) { }
hrchilds's avatar
hrchilds committed
966 967 968 969 970 971 972 973
    virtual QString GetAttributeGroupID()
    {
        return "i";
    }
    virtual QString DataNodeConversion()
    {
        return "AsInt";
    }
whitlocb's avatar
whitlocb committed
974
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
975
    {
whitlocb's avatar
whitlocb committed
976
        c << "    " << name << " = " << val << ";" << Endl;
hrchilds's avatar
hrchilds committed
977 978 979 980 981 982 983 984 985 986 987
    }
};


//
// --------------------------------- LineWidth --------------------------------
//
class AttsGeneratorLineWidth : public virtual LineWidth , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorLineWidth(const QString &n, const QString &l)
988
        : Field("linewidth",n,l), LineWidth(n,l), AttsGeneratorField("linewidth",n,l) { }
hrchilds's avatar
hrchilds committed
989 990 991 992 993 994 995 996
    virtual QString GetAttributeGroupID()
    {
        return "i";
    }
    virtual QString DataNodeConversion()
    {
        return "AsInt";
    }
whitlocb's avatar
whitlocb committed
997
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
998
    {
whitlocb's avatar
whitlocb committed
999
        c << "    " << name << " = " << val << ";" << Endl;
hrchilds's avatar
hrchilds committed
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
    }
};


//
// --------------------------------- Opacity ----------------------------------
//
class AttsGeneratorOpacity : public virtual Opacity , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorOpacity(const QString &n, const QString &l)
1011
        : Field("opacity",n,l), Opacity(n,l), AttsGeneratorField("opacity",n,l) { }
hrchilds's avatar
hrchilds committed
1012 1013 1014 1015 1016 1017 1018 1019
    virtual QString GetAttributeGroupID()
    {
        return "d";
    }
    virtual QString DataNodeConversion()
    {
        return "AsDouble";
    }
whitlocb's avatar
whitlocb committed
1020
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
1021
    {
whitlocb's avatar
whitlocb committed
1022
        c << "    " << name << " = " << val << ";" << Endl;
hrchilds's avatar
hrchilds committed
1023 1024 1025 1026
    }
};


hrchilds's avatar
hrchilds committed
1027 1028 1029 1030 1031 1032 1033
//
// -------------------------------- VariableName --------------------------------
//
class AttsGeneratorVariableName : public virtual VariableName , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorVariableName(const QString &n, const QString &l)
1034 1035 1036
        : Field("variablename",n,l), VariableName(n,l),
          AttsGeneratorField("variablename",n,l)
           { }
hrchilds's avatar
hrchilds committed
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053
    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;
    }
whitlocb's avatar
whitlocb committed
1054
    virtual void WriteSourceInitializer(QTextStream &c)
hrchilds's avatar
hrchilds committed
1055 1056 1057 1058 1059 1060
    {
        if(valueSet)
            c << name << "(\""<<val<<"\")";
        else
            c << name << "(\"default\")";
    }
whitlocb's avatar
whitlocb committed
1061
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
1062 1063 1064 1065 1066
    {
    }
};


hrchilds's avatar
hrchilds committed
1067 1068 1069 1070 1071 1072 1073
//
// ------------------------------------ Att -----------------------------------
//
class AttsGeneratorAtt : public virtual Att , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorAtt(const QString &t, const QString &n, const QString &l)
1074
        : Field("att",n,l), Att(t,n,l), AttsGeneratorField("att",n,l) { }
hrchilds's avatar
hrchilds committed
1075 1076 1077
    virtual bool CanHaveConst() { return true; }
    virtual void AddAttributeIncludes(UniqueStringList &sl) const
    {
whitlocb's avatar
whitlocb committed
1078 1079
        QString tmp(QString("#include <%1.h>\n").arg(attType));
        sl.AddString(tmp);
hrchilds's avatar
hrchilds committed
1080 1081 1082 1083 1084
    }
    virtual QString GetAttributeGroupID()
    {
        return "a";
    }
whitlocb's avatar
whitlocb committed
1085
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
1086 1087
    {
    }
whitlocb's avatar
whitlocb committed
1088
    virtual void WriteSourceSetFromNode(QTextStream &c)
hrchilds's avatar
hrchilds committed
1089 1090
    {
        c << "    if((node = searchNode->GetNode(\"" << name
whitlocb's avatar
whitlocb committed
1091 1092
          << "\")) != 0)" << Endl;
        c << "        " << name << ".SetFromNode(node);" << Endl;
hrchilds's avatar
hrchilds committed
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103
    }
};


//
// --------------------------------- AttVector --------------------------------
//
class AttsGeneratorAttVector : public virtual AttVector , public virtual AttsGeneratorField
{
  public:
    AttsGeneratorAttVector(const QString &t, const QString &n, const QString &l)
1104
        : Field("attVector",n,l), AttVector(t,n,l), AttsGeneratorField("attVector",n,l) { }
hrchilds's avatar
hrchilds committed
1105
    virtual bool CanHaveConst() { return true; }
whitlocb's avatar
whitlocb committed
1106
    virtual void WriteHeaderForwardDeclarations(QTextStream &h)
hrchilds's avatar
hrchilds committed
1107
    {
whitlocb's avatar
whitlocb committed
1108
        h << "class " << attType << ";" << Endl;
hrchilds's avatar
hrchilds committed
1109
    }
whitlocb's avatar
whitlocb committed
1110
    virtual void WriteHeaderAGVectorProto(QTextStream &h)
hrchilds's avatar
hrchilds committed
1111
    {
hrchilds's avatar
hrchilds committed
1112
        QString plural("");
hrchilds's avatar
hrchilds committed
1113
        if(Name.right(1) != "s")
hrchilds's avatar
hrchilds committed
1114 1115
            plural = "s";

whitlocb's avatar
whitlocb committed
1116 1117 1118 1119 1120 1121 1122
        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;
        h << Endl;
hrchilds's avatar
hrchilds committed
1123
    }
whitlocb's avatar
whitlocb committed
1124
    virtual void WriteHeaderSoloAGVectorProto(QTextStream &h)
hrchilds's avatar
hrchilds committed
1125
    {
whitlocb's avatar
whitlocb committed
1126 1127 1128
        h << "    " << attType << " &operator [] (int i);" << Endl;
        h << "    const " << attType << " &operator [] (int i) const;" << Endl;
        h << Endl;
hrchilds's avatar
hrchilds committed
1129
    }
whitlocb's avatar
whitlocb committed
1130
    virtual void WriteSourceIncludes(QTextStream &c)
hrchilds's avatar
hrchilds committed
1131
    {
whitlocb's avatar
whitlocb committed
1132
        c << "#include <"<<attType<<".h>" << Endl;
hrchilds's avatar
hrchilds committed
1133 1134 1135 1136 1137
    }
    virtual QString GetAttributeGroupID()
    {
        return "a*";
    }
whitlocb's avatar
whitlocb committed
1138
    virtual void WriteSourceSetDefault(QTextStream &c)
hrchilds's avatar
hrchilds committed
1139 1140
    {
    }
whitlocb's avatar
whitlocb committed
1141
    virtual void WriteHeaderSetFunction(QTextStream &h)
hrchilds's avatar
hrchilds committed
1142 1143 1144 1145
    {
        // Disabled the header method because the .C implementation (below)
        // does not output anything.
    }
whitlocb's avatar
whitlocb committed
1146
    virtual void WriteSourceSetFunction(QTextStream &c, const QString &classname)
hrchilds's avatar
hrchilds committed
1147 1148 1149 1150 1151