summaryrefslogtreecommitdiff
path: root/indra/llxuixml/llinitparam.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llxuixml/llinitparam.cpp')
-rw-r--r--indra/llxuixml/llinitparam.cpp93
1 files changed, 33 insertions, 60 deletions
diff --git a/indra/llxuixml/llinitparam.cpp b/indra/llxuixml/llinitparam.cpp
index 4c050844f8..0b324a10c9 100644
--- a/indra/llxuixml/llinitparam.cpp
+++ b/indra/llxuixml/llinitparam.cpp
@@ -3,31 +3,25 @@
* @brief parameter block abstraction for creating complex objects and
* parsing construction parameters from xml and LLSD
*
- * $LicenseInfo:firstyear=2008&license=viewergpl$
- *
- * Copyright (c) 2008-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2008&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -84,8 +78,8 @@ namespace LLInitParam
// BaseBlock
//
BaseBlock::BaseBlock()
- : mLastChangedParam(0),
- mChangeVersion(0)
+ : mChangeVersion(0),
+ mBlockDescriptor(NULL)
{}
BaseBlock::~BaseBlock()
@@ -137,15 +131,15 @@ namespace LLInitParam
}
- bool BaseBlock::validateBlock(bool silent) const
+ bool BaseBlock::validateBlock(bool emit_errors) const
{
- const BlockDescriptor& block_data = getBlockDescriptor();
+ const BlockDescriptor& block_data = mostDerivedBlockDescriptor();
for (BlockDescriptor::param_validation_list_t::const_iterator it = block_data.mValidationList.begin(); it != block_data.mValidationList.end(); ++it)
{
const Param* param = getParamFromHandle(it->first);
if (!it->second(param))
{
- if (!silent)
+ if (emit_errors)
{
llwarns << "Invalid param \"" << getParamName(block_data, param) << "\"" << llendl;
}
@@ -159,7 +153,7 @@ namespace LLInitParam
{
// named param is one like LLView::Params::follows
// unnamed param is like LLView::Params::rect - implicit
- const BlockDescriptor& block_data = getBlockDescriptor();
+ const BlockDescriptor& block_data = mostDerivedBlockDescriptor();
for (BlockDescriptor::param_list_t::const_iterator it = block_data.mUnnamedParams.begin();
it != block_data.mUnnamedParams.end();
@@ -230,7 +224,7 @@ namespace LLInitParam
{
// named param is one like LLView::Params::follows
// unnamed param is like LLView::Params::rect - implicit
- const BlockDescriptor& block_data = getBlockDescriptor();
+ const BlockDescriptor& block_data = mostDerivedBlockDescriptor();
for (BlockDescriptor::param_list_t::const_iterator it = block_data.mUnnamedParams.begin();
it != block_data.mUnnamedParams.end();
@@ -301,7 +295,7 @@ namespace LLInitParam
bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack)
{
- BlockDescriptor& block_data = getBlockDescriptor();
+ BlockDescriptor& block_data = mostDerivedBlockDescriptor();
bool names_left = name_stack.first != name_stack.second;
if (names_left)
@@ -347,7 +341,6 @@ namespace LLInitParam
if (deserialize_func && deserialize_func(*paramp, p, name_stack, name_stack.first == name_stack.second ? -1 : name_stack.first->second))
{
- mLastChangedParam = (*it)->mParamHandle;
return true;
}
}
@@ -387,7 +380,7 @@ namespace LLInitParam
void BaseBlock::addSynonym(Param& param, const std::string& synonym)
{
- BlockDescriptor& block_data = getBlockDescriptor();
+ BlockDescriptor& block_data = mostDerivedBlockDescriptor();
if (block_data.mInitializationState == BlockDescriptor::INITIALIZING)
{
param_handle_t handle = getHandleFromParam(&param);
@@ -416,8 +409,10 @@ namespace LLInitParam
void BaseBlock::setLastChangedParam(const Param& last_param, bool user_provided)
{
- mLastChangedParam = getHandleFromParam(&last_param);
- mChangeVersion++;
+ if (user_provided)
+ {
+ mChangeVersion++;
+ }
}
const std::string& BaseBlock::getParamName(const BlockDescriptor& block_data, const Param* paramp) const
@@ -444,7 +439,7 @@ namespace LLInitParam
ParamDescriptor* BaseBlock::findParamDescriptor(param_handle_t handle)
{
- BlockDescriptor& descriptor = getBlockDescriptor();
+ BlockDescriptor& descriptor = mostDerivedBlockDescriptor();
BlockDescriptor::all_params_list_t::iterator end_it = descriptor.mAllParams.end();
for (BlockDescriptor::all_params_list_t::iterator it = descriptor.mAllParams.begin();
it != end_it;
@@ -457,30 +452,9 @@ namespace LLInitParam
// take all provided params from other and apply to self
// NOTE: this requires that "other" is of the same derived type as this
- bool BaseBlock::overwriteFromImpl(BlockDescriptor& block_data, const BaseBlock& other)
- {
- bool param_changed = false;
- BlockDescriptor::all_params_list_t::const_iterator end_it = block_data.mAllParams.end();
- for (BlockDescriptor::all_params_list_t::const_iterator it = block_data.mAllParams.begin();
- it != end_it;
- ++it)
- {
- const Param* other_paramp = other.getParamFromHandle(it->mParamHandle);
- ParamDescriptor::merge_func_t merge_func = it->mMergeFunc;
- if (merge_func)
- {
- Param* paramp = getParamFromHandle(it->mParamHandle);
- param_changed |= merge_func(*paramp, *other_paramp, true);
- mLastChangedParam = it->mParamHandle;
- }
- }
- return param_changed;
- }
-
- // take all provided params that are not already provided, and apply to self
- bool BaseBlock::fillFromImpl(BlockDescriptor& block_data, const BaseBlock& other)
+ bool BaseBlock::merge(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite)
{
- bool param_changed = false;
+ bool some_param_changed = false;
BlockDescriptor::all_params_list_t::const_iterator end_it = block_data.mAllParams.end();
for (BlockDescriptor::all_params_list_t::const_iterator it = block_data.mAllParams.begin();
it != end_it;
@@ -491,11 +465,10 @@ namespace LLInitParam
if (merge_func)
{
Param* paramp = getParamFromHandle(it->mParamHandle);
- param_changed |= merge_func(*paramp, *other_paramp, false);
- mLastChangedParam = it->mParamHandle;
+ some_param_changed |= merge_func(*paramp, *other_paramp, overwrite);
}
}
- return param_changed;
+ return some_param_changed;
}
bool ParamCompare<LLSD, false>::equals(const LLSD &a, const LLSD &b)