Commit 558cc311 authored by Jussi Lindgren's avatar Jussi Lindgren

Applications: Random seed command line switch for Designer

Additionally, changed the default seed to be time(NULL),
previously the generator was not initialized.
parent 28257fdd
......@@ -24,6 +24,7 @@ namespace OpenViBEDesigner
CommandLineFlag_Define =0x00000040,
CommandLineFlag_Config =0x00000080,
CommandLineFlag_Kernel =0x00000100,
CommandLineFlag_RandomSeed =0x00000200
} ECommandLineFlag;
enum
......
#include "ovd_base.h"
#include <system/Time.h>
#include <system/CMath.h>
#include <stack>
#include <vector>
......@@ -351,6 +352,10 @@ boolean parse_arguments(int argc, char** argv, SConfiguration& rConfiguration)
{
l_oConfiguration.m_eNoManageSession=CommandLineFlag_NoManageSession;
}
else if(*it=="--random-seed")
{
l_oConfiguration.m_oFlag[CommandLineFlag_RandomSeed] = *++it;
}
// else if(*it=="--define")
// {
// l_oConfiguration.m_oFlag.push_back(std::make_pair(Flag_NoGui, *++it));
......@@ -397,12 +402,13 @@ int go(int argc, char ** argv)
cout << " --config filename : path to config file\n";
cout << " --help : displays this help message and exits\n";
cout << " --kernel filename : path to openvibe kernel library\n";
cout << " --no-gui : hides the designer graphical user interface (assumes --no-color-depth-test)\n";
cout << " --no-gui : hides the designer graphical user interface (assumes --no-check-color-depth)\n";
cout << " --no-check-color-depth : does not check 24/32 bits color depth\n";
cout << " --no-session-management : neither restore last used scenarios nor saves them at exit\n";
cout << " --open filename : opens a scenario (see also --no-session-management)\n";
cout << " --play filename : plays the opened scenario (see also --no-session-management)\n";
cout << " --play-fast filename : plays fast forward the opened scenario (see also --no-session-management)\n";
cout << " --random-seed uint : initialize random number generator with value, default=time(NULL)\n";
// l_rLogManager << LogLevel_Info << " --define : defines a variable in the configuration manager\n";
return -1;
}
......@@ -512,6 +518,15 @@ int go(int argc, char ** argv)
l_pKernelContext->getVisualisationManager().initialize3DContext();
}
if(l_oConfiguration.m_oFlag.count(CommandLineFlag_RandomSeed))
{
System::Math::initializeRandomMachine(atol(l_oConfiguration.m_oFlag[CommandLineFlag_RandomSeed].c_str()));
}
else
{
System::Math::initializeRandomMachine(time(NULL));
}
{
::CApplication app(*l_pKernelContext);
app.initialize(l_oConfiguration.getFlags());
......
......@@ -16,6 +16,9 @@ namespace System
static System::uint32 randomUInteger32(void);
static System::uint64 randomUInteger64(void);
// returns a value in [0,ui32upperLimit( -- i.e. ui32upperLimit not included in range
static System::uint32 Math::randomUInteger32WithCeiling(uint32 ui32upperLimit);
static System::int8 randomSInterger8(void);
static System::int16 randomSInterger16(void);
static System::int32 randomSInterger32(void);
......
......@@ -35,6 +35,11 @@ uint64 Math::randomUInteger64(void)
return (r1<<24)^(r2<<16)^(r3<<8)^(r4);
}
uint32 Math::randomUInteger32WithCeiling(uint32 ui32upperLimit)
{
return static_cast<int32>(randomUInteger64()) % ui32upperLimit;
}
int8 Math::randomSInterger8(void)
{
return static_cast<int8>(randomUInteger64());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment