VisionWorks Toolkit Reference

December 18, 2015 | 1.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvxio::Application Class Referenceabstract

Detailed Description

Application interface.

This class is intended to simplify the creation of your own application. It performs initialization of global resources, the environment, and parses command line arguments.

Application is a singleton. You must call the Application::get static method to get the reference to the object.

See also
NVXIO APIs

Definition at line 62 of file Application.hpp.

Public Types

enum  ApplicationExitCode {
  APP_EXIT_CODE_SUCCESS = 0,
  APP_EXIT_CODE_ERROR = 1,
  APP_EXIT_CODE_NO_MEMORY = 2,
  APP_EXIT_CODE_NO_RESOURCE = 3,
  APP_EXIT_CODE_NO_FRAMESOURCE = 4,
  APP_EXIT_CODE_NO_RENDER = 5,
  APP_EXIT_CODE_INVALID_GRAPH = 6,
  APP_EXIT_CODE_INVALID_VALUE = 7,
  APP_EXIT_CODE_INVALID_DIMENSIONS = 8,
  APP_EXIT_CODE_INVALID_FORMAT = 9,
  APP_EXIT_CODE_CAN_NOT_CREATE = 10
}
 Defines status codes that your application can return. More...
 

Public Member Functions

virtual void addBooleanOption (char shortName, const std::string &longName, const std::string &description, bool *result)=0
 Adds Boolean command line option to the application. More...
 
virtual void addOption (char shortName, const std::string &longName, const std::string &description, OptionHandler::ptr handler)=0
 Adds arbitrary command line option to the application. More...
 
virtual void allowPositionalParameters (const std::string &placeholder, std::vector< std::string > *result)=0
 Enables support of positional parameters to be used with the application. More...
 
virtual std::string findLibraryFilePath (const std::string &filename) const =0
 Finds the file in the VisionWorks data directory. More...
 
virtual std::string findSampleFilePath (const std::string &filename) const =0
 Finds the file in the sample data directory. More...
 
virtual bool getEventLogDumpFramesFlag () const =0
 
virtual std::string getEventLogName () const =0
 
virtual double getFPSLimit () const =0
 Gets a limit for frame rate in frames per second. More...
 
virtual std::string getPreferredRenderName () const =0
 
virtual int getScenarioLoopCount () const =0
 
virtual std::string getScenarioName () const =0
 
virtual int getSourceDefaultTimeout () const =0
 
virtual bool getVerboseFlag () const =0
 
virtual void init (int &argc, char **argv)=0
 Initializes the application. More...
 
virtual bool initGui ()=0
 
virtual void setDescription (const std::string &description)=0
 Sets a description of the application for the console Help message. More...
 
virtual void setSourceDefaultTimeout (int timeout)=0
 
virtual bool sleepToLimitFPS (double totalProcessTimeMs, double fpsLimit=0)=0
 Suspends execution of the calling thread to limit frame rate. More...
 
virtual ~Application ()
 Destructor. More...
 

Static Public Member Functions

static Applicationget ()
 Returns the reference to the object. More...
 

Member Enumeration Documentation

Defines status codes that your application can return.

Enumerator
APP_EXIT_CODE_SUCCESS 

Indicates the operation succeeded.

APP_EXIT_CODE_ERROR 

Indicates a generic error code; this code is used when no other code describes the error.

APP_EXIT_CODE_NO_MEMORY 

Indicates an internal or implicit allocation failure.

APP_EXIT_CODE_NO_RESOURCE 

Indicates the resource (file, etc.) cannot be acquired.

APP_EXIT_CODE_NO_FRAMESOURCE 

Indicates the framesource exists but cannot be read.

APP_EXIT_CODE_NO_RENDER 

Indicates the render cannot be created.

APP_EXIT_CODE_INVALID_GRAPH 

Indicates the supplied graph failed verification.

APP_EXIT_CODE_INVALID_VALUE 

Indicates the parameter provided does not match the algorithm's possible values or a validation procedure failure.

APP_EXIT_CODE_INVALID_DIMENSIONS 

Indicates the parameter provided is too big or too small in dimension, or is not of even size.

APP_EXIT_CODE_INVALID_FORMAT 

Indicates the parameter provided is in an invalid format.

APP_EXIT_CODE_CAN_NOT_CREATE 

Indicates the object cannot be created.

Definition at line 68 of file Application.hpp.

Constructor & Destructor Documentation

virtual nvxio::Application::~Application ( )
virtual

Destructor.

Member Function Documentation

static Application& nvxio::Application::get ( )
static

Returns the reference to the object.

Application is a singleton. You must call the Application::get static method to get the reference to the object.

Returns
Reference to the object.
Example Code
virtual void nvxio::Application::addBooleanOption ( char  shortName,
const std::string &  longName,
const std::string &  description,
bool *  result 
)
pure virtual

Adds Boolean command line option to the application.

Parameters
[in]shortNameSpecifies the single-letter name of the option. '\0' means "no short name".
[in]longNameA reference to the full name of the option. nullptr means "no long name".
[in]descriptionA reference to the description of the option for the console Help message.
[out]resultA pointer to the variable to set. result is true if the option is present in the argument list; otherwise, it is false.
Example Code
bool standardColors = false;
app.addBooleanOption('s', "standardColors", "Use yellow and green instead of full spectrum", &standardColors);
virtual void nvxio::Application::addOption ( char  shortName,
const std::string &  longName,
const std::string &  description,
OptionHandler::ptr  handler 
)
pure virtual

Adds arbitrary command line option to the application.

Parameters
[in]shortNameSpecifies the single-letter name of the option. '\0' means "no short name".
[in]longNameA reference to the full name of the option. nullptr means "no long name".
[in]descriptionA reference to the description of the option for the console Help message.
[in]handlerOptionHandler used to process the option.
Example Code 1
std::string configFile = "config.ini";
app.addOption('c', "config", "Config file path", nvxio::OptionHandler::string(&configFile));
Example Code 2
vx_enum scaleType = 0;
app.addOption(0, "scaleType", "[ScaleImage] The scale interpolation type",
{"nearest", 0},
{"bilinear", 1},
{"area", 2},
}));
virtual void nvxio::Application::allowPositionalParameters ( const std::string &  placeholder,
std::vector< std::string > *  result 
)
pure virtual

Enables support of positional parameters to be used with the application.

Parameters
[in]placeholderA reference to a short hint that describes the expected values of the parameter.
[out]resultA pointer to a vector of strings to be filled with the provided parameters.
Example Code
std::vector<std::string> images;
app.allowPositionalParameters("IMAGE", &images);
virtual void nvxio::Application::setDescription ( const std::string &  description)
pure virtual

Sets a description of the application for the console Help message.

Parameters
[in]descriptionA refernce to the description of the application for the console Help message.
Example Code
app.setDescription("This is a description.");
virtual void nvxio::Application::init ( int &  argc,
char **  argv 
)
pure virtual

Initializes the application.

Precondition
The initialization includes parsing command line arguments, so configuration of the command line options must be performed before this call.
Parameters
[in]argcA reference to the number of arguments passed into your program from the command line.
[in]argvA pointer to a pointer to the array of the command line arguments.
Example Code
app.init(argc, argv);
virtual bool nvxio::Application::initGui ( )
pure virtual
virtual std::string nvxio::Application::getScenarioName ( ) const
pure virtual
virtual int nvxio::Application::getScenarioLoopCount ( ) const
pure virtual
virtual std::string nvxio::Application::getEventLogName ( ) const
pure virtual
virtual bool nvxio::Application::getEventLogDumpFramesFlag ( ) const
pure virtual
virtual bool nvxio::Application::getVerboseFlag ( ) const
pure virtual
virtual std::string nvxio::Application::getPreferredRenderName ( ) const
pure virtual
virtual std::string nvxio::Application::findSampleFilePath ( const std::string &  filename) const
pure virtual

Finds the file in the sample data directory.

This method finds the file in the following directories:

  • path_to_your_exe/sources/data/
  • path_to_your_exe/../data/
Note
This method throws the std::runtime_error exception if the file is not found.
Parameters
[in]filenameA reference to the name of the required file.
Returns
The absolute path to the file.
virtual std::string nvxio::Application::findLibraryFilePath ( const std::string &  filename) const
pure virtual

Finds the file in the VisionWorks data directory.

This method finds the file in the following directories:

  • path_to_your_exe/data/
  • VISIONWORKS_DIR/share/visionworks/data/

    Only if VISIONWORKS_DIR is defined; VISIONWORKS_DIR is a full path to the installation directory of VisionWorks.

  • /usr/share/visionworks/data/

    On Linux and when VISIONWORKS_DIR is not defined.

Note
This method throws the std::runtime_error exception if the file is not found.
Parameters
[in]filenameA reference to the name of the required file.
Returns
The absolute path to the file.
virtual int nvxio::Application::getSourceDefaultTimeout ( ) const
pure virtual
virtual void nvxio::Application::setSourceDefaultTimeout ( int  timeout)
pure virtual
virtual double nvxio::Application::getFPSLimit ( ) const
pure virtual

Gets a limit for frame rate in frames per second.

Returns
Frame rate limit in frames per second.
virtual bool nvxio::Application::sleepToLimitFPS ( double  totalProcessTimeMs,
double  fpsLimit = 0 
)
pure virtual

Suspends execution of the calling thread to limit frame rate.

Parameters
[in]totalProcessTimeMsThe total time of processing in miliseconds (ms). If this time is less than 1000/fpsLimit ms, then the calling thread suspends on about (1000/fpsLimit - totalProcessTimeMs) ms.
[in]fpsLimitThe desired frame rate in frames per second. Call the Application::getFPSLimit method to get the default limit for frame rate.
Returns

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