}
}
+void Builder::AddConstant( const std::string& key, const Property::Value& value )
+{
+ mReplacementMap[key] = value;
+}
+
+const PropertyValueMap& Builder::GetConstants() const
+{
+ return mReplacementMap;
+}
+
+const Property::Value& Builder::GetConstant( const std::string& key ) const
+{
+ PropertyValueMap::const_iterator iter = mReplacementMap.find( key );
+ if( iter != mReplacementMap.end() )
+ {
+ return (*iter).second;
+ }
+ else
+ {
+ static Property::Value invalid;
+ return invalid;
+ }
+}
+
void Builder::LoadConstants()
{
Replacement replacer(mReplacementMap);
void AddConstants( const PropertyValueMap& map );
/**
+ * @copydoc Toolkit::Builder::AddConstant
+ */
+ void AddConstant( const std::string& key, const Property::Value& value );
+
+ /**
+ * @copydoc Toolkit::Builder::GetConstants
+ */
+ const PropertyValueMap& GetConstants() const;
+
+ /**
+ * @copydoc Toolkit::Builder::GetConstant
+ */
+ const Property::Value& GetConstant( const std::string& key ) const;
+
+ /**
* @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName );
*/
Animation CreateAnimation( const std::string& animationName );
GetImpl(*this).AddConstants( map );
}
+void Builder::AddConstant( const std::string& key, const Property::Value& value )
+{
+ GetImpl(*this).AddConstant( key, value );
+}
+
+const PropertyValueMap& Builder::GetConstants() const
+{
+ return GetImpl(*this).GetConstants();
+}
+
+const Property::Value& Builder::GetConstant( const std::string& key ) const
+{
+ return GetImpl(*this).GetConstant( key );
+}
+
Animation Builder::CreateAnimation( const std::string& animationName )
{
return GetImpl(*this).CreateAnimation( animationName );
void AddConstants( const PropertyValueMap& map );
/**
+ * @brief Adds or modifies a user defined constant to all future style template or animation expansions
+ *
+ * e.g.
+ * @code builder.AddConstant( "IMAGE_DIRECTORY", "/usr/share/images" );
+ *
+ * @pre The Builder has been initialized.
+ * @param key The constant name to add or update
+ * @param value The new value for the constant.
+ */
+ void AddConstant( const std::string& key, const Property::Value& value );
+
+ /**
+ * @brief Gets all currently defined constants.
+ *
+ * e.g.
+ * @code PropertyValueMap map = builder.GetConstants(); // get copy of current constants
+ * map["IMAGE_DIRECTORY"] = "/usr/share/images"; // make modification
+ * builder.AddConstants( map ); // write back changes
+ *
+ * @pre The Builder has been initialized.
+ * @return A reference to the currently defined constants.
+ */
+ const PropertyValueMap& GetConstants() const;
+
+ /**
+ * @brief Gets a currently defined constant, or returns Property::INVALID
+ *
+ * e.g.
+ * @code PropertyValueMap map = builder.GetConstants(); // get copy of current constants
+ * map["IMAGE_DIRECTORY"] = "/usr/share/images"; // make modification
+ * builder.AddConstants( map ); // write back changes
+ *
+ * @pre The Builder has been initialized.
+ * @param key The constant name to search for.
+ */
+ const Property::Value& GetConstant( const std::string& key ) const;
+
+ /**
* Creates an animation from the set of known animations
* e.g.
* Animation a = builder.CreateAnimation( "wobble");