Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NavigationSystem::CachedSystemIterator Class Reference

#include <navscreen.h>

Classes

struct  SystemInfo
 

Public Member Functions

 CachedSystemIterator ()
 
 CachedSystemIterator (string current_system, unsigned max_systems=2)
 
void init (string current_system, unsigned max_systems=2)
 
bool seek (unsigned position=0)
 
unsigned getIndex () const
 
unsigned size () const
 
bool done () const
 
SystemInfooperator[] (unsigned pos)
 
const SystemInfooperator[] (unsigned pos) const
 
SystemInfooperator* ()
 
const SystemInfooperator* () const
 
SystemInfooperator-> ()
 
const SystemInfooperator-> () const
 
CachedSystemIteratornext ()
 
CachedSystemIteratoroperator++ ()
 

Friends

struct SystemInfo
 

Detailed Description

Definition at line 37 of file navscreen.h.

Constructor & Destructor Documentation

NavigationSystem::CachedSystemIterator::CachedSystemIterator ( )

Definition at line 426 of file drawgalaxy.cpp.

426 {}
NavigationSystem::CachedSystemIterator::CachedSystemIterator ( string  current_system,
unsigned  max_systems = 2 
)

Definition at line 428 of file drawgalaxy.cpp.

References init().

429 {
430  init( current_system, max_systems );
431 }

Member Function Documentation

bool NavigationSystem::CachedSystemIterator::done ( ) const

Definition at line 457 of file drawgalaxy.cpp.

Referenced by NavigationSystem::DrawGalaxy(), and NavigationSystem::CachedSectorIterator::init().

458 {
459  return currentPosition >= systems.size();
460 }
unsigned NavigationSystem::CachedSystemIterator::getIndex ( ) const

Definition at line 447 of file drawgalaxy.cpp.

Referenced by NavigationSystem::DrawGalaxy(), and NavigationSystem::CachedSectorIterator::init().

448 {
449  return currentPosition;
450 }
void NavigationSystem::CachedSystemIterator::init ( string  current_system,
unsigned  max_systems = 2 
)

Definition at line 397 of file drawgalaxy.cpp.

References UniverseUtil::GetAdjacentSystem(), UniverseUtil::GetNumAdjacentSystems(), j, and SystemInfo.

Referenced by CachedSystemIterator(), and NavigationSystem::Setup().

398 {
399  systems.clear();
400  unsigned count = 0;
401  string sys;
402 
403  map< string, unsigned > index_table;
404  std::deque< std::string >frontier;
405  frontier.push_back( current_system );
406  systems.push_back( SystemInfo( current_system ) );
407  index_table[current_system] = 0;
408  while ( !frontier.empty() ) {
409  sys = frontier.front();
410  frontier.pop_front();
411 
412  int nas = UniverseUtil::GetNumAdjacentSystems( sys );
413  for (int j = 0; j < nas && count < max_systems; ++j) {
414  string n = UniverseUtil::GetAdjacentSystem( sys, j );
415  if (index_table.count( n ) == 0) {
416  frontier.push_back( n );
417  index_table[n] = systems.size();
418  systems.push_back( SystemInfo( n ) );
419  ++count;
420  }
421  }
422  systems[index_table[sys]].loadData( &index_table );
423  }
424 }
NavigationSystem::CachedSystemIterator & NavigationSystem::CachedSystemIterator::next ( )

Definition at line 553 of file drawgalaxy.cpp.

554 {
555  return ++(*this);
556 }
NavigationSystem::CachedSystemIterator::SystemInfo & NavigationSystem::CachedSystemIterator::operator* ( )

Definition at line 480 of file drawgalaxy.cpp.

References done, and nullPair.

481 {
482  if ( done() )
483  return nullPair;
484  return systems[currentPosition];
485 }
const NavigationSystem::CachedSystemIterator::SystemInfo & NavigationSystem::CachedSystemIterator::operator* ( ) const

Definition at line 487 of file drawgalaxy.cpp.

References done, and nullPair.

488 {
489  if ( done() )
490  return nullPair;
491  return systems[currentPosition];
492 }
NavigationSystem::CachedSystemIterator & NavigationSystem::CachedSystemIterator::operator++ ( )

Definition at line 558 of file drawgalaxy.cpp.

559 {
560  ++currentPosition;
561  return *this;
562 }
NavigationSystem::CachedSystemIterator::SystemInfo * NavigationSystem::CachedSystemIterator::operator-> ( )

Definition at line 494 of file drawgalaxy.cpp.

References done, and nullPair.

495 {
496  if ( done() )
497  return &nullPair;
498  return &systems[currentPosition];
499 }
const NavigationSystem::CachedSystemIterator::SystemInfo * NavigationSystem::CachedSystemIterator::operator-> ( ) const

Definition at line 501 of file drawgalaxy.cpp.

References done, and nullPair.

502 {
503  if ( done() )
504  return &nullPair;
505  return &systems[currentPosition];
506 }
NavigationSystem::CachedSystemIterator::SystemInfo & NavigationSystem::CachedSystemIterator::operator[] ( unsigned  pos)

Definition at line 465 of file drawgalaxy.cpp.

References nullPair, and size.

466 {
467  if ( pos >= size() )
468  return nullPair;
469  return systems[pos];
470 }
const NavigationSystem::CachedSystemIterator::SystemInfo & NavigationSystem::CachedSystemIterator::operator[] ( unsigned  pos) const

Definition at line 473 of file drawgalaxy.cpp.

References nullPair, and size.

474 {
475  if ( pos >= size() )
476  return nullPair;
477  return systems[pos];
478 }
bool NavigationSystem::CachedSystemIterator::seek ( unsigned  position = 0)

Definition at line 437 of file drawgalaxy.cpp.

Referenced by NavigationSystem::DrawGalaxy(), and NavigationSystem::CachedSectorIterator::init().

438 {
439  if ( position < systems.size() ) {
440  currentPosition = position;
441  return true;
442  } else {
443  return false;
444  }
445 }
unsigned NavigationSystem::CachedSystemIterator::size ( ) const

Friends And Related Function Documentation

friend struct SystemInfo
friend

Definition at line 67 of file navscreen.h.

Referenced by init().


The documentation for this class was generated from the following files: