1 | /* |
---|
2 | Copyright (C) 2014 |
---|
3 | Alejandro Mujica (amujica@cenditel.gob.ve) |
---|
4 | José Ruiz (jruiz@cenditel.gob.ve) |
---|
5 | Julie Vera (jvera@cenditel.gob.ve) |
---|
6 | |
---|
7 | CENDITEL Fundación Centro Nacional de Desarrollo e Investigación en |
---|
8 | Tecnologías Libres |
---|
9 | |
---|
10 | Este programa es software libre; Usted puede usarlo bajo los términos de la |
---|
11 | licencia de software GPL versión 2.0 de la Free Software Foundation. |
---|
12 | |
---|
13 | Este programa se distribuye con la esperanza de que sea útil, pero SIN |
---|
14 | NINGUNA GARANTÍA; tampoco las implícitas garantías de MERCANTILIDAD o |
---|
15 | ADECUACIÓN A UN PROPÓSITO PARTICULAR. |
---|
16 | Consulte la licencia GPL para más detalles. Usted debe recibir una copia |
---|
17 | de la GPL junto con este programa; si no, escriba a la Free Software |
---|
18 | Foundation Inc. 51 Franklin Street,5 Piso, Boston, MA 02110-1301, USA. |
---|
19 | */ |
---|
20 | |
---|
21 | /* |
---|
22 | Autor: Alejandro J. Mujica |
---|
23 | Fecha de creación: 05/06/2014 |
---|
24 | Este archivo contiene la implementación de la clase Product. |
---|
25 | */ |
---|
26 | |
---|
27 | # include <product.H> |
---|
28 | |
---|
29 | Product::Product() |
---|
30 | : Good(), production_capacity(0.0), production(0.0), |
---|
31 | internal_sales(0.0), external_sales(0.0), workday(0.0), |
---|
32 | num_administrative_staff(0.0), num_employees(0.0), price(0.0), |
---|
33 | other_cost(0.0), INIT_SIMULATION_ATTRIBUTES |
---|
34 | { |
---|
35 | // Empty |
---|
36 | } |
---|
37 | |
---|
38 | Product::Product(const Product & product) |
---|
39 | : Good(product), production_capacity(product.production_capacity), |
---|
40 | production(product.production), internal_sales(product.internal_sales), |
---|
41 | external_sales(product.external_sales), workday(product.workday), |
---|
42 | num_administrative_staff(product.num_administrative_staff), |
---|
43 | num_employees(product.num_employees), price(product.price), |
---|
44 | other_cost(product.other_cost), INIT_COPY_SIMULATION_ATTRIBUTES(product) |
---|
45 | { |
---|
46 | // Empty |
---|
47 | } |
---|
48 | |
---|
49 | Product::Product(Product && product) |
---|
50 | : Good(std::move(product)), production_capacity(0.0), production(0.0), |
---|
51 | internal_sales(0.0), external_sales(0.0), workday(0.0), |
---|
52 | num_administrative_staff(0.0), num_employees(0.0), price(0.0), |
---|
53 | other_cost(0.0), INIT_SIMULATION_ATTRIBUTES |
---|
54 | { |
---|
55 | std::swap(production_capacity, product.production_capacity); |
---|
56 | std::swap(production, product.production); |
---|
57 | std::swap(internal_sales, product.internal_sales); |
---|
58 | std::swap(external_sales, product.external_sales); |
---|
59 | std::swap(workday, product.workday); |
---|
60 | std::swap(num_administrative_staff, product.num_administrative_staff); |
---|
61 | std::swap(num_employees, product.num_employees); |
---|
62 | std::swap(price, product.price); |
---|
63 | std::swap(other_cost, product.other_cost); |
---|
64 | SWAP_SIMULATION_ATTRIBUTES(product) |
---|
65 | } |
---|
66 | |
---|
67 | const real & Product::get_production_capacity() const |
---|
68 | { |
---|
69 | return production_capacity; |
---|
70 | } |
---|
71 | |
---|
72 | void Product::set_production_capacity(const real & _production_capacity) |
---|
73 | { |
---|
74 | production_capacity = _production_capacity; |
---|
75 | } |
---|
76 | |
---|
77 | const real & Product::get_production() const |
---|
78 | { |
---|
79 | return production; |
---|
80 | } |
---|
81 | |
---|
82 | void Product::set_production(const real & _production) |
---|
83 | { |
---|
84 | production = _production; |
---|
85 | } |
---|
86 | |
---|
87 | const real & Product::get_internal_sales() const |
---|
88 | { |
---|
89 | return internal_sales; |
---|
90 | } |
---|
91 | |
---|
92 | void Product::set_internal_sales(const real & _internal_sales) |
---|
93 | { |
---|
94 | internal_sales = _internal_sales; |
---|
95 | } |
---|
96 | |
---|
97 | const real & Product::get_external_sales() const |
---|
98 | { |
---|
99 | return external_sales; |
---|
100 | } |
---|
101 | |
---|
102 | void Product::set_external_sales(const real & _external_sales) |
---|
103 | { |
---|
104 | external_sales = _external_sales; |
---|
105 | } |
---|
106 | |
---|
107 | const real & Product::get_workday() const |
---|
108 | { |
---|
109 | return workday; |
---|
110 | } |
---|
111 | |
---|
112 | void Product::set_workday(const real & _workday) |
---|
113 | { |
---|
114 | workday = _workday; |
---|
115 | } |
---|
116 | |
---|
117 | const real & Product::get_num_administrative_staff() const |
---|
118 | { |
---|
119 | return num_administrative_staff; |
---|
120 | } |
---|
121 | |
---|
122 | void Product::set_num_administrative_staff( |
---|
123 | const real & _num_administrative_staff) |
---|
124 | { |
---|
125 | num_administrative_staff = _num_administrative_staff; |
---|
126 | } |
---|
127 | |
---|
128 | const real & Product::get_num_employees() const |
---|
129 | { |
---|
130 | return num_employees; |
---|
131 | } |
---|
132 | |
---|
133 | void Product::set_num_employees(const real & _num_employees) |
---|
134 | { |
---|
135 | num_employees = _num_employees; |
---|
136 | } |
---|
137 | |
---|
138 | const real & Product::get_price() const |
---|
139 | { |
---|
140 | return price; |
---|
141 | } |
---|
142 | |
---|
143 | void Product::set_price(const real & _price) |
---|
144 | { |
---|
145 | price = _price; |
---|
146 | } |
---|
147 | |
---|
148 | const real & Product::get_other_cost() const |
---|
149 | { |
---|
150 | return other_cost; |
---|
151 | } |
---|
152 | |
---|
153 | void Product::set_other_cost(const real & _other_cost) |
---|
154 | { |
---|
155 | other_cost = _other_cost; |
---|
156 | } |
---|
157 | |
---|
158 | real Product::get_relationship_manhours() const |
---|
159 | { |
---|
160 | return num_employees * workday * WORKED_DAYS_IN_A_YEAR / production; |
---|
161 | } |
---|
162 | |
---|
163 | Product & Product::operator = (const Product & product) |
---|
164 | { |
---|
165 | if (&product == this) |
---|
166 | return *this; |
---|
167 | |
---|
168 | (Good &) *this = product; |
---|
169 | |
---|
170 | production_capacity = product.production_capacity; |
---|
171 | production = product.production; |
---|
172 | internal_sales = product.internal_sales; |
---|
173 | external_sales = product.external_sales; |
---|
174 | workday = product.workday; |
---|
175 | num_administrative_staff = product.num_administrative_staff; |
---|
176 | num_employees = product.num_employees; |
---|
177 | price = product.price; |
---|
178 | other_cost = product.other_cost; |
---|
179 | COPY_SIMULATION_ATTRIBUTES(product) |
---|
180 | |
---|
181 | return *this; |
---|
182 | } |
---|
183 | |
---|
184 | Product & Product::operator = (Product && product) |
---|
185 | { |
---|
186 | (Good &) *this = std::move(product); |
---|
187 | |
---|
188 | std::swap(production_capacity, product.production_capacity); |
---|
189 | std::swap(production, product.production); |
---|
190 | std::swap(internal_sales, product.internal_sales); |
---|
191 | std::swap(external_sales, product.external_sales); |
---|
192 | std::swap(workday, product.workday); |
---|
193 | std::swap(num_administrative_staff, product.num_administrative_staff); |
---|
194 | std::swap(num_employees, product.num_employees); |
---|
195 | std::swap(price, product.price); |
---|
196 | std::swap(other_cost, product.other_cost); |
---|
197 | SWAP_SIMULATION_ATTRIBUTES(product) |
---|
198 | |
---|
199 | return *this; |
---|
200 | } |
---|
201 | |
---|
202 | std::string Product::to_dot() const |
---|
203 | { |
---|
204 | std::stringstream sstr; |
---|
205 | |
---|
206 | sstr << Good::to_dot() << "\\n" |
---|
207 | << "Capacidad: " << production_capacity << "\\n" |
---|
208 | << "Produccion: " << production << "\\n" |
---|
209 | << "Ventas Internas: " << internal_sales << "\\n" |
---|
210 | << "Ventas Externas: " << external_sales << "\\n" |
---|
211 | << "Jornada: " << workday << "\\n" |
---|
212 | << "Num personal Admin: " << num_administrative_staff << "\\n" |
---|
213 | << "Num Empleados: " << num_employees << "\\n" |
---|
214 | << "Relacion horas-hombre: " << get_relationship_manhours() << "\\n" |
---|
215 | << "Precio: " << price << "\\n" |
---|
216 | << "Otros costos: " << other_cost; |
---|
217 | |
---|
218 | return sstr.str(); |
---|
219 | } |
---|
220 | |
---|
221 | Good_Type Product::get_type() const |
---|
222 | { |
---|
223 | return PRODUCT; |
---|
224 | } |
---|
225 | |
---|
226 | real & Product::production_at(const size_t & t) |
---|
227 | { |
---|
228 | return get_simulation_attributes_at(t).production; |
---|
229 | } |
---|
230 | |
---|
231 | real & Product::stock_at(const size_t & t) |
---|
232 | { |
---|
233 | return get_simulation_attributes_at(t).stock; |
---|
234 | } |
---|
235 | |
---|
236 | real & Product::internal_requested_quantity_at(const size_t & t) |
---|
237 | { |
---|
238 | return get_simulation_attributes_at(t).internal_requested_quantity; |
---|
239 | } |
---|
240 | |
---|
241 | real Product::requested_quantity_at(const size_t & t) |
---|
242 | { |
---|
243 | Product_Simulation_Attributes & sim_attr = get_simulation_attributes_at(t); |
---|
244 | |
---|
245 | return sim_attr.internal_requested_quantity + |
---|
246 | sim_attr.external_requested_quantity; |
---|
247 | } |
---|
248 | |
---|
249 | real & Product::internal_sales_at(const size_t & t) |
---|
250 | { |
---|
251 | return get_simulation_attributes_at(t).internal_sales; |
---|
252 | } |
---|
253 | |
---|
254 | real & Product::price_at(const size_t & t) |
---|
255 | { |
---|
256 | return get_simulation_attributes_at(t).price; |
---|
257 | } |
---|
258 | |
---|