/************************************************************************* returns a pointer to the requested WindowFactory object *************************************************************************/ WindowFactory* WindowFactoryManager::getFactory(const String& type) const { // first, dereference aliased types, as needed. String targetType(getDereferencedAliasType(type)); // try for a 'real' type WindowFactoryRegistry::const_iterator pos = d_factoryRegistry.find(targetType); // found an actual factory for this type if (pos != d_factoryRegistry.end()) { return pos->second; } // no concrete type, try for a falagard mapped type else { FalagardMapRegistry::const_iterator falagard = d_falagardRegistry.find(targetType); // found falagard mapping for this type if (falagard != d_falagardRegistry.end()) { // recursively call getFactory on the target base type return getFactory(falagard->second.d_baseType); } // type not found anywhere, give up with an exception. else { throw UnknownObjectException("WindowFactoryManager::getFactory - A WindowFactory object, an alias, or mapping for '" + type + "' Window objects is not registered with the system."); } } }
//----------------------------------------------------------------------------// Image& ImageManager::create(const String& type, const String& name) { if (d_images.find(name) != d_images.end()) CEGUI_THROW(AlreadyExistsException( "Image already exists: " + name)); ImageFactoryRegistry::iterator i(d_factories.find(type)); if (i == d_factories.end()) CEGUI_THROW(UnknownObjectException( "Unknown Image type: " + type)); ImageFactory* factory = i->second; Image& image = factory->create(name); d_images[name] = std::make_pair(&image, factory); char addr_buff[32]; sprintf(addr_buff, "%p", static_cast<void*>(&image)); Logger::getSingleton().logEvent( "[ImageManager] Created image: '" + name + "' (" + addr_buff + ") of type: " + type); return image; }
/************************************************************************* Return the tab button for the given tab content window *************************************************************************/ TabButton* TabControl::getButtonForTabContents(Window* wnd) const { for (size_t i = 0; i < d_tabButtonVector.size (); ++i) if (d_tabButtonVector [i]->getTargetWindow () == wnd) return d_tabButtonVector [i]; throw UnknownObjectException("TabControl::getButtonForTabContents - The Window object is not a tab contents."); }
/************************************************************************* Return whether the tab content window is currently selected. *************************************************************************/ size_t TabControl::getSelectedTabIndex() const { for (size_t i = 0; i < d_tabButtonVector.size (); ++i) if (d_tabButtonVector [i]->isSelected ()) return i; throw UnknownObjectException("TabControl::getSelectedTabIndex - Current tab not in list?"); }
/************************************************************************* Get the named WindowRenderer *************************************************************************/ WindowRendererFactory* WindowRendererManager::getFactory(const String& name) const { WR_Registry::const_iterator i = d_wrReg.find(name); if (i != d_wrReg.end()) { return (*i).second; } CEGUI_THROW(UnknownObjectException("There is no WindowRendererFactory named '"+name+"' available")); }
//----------------------------------------------------------------------------// Texture& Direct3D10Renderer::getTexture(const String& name) const { TextureMap::const_iterator i = d_textures.find(name); if (i == d_textures.end()) CEGUI_THROW(UnknownObjectException("Texture does not exist: " + name)); return *i->second; }
//----------------------------------------------------------------------------// Image& ImageManager::get(const String& name) const { ImageMap::const_iterator i = d_images.find(name); if (i == d_images.end()) CEGUI_THROW(UnknownObjectException( "Image not defined: " + name)); return *i->second.first; }
//----------------------------------------------------------------------------// Texture& DirectFBRenderer::getTexture(const String& name) const { TextureMap::const_iterator i = d_textures.find(name); if (i == d_textures.end()) CEGUI_THROW(UnknownObjectException( "No texture named '" + name + "' is available.")); return *i->second; }
//----------------------------------------------------------------------------// NamedElement* NamedElement::getChildElement(const String& name_path) const { NamedElement* e = getChildByNamePath_impl(name_path); if (e) return e; CEGUI_THROW(UnknownObjectException("The Element object " "referenced by '" + name_path + "' is not attached to Element at '" + getNamePath() + "'.")); }
/************************************************************************* return the Image object for the named image *************************************************************************/ const Image& Imageset::getImage(const String& name) const { ImageRegistry::const_iterator pos = d_images.find(name); if (pos == d_images.end()) { throw UnknownObjectException("Imageset::getImage - The Image named '" + name + "' could not be found in Imageset '" + d_name + "'."); } return pos->second; }
Scheme& SchemeManager::get(const String& object_name) const { SchemeRegistry::const_iterator i(d_registeredSchemes.find(object_name)); if (i == d_registeredSchemes.end()) throw UnknownObjectException( "No object of type '" + d_resourceType + "' named '" + object_name + "' is present in the collection."); return *i->second; }
const ImagerySection& WidgetLookFeel::getImagerySection(const CEGUI::String& section) const { ImageryList::const_iterator imgSect = d_imagerySections.find(section); if (imgSect == d_imagerySections.end()) { throw UnknownObjectException("WidgetLookFeel::getImagerySection - unknown imagery section '" + section + "' in look '" + d_lookName + "'."); } return (*imgSect).second; }
//----------------------------------------------------------------------------// void NamedElement::removeChild(const String& name_path) { NamedElement* e = getChildByNamePath_impl(name_path); if (e) removeChild(e); else CEGUI_THROW(UnknownObjectException("The Element object " "referenced by '" + name_path + "' is not attached to Element at '" + getNamePath() + "'.")); }
/************************************************************************* Set the current value of a property *************************************************************************/ void PropertySet::setProperty(const String& name,const String& value) { PropertyRegistry::iterator pos = d_properties.find(name); if (pos == d_properties.end()) { CEGUI_THROW(UnknownObjectException("There is no Property named '" + name + "' available in the set.")); } pos->second->set(this, value); }
const NamedArea& WidgetLookFeel::getNamedArea(const String& name) const { NamedAreaList::const_iterator area = d_namedAreas.find(name); if (area == d_namedAreas.end()) { throw UnknownObjectException("WidgetLookFeel::getNamedArea - unknown named area: '" + name + "' in look '" + d_lookName + "'."); } return (*area).second; }
/************************************************************************* Return a pointer to the named window *************************************************************************/ Window* WindowManager::getWindow(const String& name) const { WindowRegistry::const_iterator pos = d_windowRegistry.find(name); if (pos == d_windowRegistry.end()) { throw UnknownObjectException("WindowManager::getWindow - A Window object with the name '" + name +"' does not exist within the system"); } return pos->second; }
/************************************************************************* Returns a pointer to the Scheme object with the specified name. *************************************************************************/ Scheme* SchemeManager::getScheme(const String& name) const { SchemeRegistry::const_iterator pos = d_schemes.find(name); if (pos == d_schemes.end()) { throw UnknownObjectException("SchemeManager::getScheme - A Scheme object with the specified name '" + name +"' does not exist within the system"); } return pos->second; }
/************************************************************************* Returns a pointer to the Imageset object with the specified name *************************************************************************/ Imageset* ImagesetManager::getImageset(const String& name) const { ImagesetRegistry::const_iterator pos = d_imagesets.find(name); if (pos == d_imagesets.end()) { throw UnknownObjectException("ImagesetManager::getImageset - No Imageset named '" + name + "' is present in the system."); } return pos->second; }
const StateImagery& WidgetLookFeel::getStateImagery(const CEGUI::String& state) const { StateList::const_iterator imagery = d_stateImagery.find(state); if (imagery == d_stateImagery.end()) { throw UnknownObjectException("WidgetLookFeel::getStateImagery - unknown state '" + state + "' in look '" + d_lookName + "'."); } return (*imagery).second; }
const WidgetLookFeel& WidgetLookManager::getWidgetLook(const String& widget) const { WidgetLookList::const_iterator wlf = d_widgetLooks.find(widget); if (wlf != d_widgetLooks.end()) { return (*wlf).second; } throw UnknownObjectException("WidgetLookManager::getWidgetLook - Widget look and feel '" + widget + "' does not exist."); }
/************************************************************************* Return the help string for a property *************************************************************************/ const String& PropertySet::getPropertyHelp(const String& name) const { PropertyRegistry::const_iterator pos = d_properties.find(name); if (pos == d_properties.end()) { CEGUI_THROW(UnknownObjectException("There is no Property named '" + name + "' available in the set.")); } return pos->second->getHelp(); }
/************************************************************************* Return a pointer to the named font *************************************************************************/ FontBase* FontManager::getFont(const String& name) const { FontRegistry::const_iterator pos = d_fonts.find(name); if (pos == d_fonts.end()) { throw UnknownObjectException("FontManager::getFont - A Font object with the specified name '" + name +"' does not exist within the system"); } return pos->second; }
//----------------------------------------------------------------------------// Animation* AnimationManager::getAnimation(const String& name) const { AnimationMap::const_iterator it = d_animations.find(name); if (it == d_animations.end()) { CEGUI_THROW(UnknownObjectException("Animation with name '" + name + "' not found.")); } return it->second; }
//----------------------------------------------------------------------------// Interpolator* AnimationManager::getInterpolator(const String& type) const { InterpolatorMap::const_iterator it = d_interpolators.find(type); if (it == d_interpolators.end()) { CEGUI_THROW(UnknownObjectException("Interpolator of type '" + type + "' not found.")); } return it->second; }
//----------------------------------------------------------------------------// void AnimationManager::removeInterpolator(Interpolator* interpolator) { InterpolatorMap::iterator it = d_interpolators.find(interpolator->getType()); if (it == d_interpolators.end()) { CEGUI_THROW(UnknownObjectException("Interpolator of type '" + interpolator->getType() + "' not found.")); } d_interpolators.erase(it); }
const String& XMLAttributes::getValue(const String& attrName) const { AttributeMap::const_iterator pos = d_attrs.find(attrName); if (pos != d_attrs.end()) { return (*pos).second; } else { throw UnknownObjectException("XMLAttributes::getValue - no value exists for an attribute named '" + attrName + "'."); } }
//----------------------------------------------------------------------------// void FactoryModule::registerFactory(const String& type_name) { FactoryRegistry::iterator i = d_registry.begin(); for ( ; i != d_registry.end(); ++i) { if ((*i)->d_type == type_name) { (*i)->registerFactory(); return; } } CEGUI_THROW(UnknownObjectException("No factory for type '" + type_name + "' in this module.")); }
//----------------------------------------------------------------------------// Animation* AnimationManager::createAnimation(const String& name) { if (isAnimationPresent(name)) { CEGUI_THROW(UnknownObjectException("Animation with name '" + name + "' already exists.")); } String finalName(name.empty() ? generateUniqueAnimationName() : name); Animation* ret = CEGUI_NEW_AO Animation(finalName); d_animations.insert(std::make_pair(finalName, ret)); return ret; }
//----------------------------------------------------------------------------// Image& ImageManager::create(const XMLAttributes& attributes) { static const String type_default("BasicImage"); const String& type(attributes.getValueAsString(ImageTypeAttribute, type_default)); const String& name(attributes.getValueAsString(ImageNameAttribute)); if (name.empty()) CEGUI_THROW(InvalidRequestException( "Invalid (empty) image name passed to create.")); if (d_images.find(name) != d_images.end()) CEGUI_THROW(AlreadyExistsException( "Image already exists: " + name)); ImageFactoryRegistry::iterator i(d_factories.find(type)); if (i == d_factories.end()) CEGUI_THROW(UnknownObjectException( "Unknown Image type: " + type)); ImageFactory* factory = i->second; Image& image = factory->create(attributes); // sanity check that the created image uses the name specified in the // attributes block if (image.getName() != name) { const String message( "Factory for type: " + type + " created Image named: " + image.getName() + ". Was expecting name: " + name); factory->destroy(image); CEGUI_THROW(InvalidRequestException(message)); } d_images[name] = std::make_pair(&image, factory); char addr_buff[32]; sprintf(addr_buff, "%p", static_cast<void*>(&image)); Logger::getSingleton().logEvent( "[ImageManager] Created image: '" + name + "' (" + addr_buff + ") of type: " + type); return image; }
//----------------------------------------------------------------------------// void AnimationManager::destroyAnimation(const String& name) { AnimationMap::iterator it = d_animations.find(name); if (it == d_animations.end()) { CEGUI_THROW(UnknownObjectException("Animation with name '" + name + "' not found.")); } Animation* animation = it->second; destroyAllInstancesOfAnimation(animation); d_animations.erase(it); CEGUI_DELETE_AO animation; }