本文整理汇总了C++中misc::ConfigurationFileSection::getSection方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigurationFileSection::getSection方法的具体用法?C++ ConfigurationFileSection::getSection怎么用?C++ ConfigurationFileSection::getSection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类misc::ConfigurationFileSection
的用法示例。
在下文中一共展示了ConfigurationFileSection::getSection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeAdapter
void InputDeviceAdapter::initializeAdapter(const Misc::ConfigurationFileSection& configFileSection)
{
/* Allocate adapter state arrays: */
typedef std::vector<std::string> StringList;
StringList inputDeviceNames=configFileSection.retrieveValue<StringList>("./inputDeviceNames");
numInputDevices=inputDeviceNames.size();
inputDevices=new InputDevice*[numInputDevices];
for(int i=0;i<numInputDevices;++i)
inputDevices[i]=0;
/* Initialize input devices: */
for(int i=0;i<numInputDevices;++i)
{
/* Go to device's section: */
Misc::ConfigurationFileSection deviceSection=configFileSection.getSection(inputDeviceNames[i].c_str());
/* Initialize input device: */
createInputDevice(i,deviceSection);
}
}
示例2: initialize
void InputDeviceManager::initialize(const Misc::ConfigurationFileSection& configFileSection)
{
/* Retrieve the list of input device adapters: */
typedef std::vector<std::string> StringList;
StringList inputDeviceAdapterNames=configFileSection.retrieveValue<StringList>("./inputDeviceAdapterNames");
/* Remove all duplicates from the list of input device adapters: */
for(unsigned int i=0;i<inputDeviceAdapterNames.size()-1;++i)
{
for(unsigned int j=inputDeviceAdapterNames.size()-1;j>i;--j)
{
if(inputDeviceAdapterNames[j]==inputDeviceAdapterNames[i])
{
/* Remove the duplicate list entry: */
inputDeviceAdapterNames.erase(inputDeviceAdapterNames.begin()+j);
}
}
}
/* Initialize the adapter array: */
numInputDeviceAdapters=inputDeviceAdapterNames.size();
inputDeviceAdapters=new InputDeviceAdapter*[numInputDeviceAdapters];
/* Initialize input device adapters: */
int numIgnoredAdapters=0;
int mouseAdapterIndex=-1;
for(int i=0;i<numInputDeviceAdapters;++i)
{
/* Go to input device adapter's section: */
Misc::ConfigurationFileSection inputDeviceAdapterSection=configFileSection.getSection(inputDeviceAdapterNames[i].c_str());
/* Determine input device adapter's type: */
std::string inputDeviceAdapterType=inputDeviceAdapterSection.retrieveString("./inputDeviceAdapterType");
bool typeFound=true;
try
{
if(inputDeviceAdapterType=="Mouse")
{
/* Check if there is already a mouse input device adapter: */
if(mouseAdapterIndex>=0)
{
/* Ignore this input device adapter: */
inputDeviceAdapters[i]=0;
++numIgnoredAdapters;
std::cout<<"InputDeviceManager: Ignoring mouse input device adapter "<<inputDeviceAdapterNames[i]<<" because there is already a mouse input device adapter"<<std::endl;
}
else
{
/* Create mouse input device adapter: */
inputDeviceAdapters[i]=new InputDeviceAdapterMouse(this,inputDeviceAdapterSection);
mouseAdapterIndex=i;
}
}
else if(inputDeviceAdapterType=="DeviceDaemon")
{
/* Create device daemon input device adapter: */
inputDeviceAdapters[i]=new InputDeviceAdapterDeviceDaemon(this,inputDeviceAdapterSection);
}
else if(inputDeviceAdapterType=="Trackd")
{
/* Create trackd input device adapter: */
inputDeviceAdapters[i]=new InputDeviceAdapterTrackd(this,inputDeviceAdapterSection);
}
else if(inputDeviceAdapterType=="VisBox")
{
/* Create VisBox input device adapter: */
inputDeviceAdapters[i]=new InputDeviceAdapterVisBox(this,inputDeviceAdapterSection);
}
else if(inputDeviceAdapterType=="HID")
{
/* Create HID input device adapter: */
inputDeviceAdapters[i]=new InputDeviceAdapterHID(this,inputDeviceAdapterSection);
}
else if(inputDeviceAdapterType=="Playback")
{
/* Create device daemon input device adapter: */
inputDeviceAdapters[i]=new InputDeviceAdapterPlayback(this,inputDeviceAdapterSection);
}
else
typeFound=false;
}
catch(std::runtime_error err)
{
/* Print a warning message: */
std::cout<<"InputDeviceManager: Ignoring input device adapter "<<inputDeviceAdapterNames[i];
std::cout<<" due to exception "<<err.what()<<std::endl;
/* Ignore the input device adapter: */
inputDeviceAdapters[i]=0;
++numIgnoredAdapters;
}
if(!typeFound)
Misc::throwStdErr("InputDeviceManager: Unknown input device adapter type \"%s\"",inputDeviceAdapterType.c_str());
}
if(numIgnoredAdapters!=0)
{
/* Remove any ignored input device adapters from the array: */
InputDeviceAdapter** newInputDeviceAdapters=new InputDeviceAdapter*[numInputDeviceAdapters-numIgnoredAdapters];
//.........这里部分代码省略.........
示例3: initialize
void InputDeviceManager::initialize(const Misc::ConfigurationFileSection& configFileSection)
{
/* Retrieve the list of input device adapters: */
typedef std::vector<std::string> StringList;
StringList inputDeviceAdapterNames=configFileSection.retrieveValue<StringList>("./inputDeviceAdapterNames");
numInputDeviceAdapters=inputDeviceAdapterNames.size();
inputDeviceAdapters=new InputDeviceAdapter*[numInputDeviceAdapters];
/* Initialize input device adapters: */
int numIgnoredAdapters=0;
for(int i=0;i<numInputDeviceAdapters;++i)
{
/* Go to input device adapter's section: */
Misc::ConfigurationFileSection inputDeviceAdapterSection=configFileSection.getSection(inputDeviceAdapterNames[i].c_str());
/* Determine input device adapter's type: */
std::string inputDeviceAdapterType=inputDeviceAdapterSection.retrieveString("./inputDeviceAdapterType");
bool typeFound=true;
try
{
if(inputDeviceAdapterType=="Mouse")
{
/* Create mouse input device adapter: */
inputDeviceAdapters[i]=new InputDeviceAdapterMouse(this,inputDeviceAdapterSection);
}
else if(inputDeviceAdapterType=="DeviceDaemon")
{
/* Create device daemon input device adapter: */
inputDeviceAdapters[i]=new InputDeviceAdapterDeviceDaemon(this,inputDeviceAdapterSection);
}
else if(inputDeviceAdapterType=="Trackd")
{
/* Create trackd input device adapter: */
inputDeviceAdapters[i]=new InputDeviceAdapterTrackd(this,inputDeviceAdapterSection);
}
else if(inputDeviceAdapterType=="VisBox")
{
/* Create VisBox input device adapter: */
inputDeviceAdapters[i]=new InputDeviceAdapterVisBox(this,inputDeviceAdapterSection);
}
else if(inputDeviceAdapterType=="HID")
{
/* Create HID input device adapter: */
inputDeviceAdapters[i]=new InputDeviceAdapterHID(this,inputDeviceAdapterSection);
}
else if(inputDeviceAdapterType=="Playback")
{
/* Create device daemon input device adapter: */
inputDeviceAdapters[i]=new InputDeviceAdapterPlayback(this,inputDeviceAdapterSection);
}
else
typeFound=false;
}
catch(std::runtime_error err)
{
/* Print a warning message: */
std::cout<<"InputDeviceManager: Ignoring input device adapter "<<inputDeviceAdapterNames[i];
std::cout<<" due to exception "<<err.what()<<std::endl;
/* Ignore the input device adapter: */
inputDeviceAdapters[i]=0;
++numIgnoredAdapters;
}
if(!typeFound)
Misc::throwStdErr("InputDeviceManager: Unknown input device adapter type \"%s\"",inputDeviceAdapterType.c_str());
}
if(numIgnoredAdapters!=0)
{
/* Remove any ignored input device adapters from the array: */
InputDeviceAdapter** newInputDeviceAdapters=new InputDeviceAdapter*[numInputDeviceAdapters-numIgnoredAdapters];
int newNumInputDeviceAdapters=0;
for(int i=0;i<numInputDeviceAdapters;++i)
if(inputDeviceAdapters[i]!=0)
{
newInputDeviceAdapters[newNumInputDeviceAdapters]=inputDeviceAdapters[i];
++newNumInputDeviceAdapters;
}
delete[] inputDeviceAdapters;
numInputDeviceAdapters=newNumInputDeviceAdapters;
inputDeviceAdapters=newInputDeviceAdapters;
}
/* Check if there are any valid input device adapters: */
if(numInputDeviceAdapters==0)
Misc::throwStdErr("InputDeviceManager: No valid input device adapters found; I refuse to work under conditions like these!");
}
示例4: if
//.........这里部分代码省略.........
unsigned int mouseCursorNominalSize=configFileSection.retrieveValue<unsigned int>("./mouseCursorNominalSize",24);
/* Create the mouse cursor faker: */
mouseCursorFaker=new MouseCursorFaker(inputDevices[fakeMouseCursorDevice],mouseCursorImageFileName.c_str(),mouseCursorNominalSize);
mouseCursorFaker->setCursorSize(configFileSection.retrieveValue<Size>("./mouseCursorSize",mouseCursorFaker->getCursorSize()));
mouseCursorFaker->setCursorHotspot(configFileSection.retrieveValue<Vector>("./mouseCursorHotspot",mouseCursorFaker->getCursorHotspot()));
}
/* Read time stamp of first data frame: */
try
{
nextTimeStamp=inputDeviceDataFile->read<double>();
/* Request an update for the next frame: */
requestUpdate();
}
catch(IO::File::ReadError)
{
done=true;
nextTimeStamp=Math::Constants<double>::max;
if(quitWhenDone)
{
/* Request exiting the program: */
shutdown();
}
}
/* Check if the user wants to play back a commentary sound track: */
std::string soundFileName=configFileSection.retrieveString("./soundFileName","");
if(!soundFileName.empty())
{
try
{
/* Create a sound player for the given sound file name: */
soundPlayer=new Sound::SoundPlayer(soundFileName.c_str());
}
catch(std::runtime_error error)
{
/* Print a message, but carry on: */
std::cerr<<"InputDeviceAdapterPlayback: Disabling sound playback due to exception "<<error.what()<<std::endl;
}
}
#ifdef VRUI_INPUTDEVICEADAPTERPLAYBACK_USE_KINECT
/* Check if the user wants to play back 3D video: */
std::string kinectPlayerSectionName=configFileSection.retrieveString("./kinectPlayer","");
if(!kinectPlayerSectionName.empty())
{
/* Go to the Kinect player's section: */
Misc::ConfigurationFileSection kinectPlayerSection=configFileSection.getSection(kinectPlayerSectionName.c_str());
kinectPlayer=new KinectPlayback(nextTimeStamp,kinectPlayerSection);
}
#endif
/* Check if the user wants to save a movie: */
if(saveMovie)
{
/* Read the movie image file name template: */
movieFileNameTemplate=configFileSection.retrieveString("./movieFileNameTemplate");
/* Check if the name template has the correct format: */
int numConversions=0;
bool hasIntConversion=false;
for(std::string::const_iterator mfntIt=movieFileNameTemplate.begin();mfntIt!=movieFileNameTemplate.end();++mfntIt)
{
if(*mfntIt=='%')
{
++mfntIt;
if(*mfntIt!='%')
{
++numConversions;
/* Skip width modifiers: */
while(isdigit(*mfntIt))
++mfntIt;
/* Check for integer conversion: */
if(*mfntIt=='d')
hasIntConversion=true;
}
}
else if(*mfntIt=='/') // Only accept conversions in the file name part
hasIntConversion=false;
}
if(numConversions!=1||!hasIntConversion)
Misc::throwStdErr("InputDeviceAdapterPlayback::InputDeviceAdapterPlayback: movie file name template \"%s\" does not have exactly one %%d conversion",movieFileNameTemplate.c_str());
/* Get the index of the window from which to save the frames: */
movieWindowIndex=configFileSection.retrieveValue<int>("./movieWindowIndex",movieWindowIndex);
/* Get the intended frame rate for the movie: */
double frameRate=configFileSection.retrieveValue<double>("./movieFrameRate",30.0);
movieFrameTimeInterval=1.0/frameRate;
/* Calculate the first time at which to save a frame: */
nextMovieFrameTime=nextTimeStamp+movieFrameTimeInterval*0.5;
nextMovieFrameCounter=0;
}
}
示例5: usbDevices
KinectServer::KinectServer(USB::Context& usbContext,Misc::ConfigurationFileSection& configFileSection)
:numCameras(0),cameraStates(0),
listeningSocket(configFileSection.retrieveValue<int>("./listenPortId",26000),1)
{
/* Read the list of cameras: */
std::vector<std::string> cameraNames=configFileSection.retrieveValue<std::vector<std::string> >("./cameras",std::vector<std::string>());
numCameras=cameraNames.size();
cameraStates=new CameraState*[numCameras];
/* Enumerate all USB devices: */
#ifdef VERBOSE
std::cout<<"KinectServer: Enumerating Kinect camera devices on USB bus"<<std::endl;
#endif
USB::DeviceList usbDevices(usbContext);
size_t numKinectCameras=usbDevices.getNumDevices(0x045eU,0x02aeU);
unsigned int numFoundCameras=0;
for(unsigned int i=0; i<numCameras; ++i)
{
/* Read the camera's serial number: */
Misc::ConfigurationFileSection cameraSection=configFileSection.getSection(cameraNames[i].c_str());
std::string serialNumber=cameraSection.retrieveValue<std::string>("./serialNumber");
/* Find a Kinect camera of the specified serial number: */
unsigned int j;
for(j=0; j<numKinectCameras; ++j)
{
/* Tentatively open the Kinect camera device: */
USB::Device cam(usbDevices.getDevice(0x045eU,0x02aeU,j));
if(cam.getSerialNumber()==serialNumber) // Bail out if the desired device was found
break;
}
if(j<numKinectCameras)
{
/* Create a streamer for the found camera: */
#ifdef VERBOSE
std::cout<<"KinectServer: Creating streamer for camera with serial number "<<serialNumber<<std::endl;
#endif
cameraStates[numFoundCameras]=new CameraState(usbDevices.getDevice(0x045eU,0x02aeU,j),newFrameCond,newFrameCond);
/* Check if camera is to remove background: */
if(cameraSection.retrieveValue<bool>("./removeBackground",true))
{
Kinect::Camera& camera=cameraStates[numFoundCameras]->camera;
/* Check whether to load a previously saved background file: */
std::string backgroundFile=cameraSection.retrieveValue<std::string>("./backgroundFile",std::string());
if(!backgroundFile.empty())
{
/* Load the background file: */
std::string fullBackgroundFileName=KINECT_CONFIG_DIR;
fullBackgroundFileName.push_back('/');
fullBackgroundFileName.append(backgroundFile);
#ifdef VERBOSE
std::cout<<"KinectServer: Loading background depth image file "<<fullBackgroundFileName<<'-'<<serialNumber<<".background"<<std::endl;
#endif
camera.loadBackground(fullBackgroundFileName.c_str());
}
/* Check whether to capture background: */
unsigned int captureBackgroundFrames=cameraSection.retrieveValue<unsigned int>("./captureBackgroundFrames",0);
if(captureBackgroundFrames>0)
{
/* Request background capture: */
#ifdef VERBOSE
std::cout<<"KinectServer: Capturing "<<captureBackgroundFrames<<" background depth frames"<<std::endl;
#endif
camera.captureBackground(captureBackgroundFrames,false);
}
/* Check whether to set a maximum depth value: */
unsigned int maxDepth=cameraSection.retrieveValue<unsigned int>("./maxDepth",0);
if(maxDepth>0)
{
/* Set the maximum depth: */
#ifdef VERBOSE
std::cout<<"KinectServer: Setting maximum depth value to "<<maxDepth<<std::endl;
#endif
camera.setMaxDepth(maxDepth,false);
}
/* Set the background removal fuzz value: */
int backgroundFuzz=cameraSection.retrieveValue<int>("./backgroundFuzz",camera.getBackgroundRemovalFuzz());
#ifdef VERBOSE
std::cout<<"KinectServer: Setting background depth fuzz value to "<<backgroundFuzz<<std::endl;
#endif
camera.setBackgroundRemovalFuzz(backgroundFuzz);
/* Enable background removal: */
camera.setRemoveBackground(true);
}
++numFoundCameras;
}
else
std::cerr<<"Kinect camera with serial number "<<serialNumber<<" not found on USB bus"<<std::endl;
}
/* Initialize streaming state: */
#ifdef VERBOSE
std::cout<<"KinectServer: "<<numFoundCameras<<" Kinect cameras initialized"<<std::endl;
//.........这里部分代码省略.........