Cinder  0.9.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
cinder::app::Platform Class Referenceabstract

#include <Platform.h>

Inherited by cinder::app::PlatformCocoa, cinder::app::PlatformMsw, and cinder::app::PlatformWinRt.

Public Member Functions

virtual ~Platform ()
 
virtual void prepareLaunch ()
 
virtual void cleanupLaunch ()
 
DataSourceRef loadAsset (const fs::path &relativePath)
 
fs::path getAssetPath (const fs::path &relativePath) const
 
void addAssetDirectory (const fs::path &directory)
 
const std::vector< fs::path > & getAssetDirectories () const
 
virtual DataSourceRef loadResource (const fs::path &resourcePath, int mswID, const std::string &mswType)=0
 
virtual fs::path getResourceDirectory () const =0
 
virtual fs::path getResourcePath (const fs::path &rsrcRelativePath) const =0
 
fs::path getExecutablePath () const
 
void setExecutablePath (const fs::path &execPath)
 
virtual fs::path getOpenFilePath (const fs::path &initialPath=fs::path(), const std::vector< std::string > &extensions=std::vector< std::string >())=0
 
virtual fs::path getFolderPath (const fs::path &initialPath=fs::path())=0
 
virtual fs::path getSaveFilePath (const fs::path &initialPath=fs::path(), const std::vector< std::string > &extensions=std::vector< std::string >())=0
 
virtual std::ostream & console ()
 
virtual std::map< std::string, std::string > getEnvironmentVariables ()=0
 
virtual fs::path expandPath (const fs::path &path)=0
 
virtual fs::path getHomeDirectory () const =0
 
virtual fs::path getDocumentsDirectory () const =0
 
virtual fs::path getDefaultExecutablePath () const =0
 
virtual void sleep (float milliseconds)=0
 
virtual void launchWebBrowser (const Url &url)=0
 
virtual std::vector< std::string > stackTrace ()=0
 
virtual const std::vector< DisplayRef > & getDisplays ()=0
 

Static Public Member Functions

static Platformget ()
 
static void set (Platform *platform)
 

Protected Member Functions

 Platform ()
 
virtual void prepareAssetLoading ()
 
virtual void findAndAddDefaultAssetPath ()
 

Constructor & Destructor Documentation

virtual cinder::app::Platform::~Platform ( )
virtual
cinder::app::Platform::Platform ( )
protected

Member Function Documentation

Platform * cinder::app::Platform::get ( )
static

Returns the current Platform.

void cinder::app::Platform::set ( Platform platform)
static

Sets the current Platform.

virtual void cinder::app::Platform::prepareLaunch ( )
virtual

Called at the beginning of a launch, can be overridden for platform-specifc preparation.

Reimplemented in cinder::app::PlatformCocoa.

virtual void cinder::app::Platform::cleanupLaunch ( )
virtual

Called at the end of a launch, can be overridden for platform-specifc cleanup.

Reimplemented in cinder::app::PlatformCocoa.

DataSourceRef cinder::app::Platform::loadAsset ( const fs::path &  relativePath)

Returns a DataSourceRef to an application asset. Throws a AssetLoadExc on failure.

fs::path cinder::app::Platform::getAssetPath ( const fs::path &  relativePath) const

Returns a fs::path to an application asset. Returns an empty path on failure.

void cinder::app::Platform::addAssetDirectory ( const fs::path &  directory)

Adds an absolute path to the list of directories which are searched for assets.

Note
Not thread-safe, e.g. you should not call this when loadAsset() or getAssetPath() can occur from a different thread.
const vector< fs::path > & cinder::app::Platform::getAssetDirectories ( ) const

Returns a vector of directories that are searched when looking up an asset path.

virtual DataSourceRef cinder::app::Platform::loadResource ( const fs::path &  resourcePath,
int  mswID,
const std::string &  mswType 
)
pure virtual

(MSW only) Returns a DataSource to an application resource. mswID and mswType identify the resource as defined the application's .rc file(s).

See also
CinderResources

Implemented in cinder::app::PlatformMsw.

virtual fs::path cinder::app::Platform::getResourceDirectory ( ) const
pure virtual

Returns the absolute file path to the resources folder. Returns an empty fs::path on windows.

See also
CinderResources

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

virtual fs::path cinder::app::Platform::getResourcePath ( const fs::path &  rsrcRelativePath) const
pure virtual

Returns the absolute file path to a resource located at rsrcRelativePath inside the bundle's resources folder. Returns an empty fs::path on windows. Throws ResourceLoadExc on failure.

See also
CinderResources

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

fs::path cinder::app::Platform::getExecutablePath ( ) const

Returns the path to the associated executable.

void cinder::app::Platform::setExecutablePath ( const fs::path &  execPath)

Sets the path to the associated executable, overriding the default.

virtual fs::path cinder::app::Platform::getOpenFilePath ( const fs::path &  initialPath = fs::path(),
const std::vector< std::string > &  extensions = std::vector< std::string >() 
)
pure virtual

Presents the user with an open-file dialog and returns the selected file path. The dialog optionally begins at the path initialPath and can be limited to allow selection of files ending in the extensions enumerated in extensions.

Returns
the selected file path, or an empty fs::path if the user cancelled or this operation isn't supported on the current platform.

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

virtual fs::path cinder::app::Platform::getFolderPath ( const fs::path &  initialPath = fs::path())
pure virtual

Presents the user with an open-folder dialog.

Returns
the selected file path, or an empty fs::path if the user cancelled or this operation isn't supported on the current platform.

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

virtual fs::path cinder::app::Platform::getSaveFilePath ( const fs::path &  initialPath = fs::path(),
const std::vector< std::string > &  extensions = std::vector< std::string >() 
)
pure virtual

Presents the user with a save-file dialog and returns the selected file path. The dialog optionally begins at the path initialPath and can be limited to allow selection of files ending in the extensions enumerated in extensions.

Returns
the selected file path, or an empty fs::path if the user cancelled or this operation isn't supported on the current platform.

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

std::ostream & cinder::app::Platform::console ( )
virtual

Returns a reference to an output console, which is by default an alias to std::cout. Other platforms may override to use other necessary console mechanisms.

Reimplemented in cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

virtual std::map<std::string,std::string> cinder::app::Platform::getEnvironmentVariables ( )
pure virtual

Returns a std::map of the system's environment variables. Empty on WinRT.

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

virtual fs::path cinder::app::Platform::expandPath ( const fs::path &  path)
pure virtual

Returns a canonical version of path. Collapses '.', ".." and "//". Converts '~' on Cocoa. Expands environment variables on MSW.

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

virtual fs::path cinder::app::Platform::getHomeDirectory ( ) const
pure virtual

Returns the path to the user's home directory.

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

virtual fs::path cinder::app::Platform::getDocumentsDirectory ( ) const
pure virtual

Returns the path to the user's documents directory.

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

virtual fs::path cinder::app::Platform::getDefaultExecutablePath ( ) const
pure virtual

Returns the path used for the default executable location. Users may override this with setExecutablePath() for application specific purposes.

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

virtual void cinder::app::Platform::sleep ( float  milliseconds)
pure virtual

Suspends the execution of the current thread until milliseconds have passed. Supports sub-millisecond precision only on OS X.

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

virtual void cinder::app::Platform::launchWebBrowser ( const Url url)
pure virtual

Launches a path in the system's default web browser.

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

virtual std::vector<std::string> cinder::app::Platform::stackTrace ( )
pure virtual

Returns a stack trace (aka backtrace) where stackTrace()[0] == caller, stackTrace()[1] == caller's parent, etc.

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

virtual const std::vector<DisplayRef>& cinder::app::Platform::getDisplays ( )
pure virtual

Returns a std::vector of Displays connected to the system.

Implemented in cinder::app::PlatformCocoa, cinder::app::PlatformWinRt, and cinder::app::PlatformMsw.

virtual void cinder::app::Platform::prepareAssetLoading ( )
protectedvirtual

Called when asset directories are first prepared, subclasses can override to add platform specific directories.

Reimplemented in cinder::app::PlatformCocoa, and cinder::app::PlatformWinRt.

void cinder::app::Platform::findAndAddDefaultAssetPath ( )
protectedvirtual

Called to add the default assets folder by walking up the path from the executable until a folder named 'assets' is found. Subclasses can override this method to disable this functionality.


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