OpenTTDLib
[ class tree: OpenTTDLib ] [ index: OpenTTDLib ] [ all elements ]

Class: OpenTTDLibCache

Source Location: /includes/OpenTTDLibCache.php

Class Overview


OpenTTDLibCache handles cached newgrf details, once a grfid and grf_md5sum pair is known, we dont have to query the game for it again.


Author(s):

Variables

Methods



Class Details

[line 33]
OpenTTDLibCache handles cached newgrf details, once a grfid and grf_md5sum pair is known, we dont have to query the game for it again.



Tags:

author:  dihedral <dihedral@codecubes.org>
since:  version 0.3 (r46)
license:  GNU General Public License v2


[ Top ]


Class Variables

$_cache =

[line 40]



Tags:

var:  holds the parsed xml file
access:  protected

Type:   SimpleXMLElement


[ Top ]

$_file =

[line 46]



Tags:

var:  path or url of the xml file
access:  protected

Type:   string


[ Top ]

$_updated =  false

[line 52]



Tags:

var:  set to true if anything in $_cache has been changed, this way we know if the file needs updating
access:  protected

Type:   boolean


[ Top ]



Class Methods


constructor __construct [line 61]

void __construct( string $file)

constructor of OpenTTDLIbCache



Tags:

access:  public


Parameters:

string   $file   path or url of the cache file

[ Top ]

method addNewGrf [line 252]

void addNewGrf( string $grf_id, string $grf_md5, string $name)

add a grf to the cache



Tags:

access:  public


Parameters:

string   $grf_id  
string   $grf_md5  
string   $name   return void

[ Top ]

method asPrettyXML [line 121]

string asPrettyXML( [integer $indent = 1], [string $str_indent = "\t"], [string $lf = "\n"])

convert the xml data into pretty indented xml



Tags:

return:  pretty xml data
access:  public


Parameters:

integer   $indent   how often $str_indent is used for a single indention
string   $str_indent   char for used when indenting (i.e. space or tap)
string   $lf   linefeed (i.e. *nix uses \n, win uses \r\n )

[ Top ]

method findNewGrf [line 203]

mixed, findNewGrf( string $grf_id, string $grf_md5, [integer $pos = null])

find a cached newgrf by it's id and md5sum



Tags:

return:  false when none was found, else integer of the internal position of the grf
access:  public


Parameters:

string   $grf_id   id of the newgrf to find
string   $grf_md5   md5sum of the newgrf to find
integer   $pos   used by OpenTTDLibNewGrfCache::unique() to determin the internal position of the grf, there will never be a reason for you to use it.

[ Top ]

method getNewGrf [line 227]

mixed getNewGrf( string $grf_id, string $grf_md5)

get newgrf data from the cache if it can be found



Tags:

return:  object holding the details if newgrf could be found in the cache, false otherwise
access:  public


Parameters:

string   $grf_id   the grfid of the newgrf file
string   $grf_md5   the md5 checksum of the newgrf file

[ Top ]

method uniqueNewGrf [line 183]

void uniqueNewGrf( )

remove double entries, determind by grf_id and grf_md5sum



Tags:

access:  public


[ Top ]

method updateCache [line 168]

mixed, updateCache( )

writes data from OpenTTDLibCache::asPrettyXML() back to the cache file, but only if the cache is different from that in the file



Tags:

return:  value of file_put_contents if the xml data has changed, or true
access:  public


[ Top ]


Documentation generated on Wed, 29 Apr 2009 23:33:50 +0200 by phpDocumentor 1.4.2