gServerFavoritesHolder Class Reference

server favorites management class: holds an array of servers More...

Collaboration diagram for gServerFavoritesHolder:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 gServerFavoritesHolder (char const *prefix)
 ~gServerFavoritesHolder ()
gServerFavoriteGetFavorite (int index)
 returns the favorite server info with the given index
bool AddFavorite (nServerInfoBase const *server)
bool IsFavorite (nServerInfoBase const *server)

Private Attributes

gServerFavoritefavorites [NUM_FAVORITES]
gServerFavorite custom


Detailed Description

server favorites management class: holds an array of servers

Definition at line 119 of file gServerFavorites.cpp.


Constructor & Destructor Documentation

gServerFavoritesHolder::gServerFavoritesHolder ( char const *  prefix  )  [inline]

Definition at line 122 of file gServerFavorites.cpp.

References favorites, and NUM_FAVORITES.

00123     :custom(-1, prefix)
00124     {
00125         // generate favorites
00126         for (int i = NUM_FAVORITES-1; i>=0; --i )
00127             favorites[i] = new gServerFavorite( i, prefix );
00128     }

gServerFavoritesHolder::~gServerFavoritesHolder (  )  [inline]

Definition at line 130 of file gServerFavorites.cpp.

References favorites, and NUM_FAVORITES.

00131     {
00132         // destroy favorites
00133         for (int i = NUM_FAVORITES-1; i>=0; --i )
00134             delete favorites[i];
00135     }


Member Function Documentation

gServerFavorite& gServerFavoritesHolder::GetFavorite ( int  index  )  [inline]

returns the favorite server info with the given index

Definition at line 138 of file gServerFavorites.cpp.

References custom, favorites, NUM_FAVORITES, and tASSERT.

Referenced by AddFavorite(), gServerFavorites::CustomConnectMenu(), IsFavorite(), sg_AlternativeMaster(), sg_ConnectFavorite(), sg_EditServers(), and sg_GenerateConnectionItems().

00139     {
00140         if ( index == -1 )
00141             return custom;
00142 
00143         tASSERT( index >=0 && index < NUM_FAVORITES );
00144         tASSERT( favorites[index] );
00145         return *favorites[index];
00146     }

Here is the caller graph for this function:

bool gServerFavoritesHolder::AddFavorite ( nServerInfoBase const *  server  )  [inline]

Definition at line 148 of file gServerFavorites.cpp.

References gServerFavorite::address_, nServerInfoBase::GetConnectionName(), GetFavorite(), nServerInfoBase::GetName(), nServerInfoBase::GetPort(), gServerFavorite::name_, NUM_FAVORITES, and gServerFavorite::port_.

Referenced by gServerFavorites::AddFavorite(), and gServerFavorites::AlternativesMenu().

00149     {
00150         if ( !server )
00151             return false;
00152         
00153         for ( int i = NUM_FAVORITES-1; i>=0; --i )
00154         {
00155             gServerFavorite & fav = GetFavorite(i);
00156             
00157             if (fav.name_ == "" || fav.name_ == "Empty")
00158             {
00159                 fav.name_ = tColoredString::RemoveColors(server->GetName());
00160                 fav.address_ = server->GetConnectionName();
00161                 fav.port_ = server->GetPort();
00162                 
00163                 return true;
00164             }
00165         }
00166         
00167         return false;
00168 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool gServerFavoritesHolder::IsFavorite ( nServerInfoBase const *  server  )  [inline]

Definition at line 170 of file gServerFavorites.cpp.

References gServerFavorite::address_, nServerInfoBase::GetConnectionName(), GetFavorite(), nServerInfoBase::GetPort(), gServerFavorite::name_, NUM_FAVORITES, and gServerFavorite::port_.

Referenced by gServerFavorites::AlternativesMenu(), and gServerFavorites::IsFavorite().

00171     {
00172         if ( !server )
00173             return false;
00174         
00175         for ( int i = NUM_FAVORITES-1; i>=0; --i )
00176         {
00177             gServerFavorite & fav = GetFavorite(i);
00178             
00179             if (fav.name_ != "" && fav.name_ != "Empty" && fav.address_ == server->GetConnectionName() && fav.port_ == static_cast< int >( server->GetPort() ) )
00180             {
00181                 return true;
00182             }
00183         }
00184         
00185         return false;
00186     }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

gServerFavorite* gServerFavoritesHolder::favorites[NUM_FAVORITES] [private]

Definition at line 190 of file gServerFavorites.cpp.

Referenced by GetFavorite(), gServerFavoritesHolder(), and ~gServerFavoritesHolder().

gServerFavorite gServerFavoritesHolder::custom [private]

Definition at line 193 of file gServerFavorites.cpp.

Referenced by GetFavorite().


The documentation for this class was generated from the following file:
Generated on Sat Mar 15 23:45:14 2008 for Armagetron Advanced by  doxygen 1.5.4