| 1 | /*************************************************************************** |
| 2 | electricitysim.h - description |
| 3 | ------------------- |
| 4 | begin : march 3rd, 2004 |
| 5 | copyright : (C) 2004-2008 by Duong Khang NGUYEN |
| 6 | email : neoneurone @ gmail com |
| 7 | internal sim version : 0.0.2 |
| 8 | |
| 9 | $Id: electricitysim.h 450 2010-11-21 19:11:43Z neoneurone $ |
| 10 | ***************************************************************************/ |
| 11 | |
| 12 | /*************************************************************************** |
| 13 | * * |
| 14 | * This program is free software; you can redistribute it and/or modify * |
| 15 | * it under the terms of the GNU General Public License as published by * |
| 16 | * the Free Software Foundation; either version 2 of the License, or * |
| 17 | * any later version. * |
| 18 | * * |
| 19 | ***************************************************************************/ |
| 20 | |
| 21 | #ifndef _OPENCITY_ELECTRICITYSIM_H_ |
| 22 | #define _OPENCITY_ELECTRICITYSIM_H_ 1 |
| 23 | |
| 24 | #include "main.h" |
| 25 | #include "simulator.h" |
| 26 | |
| 27 | #include <deque> |
| 28 | #include <vector> |
| 29 | |
| 30 | |
| 31 | //======================================================================== |
| 32 | /** This class is a threaded mini-simulator which handles the transmission |
| 33 | of electricity in the game |
| 34 | */ |
| 35 | class ElectricitySim : public Simulator |
| 36 | { |
| 37 | public: |
| 38 | ElectricitySim( |
| 39 | SDL_mutex* mutex, |
| 40 | BuildingLayer* pblayer, |
| 41 | Map* pmap ); |
| 42 | ~ElectricitySim(); |
| 43 | |
| 44 | |
| 45 | //======================================================================== |
| 46 | /** Overload the base method in order to save our properties |
| 47 | \param rfs A reference to a file stream which is ready for writing |
| 48 | */ |
| 49 | void |
| 50 | SaveTo( std::fstream& rfs ); |
| 51 | |
| 52 | |
| 53 | //======================================================================== |
| 54 | /** Overload the base method in order to load our properties |
| 55 | \param rfs A reference to a file stream which is ready for reading |
| 56 | */ |
| 57 | void |
| 58 | LoadFrom( std::fstream& rfs ); |
| 59 | |
| 60 | |
| 61 | int |
| 62 | Main(); |
| 63 | |
| 64 | void |
| 65 | AddStructure( |
| 66 | const uint & w1, |
| 67 | const uint & h1, |
| 68 | const uint & w2, |
| 69 | const uint & h2 ); |
| 70 | |
| 71 | void |
| 72 | RemoveStructure( |
| 73 | const uint & w1, |
| 74 | const uint & h1, |
| 75 | const uint & w2, |
| 76 | const uint & h2 ); |
| 77 | |
| 78 | |
| 79 | //======================================================================== |
| 80 | /** Return the possible max value of the micro simulator. |
| 81 | */ |
| 82 | const int |
| 83 | GetMaxValue() const; |
| 84 | |
| 85 | |
| 86 | private: |
| 87 | uint _uiNumberEPlant; |
| 88 | int _iValueMax; |
| 89 | std::deque<std::pair<uint, uint> > _dequepairui; |
| 90 | std::vector<std::pair<uint, uint> > _vectorpairuiEPlant; |
| 91 | |
| 92 | /*=====================================================================*/ |
| 93 | bool |
| 94 | DequeContain( const std::pair<uint, uint> &); |
| 95 | |
| 96 | }; |
| 97 | |
| 98 | #endif |