<commit_before>/* Begin CVS Header
   $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/report/CCopasiObject.cpp,v $
   $Revision: 1.61 $
   $Name:  $
   $Author: shoops $
   $Date: 2006/09/11 14:24:33 $
   End CVS Header */

// Copyright  2005 by <NAME>, Virginia Tech Intellectual
// Properties, Inc. and EML Research, gGmbH.
// All rights reserved.

/**
 * Class CCopasiObject
 *
 * This class is the base class for all global accessible objects in copasi.
 *
 * Copyright <NAME> 2002
 */

#include <sstream>
#include <algorithm>

#include "copasi.h"
#include "CCopasiObjectName.h"
#include "CCopasiObject.h"
#include "CCopasiContainer.h"
#include "CRenameHandler.h"
#include "utilities/CCopasiVector.h"
#include "model/CModelValue.h"
#include "model/CModel.h"

//static
const C_FLOAT64 CCopasiObject::DummyValue = 0.0;

//static
const CRenameHandler * CCopasiObject::smpRenameHandler = NULL;

//static
UpdateMethod CCopasiObject::mDefaultUpdateMethod;

CCopasiObject::CCopasiObject():
    mObjectName("No Name"),
    mObjectType("Unknown Type"),
    mpObjectParent(NULL),
    mObjectFlag(0),
    mpUpdateMethod(&this->mDefaultUpdateMethod),
    mpRefresh(NULL)
{}

CCopasiObject::CCopasiObject(const std::string & name,
                             const CCopasiContainer * pParent,
                             const std::string & type,
                             const unsigned C_INT32 & flag):
    mObjectName((name == "") ? "No Name" : name),
    mObjectType(type),
    mpObjectParent(const_cast<CCopasiContainer *>(pParent)),
    mObjectFlag(flag),
    mpUpdateMethod(&this->mDefaultUpdateMethod),
    mpRefresh(NULL)
{
  if (mpObjectParent)
    if (mpObjectParent->isContainer()) mpObjectParent->add(this);
}

CCopasiObject::CCopasiObject(const CCopasiObject & src,
                             const CCopasiContainer * pParent):
mObjectName(src.mObjectName),
mObjectType(src.mObjectType),
mpObjectParent(const_cast<CCopasiContainer *>(pParent)),
mObjectFlag(src.mObjectFlag),
mpUpdateMethod(&this->mDefaultUpdateMethod),
mpRefresh(NULL)
{if (mpObjectParent) mpObjectParent->add(this);}

CCopasiObject::~CCopasiObject()
{
  if (mpObjectParent)
    mpObjectParent->remove(this);

  if (mpUpdateMethod != &mDefaultUpdateMethod)
    pdelete(mpUpdateMethod);

  pdelete(mpRefresh);<commit_msg>Corrected checking fo NULL pointer.<commit_after>/* Begin CVS Header
   $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/report/CCopasiObject.cpp,v $
   $Revision: 1.62 $
   $Name:  $
   $Author: shoops $
   $Date: 2006/11/16 15:36:13 $
   End CVS Header */

// Copyright  2005 by <NAME>, Virginia Tech Intellectual
// Properties, Inc. and EML Research, gGmbH.
// All rights reserved.

/**
 * Class CCopasiObject
 *
 * This class is the base class for all global accessible objects in copasi.
 *
 * Copyright <NAME> 2002
 */

#include <sstream>
#include <algorithm>

#include "copasi.h"
#include "CCopasiObjectName.h"
#include "CCopasiObject.h"
#include "CCopasiContainer.h"
#include "CRenameHandler.h"
#include "utilities/CCopasiVector.h"
#include "model/CModelValue.h"
#include "model/CModel.h"

//static
const C_FLOAT64 CCopasiObject::DummyValue = 0.0;

//static
const CRenameHandler * CCopasiObject::smpRenameHandler = NULL;

//static
UpdateMethod CCopasiObject::mDefaultUpdateMethod;

CCopasiObject::CCopasiObject():
    mObjectName("No Name"),
    mObjectType("Unknown Type"),
    mpObjectParent(NULL),
    mObjectFlag(0),
    mpUpdateMethod(&this->mDefaultUpdateMethod),
    mpRefresh(NULL)
{}

CCopasiObject::CCopasiObject(const std::string & name,
                             const CCopasiContainer * pParent,
                             const std::string & type,
                             const unsigned C_INT32 & flag):
    mObjectName((name == "") ? "No Name" : name),
    mObjectType(type),
    mpObjectParent(const_cast<CCopasiContainer *>(pParent)),
    mObjectFlag(flag),
    mpUpdateMethod(&this->mDefaultUpdateMethod),
    mpRefresh(NULL)
{
  if (mpObjectParent != NULL)
    if (mpObjectParent->isContainer()) mpObjectParent->add(this);
}

CCopasiObject::CCopasiObject(const CCopasiObject & src,
                             const CCopasiContainer * pParent):
mObjectName(src.mObjectName),
mObjectType(src.mObjectType),
mpObjectParent(const_cast<CCopasiContainer *>(pParent)),
mObjectFlag(src.mObjectFlag),
mpUpdateMethod(&this->mDefaultUpdateMethod),
mpRefresh(NULL)
{if (mpObjectParent != NULL) mpObjectParent->add(this);}

CCopasiObject::~CCopasiObject()
{
  if (mpObjectParent)
    mpObjectParent->remove(this);

  if (mpUpdateMethod != &mDefaultUpdateMethod)
    pdelete(mpUpdateMethod);

  pdelete(mpRefresh);
{'fraction_non_alphanumeric': 0.12607388316151202, 'fraction_numerical': 0.013745704467353952, 'mean_word_length': 4.04004329004329, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2245476', 'n_tokens_mistral': 1561, 'n_tokens_neox': 1507, 'n_words': 297}