本文整理汇总了C++中Config类的典型用法代码示例。如果您正苦于以下问题:C++ Config类的具体用法?C++ Config怎么用?C++ Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VBox
void
MapNodeHelper::parse(MapNode* mapNode,
osg::ArgumentParser& args,
osgViewer::View* view,
osg::Group* root,
Control* userControl ) const
{
if ( !root )
root = mapNode;
// parse out custom example arguments first:
bool useSky = args.read("--sky");
bool useOcean = args.read("--ocean");
bool useMGRS = args.read("--mgrs");
bool useDMS = args.read("--dms");
bool useDD = args.read("--dd");
bool useCoords = args.read("--coords") || useMGRS || useDMS || useDD;
std::string kmlFile;
args.read( "--kml", kmlFile );
// install a canvas for any UI controls we plan to create:
ControlCanvas* canvas = ControlCanvas::get(view, false);
Container* mainContainer = canvas->addControl( new VBox() );
mainContainer->setBackColor( Color(Color::Black, 0.8) );
mainContainer->setHorizAlign( Control::ALIGN_LEFT );
mainContainer->setVertAlign( Control::ALIGN_BOTTOM );
// install the user control:
if ( userControl )
mainContainer->addControl( userControl );
// look for external data in the map node:
const Config& externals = mapNode->externalConfig();
const Config& skyConf = externals.child("sky");
const Config& oceanConf = externals.child("ocean");
const Config& annoConf = externals.child("annotations");
const Config& declutterConf = externals.child("decluttering");
Config viewpointsConf = externals.child("viewpoints");
// backwards-compatibility: read viewpoints at the top level:
const ConfigSet& old_viewpoints = externals.children("viewpoint");
for( ConfigSet::const_iterator i = old_viewpoints.begin(); i != old_viewpoints.end(); ++i )
viewpointsConf.add( *i );
// Loading a viewpoint list from the earth file:
if ( !viewpointsConf.empty() )
{
std::vector<Viewpoint> viewpoints;
const ConfigSet& children = viewpointsConf.children();
if ( children.size() > 0 )
{
for( ConfigSet::const_iterator i = children.begin(); i != children.end(); ++i )
{
viewpoints.push_back( Viewpoint(*i) );
}
}
if ( viewpoints.size() > 0 )
{
Control* c = ViewpointControlFactory().create(viewpoints, view);
if ( c )
mainContainer->addControl( c );
}
}
// Adding a sky model:
if ( useSky || !skyConf.empty() )
{
double hours = skyConf.value( "hours", 12.0 );
SkyNode* sky = new SkyNode( mapNode->getMap() );
sky->setDateTime( 2011, 3, 6, hours );
sky->attach( view );
root->addChild( sky );
Control* c = SkyControlFactory().create(sky, view);
if ( c )
mainContainer->addControl( c );
}
// Adding an ocean model:
if ( useOcean || !oceanConf.empty() )
{
OceanSurfaceNode* ocean = new OceanSurfaceNode( mapNode, oceanConf );
if ( ocean )
{
root->addChild( ocean );
Control* c = OceanControlFactory().create(ocean, view);
if ( c )
mainContainer->addControl(c);
}
}
// Loading KML from the command line:
if ( !kmlFile.empty() )
{
//.........这里部分代码省略.........
示例2: writeDISSection
void writeDISSection(std::ostream& out, Config& config)
{
out << "# DIS" << std::endl;
out << config.getParameter("VRLINK") << std::endl;
out << config.getParameter("VRLINK-PROTOCOL") << std::endl;
out << config.getParameter("VRLINK-DIS-IP-ADDRESS") << std::endl;
out << config.getParameter("VRLINK-DIS-NETWORK-INTERFACE") << std::endl;
out << config.getParameter("VRLINK-DIS-PORT") << std::endl;
if (config.parameterExists("VRLINK-DIS-SUBNET-MASK"))
{
out << config.getParameter("VRLINK-DIS-SUBNET-MASK") << std::endl;
}
out << config.getParameter("VRLINK-ENTITIES-FILE-PATH") << std::endl;
out << config.getParameter("VRLINK-RADIOS-FILE-PATH") << std::endl;
out << config.getParameter("VRLINK-NETWORKS-FILE-PATH") << std::endl;
out << config.getParameter("VRLINK-DEBUG-PRINT-COMMS") << std::endl;
out << config.getParameter("VRLINK-DEBUG-PRINT-COMMS-2") << std::endl;
out << config.getParameter("VRLINK-DEBUG-PRINT-MAPPING") << std::endl;
out << config.getParameter("VRLINK-DEBUG-PRINT-DAMAGE") << std::endl;
out << config.getParameter("VRLINK-DEBUG-PRINT-TX-STATE") << std::endl;
out << config.getParameter("VRLINK-DEBUG-PRINT-TX-POWER") << std::endl;
out << config.getParameter("VRLINK-DEBUG-PRINT-MOBILITY") << std::endl;
out << config.getParameter(
"VRLINK-DEBUG-PRINT-TRANSMITTER-PDU") << std::endl;
out << config.getParameter("VRLINK-DEBUG-PRINT-PDUS") << std::endl;
out << config.getParameter("VRLINK-RECEIVE-DELAY") << std::endl;
out << config.getParameter("VRLINK-MAX-RECEIVE-DURATION") << std::endl;
out << config.getParameter("VRLINK-XYZ-EPSILON") << std::endl;
out << config.getParameter("VRLINK-MOBILITY-INTERVAL") << std::endl;
out << std::endl;
}
示例3: Load
// ---------------------------------------------------------
void ResourceAudio::Load(const Config & config)
{
Resource::Load(config);
format = (Format) config.GetInt("Format", unknown);
}
示例4: writePhysicalSection
void writePhysicalSection(std::ostream& out, Config& config, NodeSet& ns)
{
out << "# Physical" << std::endl;
NetworkSet& nets = ns.networksUsed();
std::string defaultModel =
config.getParameter("VRLINK-DEFAULT-ROUTER-MODEL").value;
std::set<std::string> models;
NetworkSet::iterator nit = nets.begin();
while (nit != nets.end())
{
if ((*nit)->models.size() == 0)
{
models.insert(defaultModel);
}
else
{
models.insert((*nit)->models.begin(), (*nit)->models.end());
}
nit++;
}
if (models.size() == 1)
{
ParameterMap* parameters = config.getModelParameterList(*models.begin());
if (parameters)
{
writeParameters(out, "", parameters);
}
}
else if (models.size() > 1)
{
nit = nets.begin();
while (nit != nets.end())
{
Network* n = *nit;
ParameterMap* common = n->getCommonParameters();
std::stringstream subnet;
subnet << "[" << n->address << "]";
writeParameters(out, subnet.str(), common);
std::set<std::string>::iterator mit = n->models.begin();
while (mit != n->models.end())
{
ParameterMap* parameters = config.getModelParameterList(*mit);
ParameterMap* specfic = *parameters - *common;
std::string group = n->getGroup(*mit);
if (parameters && !group.empty())
{
writeParameters(out, group, specfic);
}
delete specfic;
mit++;
}
nit++;
}
}
std::set<std::string>::iterator it = ns.modelsUsed().begin();
if (it != ns.modelsUsed().end())
{
out << config.getParameter("ROUTER-MODEL-CONFIG-FILE") << std::endl;
}
}
示例5: if
void
AltitudeSymbol::parseSLD(const Config& c, Style& style)
{
if ( match(c.key(), "altitude-clamping") ) {
if ( match(c.value(), "none") )
style.getOrCreate<AltitudeSymbol>()->clamping() = CLAMP_NONE;
else if ( match(c.value(), "terrain") )
style.getOrCreate<AltitudeSymbol>()->clamping() = CLAMP_TO_TERRAIN;
else if ( match(c.value(), "absolute") )
style.getOrCreate<AltitudeSymbol>()->clamping() = CLAMP_ABSOLUTE;
else if ( match(c.value(), "relative") )
style.getOrCreate<AltitudeSymbol>()->clamping() = CLAMP_RELATIVE_TO_TERRAIN;
else if ( match(c.value(), "terrain-drape") )
{
style.getOrCreate<AltitudeSymbol>()->clamping() = CLAMP_TO_TERRAIN;
style.getOrCreate<AltitudeSymbol>()->technique() = TECHNIQUE_DRAPE;
}
else if ( match(c.value(), "terrain-gpu") )
{
style.getOrCreate<AltitudeSymbol>()->clamping() = CLAMP_TO_TERRAIN;
style.getOrCreate<AltitudeSymbol>()->technique() = TECHNIQUE_GPU;
}
}
else if ( match(c.key(), "altitude-technique") ) {
if ( match(c.value(), "map") )
style.getOrCreate<AltitudeSymbol>()->technique() = TECHNIQUE_MAP;
else if ( match(c.value(), "scene") )
style.getOrCreate<AltitudeSymbol>()->technique() = TECHNIQUE_SCENE;
else if ( match(c.value(), "gpu") )
style.getOrCreate<AltitudeSymbol>()->technique() = TECHNIQUE_GPU;
else if ( match(c.value(), "drape") )
style.getOrCreate<AltitudeSymbol>()->technique() = TECHNIQUE_DRAPE;
}
else if ( match(c.key(), "altitude-binding") ) {
if ( match(c.value(), "vertex") )
style.getOrCreate<AltitudeSymbol>()->binding() = BINDING_VERTEX;
else if ( match(c.value(), "centroid") )
style.getOrCreate<AltitudeSymbol>()->binding() = BINDING_CENTROID;
}
else if ( match(c.key(), "altitude-resolution") ) {
style.getOrCreate<AltitudeSymbol>()->clampingResolution() = as<float>( c.value(), 0.0f );
}
else if ( match(c.key(), "altitude-offset") ) {
style.getOrCreate<AltitudeSymbol>()->verticalOffset() = NumericExpression( c.value() );
}
else if ( match(c.key(), "altitude-scale") ) {
style.getOrCreate<AltitudeSymbol>()->verticalScale() = NumericExpression( c.value() );
}
}
示例6: switch
//======================================================================
// event-handler methods
//======================================================================
bool Window::processEvent( const Event& event )
{
ConfigEvent configEvent;
switch( event.type )
{
case Event::WINDOW_HIDE:
setPixelViewport( PixelViewport( 0, 0, 0, 0 ));
break;
case Event::WINDOW_SHOW:
case Event::WINDOW_RESIZE:
setPixelViewport( PixelViewport( event.resize.x, event.resize.y,
event.resize.w, event.resize.h ));
break;
case Event::KEY_PRESS:
case Event::KEY_RELEASE:
if( event.key.key == KC_VOID )
return true; // ignore
// else fall through
case Event::WINDOW_EXPOSE:
case Event::WINDOW_CLOSE:
case Event::WINDOW_POINTER_WHEEL:
case Event::STATISTIC:
break;
case Event::WINDOW_POINTER_MOTION:
case Event::WINDOW_POINTER_BUTTON_PRESS:
case Event::WINDOW_POINTER_BUTTON_RELEASE:
{
// dispatch pointer events to destination channel, if any
const Channels& channels = getChannels();
for( Channels::const_iterator i = channels.begin();
i != channels.end(); ++i )
{
Channel* channel = *i;
if( !channel->isDestination( ))
continue;
const PixelViewport& pvp = getPixelViewport();
const PixelViewport& channelPVP =
channel->getNativePixelViewport();
// convert y to GL notation (Channel PVP uses GL coordinates)
const int32_t y = pvp.h - event.pointer.y;
if( !channelPVP.isInside( event.pointer.x, y ))
continue;
Event channelEvent = event;
switch( event.type )
{
case Event::WINDOW_POINTER_MOTION:
channelEvent.type = Event::CHANNEL_POINTER_MOTION;
break;
case Event::WINDOW_POINTER_BUTTON_PRESS:
channelEvent.type = Event::CHANNEL_POINTER_BUTTON_PRESS;
break;
case Event::WINDOW_POINTER_BUTTON_RELEASE:
channelEvent.type = Event::CHANNEL_POINTER_BUTTON_RELEASE;
break;
default:
LBWARN << "Unhandled window event of type " << event.type
<< std::endl;
LBUNIMPLEMENTED;
}
LBASSERT( channel->getID() != UUID::ZERO );
channelEvent.originator = channel->getID();
channelEvent.serial = channel->getSerial();
channelEvent.pointer.x -= channelPVP.x;
channelEvent.pointer.y = channelPVP.h - y + channelPVP.y;
channel->processEvent( channelEvent );
}
break;
}
case Event::WINDOW_SCREENSAVER:
switch( getIAttribute( IATTR_HINT_SCREENSAVER ))
{
case OFF:
return true; // screen saver stays inactive
case ON:
return false; // screen saver becomes active
default: // AUTO
if( getDrawableConfig().doublebuffered &&
getIAttribute( IATTR_HINT_DRAWABLE ) == WINDOW )
{
return true; // screen saver stays inactive
}
return false;
}
case Event::UNKNOWN:
// unknown window-system native event, which was not handled
return false;
default:
//.........这里部分代码省略.........
示例7: SplatCatalog
bool
SplatExtension::connect(MapNode* mapNode)
{
if ( !mapNode )
{
OE_WARN << LC << "Illegal: MapNode cannot be null." << std::endl;
return false;
}
OE_INFO << LC << "Connecting to MapNode.\n";
if ( !_options.catalogURI().isSet() )
{
OE_WARN << LC << "Illegal: catalog URI is required" << std::endl;
return false;
}
if ( !_options.legendURI().isSet() )
{
OE_WARN << LC << "Illegal: legend URI is required" << std::endl;
return false;
}
if ( !_options.coverageLayerName().isSet() )
{
OE_WARN << LC << "Illegal: coverage layer name is required" << std::endl;
return false;
}
// Locate the coverage layer in the map.
const Map* map = mapNode->getMap();
const ImageLayer* coverageLayer = map->getImageLayerByName( _options.coverageLayerName().get() );
if ( !coverageLayer )
{
OE_WARN << LC << "Coverage layer \""
<< _options.coverageLayerName().get()
<< "\" not found in map."
<< std::endl;
return false;
}
// Read in the catalog.
osg::ref_ptr<SplatCatalog> catalog = new SplatCatalog();
{
ReadResult result = _options.catalogURI()->readString( _dbOptions.get() );
if ( result.succeeded() )
{
Config conf;
conf.setReferrer(_options.catalogURI()->full());
std::string json = result.getString();
conf.fromJSON( json );
catalog->fromConfig( conf );
OE_INFO << LC << "Catalog: " << catalog->getClasses().size() << " classes\n";
}
else
{
OE_WARN << LC
<< "Failed to read catalog from \""
<< _options.catalogURI()->full() << "\"\n";
return false;
}
}
// Read in the legend.
osg::ref_ptr<SplatCoverageLegend> legend = new SplatCoverageLegend();
{
ReadResult result = _options.legendURI()->readString( _dbOptions.get() );
if ( result.succeeded() )
{
Config conf;
conf.setReferrer(_options.legendURI()->full());
conf.fromJSON( result.getString() );
legend->fromConfig( conf );
OE_INFO << LC << "Legend: " << legend->getPredicates().size() << " mappings \n";
}
else
{
OE_WARN << LC
<< "Failed to read legend from \""
<< _options.legendURI()->full() << "\"\n";
return false;
}
}
// Install the splatter on the terrain engine.
_effect = new SplatTerrainEffect( catalog, legend, _dbOptions.get() );
// set the coverage layer (mandatory)
_effect->setCoverageLayer( coverageLayer );
// set the render order (optional)
if ( _options.drawAfterImageLayers() == true )
_effect->setRenderOrder( 1.0f );
mapNode->getTerrainEngine()->addEffect( _effect.get() );
//.........这里部分代码省略.........
示例8: initGrx
void TextureUtil::initGrx() {
Config * config = Config::getInstance();
#if EM_USE_SDL
cerr << "Initing SDL" << endl << endl;
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
cerr << "Couldn't initialize SDL video" << SDL_GetError() << endl;
exit(1);
}
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) {
cerr << "Couldn't initialize SDL joystick: " << SDL_GetError() << endl << endl;
} else {
int njoystick = SDL_NumJoysticks();
cerr << njoystick << " joysticks were found." << endl;
if (njoystick != 0) {
cerr << "The names of the joysticks are:" << endl;
for(int a=0; a<njoystick; a++ ) {
cerr << " " << SDL_JoystickName(a) << endl;
}
cerr << "Using " << SDL_JoystickName(0) << endl << endl;
SDL_JoystickOpen(0);
SDL_JoystickEventState(SDL_ENABLE);
}
}
// See if we should detect the display depth
if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8 ) {
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 2 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 3 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 3 );
} else if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 16 ) {
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
} else {
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
}
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
/* Initialize the display */
SDL_Surface* screen =
SDL_SetVideoMode(config->getWidth(), config->getHeight(), config->getBpp(),
SDL_OPENGL
| (config->useFullScreen() ? SDL_FULLSCREEN : 0));
// if (config->useFullScreen()) {
SDL_ShowCursor(SDL_DISABLE);
// }
SDL_WM_SetCaption("Emilia Pinball", NULL);
if (screen == NULL) {
cerr << "Couldn't set video mode: " << SDL_GetError() << endl;
exit(1);
}
cerr << "Vendor : " << glGetString( GL_VENDOR ) << endl;
cerr << "Renderer : " << glGetString( GL_RENDERER ) << endl;
cerr << "Version : " << glGetString( GL_VERSION ) << endl;
cerr << "Extensions : " << glGetString( GL_EXTENSIONS ) << endl << endl;
//TODO: that would be usefull to report CPU/RAM specs also //!rzr
int value;
SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
cerr << "SDL_GL_RED_SIZE: " << value << endl;
SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
cerr << "SDL_GL_GREEN_SIZE: " << value << endl;
SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
cerr << "SDL_GL_BLUE_SIZE: " << value << endl;
SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
cerr << "SDL_GL_DEPTH_SIZE: " << value << endl;
SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
cerr << "SDL_GL_DOUBLEBUFFER: " << value << endl << endl;
this->resizeView(config->getWidth(), config->getHeight());
#endif // EM_USE_SDL
#if EM_USE_ALLEGRO
//config->setSize(320, 240);
allegro_init();
install_keyboard();
install_timer();
install_mouse();
COLOR_MAP colorMap;
RGB_MAP rgbMap;
COLOR_MAP transMap;
RGB* paPalette = (RGB*) calloc(256, sizeof(RGB));
generate_332_palette(paPalette);
// create rgb table
create_rgb_table(&rgbMap, paPalette, NULL);
rgb_map = &rgbMap;
// create light table and setup the truecolor blending functions.
create_light_table(&colorMap, paPalette, 0, 0, 0, NULL);
//.........这里部分代码省略.........
示例9: Config
int Global::init(){
Global::CONFIG_FILE = "game.conf";
Config * config = new Config(Global::CONFIG_FILE);
Global::SCREEN_WIDTH=960;
Global::SCREEN_HEIGHT=540;
Global::SCREEN_RES_WIDTH=atoi(config->getSetting("GAMESETTINGS","RES_X").c_str());
Global::SCREEN_RES_HEIGHT=atoi(config->getSetting("GAMESETTINGS","RES_Y").c_str());;
Global::GRAVITY=840;
//Initialize SDL
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() );
return 1;
}
//Enable VSync
if( !SDL_SetHint( SDL_HINT_RENDER_VSYNC, "1" ) )
{
printf( "Warning: VSync not enabled!" );
}
//Set texture filtering to linear
if( !SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" ) )
{
printf( "Warning: Linear texture filtering not enabled!" );
}
//Create window
Uint32 flags = SDL_WINDOW_SHOWN;
if(config->getSetting("GAMESETTINGS","WINDOW_BORDER").compare("FALSE")==0){
flags = flags|SDL_WINDOW_BORDERLESS;
}
Global::gameWindow = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, Global::SCREEN_RES_WIDTH, Global::SCREEN_RES_HEIGHT, flags);
if( Global::gameWindow == NULL )
{
printf( "Window could not be created! SDL Error: %s\n", SDL_GetError() );
return 1;
}
//Create renderer for window
Global::gameRenderer = SDL_CreateRenderer( Global::gameWindow, -1, SDL_RENDERER_ACCELERATED );
if( Global::gameRenderer == NULL )
{
printf( "Renderer could not be created! SDL Error: %s\n", SDL_GetError() );
return 1;
}
SDL_RenderSetScale(gameRenderer,(float)Global::SCREEN_RES_WIDTH/(float)Global::SCREEN_WIDTH,(float)Global::SCREEN_RES_HEIGHT/(float)Global::SCREEN_HEIGHT);
//Initialize PNG loading
int imgFlags = IMG_INIT_PNG;
if( !( IMG_Init( imgFlags ) & imgFlags ) )
{
printf( "SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError() );
return 1;
}
return 0;
}
示例10: main
// Entry point of the slot machine engine
int main(int argc, char**argv)
{
// Money input
int money = 0;
// Check argc and set flags
if(argc <= 1)
{
DisplayInfos(argv[0]);
return 0;
}
else
{
// Check for flag and money input
for(int i = 1; i < argc; i++)
{
// Flag input
if(argv[i][0] == '-')
{
// Trace enabled
if(strncmp(argv[i], "-t", 2) == 0)
{
g_trace = true;
}
// RTE enabled
else if(strncmp(argv[i], "-rte", 4) == 0)
{
g_rte = true;
}
// Variance enabled
else if(strncmp(argv[i], "-v", 2) == 0)
{
g_var = true;
}
}
// Money input
else
{
money = atoi(argv[i]);
}
}
}
// Check money value
if(money <= 0)
{
DisplayInfos(argv[0]);
return 0;
}
// Reset the random seed at start
// Take the time in µsec in order to get different result all the time
timeval tv;
gettimeofday(&tv, NULL);
std::srand(tv.tv_sec * 1000000 + tv.tv_usec);
// Load main configuration first
Config* config = Config::GetInst();
if(config->GetLoadErr())
{
std::cerr << std::endl << "Error while loading " << CONFIG_FILE << "." << std::endl << "Closing application." << std::endl;
// Delete the config Singleton
config->DeleteSingleton();
return ERR_LOAD_FILE;
}
// Display for debug
if(g_trace)
{
config->DebugPrint();
}
// Load Line Shape Manager Then
LineShapeManager* LSM = LineShapeManager::GetInst();
if(LSM->GetLoadErr())
{
std::cerr << std::endl << "Error while loading " << LINE_SHAPES_FILE << "." << std::endl << "Closing application." << std::endl;
// Delete the LSM Singleton
LSM->DeleteSingleton();
// Delete the config Singleton
config->DeleteSingleton();
return ERR_LOAD_FILE;
}
// Display for debug
if(g_trace)
{
LSM->DebugPrint();
}
// Load Symbol Manager
SymbolManager* SM = SymbolManager::GetInst();
if(SM->GetLoadErr())
{
//.........这里部分代码省略.........
示例11:
Config
MapNodeOptions::getConfig() const
{
Config conf; // start with a fresh one since this is a FINAL object // = ConfigOptions::getConfig();
conf.key() = "options";
conf.updateObjIfSet( "proxy", _proxySettings );
conf.updateIfSet ( "cache_only", _cacheOnly );
conf.updateIfSet ( "lighting", _enableLighting );
conf.updateIfSet ( "terrain", _terrainOptionsConf );
conf.updateIfSet ( "overlay_warping", _overlayVertexWarping );
conf.updateIfSet ( "overlay_blending", _overlayBlending );
conf.updateIfSet ( "overlay_texture_size", _overlayTextureSize );
conf.updateIfSet ( "overlay_mipmapping", _overlayMipMapping );
conf.updateIfSet ( "overlay_attach_stencil", _overlayAttachStencil );
conf.updateIfSet ( "overlay_resolution_ratio", _overlayResolutionRatio );
return conf;
}
示例12: main
int main(int argc, char *argv[])
{
Config config;
config.setValue("bool", true);
config.setValue("int", 21334);
config.setValue("string", "babablsh?");
config.setValue("awful string::", "babablsh? Hayouasd");
Config merge;
merge.setValue("test", "lololo");
merge.setValue("test/subkey", "..adasdasd");
config.beginGroup("group");
config.addValues(merge);
config.beginGroup("test");
config.values().save("test_subkeys.conf");
config.endGroup();
config.endGroup();
config.save("test.conf");
Config *read = Config::load("test.conf");
assert(read);
assert(read->boolValue("bool") == true);
assert(read->intValue("int") == 21334);
assert(read->stringValue("awful string::").compare("babablsh? Hayouasd") == 0);
delete read;
return 0;
}
示例13:
Config
AltitudeSymbol::getConfig() const
{
Config conf;
conf.key() = "altitude";
conf.addIfSet ( "clamping", "none", _clamping, CLAMP_NONE );
conf.addIfSet ( "clamping", "terrain", _clamping, CLAMP_TO_TERRAIN );
conf.addIfSet ( "clamping", "absolute", _clamping, CLAMP_ABSOLUTE );
conf.addIfSet ( "clamping", "relative", _clamping, CLAMP_RELATIVE_TO_TERRAIN );
conf.addIfSet ( "technique", "map", _technique, TECHNIQUE_MAP );
conf.addIfSet ( "technique", "scene", _technique, TECHNIQUE_SCENE );
conf.addIfSet ( "technique", "gpu", _technique, TECHNIQUE_GPU );
conf.addIfSet ( "technique", "drape", _technique, TECHNIQUE_DRAPE );
conf.addIfSet ( "binding", "vertex", _binding, BINDING_VERTEX );
conf.addIfSet ( "binding", "centroid", _binding, BINDING_CENTROID );
conf.addIfSet ( "clamping_resolution", _resolution );
conf.addObjIfSet( "vertical_offset", _verticalOffset );
conf.addObjIfSet( "vertical_scale", _verticalScale );
return conf;
}
示例14: TrainTargetByLabel
// Training of client Speakers
// The same than TrainTarget but train simultaneoulsy 1 model for each cluster (set of segments with the same label)
// found in the input files labels.
// One option in order to save the n models as a modification of the world model - save disk space
int TrainTargetByLabel(Config& config)
{
String inputClientListFileName = config.getParam("targetIdList");
String inputWorldFilename = config.getParam("inputWorldFilename");
String outputSERVERFilename = config.getParam("mixtureServer");
// label for selected frames - Only the frames associated with this label, in the label files, will be used
//bool fixedLabelSelectedFrame;
bool initByClient=false;
bool aprioriWorld=true;
if (config.existsParam("initByClient")) initByClient=true;
if (config.existsParam("aprioriClient")){
aprioriWorld=false;
initByClient=true;
}
bool saveCompleteServer=false;
bool outputAdaptParam=false;
if (config.existsParam("outputAdaptParam")) outputAdaptParam=config.getParam("outputAdaptParam").toBool();
try{
XList inputClientList(inputClientListFileName,config); // read the Id + filenames for each client
XLine *linep;
inputClientList.getLine(0);
MixtureServer ms(config);
StatServer ss(config, ms);
if (verbose) cout << "TrainTarget - by label opption - Load world model [" << inputWorldFilename<<"]"<<endl;
MixtureGD& world = ms.loadMixtureGD(inputWorldFilename);
// *********** Target loop *****************
while ((linep=inputClientList.getLine()) != NULL){ // linep gives the XLine with the Id of a given client and the list of files
String clientId=(*linep->getElement()); // Get the Client ID (clientId)
XLine featureFileListp=linep->getElements(); // Get the list of feature file for the client (end of the line)
FeatureServer fs(config,featureFileListp); // Reading the features (from several files)
if (verbose) cout << "Train label models for client ["<<clientId<<"]"<<endl;
MixtureGD &clientGModel=ms.createMixtureGD();
if (initByClient) {
if (verbose) cout << "Load client model [" << clientId <<"]"<<endl;
clientGModel = ms.loadMixtureGD(clientId); //not necessary to load client model
}
SegServer segmentsServer; // Create the segment server for managing the segments/clusters
LabelServer labelServer; // Create the lable server, for indexing the segments/clusters
initializeClusters(featureFileListp,segmentsServer,labelServer,config); // Reading the segmentation files for each feature input file
verifyClusterFile(segmentsServer,fs,config); // Verify if the segments ending before the end of the feature files...
for (unsigned long codeSelectedFrame=0;codeSelectedFrame<segmentsServer.getClusterCount();codeSelectedFrame++){ // For each cluster
String clientIdByLabel=clientId+"_"+labelServer.getLabel(codeSelectedFrame).getString(); // Build the model name for the client and the label
if (verbose) cout << "Train labeldependent model ["<<clientIdByLabel<<"]"<<endl;
SegCluster& selectedSegments=segmentsServer.getCluster(codeSelectedFrame); // Gives the cluster of the selected/used segments
MixtureGD & clientMixture = ms.duplicateMixture(world,DUPL_DISTRIB); // Creating clientMixture as a copy of the world model
ms.setMixtureId(clientMixture,clientIdByLabel); // Set the client model Id
if (initByClient) // During trainig data statistic estimation by EM,
clientMixture=clientGModel; // the global client model is used for initalization
if (aprioriWorld) // EM algo with MAP criterion
adaptModel(config,ss,ms,fs,selectedSegments,world,clientMixture); // A priori info is the world model
else adaptModel(config,ss,ms,fs,selectedSegments,clientGModel,clientMixture);// A priori info is the client model-by default initByClient is also set
if (!outputAdaptParam) {
if (verbose) cout << "Save client model ["<<clientIdByLabel<<"]" << endl;
clientMixture.save(clientIdByLabel, config); // Save the client model
}
if (!saveCompleteServer){
long tid=ms.getMixtureIndex(clientIdByLabel); // TO BE SUPPRESSED BY
ms.deleteMixtures(tid,tid); // ADDING a delete on a mixture pointor
ms.deleteUnusedDistribs();
}
}
if (!saveCompleteServer){
long tid=ms.getMixtureIndex(clientId); // TO BE SUPPRESSED BY
ms.deleteMixtures(tid,tid); // ADDING a delete on a mixture pointor
ms.deleteUnusedDistribs();
} // end of the the label loop fr a speaker
} // end of the the target loop
// Save the complete mixture server
// TODO
} // fin try
catch (Exception& e)
{
cout << e.toString().c_str() << endl;
}
return 0;
}
示例15: TrainTargetFA
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
int TrainTargetFA(Config& config)
{
String inputClientListFileName = config.getParam("targetIdList");
String inputWorldFilename = config.getParam("inputWorldFilename");
String outputSERVERFilename = "";
if (config.existsParam("mixtureServer")) outputSERVERFilename =config.getParam("mixtureServer");
bool initByClient=false; // In this case, the init model is read from the file
if (config.existsParam("initByClient")) initByClient=config.getParam("initByClient").toBool();
bool saveEmptyModel=false;
if (config.existsParam("saveEmptyModel")) saveEmptyModel=config.getParam("saveEmptyModel").toBool();
// label for selected frames - Only the frames associated with this label, in the label files, will be used
bool fixedLabelSelectedFrame=true;
String labelSelectedFrames;
if (config.existsParam("useIdForSelectedFrame")) // the ID of each speaker is used as labelSelectedFrame ?
fixedLabelSelectedFrame=(config.getParam("useIdForSelectedFrame").toBool()==false);
if (fixedLabelSelectedFrame) // the label is decided by the command line and is unique for the run
labelSelectedFrames=config.getParam("labelSelectedFrames");
bool modelData=false;
if (config.existsParam("useModelData")) modelData=config.getParam("useModelData").toBool();
String initModelS=inputWorldFilename;
if (modelData) if (config.existsParam("initModel")) initModelS=config.getParam("initModel"); // Use a specific model for Em init
bool outputAdaptParam=false;
if (config.existsParam("superVectors")) outputAdaptParam=true;
Matrix <double> ChannelMatrix;
if (verbose) cout<< "EigenMAP and Eigenchannel with [" << config.getParam("initChannelMatrix") << "] of size: [";
ChannelMatrix.load(config.getParam("initChannelMatrix"),config); //get Channel Matrix from args and load in a Matrix object
if (verbose) cout << ChannelMatrix.rows() << "," <<ChannelMatrix.cols() << "]" << endl;
bool varAdapt=false;
if (config.existsParam("FAVarAdapt")) varAdapt=true;
bool saveCompleteServer=false;
try{
XList inputClientList(inputClientListFileName,config); // read the Id + filenames for each client
XLine * linep;
inputClientList.getLine(0);
MixtureServer ms(config);
StatServer ss(config, ms);
if (verbose) cout << "(TrainTarget) Factor Analysis - Load world model [" << inputWorldFilename<<"]"<<endl;
MixtureGD& world = ms.loadMixtureGD(inputWorldFilename);
if (verbose) cout <<"(TrainTarget) Use["<<initModelS<<"] for initializing EM"<<endl;
// *********** Target loop *****************
while ((linep=inputClientList.getLine()) != NULL){ // linep gives the XLine with the Id of a given client and the list of files
String *id=linep->getElement(); // Get the Client ID (id)
XLine featureFileListp=linep->getElements(); // Get the list of feature file for the client (end of the line)
if (verbose) cout << "(TrainTarget) Train model ["<<*id<<"]"<<endl;
FeatureServer fs(config,featureFileListp); // Reading the features (from several files)
SegServer segmentsServer; // Create the segment server for managing the segments/clusters
LabelServer labelServer; // Create the lable server, for indexing the segments/clusters
initializeClusters(featureFileListp,segmentsServer,labelServer,config); // Reading the segmentation files for each feature input file
verifyClusterFile(segmentsServer,fs,config); // Verify if the segments ending before the end of the feature files...
MixtureGD & adaptedMixture = ms.duplicateMixture(world,DUPL_DISTRIB); // Creating final as a copy of the world model
MixtureGD & clientMixture= ms.duplicateMixture(world,DUPL_DISTRIB);
long codeSelectedFrame=labelServer.getLabelIndexByString(labelSelectedFrames); // Get the index of the cluster with in interest audio segments
if (codeSelectedFrame==-1){ // No data for this model !!!!!!!!!!!!!!
cout << " WARNING - NO DATA FOR TRAINING ["<<*id<<"]";
if (saveEmptyModel){
cout <<" World model is returned"<<endl; // In this case, the client model is the world model
if (verbose) cout << "Save client model ["<<*id<<"]" << endl;
adaptedMixture.save(*id, config); // Save the client model
}
}
else{
SegCluster& selectedSegments=segmentsServer.getCluster(codeSelectedFrame); // Gives the cluster of the selected/used segments
/// **** Factor Analysis Stuff
XList faNdx;
faNdx.addLine()=featureFileListp;
FactorAnalysisStat FA(faNdx,fs,config); // give all features to FA stats
//FA.computeAndAccumulateGeneralFAStats(selectedSegments,fs,config);
for(int i=0;i<config.getParam("nbTrainIt").toLong();i++){
if (verbose) cout << "------ Iteration ["<<i<<"] ------"<<endl;
FA.computeAndAccumulateGeneralFAStats(selectedSegments,fs,config);
/*if (!varAdapt) FA.getTrueSpeakerModel(clientMixture,linep->getElement(1));
else FA.getFactorAnalysisModel(clientMixture,linep->getElement(1));
if (verbose) cout << "LLK for model["<<*id<<"] at it["<<i-1<<"]="<<FA.getLLK(selectedSegments,clientMixture,fs,config) << endl; */
FA.estimateAndInverseL(config);
FA.substractSpeakerStats();
FA.getXEstimate();
FA.substractChannelStats();
FA.getYEstimate();
}
MixtureGD & sessionMixture= ms.duplicateMixture(world,DUPL_DISTRIB);
bool saveSessionModel=false;
if (config.existsParam("saveSessionModel")) saveSessionModel=true;
if (saveSessionModel) FA.getSessionModel(sessionMixture,linep->getElement(1));
if (!varAdapt) FA.getTrueSpeakerModel(clientMixture,linep->getElement(1)); // basically compute M_s_h=M+Dy_s and get a model
else FA.getFactorAnalysisModel(clientMixture,linep->getElement(1)); // get FA variance adapted model
if (verbose) cout << "Final LLK for model["<<*id<<"]="<<FA.getLLK(selectedSegments,clientMixture,fs,config) << endl;
/// **** End of FA
if (!outputAdaptParam) {
if (verbose) cout << "Save client model ["<<*id<<"]" << endl;
clientMixture.save(*id, config); // Save the client model
if (saveSessionModel) {
String sessionfile=*id+".session";
if (verbose) cout << "Save session model ["<<sessionfile<<"]" << endl;
sessionMixture.save(sessionfile,config);
//.........这里部分代码省略.........