AnimationAttributes.C 12.7 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2 3 4 5 6 7 8 9 10 11 12
#include <AnimationAttributes.h>
#include <DataNode.h>

// ****************************************************************************
// Method: AnimationAttributes::AnimationAttributes
//
// Purpose: 
//   Constructor for the AnimationAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
13
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
14 15 16 17 18 19 20
//
// Modifications:
//   
// ****************************************************************************

AnimationAttributes::AnimationAttributes() : AttributeSubject("bi")
{
hrchilds's avatar
hrchilds committed
21
    pipelineCachingMode = false;
hrchilds's avatar
hrchilds committed
22 23 24 25 26 27 28 29 30 31 32 33
    timeout = 1;
}

// ****************************************************************************
// Method: AnimationAttributes::AnimationAttributes
//
// Purpose: 
//   Copy constructor for the AnimationAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
34
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
//
// Modifications:
//   
// ****************************************************************************

AnimationAttributes::AnimationAttributes(const AnimationAttributes &obj) : AttributeSubject("bi")
{
    pipelineCachingMode = obj.pipelineCachingMode;
    timeout = obj.timeout;

    SelectAll();
}

// ****************************************************************************
// Method: AnimationAttributes::~AnimationAttributes
//
// Purpose: 
//   Destructor for the AnimationAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
57
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
//
// Modifications:
//   
// ****************************************************************************

AnimationAttributes::~AnimationAttributes()
{
    // nothing here
}

// ****************************************************************************
// Method: AnimationAttributes::operator = 
//
// Purpose: 
//   Assignment operator for the AnimationAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
77
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
//
// Modifications:
//   
// ****************************************************************************

void
AnimationAttributes::operator = (const AnimationAttributes &obj)
{
    pipelineCachingMode = obj.pipelineCachingMode;
    timeout = obj.timeout;

    SelectAll();
}

// ****************************************************************************
// Method: AnimationAttributes::operator == 
//
// Purpose: 
//   Comparison operator == for the AnimationAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
101
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
//
// Modifications:
//   
// ****************************************************************************

bool
AnimationAttributes::operator == (const AnimationAttributes &obj) const
{
    // Create the return value
    return ((pipelineCachingMode == obj.pipelineCachingMode) &&
            (timeout == obj.timeout));
}

// ****************************************************************************
// Method: AnimationAttributes::operator != 
//
// Purpose: 
//   Comparison operator != for the AnimationAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
124
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
//
// Modifications:
//   
// ****************************************************************************

bool
AnimationAttributes::operator != (const AnimationAttributes &obj) const
{
    return !(this->operator == (obj));
}

// ****************************************************************************
// Method: AnimationAttributes::TypeName
//
// Purpose: 
//   Type name method for the AnimationAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
145
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
//
// Modifications:
//   
// ****************************************************************************

const std::string
AnimationAttributes::TypeName() const
{
    return "AnimationAttributes";
}

// ****************************************************************************
// Method: AnimationAttributes::CopyAttributes
//
// Purpose: 
//   CopyAttributes method for the AnimationAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
166
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
//
// Modifications:
//   
// ****************************************************************************

bool
AnimationAttributes::CopyAttributes(const AttributeGroup *atts)
{
    if(TypeName() != atts->TypeName())
        return false;

    // Call assignment operator.
    const AnimationAttributes *tmp = (const AnimationAttributes *)atts;
    *this = *tmp;

    return true;
}

// ****************************************************************************
// Method: AnimationAttributes::CreateCompatible
//
// Purpose: 
//   CreateCompatible method for the AnimationAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
194
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
//
// Modifications:
//   
// ****************************************************************************

AttributeSubject *
AnimationAttributes::CreateCompatible(const std::string &tname) const
{
    AttributeSubject *retval = 0;
    if(TypeName() == tname)
        retval = new AnimationAttributes(*this);
    // Other cases could go here too. 

    return retval;
}

hrchilds's avatar
hrchilds committed
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
// ****************************************************************************
// Method: AnimationAttributes::NewInstance
//
// Purpose: 
//   NewInstance method for the AnimationAttributes class.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation:   Wed Jul 23 11:29:25 PDT 2003
//
// Modifications:
//   
// ****************************************************************************

AttributeSubject *
AnimationAttributes::NewInstance(bool copy) const
{
    AttributeSubject *retval = 0;
    if(copy)
        retval = new AnimationAttributes(*this);
    else
        retval = new AnimationAttributes;

    return retval;
}

hrchilds's avatar
hrchilds committed
238 239 240 241 242 243 244 245 246
// ****************************************************************************
// Method: AnimationAttributes::SelectAll
//
// Purpose: 
//   Selects all attributes.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
247
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
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
//
// Modifications:
//   
// ****************************************************************************

void
AnimationAttributes::SelectAll()
{
    Select(0, (void *)&pipelineCachingMode);
    Select(1, (void *)&timeout);
}

///////////////////////////////////////////////////////////////////////////////
// Persistence methods
///////////////////////////////////////////////////////////////////////////////

// ****************************************************************************
// Method: AnimationAttributes::CreateNode
//
// Purpose: 
//   This method creates a DataNode representation of the object so it can be saved to a config file.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
273
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
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 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
//
// Modifications:
//   
// ****************************************************************************

bool
AnimationAttributes::CreateNode(DataNode *parentNode, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    AnimationAttributes defaultObject;
    bool addToParent = false;
    // Create a node for AnimationAttributes.
    DataNode *node = new DataNode("AnimationAttributes");

    if(!FieldsEqual(0, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("pipelineCachingMode", pipelineCachingMode));
    }

    if(!FieldsEqual(1, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("timeout", timeout));
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}

// ****************************************************************************
// Method: AnimationAttributes::SetFromNode
//
// Purpose: 
//   This method sets attributes in this object from values in a DataNode representation of the object.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
321
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 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
//
// Modifications:
//   
// ****************************************************************************

void
AnimationAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("AnimationAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("pipelineCachingMode")) != 0)
        SetPipelineCachingMode(node->AsBool());
    if((node = searchNode->GetNode("timeout")) != 0)
        SetTimeout(node->AsInt());
}

///////////////////////////////////////////////////////////////////////////////
// Set property methods
///////////////////////////////////////////////////////////////////////////////

void
AnimationAttributes::SetPipelineCachingMode(bool pipelineCachingMode_)
{
    pipelineCachingMode = pipelineCachingMode_;
    Select(0, (void *)&pipelineCachingMode);
}

void
AnimationAttributes::SetTimeout(int timeout_)
{
    timeout = timeout_;
    Select(1, (void *)&timeout);
}

///////////////////////////////////////////////////////////////////////////////
// Get property methods
///////////////////////////////////////////////////////////////////////////////

bool
AnimationAttributes::GetPipelineCachingMode() const
{
    return pipelineCachingMode;
}

int
AnimationAttributes::GetTimeout() const
{
    return timeout;
}

///////////////////////////////////////////////////////////////////////////////
// Keyframing methods
///////////////////////////////////////////////////////////////////////////////

// ****************************************************************************
// Method: AnimationAttributes::GetFieldName
//
// Purpose: 
//   This method returns the name of a field given its index.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
391
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
//
// Modifications:
//   
// ****************************************************************************

std::string
AnimationAttributes::GetFieldName(int index) const
{
    switch (index)
    {
        case 0:  return "pipelineCachingMode";
        case 1:  return "timeout";
        default:  return "invalid index";
    }
}

// ****************************************************************************
// Method: AnimationAttributes::GetFieldType
//
// Purpose: 
//   This method returns the type of a field given its index.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
417
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
//
// Modifications:
//   
// ****************************************************************************

AttributeGroup::FieldType
AnimationAttributes::GetFieldType(int index) const
{
    switch (index)
    {
        case 0:  return FieldType_bool;
        case 1:  return FieldType_int;
        default:  return FieldType_unknown;
    }
}

// ****************************************************************************
// Method: AnimationAttributes::GetFieldTypeName
//
// Purpose: 
//   This method returns the name of a field type given its index.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
443
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
//
// Modifications:
//   
// ****************************************************************************

std::string
AnimationAttributes::GetFieldTypeName(int index) const
{
    switch (index)
    {
        case 0:  return "bool";
        case 1:  return "int";
        default:  return "invalid index";
    }
}

// ****************************************************************************
// Method: AnimationAttributes::FieldsEqual
//
// Purpose: 
//   This method compares two fields and return true if they are equal.
//
// Note:       Autogenerated by xml2atts.
//
// Programmer: xml2atts
hrchilds's avatar
hrchilds committed
469
// Creation:   Wed Jul 23 11:29:25 PDT 2003
hrchilds's avatar
hrchilds committed
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501
//
// Modifications:
//   
// ****************************************************************************

bool
AnimationAttributes::FieldsEqual(int index_, const AttributeGroup *rhs) const
{
    const AnimationAttributes &obj = *((const AnimationAttributes*)rhs);
    bool retval = false;
    switch (index_)
    {
    case 0:
        {  // new scope
        retval = (pipelineCachingMode == obj.pipelineCachingMode);
        }
        break;
    case 1:
        {  // new scope
        retval = (timeout == obj.timeout);
        }
        break;
    default: retval = false;
    }

    return retval;
}

///////////////////////////////////////////////////////////////////////////////
// User-defined methods.
///////////////////////////////////////////////////////////////////////////////