MinVR  0.9.0
A multi-platform virtual reality library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Typedefs | Functions
MinVR Namespace Reference

Classes

class  AbstractCamera
 
class  AbstractInputDevice
 Base class for InputDevices. Input Devices should be polled once per frame and append Events that were generated since the last call to poll to the array passed into the poll routine. More...
 
class  AbstractMVRApp
 Pure virtual base class for MinVR applications. More...
 
class  AbstractMVREngine
 Base class for vr engines. More...
 
class  AbstractWindow
 Base class for windows. More...
 
class  CameraOffAxis
 
class  CameraTraditional
 
class  ConfigMap
 
class  ConfigValMap
 
class  DataFileUtils
 
class  Event
 
class  InputDeviceSpaceNav
 
class  InputDeviceTUIOClient
 
class  InputDeviceVRPNAnalog
 
class  InputDeviceVRPNButton
 
class  InputDeviceVRPNTracker
 
class  Rect2D
 
class  RenderThread
 
class  WindowSettings
 
class  MVREngineGLFW
 VR Engine for raw OpenGL apps based on GLFW. More...
 
class  WindowGLFW
 

Typedefs

typedef boost::shared_ptr
< class AbstractCamera
AbstractCameraRef
 
typedef boost::shared_ptr
< class AbstractInputDevice
AbstractInputDeviceRef
 
typedef boost::shared_ptr
< class AbstractMVRApp
AbstractMVRAppRef
 
typedef boost::shared_ptr
< class AbstractWindow
WindowRef
 
typedef boost::shared_ptr
< class ConfigMap
ConfigMapRef
 
typedef boost::shared_ptr
< class Event
EventRef
 
typedef boost::shared_ptr
< class RenderThread
RenderThreadRef
 
typedef boost::shared_ptr
< class WindowSettings
WindowSettingsRef
 

Functions

template<class KEYTYPE , class VALTYPE >
VALTYPE ConfigVal (KEYTYPE keyString, const VALTYPE &defaultVal, bool warn=true)
 
std::string ConfigVal (QUOTED_STRING keyString, QUOTED_STRING defaultVal, bool warn=true)
 
std::string ConfigVal (QUOTED_STRING keyString, std::string defaultVal, bool warn=true)
 
std::string ConfigVal (std::string keyString, QUOTED_STRING defaultVal, bool warn=true)
 
std::string ConfigVal (std::string keyString, std::string defaultVal, bool warn=true)
 
EventRef createCopyOfEvent (EventRef e)
 
std::vector< std::string > splitStringIntoArray (const std::string &in)
 
std::string decygifyPath (const std::string &in)
 
std::string replaceEnvVars (const std::string &in)
 
unsigned int hashCode (const double d)
 
std::ostream & operator<< (std::ostream &os, const glm::vec2 &vec2)
 
std::istream & operator>> (std::istream &is, glm::vec2 &vec2)
 
std::ostream & operator<< (std::ostream &os, const glm::vec3 &vec3)
 
std::istream & operator>> (std::istream &is, glm::vec3 &vec3)
 
std::ostream & operator<< (std::ostream &os, const glm::vec4 &vec4)
 
std::istream & operator<< (std::istream &is, glm::vec4 &vec4)
 
std::ostream & operator<< (std::ostream &os, const glm::mat3 &m)
 
std::istream & operator>> (std::istream &is, glm::mat3 &m)
 
std::ostream & operator<< (std::ostream &os, const glm::mat4 &m)
 
std::istream & operator>> (std::istream &is, glm::mat4 &m)
 
std::string intToString (int i)
 
int stringToInt (const std::string &in)
 
std::string realToString (double r)
 
double stringToReal (const std::string &in)
 
bool popNextToken (std::string &in, std::string &token, bool returnFalseOnSemiColon=false)
 
bool popUntilSemicolon (std::string &in, std::string &popped)
 
std::vector< std::vector
< std::string > > 
readDelimitedData (const std::string &csvString, const std::string &delimiter, bool removeQuotes=true)
 
std::string joinIntoString (const std::vector< std::string > &in, const std::string &delimiter=std::string(" "))
 
std::string convertNewlinesAndTabsToSpaces (std::string input)
 Converts DOS and UNIX style newlines and tab characters to spaces. More...
 
int iMinNonNeg (int i1, int i2)
 
std::string spacesString (int num)
 Returns a string containing num spaces in it. More...
 
int numSubstringOccurances (const std::string &str, const std::string &substr)
 Returns the number of occurances of substr in str. More...
 
int findNth (const std::string &str, const std::string &substr, const int n)
 
template<class T >
std::vector< T > insertIntoArray (std::vector< T > inputArray, T newElement, int insertBeforeElementNum)
 
std::string trimWhitespace (const std::string &s)
 Trims whitespace characters from both sides of s. More...
 
std::string readWholeFile (const std::string &filename)
 

Typedef Documentation

typedef boost::shared_ptr<class AbstractCamera> MinVR::AbstractCameraRef
typedef boost::shared_ptr<class AbstractInputDevice> MinVR::AbstractInputDeviceRef
typedef boost::shared_ptr<class AbstractMVRApp> MinVR::AbstractMVRAppRef
typedef boost::shared_ptr<class ConfigMap> MinVR::ConfigMapRef

ConfigVal's and config files description:

ConfigVal's are an easy way to access program settings that can be stored in a configuration file. They are all key=value pairs where key and value are both originally std::strings. But, the value string can be easily reinterpreted by any class that overrides the stream >> and << operators. The ConfigVal() function figures out what type to try to convert to by the type of the second parameter to the function. This parameter also specifies the default value to return if the key is not found in the ConfigMap::_map Table.

To use a config file, call ConfigMap::readFile() with the filename of a text file to read. The format of each line of the file should be:

key value

where key has no spaces in it. value is everything after the space until the end of the line, so it can have spaces in it. Any line that starts with the character # is a comment and is ignored. A single \ character means cut the line here and continue on the next line. Everything after the \ is ignored and the text on the next line is appended to the text on the current line. You can escape the \ operator with a \ to get a single \ character.

Additionally, any value X appearing inside the special character sequence will be replaced by the value of the environment variable named X. If X is not defined, it will be replaced by a null string. If X takes the form of the path to a file and you're running in Windows under cygwin then X will be automatically converted from the form /cygdrive/c/blah/blah to the more Windows friendly form c:/blah/blah to stay compatible with the Visual C++ compiler.

Additionally, if you put a += after the key and the key has already been defined, then the value is appended to the key's current value. If you don't have the += and the same key is read in from a file, then the new value overwrites the old. For example:

mykey1 value1 mykey1 value2 mykey2 value3 mykey2+= value4

The value of mykey1 will be "value2". The value of mykey2 will be "value3 value4".

— inside config-file.cfg —

MyLength 0.4 MyVector (0.2, 0.4, 0.3)

— end of file —

Log *log = new Log("log.txt"); ConfigMapRef myMap = new ConfigMap("config-file.cfg", log); double l = myMap->get("MyLength", 0.0); Vector3 v = myMap->get("MyVector", Vector3::zero());This class stores the data for the ConfigVal accessor functions Essentially, this is a big associative array std::string's map to std::strings. The ConfigVal function is used to access values and reinterpret them as different types. The key/value pairs can be read in from a file(s), or set manually with the set function.

typedef boost::shared_ptr<class Event> MinVR::EventRef
typedef boost::shared_ptr<class RenderThread> MinVR::RenderThreadRef
typedef boost::shared_ptr< class AbstractWindow > MinVR::WindowRef
typedef boost::shared_ptr<class WindowSettings> MinVR::WindowSettingsRef

Function Documentation

template<class KEYTYPE , class VALTYPE >
VALTYPE MinVR::ConfigVal ( KEYTYPE  keyString,
const VALTYPE &  defaultVal,
bool  warn = true 
)

This is the main templated function that is used to access a ConfigVal. The value is stored internally as a string, the function will attempt to reinterpret the value as the same type as that which is passed in to the defaultVal parameter. This function is overridden by several variants below for various string-like types, which generally don't require a type conversion, but can confuse a compiler.

std::string MinVR::ConfigVal ( QUOTED_STRING  keyString,
QUOTED_STRING  defaultVal,
bool  warn = true 
)
inline
std::string MinVR::ConfigVal ( QUOTED_STRING  keyString,
std::string  defaultVal,
bool  warn = true 
)
inline
std::string MinVR::ConfigVal ( std::string  keyString,
QUOTED_STRING  defaultVal,
bool  warn = true 
)
inline
std::string MinVR::ConfigVal ( std::string  keyString,
std::string  defaultVal,
bool  warn = true 
)
inline
std::string MinVR::convertNewlinesAndTabsToSpaces ( std::string  input)
EventRef MinVR::createCopyOfEvent ( EventRef  e)

Creates a copy of the Event pointed to by e and returns a ref counted pointer to the new copy.

std::string MinVR::decygifyPath ( const std::string &  in)

This function changes occurances of /cygdrive/c/folder1/folder2/etc.. to c:/folder1/folder2/etc.. when running in Windows. Paths coming from program arguments or environment variables will tend to take the /cygdrive/<drive-letter>/ form when running under cygwin, but file commands compiled with the MS Visual C++ compiler can't deal with paths of this form.

int MinVR::findNth ( const std::string &  str,
const std::string &  substr,
const int  n 
)

Like std::string.find() but returns the n-th occurance of substr rather than the first one.

unsigned int MinVR::hashCode ( const double  d)
int MinVR::iMinNonNeg ( int  i1,
int  i2 
)

returns the minimum of i1 and i2 that is also >=0. if both are negative, returns a large positive number.

template<class T >
std::vector<T> MinVR::insertIntoArray ( std::vector< T >  inputArray,
newElement,
int  insertBeforeElementNum 
)

This isn't so much a string utility as an Array utility. You can use this with an Array of strings, or any other Array.

std::string MinVR::intToString ( int  i)
std::string MinVR::joinIntoString ( const std::vector< std::string > &  in,
const std::string &  delimiter = std::string(" ") 
)

returns a string of that is the concatanation of all elements in the array separated by the specified delimiter

int MinVR::numSubstringOccurances ( const std::string &  str,
const std::string &  substr 
)
std::ostream& MinVR::operator<< ( std::ostream &  os,
const glm::vec2 &  vec2 
)
std::ostream& MinVR::operator<< ( std::ostream &  os,
const glm::vec3 &  vec3 
)
std::ostream& MinVR::operator<< ( std::ostream &  os,
const glm::vec4 &  vec4 
)
std::istream& MinVR::operator<< ( std::istream &  is,
glm::vec4 &  vec4 
)
std::ostream& MinVR::operator<< ( std::ostream &  os,
const glm::mat3 &  m 
)
std::ostream& MinVR::operator<< ( std::ostream &  os,
const glm::mat4 &  m 
)
std::istream& MinVR::operator>> ( std::istream &  is,
glm::vec2 &  vec2 
)
std::istream& MinVR::operator>> ( std::istream &  is,
glm::vec3 &  vec3 
)
std::istream& MinVR::operator>> ( std::istream &  is,
glm::mat3 &  m 
)
std::istream& MinVR::operator>> ( std::istream &  is,
glm::mat4 &  m 
)
bool MinVR::popNextToken ( std::string &  in,
std::string &  token,
bool  returnFalseOnSemiColon = false 
)

Pops off the next token in the string where a token is separated by a space, a tab, a newline, a comma, or a semicolon. if the last parameter is set then this returns false if it is the last item in the string OR if there is a semicolon immediately following the token, otherwise it returns false when there are no more tokens in the string.

bool MinVR::popUntilSemicolon ( std::string &  in,
std::string &  popped 
)

pops off the everything in the string until a semicolon is reached. after the call, in is what's left of the string. returns true if a semicolon was found, false otherwise

std::vector< std::vector< std::string > > MinVR::readDelimitedData ( const std::string &  csvString,
const std::string &  delimiter,
bool  removeQuotes = true 
)

Reads comma, tab, etc.. separated data into a 2D array of strings. csvString should is normally read from a file. Each entry of a line of the file should be separated by the delimiter string. If removeQuotes is true than quotes around entries are removed before appending them to the 2D array that is returned.

std::string MinVR::readWholeFile ( const std::string &  filename)
std::string MinVR::realToString ( double  r)
std::string MinVR::replaceEnvVars ( const std::string &  in)

Given an input string, replaces all occurances of with the decygified (see above) value of the environment variable NAME. If NAME is not defined, then a blank string is returned.

std::string MinVR::spacesString ( int  num)
std::vector<std::string> MinVR::splitStringIntoArray ( const std::string &  in)
int MinVR::stringToInt ( const std::string &  in)
double MinVR::stringToReal ( const std::string &  in)
std::string MinVR::trimWhitespace ( const std::string &  s)