# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

# D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlCore/VLXValue.cpp

Go to the documentation of this file.

    00001 /**************************************************************************************/
    00002 /*                                                                                    */
    00003 /*  Visualization Library                                                             */
    00004 /*  http://www.visualizationlibrary.org                                               */
    00005 /*                                                                                    */
    00006 /*  Copyright (c) 2005-2010, Michele Bosi                                             */
    00007 /*  All rights reserved.                                                              */
    00008 /*                                                                                    */
    00009 /*  Redistribution and use in source and binary forms, with or without modification,  */
    00010 /*  are permitted provided that the following conditions are met:                     */
    00011 /*                                                                                    */
    00012 /*  - Redistributions of source code must retain the above copyright notice, this     */
    00013 /*  list of conditions and the following disclaimer.                                  */
    00014 /*                                                                                    */
    00015 /*  - Redistributions in binary form must reproduce the above copyright notice, this  */
    00016 /*  list of conditions and the following disclaimer in the documentation and/or       */
    00017 /*  other materials provided with the distribution.                                   */
    00018 /*                                                                                    */
    00019 /*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
    00020 /*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
    00021 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
    00022 /*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
    00023 /*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
    00024 /*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
    00025 /*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
    00026 /*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
    00027 /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
    00028 /*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
    00029 /*                                                                                    */
    00030 /**************************************************************************************/
    00031
    00032 #include <vlCore/VLXValue.hpp>
    00033
    00034 using namespace vl;
    00035
    00036 //-----------------------------------------------------------------------------
    00037 void VLXValue::release()
    00038 {
    00039   switch(mType)
    00040   {
    00041   case Structure:
    00042     if (mUnion.mStructure)
    00043       mUnion.mStructure->decReference();
    00044     break;
    00045
    00046   case List:
    00047     if (mUnion.mList)
    00048       mUnion.mList->decReference();
    00049     break;
    00050
    00051   case RawtextBlock:
    00052     if (mUnion.mRawtextBlock)
    00053       mUnion.mRawtextBlock->decReference();
    00054     break;
    00055
    00056   /*
    00057   case ArrayString:
    00058   case ArrayID:
    00059   case ArrayIdentifier:
    00060   */
    00061   case ArrayInteger:
    00062   case ArrayReal:
    00063     if (mUnion.mArray)
    00064       mUnion.mArray->decReference();
    00065     break;
    00066
    00067   case String:
    00068   case ID:
    00069   case Identifier:
    00070     VL_CHECK(mUnion.mString)
    00071     delete mUnion.mString;
    00072     mUnion.mString = NULL;
    00073     break;
    00074
    00075   default:
    00076     break;
    00077   }
    00078
    00079   mType = Integer;
    00080   mUnion.mInteger = 0;
    00081 }
    00082 //-----------------------------------------------------------------------------
    00083 VLXValue& VLXValue::operator=(const VLXValue& other)
    00084 {
    00085   mLineNumber = other.mLineNumber;
    00086
    00087   // must be done first
    00088   switch(other.mType)
    00089   {
    00090   case Structure:
    00091     if (other.mUnion.mStructure)
    00092       other.mUnion.mStructure->incReference();
    00093     break;
    00094
    00095   case List:
    00096     if (other.mUnion.mList)
    00097       other.mUnion.mList->incReference();
    00098     break;
    00099
    00100   case RawtextBlock:
    00101     if (other.mUnion.mRawtextBlock)
    00102       other.mUnion.mRawtextBlock->incReference();
    00103     break;
    00104
    00105   /*
    00106   case ArrayString:
    00107   case ArrayID:
    00108   case ArrayIdentifier:
    00109   */
    00110   case ArrayInteger:
    00111   case ArrayReal:
    00112     if (other.mUnion.mArray)
    00113       other.mUnion.mArray->incReference();
    00114     break;
    00115
    00116   default:
    00117     break;
    00118   }
    00119
    00120   // must be done after
    00121   release();
    00122
    00123   mUnion = other.mUnion;
    00124   mType = other.mType;
    00125
    00126   // make local copy of the string
    00127   if (mType == String || mType == Identifier || mType == ID)
    00128     mUnion.mString = new std::string(*mUnion.mString);
    00129
    00130   return *this;
    00131 }
    00132 //-----------------------------------------------------------------------------
    00133 VLXStructure* VLXValue::setStructure(VLXStructure* obj)
    00134 {
    00135   release();
    00136   mType = Structure;
    00137   mUnion.mStructure = obj;
    00138   if (mUnion.mStructure)
    00139     mUnion.mStructure->incReference();
    00140   return obj;
    00141 }
    00142 //-----------------------------------------------------------------------------
    00143 VLXList* VLXValue::setList(VLXList* list)
    00144 {
    00145   VL_CHECK(list);
    00146
    00147   release();
    00148   mType = List;
    00149   mUnion.mList = list;
    00150   if (mUnion.mList)
    00151     mUnion.mList->incReference();
    00152   return list;
    00153 }
    00154 //-----------------------------------------------------------------------------
    00155 VLXRawtextBlock* VLXValue::setRawtextBlock(VLXRawtextBlock* fblock)
    00156 {
    00157   VL_CHECK(fblock);
    00158
    00159   release();
    00160   mType = RawtextBlock;
    00161   mUnion.mRawtextBlock = fblock;
    00162   if (mUnion.mRawtextBlock)
    00163     mUnion.mRawtextBlock->incReference();
    00164   return fblock;
    00165 }
    00166 //-----------------------------------------------------------------------------
    00167 VLXArrayInteger* VLXValue::setArrayInteger(VLXArrayInteger* arr)
    00168 {
    00169   VL_CHECK(arr);
    00170   release();
    00171   mType = ArrayInteger;
    00172   mUnion.mArray = arr;
    00173   if (mUnion.mArray)
    00174     mUnion.mArray->incReference();
    00175   return arr;
    00176 }
    00177 //-----------------------------------------------------------------------------
    00178 VLXArrayReal* VLXValue::setArrayReal(VLXArrayReal* arr)
    00179 {
    00180   VL_CHECK(arr);
    00181   release();
    00182   mType = ArrayReal;
    00183   mUnion.mArray = arr;
    00184   if (mUnion.mArray)
    00185     mUnion.mArray->incReference();
    00186   return arr;
    00187 }
    00188 //-----------------------------------------------------------------------------
    00189 /*
    00190 VLXArrayString* VLXValue::setArrayString(VLXArrayString* arr)
    00191 {
    00192   VL_CHECK(arr);
    00193   release();
    00194   mType = ArrayString;
    00195   mUnion.mArray = arr;
    00196   if (mUnion.mArray)
    00197     mUnion.mArray->incReference();
    00198   return arr;
    00199 }
    00200 //-----------------------------------------------------------------------------
    00201 VLXArrayIdentifier* VLXValue::setArrayIdentifier(VLXArrayIdentifier* arr)
    00202 {
    00203   VL_CHECK(arr);
    00204   release();
    00205   mType = ArrayIdentifier;
    00206   mUnion.mArray = arr;
    00207   if (mUnion.mArray)
    00208     mUnion.mArray->incReference();
    00209   return arr;
    00210 }
    00211 //-----------------------------------------------------------------------------
    00212 VLXArrayID* VLXValue::setArrayID(VLXArrayID* arr)
    00213 {
    00214   VL_CHECK(arr);
    00215   release();
    00216   mType = ArrayID;
    00217   mUnion.mArray = arr;
    00218   if (mUnion.mArray)
    00219     mUnion.mArray->incReference();
    00220   return arr;
    00221 }
    00222 */
    00223 //-----------------------------------------------------------------------------
    00224 VLXArray* VLXValue::setArray(VLXArray* arr)
    00225 {
    00226   if (arr->classType() == VLXArrayInteger::Type())
    00227     return setArrayInteger(arr->as<VLXArrayInteger>());
    00228   else
    00229   if (arr->classType() == VLXArrayReal::Type())
    00230     return setArrayReal(arr->as<VLXArrayReal>());
    00231   /*
    00232   else
    00233   if (arr->classType() == VLXArrayString::Type())
    00234     return setArrayString(arr->as<VLXArrayString>());
    00235   else
    00236   if (arr->classType() == VLXArrayIdentifier::Type())
    00237     return setArrayIdentifier(arr->as<VLXArrayIdentifier>());
    00238   else
    00239   if (arr->classType() == VLXArrayID::Type())
    00240     return setArrayID(arr->as<VLXArrayID>());
    00241   */
    00242   else
    00243   {
    00244     VL_TRAP();
    00245     return NULL;
    00246   }
    00247 }
    00248 //-----------------------------------------------------------------------------

Visualization Library v2011.09.1162 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu Jan 26 2012 00:43:33.
Permission is granted to use this page to write and publish articles regarding Visualization Library.