Page principale | Liste des namespaces | Hiérarchie des classes | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de namespace | Membres de classe | Membres de fichier

NumVarArray.cpp

Aller à la documentation de ce fichier.
00001 /*
00002     Copyright (c) 2005, Quentin Lequy and Romain Gaucher
00003     All rights reserved.
00004 
00005     Redistribution and use in source and binary forms, with or 
00006     without modification, are permitted provided that the following 
00007     conditions are met:
00008 
00009         * Redistributions of source code must retain the above copyright 
00010           notice, this list of conditions and the following disclaimer.
00011 
00012         * Redistributions in binary form must reproduce the above copyright 
00013           notice, this list of conditions and the following disclaimer in the 
00014           documentation and/or other materials provided with the distribution.
00015 
00016         * Neither the name of Quentin Lequy or Romain Gaucher nor the names 
00017           of its contributors may be used to endorse or promote products 
00018           derived from this software without specific prior written permission.
00019 
00020     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00021     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00022     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00023     ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
00024     LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
00025     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
00026     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
00027     AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00028     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00029     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 */
00031 
00032 #include "NumVarArray.h"
00033 #include "Model.h"
00034 
00035 namespace Modelib {
00036 
00037 /*----------------------------------------------------------------------------*/
00038 
00045 NumVarArray::NumVarArray( Model & _modele,
00046              unsigned size,
00047              float _lb,
00048              float _ub,
00049              MuteVar::VarType _type,
00050              const std::string & nom,
00051              const std::string & fin )
00052 : modele(&_modele),type(_type)
00053 {
00054   if(nom != "unknow")
00055     for(unsigned i=0;i < size; ++i)
00056     {
00057       char id[16];
00058       sprintf(id,"%d",i);
00059       varArray.push_back(new NumVar(_modele,_lb,_ub,_type,nom+id+fin));
00060     }
00061   else
00062   for(unsigned i=0;i < size; ++i)
00063     varArray.push_back(new NumVar(_modele,_lb,_ub,_type));
00064 }
00065 
00069 NumVarArray::NumVarArray( const NumVarArray & nva )
00070 :type(nva.type)
00071 {
00072   for(unsigned i = 0; i < nva.varArray.size(); ++i)
00073     varArray.push_back(new NumVar(*nva.varArray[i]));
00074 }
00075 
00080 NumVarArray::NumVarArray( const std::vector<NumVar> & nva )
00081 {
00082   if( nva.size() )
00083   {
00084     type = nva[0].GetType();
00085     for(unsigned i = 0; i < nva.size(); ++i)
00086         varArray.push_back(new NumVar(nva[i]));
00087   }
00088 }
00089 
00090 
00091 /*----------------------------------------------------------------------------*/
00092 
00096 NumVarArray & NumVarArray::operator= ( const NumVarArray & nva )
00097 {
00098   type = nva.type;
00099   for(unsigned i = 0; i < nva.varArray.size(); ++i)
00100     varArray.push_back(new NumVar(*nva.varArray[i]));
00101   return *this;
00102 }
00103 
00104 /*----------------------------------------------------------------------------*/
00105 
00109 NumVarArray::~NumVarArray()
00110 {
00111   for(unsigned i = 0; i < Size(); ++i)
00112     delete varArray[i];
00113 }
00114 
00115 
00116 #ifdef COMPILE_FOR_PYTHON
00117        #include "py_NumVarArray.cxx"
00118 #endif
00119 
00120 
00121 }
00122 

Généré le Sun Oct 2 19:13:12 2005 pour Modelib par  doxygen 1.4.4