** WPSC_Data_Map class **

Much of the countries/regions/currency efficiency gains comes from not reloading the same data from the database multiple times.  Once data is loaded it is stored into a construction that provides easy access to highly structured data, and can save and restore itself from persistent cache as needed.  The class only loads the data it needs

In support of these enhancements to the country / regions / currency class it was useful to create a general purpose object that did these things.

* could return a value from a list of values based on a unique identifier
* could retain its list of values throughout a transactions execution without having to go back to a database
* could be smart enough restore its list of values from a cached copy of itself only if it was necessary, and without a client needing to initiate the save
* could automatically save itself when appropriate, and without a client object needing to initiate the save
* could automatically recreate itself should it be the case that  the cached copy its data was no longer available

And thus was born the WPSC_Data_Map Class
** WPSC_Currency class **

Access all information about a currency creating a WPSC_Currency object.  No longer a need to do database queries to WPSC_TABLE_REGION_TAX. Information is retrieved from the WPSC_Countries object which maintains a cache used by a geographic classes.

Creating a currency object:
new WPSC_Currency ( $currency_name )

As an example, if you have a currency name in hand, you can find all information by doing
$wpsc_currency = new WPSC_Currency (  ‘USD’ );

If you are working with a country there is also an easy way to get the currency for that country through the WPSC_Country class

$wpsc_currency = $wpsc_country->currency();
** WPSC_Region class **

Access all information about a region by creating a WPSC_Region object.  No longer a need to do database queries to WPSC_TABLE_REGION_TAX. Information is retrieved from the WPSC_Countries object which maintains a cache used by a geographic classes.

Creating a region object:
	new WPSC_Region ( $country_id_or_isocode, $region_id_or_code )

As an example, you can find all about massachussets my doing any of the following,
	$ma = new WPSC_Region ( ‘US’, ‘MA’ )
	$ma = new WPSC_Region ( ‘US’, 34 )
	$ma = new WPSC_Region ( 136, ‘MA’ )
	$ma = new WPSC_Region ( 136, 34 )
	$ma = new WPSC_Region ( null, ‘34’ )

The class can also be used to create a new region in the database:
	$ma = WPSC_Region( ‘US’,, array( 'code' => 'MA', 'name' => 'Massachussets ', 'tax' => 6.5, )
** WPSC_Country class **

Access all information about a country by creating a WPSC_Country object.  No longer a need to do database queries to WP_TABLE_CURRENCY_LIST . Information is retrieved from the WPSC_Countries object which maintains a cache used by all geographic classes.

Creating a currency object:
	new WPSC_Country(  $country_id_or_isocode )

You can create a country object if you know string country ISO code, or the unique integer country id.

As an example, if you have a currency name in hand, you can find all information by doing something like this:
	$usa = new WPSC_Country( ‘US’ );

Which is the same as doing this:
	$usa = new WPSC_Country( 136 );

If a new country needs to be created or updated, pass an array of attribute value pairs to the country class.

	$wpsc_country = new WPSC_Country(
		array(											  						'country' 	=> 'Atlantis',
			'isocode' 	=> 'AA',
			'currency' 	=> 'Sand Dollar',
			'symbol' 	=> '$',
			'symbol_html' 	=> '&#036;',
			'code' 		=> 'ASD',
			'has_regions' 	=> false,
			'tax' 		=> 80,
			‘continent' 	=> 'Atlantis',
			)
		)
	);

Class does not allow direct access to properties.  However, if your code desires to use the individual country properties you can easily get an array with them us the as_array() method. 	 You can even 'explode' this to get individual variables each with the country property value.