cocos2d-x  3.3rc0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AssetsManagerEx Class Reference

This class is used to auto update resources, such as pictures or scripts. More...

#include <AssetsManagerEx.h>

Inheritance diagram for AssetsManagerEx:
Ref

Public Types

enum  State {
  UNCHECKED, PREDOWNLOAD_VERSION, DOWNLOADING_VERSION, VERSION_LOADED,
  PREDOWNLOAD_MANIFEST, DOWNLOADING_MANIFEST, MANIFEST_LOADED, NEED_UPDATE,
  UPDATING, UP_TO_DATE, FAIL_TO_UPDATE
}
 Update states. More...
 

Public Member Functions

void checkUpdate ()
 Check out if there is a new version of manifest. More...
 
void update ()
 Update with the current local manifest. More...
 
void downloadFailedAssets ()
 Reupdate all failed assets under the current AssetsManagerEx context. More...
 
State getState () const
 Gets the current update state. More...
 
const std::string & getStoragePath () const
 Gets storage path. More...
 
const ManifestgetLocalManifest () const
 Function for retrieve the local manifest object. More...
 
const ManifestgetRemoteManifest () const
 Function for retrieve the remote manifest object. More...
 
virtual ~AssetsManagerEx ()
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
local getReferenceCount ()
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()

Static Public Member Functions

static AssetsManagerExcreate (const std::string &manifestUrl, const std::string &storagePath)
 Create function for creating a new AssetsManagerEx. More...
 
var create ( var manifestUrl, var storagePath)
 Create function for creating a new AssetsManagerEx. More...
 
local create ( local manifestUrl, local storagePath)
 Create function for creating a new AssetsManagerEx. More...
 

Public Attributes

CC_CONSTRUCTOR_ACCESS __pad0__: AssetsManagerEx(const std::string& manifestUrl
CC_CONSTRUCTOR_ACCESS const
std::string & 
storagePath

Static Public Attributes

static const std::string VERSION_ID
var VERSION_ID
local VERSION_ID
static const std::string MANIFEST_ID
local MANIFEST_ID
static const std::string BATCH_UPDATE_ID

Protected Member Functions

std::string basename (const std::string &path) const
local basename ( local path)
std::string get (const std::string &key) const
void loadLocalManifest (const std::string &manifestUrl)
void prepareLocalManifest ()
void setStoragePath (const std::string &storagePath)
var setStoragePath ( var storagePath)
local setStoragePath ( local storagePath)
void adjustPath (std::string &path)
void dispatchUpdateEvent (EventAssetsManagerEx::EventCode code, const std::string &message="", const std::string &assetId="", int curle_code=0, int curlm_code=0)
local dispatchUpdateEvent ( local code, local 0, local 0)
void downloadVersion ()
void parseVersion ()
void downloadManifest ()
var downloadManifest ()
local downloadManifest ()
void parseManifest ()
void startUpdate ()
void updateSucceed ()
bool decompress (const std::string &filename)
var decompress ( var filename)
local decompress ( local filename)
void decompressDownloadedZip ()
void updateAssets (const Downloader::DownloadUnits &assets)
 Update a list of assets under the current AssetsManagerEx context. More...
 
const Downloader::DownloadUnitsgetFailedAssets () const
 Retrieve all failed assets during the last update. More...
 
void destroyDownloadedVersion ()
 Function for destorying the downloaded version file and manifest file. More...
 
virtual void onError (const Downloader::Error &error)
 Call back function for error handling, the error will then be reported to user's listener registed in addUpdateEventListener. More...
 
virtual void onProgress (double total, double downloaded, const std::string &url, const std::string &customId)
 Call back function for recording downloading percent of the current asset, the progression will then be reported to user's listener registed in addUpdateProgressEventListener. More...
 
virtual void onSuccess (const std::string &srcUrl, const std::string &storagePath, const std::string &customId)
 Call back function for success of the current asset the success event will then be send to user's listener registed in addUpdateEventListener. More...
 
- Protected Member Functions inherited from Ref
 Ref ()
 Constructor. More...
 
 Ref ()
 Constructor. More...
 

Friends

class Downloader
int downloadProgressFunc (Downloader::ProgressData *ptr, double totalToDownload, double nowDownloaded, double totalToUpLoad, double nowUpLoaded)

Additional Inherited Members

- Protected Attributes inherited from Ref
unsigned int _referenceCount
 count of references More...
 
local _referenceCount
 count of references More...
 

Detailed Description

This class is used to auto update resources, such as pictures or scripts.

Member Enumeration Documentation

enum State
strong

Update states.

Enumerator
UNCHECKED 
PREDOWNLOAD_VERSION 
DOWNLOADING_VERSION 
VERSION_LOADED 
PREDOWNLOAD_MANIFEST 
DOWNLOADING_MANIFEST 
MANIFEST_LOADED 
NEED_UPDATE 
UPDATING 
UP_TO_DATE 
FAIL_TO_UPDATE 
var State
strong

Update states.

Enumerator
UNCHECKED 
PREDOWNLOAD_VERSION 
DOWNLOADING_VERSION 
VERSION_LOADED 
PREDOWNLOAD_MANIFEST 
DOWNLOADING_MANIFEST 
MANIFEST_LOADED 
NEED_UPDATE 
UPDATING 
UP_TO_DATE 
FAIL_TO_UPDATE 
local State
strong

Update states.

Enumerator
UNCHECKED 
PREDOWNLOAD_VERSION 
DOWNLOADING_VERSION 
VERSION_LOADED 
PREDOWNLOAD_MANIFEST 
DOWNLOADING_MANIFEST 
MANIFEST_LOADED 
NEED_UPDATE 
UPDATING 
UP_TO_DATE 
FAIL_TO_UPDATE 

Constructor & Destructor Documentation

virtual ~AssetsManagerEx ( )
virtual
var ~AssetsManagerEx ( )
virtual
local ~AssetsManagerEx ( )
virtual

Member Function Documentation

void adjustPath ( std::string &  path)
protected
var adjustPath ( var  path)
protected
local adjustPath ( local  path)
protected
std::string basename ( const std::string &  path) const
protected
var basename ( var  path)
protected
local basename ( local  path)
protected
void checkUpdate ( )

Check out if there is a new version of manifest.

You may use this method before updating, then let user determine whether he wants to update resources.

var checkUpdate ( )

Check out if there is a new version of manifest.

You may use this method before updating, then let user determine whether he wants to update resources.

local checkUpdate ( )

Check out if there is a new version of manifest.

You may use this method before updating, then let user determine whether he wants to update resources.

static AssetsManagerEx* create ( const std::string &  manifestUrl,
const std::string &  storagePath 
)
static

Create function for creating a new AssetsManagerEx.

Parameters
manifestUrlThe url for the local manifest file
storagePathThe storage path for downloaded assetes
Warning
The cached manifest in your storage path have higher priority and will be searched first, only if it doesn't exist, AssetsManagerEx will use the given manifestUrl.
var create ( var  manifestUrl,
var  storagePath 
)
static

Create function for creating a new AssetsManagerEx.

Parameters
manifestUrlThe url for the local manifest file
storagePathThe storage path for downloaded assetes
Warning
The cached manifest in your storage path have higher priority and will be searched first, only if it doesn't exist, AssetsManagerEx will use the given manifestUrl.
local create ( local  manifestUrl,
local  storagePath 
)
static

Create function for creating a new AssetsManagerEx.

Parameters
manifestUrlThe url for the local manifest file
storagePathThe storage path for downloaded assetes
Warning
The cached manifest in your storage path have higher priority and will be searched first, only if it doesn't exist, AssetsManagerEx will use the given manifestUrl.
bool decompress ( const std::string &  filename)
protected
var decompress ( var  filename)
protected
local decompress ( local  filename)
protected
void decompressDownloadedZip ( )
protected
var decompressDownloadedZip ( )
protected
local decompressDownloadedZip ( )
protected
void destroyDownloadedVersion ( )
protected

Function for destorying the downloaded version file and manifest file.

var destroyDownloadedVersion ( )
protected

Function for destorying the downloaded version file and manifest file.

local destroyDownloadedVersion ( )
protected

Function for destorying the downloaded version file and manifest file.

void dispatchUpdateEvent ( EventAssetsManagerEx::EventCode  code,
const std::string &  message = "",
const std::string &  assetId = "",
int  curle_code = 0,
int  curlm_code = 0 
)
protected
var dispatchUpdateEvent ( var  code,
var  message = "",
var  assetId = "",
var  curle_code = 0,
var  curlm_code = 0 
)
protected
local dispatchUpdateEvent ( local  code,
local  message = "",
local  assetId = "",
local  curle_code = 0,
local  curlm_code = 0 
)
protected
void downloadFailedAssets ( )

Reupdate all failed assets under the current AssetsManagerEx context.

var downloadFailedAssets ( )

Reupdate all failed assets under the current AssetsManagerEx context.

local downloadFailedAssets ( )

Reupdate all failed assets under the current AssetsManagerEx context.

void downloadManifest ( )
protected
var downloadManifest ( )
protected
local downloadManifest ( )
protected
void downloadVersion ( )
protected
var downloadVersion ( )
protected
local downloadVersion ( )
protected
std::string get ( const std::string &  key) const
protected
var get ( var  key)
protected
local get ( local  key)
protected
const
Downloader::DownloadUnits&
getFailedAssets
( ) const
protected

Retrieve all failed assets during the last update.

var getFailedAssets ( )
protected

Retrieve all failed assets during the last update.

local getFailedAssets ( )
protected

Retrieve all failed assets during the last update.

const Manifest* getLocalManifest ( ) const

Function for retrieve the local manifest object.

var getLocalManifest ( )

Function for retrieve the local manifest object.

local getLocalManifest ( )

Function for retrieve the local manifest object.

const Manifest* getRemoteManifest ( ) const

Function for retrieve the remote manifest object.

var getRemoteManifest ( )

Function for retrieve the remote manifest object.

local getRemoteManifest ( )

Function for retrieve the remote manifest object.

State getState ( ) const

Gets the current update state.

var getState ( )

Gets the current update state.

local getState ( )

Gets the current update state.

const std::string& getStoragePath ( ) const

Gets storage path.

var getStoragePath ( )

Gets storage path.

local getStoragePath ( )

Gets storage path.

void loadLocalManifest ( const std::string &  manifestUrl)
protected
var loadLocalManifest ( var  manifestUrl)
protected
local loadLocalManifest ( local  manifestUrl)
protected
virtual void onError ( const Downloader::Error error)
protectedvirtual

Call back function for error handling, the error will then be reported to user's listener registed in addUpdateEventListener.

Parameters
errorThe error object contains ErrorCode, message, asset url, asset key
Warning
AssetsManagerEx internal use only
virtual void onProgress ( double  total,
double  downloaded,
const std::string &  url,
const std::string &  customId 
)
protectedvirtual

Call back function for recording downloading percent of the current asset, the progression will then be reported to user's listener registed in addUpdateProgressEventListener.

Parameters
totalTotal size to download for this asset
downloadedTotal size already downloaded for this asset
urlThe url of this asset
customIdThe key of this asset
Warning
AssetsManagerEx internal use only
virtual void onSuccess ( const std::string &  srcUrl,
const std::string &  storagePath,
const std::string &  customId 
)
protectedvirtual

Call back function for success of the current asset the success event will then be send to user's listener registed in addUpdateEventListener.

Parameters
srcUrlThe url of this asset
customIdThe key of this asset
Warning
AssetsManagerEx internal use only
void parseManifest ( )
protected
var parseManifest ( )
protected
local parseManifest ( )
protected
void parseVersion ( )
protected
var parseVersion ( )
protected
local parseVersion ( )
protected
void prepareLocalManifest ( )
protected
var prepareLocalManifest ( )
protected
local prepareLocalManifest ( )
protected
void setStoragePath ( const std::string &  storagePath)
protected
var setStoragePath ( var  storagePath)
protected
local setStoragePath ( local  storagePath)
protected
void startUpdate ( )
protected
var startUpdate ( )
protected
local startUpdate ( )
protected
void update ( )

Update with the current local manifest.

var update ( )

Update with the current local manifest.

local update ( )

Update with the current local manifest.

void updateAssets ( const Downloader::DownloadUnits assets)
protected

Update a list of assets under the current AssetsManagerEx context.

var updateAssets ( var  assets)
protected

Update a list of assets under the current AssetsManagerEx context.

local updateAssets ( local  assets)
protected

Update a list of assets under the current AssetsManagerEx context.

void updateSucceed ( )
protected
var updateSucceed ( )
protected
local updateSucceed ( )
protected

Friends And Related Function Documentation

friend class Downloader
friend
var Downloader
friend
local Downloader
friend
int downloadProgressFunc ( Downloader::ProgressData ptr,
double  totalToDownload,
double  nowDownloaded,
double  totalToUpLoad,
double  nowUpLoaded 
)
friend
var downloadProgressFunc ( var  ptr,
var  totalToDownload,
var  nowDownloaded,
var  totalToUpLoad,
var  nowUpLoaded 
)
friend
local downloadProgressFunc ( local  ptr,
local  totalToDownload,
local  nowDownloaded,
local  totalToUpLoad,
local  nowUpLoaded 
)
friend

Member Data Documentation

var __pad0__
local __pad0__
const std::string BATCH_UPDATE_ID
static
var BATCH_UPDATE_ID
static
local BATCH_UPDATE_ID
static
const std::string MANIFEST_ID
static
var MANIFEST_ID
static
local MANIFEST_ID
static
CC_CONSTRUCTOR_ACCESS const
std::string& storagePath
var storagePath
local storagePath
const std::string VERSION_ID
static
var VERSION_ID
static
local VERSION_ID
static

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