Pixel.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006-2008 by Antonello Lobianco                         *
00003  *   http://regmas.org                                                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 3 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef PIXELS_H
00021 #define PIXELS_H
00022 
00023 #include <string>
00024 #include <vector>
00025 #include <stdexcept>
00026 #include <iostream>
00027 #include <sstream>
00028 
00029 // regmas headers...
00030 #include "BaseRegmas.h"
00031 #include "RegData.h"
00032 #include "Gis.h"
00033 #include "ModelObject.h"
00034 
00035 class Agent_space; //forward declaration
00036 class Gis;        //forward declaration
00037 
00039 
00044 class Pixel: public BaseRegmas{
00045     
00046 public:
00047                         Pixel(double ID_h, ThreadManager* MTHREAD_h);
00048                        ~Pixel();
00049 
00051     double              getDoubleValue ( string layerName_h ) const;
00052     void                initObjects(); 
00053 
00054     void                acquireObject(ModelObject acquiredObject_h, int case_h=STAGE_NORMAL);
00055     void                newYear();
00057     void                setRandomRenting(string contractType);
00058     bool                isAgricultural() const;
00060     double              getStartingRentalCosts() const;
00062     void                destroyRentalContract();
00063 
00065     int                 getLastRentingYear() const {return startRentingYear+rentingTerm-1;};
00066     int                 getStartRentingYear() const {return startRentingYear;};
00067     int                 getRentingTerm() const {return rentingTerm;};
00068     int                 getRentingAge() const;
00069     int                 getRemainingRentingAge() const {return getRentingTerm()-getRentingAge();};
00070 
00071 
00072     // space..
00073     double              getID() const {return ID;}  ;
00074     int                 getX() const {return pxX;} ;
00075     int                 getY() const {return pxY;};
00077     vector <Pixel *>    getPixelsAtDistLevel (int distLevel_h) const;
00078     Agent_space*        getOwner() {return pxOwner;};
00079     Agent_space*        getTenant() {return pxTenant;};
00080     string              getPxComments() const {return pxComments;};
00081     Agent_space *       getCachedAgent(){return cachedAgent;};  
00082     double              getCachedDouble() const {return cachedDouble;}; 
00084     vector <ModelObject*> getIncludedObjects();
00085     vector <string>     getIncludedObjectNames() const;
00086     int                 countMyObjects() const {return myObjects.size();};
00087     double              getRentalCosts() const {return rentalCosts;};
00088     double              getShRentalPriceCoeff() const {return shRentalPriceCoeff;};
00089 
00090 
00092     void                setValue ( string layerName_h, double value_h );
00094     void                changeValue ( string layerName_h, double value_h );
00095     void                setCoordinates ( int x_h, int y_h ) {pxX=x_h; pxY=y_h;};
00096     void                setOwner ( Agent_space* owner_h ) {pxOwner=owner_h;};
00097     void                setTenant ( Agent_space* tenant_h ) {pxTenant=tenant_h;};
00098     void                setPxComments ( std::string pxComments_h ) {pxComments = pxComments_h;};
00099     void                setCachedAgent(Agent_space * cachedAgent_h){cachedAgent=cachedAgent_h;};
00100     void                setCachedDouble(double cachedDouble_h){cachedDouble=cachedDouble_h;};
00101     void                clearCache(){cachedAgent=0;cachedDouble=0;};
00102     void                setRemainingRentingTerm (int years_h);
00103     void                setRentingTerm(int years){rentingTerm=years;};
00104     void                setRentalCosts(double rentalCosts_h){rentalCosts=rentalCosts_h;};
00105     void                setShRentalPriceCoeff(double shRentalPriceCoeff_h){shRentalPriceCoeff = shRentalPriceCoeff_h;};
00106 
00107 
00108 
00109 private:    
00110     map<string, double>            values;  
00111     double                             ID;
00112     int                               pxX;
00113     int                               pxY;
00114     string                     pxComments;
00115     Agent_space*                  pxOwner;
00116     Agent_space*                 pxTenant;
00117     Agent_space*              cachedAgent;  
00118     double                   cachedDouble;  
00119     vector <ModelObject>        myObjects;  
00120 
00122     int                       rentingTerm;
00124     int                  startRentingYear;
00125     double                    rentalCosts;
00126     double             shRentalPriceCoeff; 
00127 
00128 };
00129 
00130 #endif