Pol  Revision:3cfda13
systemstate.cpp
Go to the documentation of this file.
1 
2 #include "systemstate.h"
3 
4 #include "../clib/stlutil.h"
5 #include "../pol/tiles.h"
6 #include "pkg.h"
7 
8 namespace Pol
9 {
10 namespace Plib
11 {
13 
14 
16  : packages(),
17  packages_byname(),
18  accounts_txt_dirty( false ),
19  accounts_txt_stat(),
20  config(),
21  tile( nullptr ),
22  tiles_loaded( false )
23 {
24 }
26 
28 {
30  packages_byname.clear();
31  if ( tile != nullptr )
32  delete[] tile;
33 }
34 
36 {
37  size_t size = sizeof( SystemState );
38  size += ( config.max_tile_id + 1 ) * sizeof( Core::Tile );
39 
40  size += 3 * sizeof( Package** ) + packages.capacity() * sizeof( Package* );
41  for ( const auto& pkg : packages )
42  if ( pkg != nullptr )
43  size += pkg->estimateSize();
44 
45  for ( const auto& pkg_pair : packages_byname )
46  size += pkg_pair.first.capacity() + sizeof( Package* ) + ( sizeof( void* ) * 3 + 1 ) / 2;
47  return size;
48 }
49 }
50 }
void delete_all(T &coll)
Definition: stlutil.h:24
SystemState systemstate
Definition: systemstate.cpp:12
Core::PolConfig config
Definition: systemstate.h:43
size_t estimatedSize() const
Definition: systemstate.cpp:35
unsigned int max_tile_id
Definition: polcfg.h:61
Definition: berror.cpp:12
PackagesByName packages_byname
Definition: systemstate.h:38