Commits

richard_linden committed 5ff142d

added Flag as new param type...
usage: <foo><bar/></foo> will set the bar flag on foo
LLSD foo; foo["bar"]; will set the bar flag on foo
converted notifications unique to use flag

Comments (0)

Files changed (5)

indra/llui/llnotificationtemplate.h

 	{
 	private:
 		// this idiom allows 
-		// <notification unique="true">
+		// <notification> <unique/> </notification>
 		// as well as
 		// <notification> <unique> <context></context> </unique>...
-		Optional<bool>			dummy_val;
+		Flag			dummy_val;
 	public:
 		Multiple<UniquenessContext>	contexts;
 

indra/llui/lluictrlfactory.h

 
 	// base case for recursion, there are NO base classes of LLInitParam::BaseBlock
 	template<int DUMMY>
-	class ParamDefaults<LLInitParam::BaseBlock, DUMMY> : public LLSingleton<ParamDefaults<LLInitParam::BaseBlock, DUMMY> >
+	class ParamDefaults<LLInitParam::BaseBlockWithFlags, DUMMY> : public LLSingleton<ParamDefaults<LLInitParam::BaseBlockWithFlags, DUMMY> >
 	{
 	public:
-		const LLInitParam::BaseBlock& get() { return mBaseBlock; }
+		const LLInitParam::BaseBlockWithFlags& get() { return mBaseBlock; }
 	private:
-		LLInitParam::BaseBlock mBaseBlock;
+		LLInitParam::BaseBlockWithFlags mBaseBlock;
 	};
 
 public:

indra/llxuixml/llinitparam.h

 	protected:
 		bool anyProvided() const { return mIsProvided; }
 
-		Param(class BaseBlock* enclosing_block);
+		Param(BaseBlock* enclosing_block);
 
 		// store pointer to enclosing block as offset to reduce space and allow for quick copying
-		class BaseBlock& enclosingBlock() const
+		BaseBlock& enclosingBlock() const
 		{ 
 			const U8* my_addr = reinterpret_cast<const U8*>(this);
 			// get address of enclosing BLOCK class using stored offset to enclosing BaseBlock class
-			return *const_cast<class BaseBlock*>
-				(reinterpret_cast<const class BaseBlock*>
+			return *const_cast<BaseBlock*>
+				(reinterpret_cast<const BaseBlock*>
 					(my_addr - (ptrdiff_t)(S32)mEnclosingBlockOffset));
 		}
 
 	private:
-		friend class BaseBlock;
+		friend BaseBlock;
 
 		U32		mEnclosingBlockOffset:31;
 		U32		mIsProvided:1;
 
 		typedef boost::unordered_map<const std::string, ParamDescriptorPtr>						param_map_t; 
 		typedef std::vector<ParamDescriptorPtr>													param_list_t; 
-		typedef std::list<ParamDescriptorPtr>														all_params_list_t;
+		typedef std::list<ParamDescriptorPtr>													all_params_list_t;
 		typedef std::vector<std::pair<param_handle_t, ParamDescriptor::validation_func_t> >		param_validation_list_t;
 
 		param_map_t						mNamedParams;			// parameters with associated names
 		param_list_t					mUnnamedParams;			// parameters with_out_ associated names
 		param_validation_list_t			mValidationList;		// parameters that must be validated
 		all_params_list_t				mAllParams;				// all parameters, owns descriptors
-
-		size_t					mMaxParamOffset;
-
-		EInitializationState	mInitializationState;	// whether or not static block data has been initialized
-		class BaseBlock*		mCurrentBlockPtr;		// pointer to block currently being constructed
+		size_t							mMaxParamOffset;
+		EInitializationState			mInitializationState;	// whether or not static block data has been initialized
+		BaseBlock*						mCurrentBlockPtr;		// pointer to block currently being constructed
 	};
 
 	class BaseBlock
 		const std::string& getParamName(const BlockDescriptor& block_data, const Param* paramp) const;
 	};
 
+	class BaseBlockWithFlags : public BaseBlock
+	{
+	public:
+		class FlagBase : public Param
+		{
+		public:
+			typedef FlagBase self_t;
+
+			FlagBase(const char* name, BaseBlock* enclosing_block) : Param(enclosing_block) 
+			{
+				if (LL_UNLIKELY(enclosing_block->mostDerivedBlockDescriptor().mInitializationState == BlockDescriptor::INITIALIZING))
+				{
+					ParamDescriptorPtr param_descriptor = ParamDescriptorPtr(new ParamDescriptor(
+						enclosing_block->getHandleFromParam(this),
+						&mergeWith,
+						&deserializeParam,
+						&serializeParam,
+						NULL,
+						&inspectParam,
+						0, 1));
+					BaseBlock::addParam(enclosing_block->mostDerivedBlockDescriptor(), param_descriptor, name);
+				}
+			}
+
+			bool isProvided() const { return anyProvided(); }
+
+		private:
+			static bool mergeWith(Param& dst, const Param& src, bool overwrite)
+			{
+				const self_t& src_typed_param = static_cast<const self_t&>(src);
+				self_t& dst_typed_param = static_cast<self_t&>(dst);
+
+				if (src_typed_param.isProvided()
+					&& (overwrite || !dst_typed_param.isProvided()))
+				{
+					dst.setProvided(true);
+					return true;
+				}
+				return false;
+			}
+
+			static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack, S32 generation)
+			{
+				self_t& typed_param = static_cast<self_t&>(param);
+
+				// no further names in stack, parse value now
+				if (name_stack.first == name_stack.second)
+				{
+					typed_param.setProvided(true);
+					typed_param.enclosingBlock().paramChanged(param, true);
+					return true;
+				}
+
+				return false;
+			}
+
+			static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param)
+			{
+				const self_t& typed_param = static_cast<const self_t&>(param);
+				const self_t* typed_diff_param = static_cast<const self_t*>(diff_param);
+
+				if (!typed_param.isProvided()) return;
+
+				if (!name_stack.empty())
+				{
+					name_stack.back().second = parser.newParseGeneration();
+				}
+
+				// then try to serialize value directly
+				if (!typed_diff_param || !typed_diff_param->isProvided())
+				{
+					if (!parser.writeValue(NoParamValue(), name_stack)) 
+					{
+						return;
+					}
+				}
+			}
+
+			static void inspectParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, S32 min_count, S32 max_count)
+			{
+				// tell parser about our actual type
+				parser.inspectValue<NoParamValue>(name_stack, min_count, max_count, NULL);
+			}
+		};
+	};
+
 	// these templates allow us to distinguish between template parameters
 	// that derive from BaseBlock and those that don't
 	template<typename T, typename Void = void>
 		}
 	};
 
-	template <typename DERIVED_BLOCK, typename BASE_BLOCK = BaseBlock>
+	template <typename DERIVED_BLOCK, typename BASE_BLOCK = BaseBlockWithFlags>
 	class Block 
 	:	public BASE_BLOCK
 	{
 
 		};
 
+		class Flag : public FlagBase
+		{
+		public:
+			Flag(const char* name) : FlagBase(name, DERIVED_BLOCK::selfBlockDescriptor().mCurrentBlockPtr)
+			{}
+		};
+
 		template <typename T, typename RANGE = BaseBlock::AnyAmount, typename NAME_VALUE_LOOKUP = TypeValues<T> >
 		class Multiple : public TypedParam<T, NAME_VALUE_LOOKUP, true>
 		{

indra/llxuixml/llxuiparser.cpp

 		&& nodep->mAttributes.empty() 
 		&& nodep->getSanitizedValue().empty())
 	{
-		// empty node, just parse as NoValue
+		// empty node, just parse as flag
 		mCurReadNode = DUMMY_NODE;
 		return block.submitValue(mNameStack, *this, silent);
 	}
 
-
 	// submit attributes for current node
 	values_parsed |= readAttributes(nodep, block);
 

indra/newview/skins/default/xui/en/notifications.xml

  icon="alertmodal.tga"
  label="Save Outfit"
  name="SaveOutfitAs"
- type="alertmodal"
- unique="true">
+ type="alertmodal">
+    <unique/>
     Save what I'm wearing as a new Outfit:
     <tag>confirm</tag>
     <form name="form">
   <notification
    icon="alertmodal.tga"
    name="ConfirmQuit"
-   type="alertmodal"
-   unique="true">
+   type="alertmodal">
+    <unique/>
 Are you sure you want to quit?
     <tag>confirm</tag>
     <usetemplate
   <notification
    icon="alertmodal.tga"
    name="DeleteItems"
-   type="alertmodal"
-   unique="true">
+   type="alertmodal">
+    <unique/>
     [QUESTION]
     <tag>confirm</tag>
     <usetemplate
   <notification
    icon="alertmodal.tga"
    name="HelpReportAbuseEmailLL"
-   type="alert"
-   unique="true">
+   type="alert">
+    <unique/>
+    
 Use this tool to report violations of the [http://secondlife.com/corporate/tos.php Terms of Service] and [http://secondlife.com/corporate/cs.php Community Standards].
 
 All reported abuses are investigated and resolved.
    icon="notify.tga"
    name="NotSafe"
    persist="true"
-   type="notify"
-   unique="true">
+   type="notify">
+    <unique/>
 This land has damage enabled.
 You can be hurt here. If you die, you will be teleported to your home location.
   </notification>
    icon="notify.tga"
    name="NoFly"
    persist="true"
-   type="notify"
-   unique="true">
-   <tag>fail</tag>
+   type="notify">
+    <unique/>
+    <tag>fail</tag>
 This area has flying disabled.
 You can&apos;t fly here.
   </notification>
    icon="notify.tga"
    name="PushRestricted"
    persist="true"
-   type="notify"
-   unique="true">
+   type="notify">
+    <unique/>    
 This area does not allow pushing. You can&apos;t push others here unless you own the land.
   </notification>
 
    icon="notify.tga"
    name="NoVoice"
    persist="true"
-   type="notify"
-   unique="true">
+   type="notify">
+    <unique/>    
 This area has voice chat disabled. You won&apos;t be able to hear anyone talking.
     <tag>voice</tag>
   </notification>
    icon="notify.tga"
    name="NoBuild"
    persist="true"
-   type="notify"
-   unique="true">
+   type="notify">
+    <unique/>    
 This area has building disabled. You can&apos;t build or rez objects here.
   </notification>
 
    icon="notify.tga"
    name="SeeAvatars"
    persist="true"
-   type="notify"
-   unique="true">
+   type="notify">
+    <unique/>    
 This parcel hides avatars and text chat from another parcel.   You can&apos;t see other residents outside the parcel, and those outside are not able to see you.  Regular text chat on channel 0 is also blocked.
   </notification>
 
   <notification
    icon="notifytip.tga"
    name="ProximalVoiceChannelFull"
-   type="notifytip"
-   unique="true">
+   type="notifytip">
+    <unique/>
     We&apos;re sorry.  This area has reached maximum capacity for voice conversations.  Please try to use voice in another area.
     <tag>fail</tag>
     <tag>voice</tag>
    duration="10"
    icon="notifytip.tga"
    name="VoiceLoginRetry"
-   type="notifytip"
-   unique="true">
+   type="notifytip">
+    <unique/>    
 We are creating a voice channel for you. This may take up to one minute.
   <tag>status</tag>
   <tag>voice</tag>
    name="VoiceEffectsExpired"
    sound="UISndAlert"
    persist="true"
-   type="notify"
-   unique="true">
+   type="notify">
+    <unique/>    
 One or more of your subscribed Voice Morphs has expired.
 [[URL] Click here] to renew your subscription.
   <tag>fail</tag>
    name="VoiceEffectsExpiredInUse"
    sound="UISndAlert"
    persist="true"
-   type="notify"
-   unique="true">
+   type="notify">
+    <unique/>
 The active Voice Morph has expired, your normal voice settings have been applied.
 [[URL] Click here] to renew your subscription.
     <tag>fail</tag>
    name="VoiceEffectsWillExpire"
    sound="UISndAlert"
    persist="true"
-   type="notify"
-   unique="true">
+   type="notify">
+    <unique/>    
 One or more of your Voice Morphs will expire in less than [INTERVAL] days.
 [[URL] Click here] to renew your subscription.
   <tag>fail</tag>
    name="VoiceEffectsNew"
    sound="UISndAlert"
    persist="true"
-   type="notify"
-   unique="true">
+   type="notify">
+    <unique/>    
 New Voice Morphs are available!
    <tag>voice</tag>
   </notification>
      ignoretext="Confirm before I leave call"
      name="okcancelignore"
      notext="No"
-     yestext="Yes"
-     unique="true"/>
+     yestext="Yes">
+      <unique/>
+    </usetemplate>
   </notification>
 
   <notification
      ignoretext="Confirm before I mute all participants in a group call"
      name="okcancelignore"
      yestext="Ok"
-     notext="Cancel"
-     unique="true"/>
-  </notification>
+     notext="Cancel">
+      <unique/>
+    </usetemplate>
+    </notification>
   <notification
   name="HintChat"
   label="Chat"
-  type="hint"
-  unique="true">
+  type="hint">
+    <unique/>
     To join the conversation, type into the chat field below.
   </notification>
 
   <notification
   name="HintSit"
-  
   label="Stand"
-  type="hint"
-  unique="true">
+  type="hint">
+    <unique/>
     To stand up and exit the sitting position, click the Stand button.
   </notification>
 
   <notification
   name="HintSpeak"
   label="Speak"
-  type="hint"
-  unique="true">
+  type="hint">
+    <unique/>    
 Click the Speak button to turn your microphone on and off.
 
 Click on the up arrow to see the voice control panel.
   <notification
   name="HintDestinationGuide"
   label="Explore the World"
-  type="hint"
-  unique="true">
+  type="hint">
+    <unique/>
     The Destination Guide contains thousands of new places to discover. Select a location and choose Teleport to start exploring.
   </notification>
 
   <notification
     name="HintSidePanel"
     label="Side Panel"
-    type="hint"
-    unique="true">
+    type="hint">
+    <unique/>
     Get quick access to your inventory, outfits, profiles and more in the side panel.
   </notification>
 
   <notification
   name="HintMove"
   label="Move"
-  type="hint"
-  unique="true">
+  type="hint">
+    <unique/>
     To walk or run, open the Move Panel and use the directional arrows to navigate. You can also use the directional keys on your keyboard.
   </notification>
 
   <notification
   name="HintMoveClick"
   label=""
-  type="hint"
-  unique="true">
+  type="hint">
+    <unique/>    
 1. Click to Walk
 Click anywhere on the ground to walk to that spot.
 
   <notification
   name="HintDisplayName"
   label="Display Name"
-  type="hint"
-  unique="true">
+  type="hint">
+    <unique/>
     Set your customizable display name here. This is in addition to your unique username, which can't be changed. You can change how you see other people's names in your preferences.
   </notification>
 
   <notification
   name="HintView"
   label="View"
-  type="hint"
-  unique="true">
+  type="hint">
+    <unique/>
     To change your camera view, use the Orbit and Pan controls. Reset your view by pressing Escape or walking.
     <tag>custom_skin</tag>
   </notification>
   <notification
   name="HintInventory"
   label="Inventory"
-  type="hint"
-  unique="true">
+  type="hint">
+    <unique/>
     Check your inventory to find items. Newest items can be easily found in the Recent tab.
   </notification>
 
   <notification
   name="HintLindenDollar"
   label="You've got Linden Dollars!"
-  type="hint"
-  unique="true">
+  type="hint">
+    <unique/>
     Here's your current balance of L$. Click Buy L$ to purchase more Linden Dollars.
     <tag>funds</tag>
   </notification>
   <notification
  name="ModeChange"
  label=""
- type="alertmodal"
- unique="true">
+ type="alertmodal">
+    <unique/>
     Changing modes requires you to quit and restart.
     <tag>confirm</tag>
     <usetemplate
   <notification
  name="NoClassifieds"
  label=""
- type="alertmodal"
- unique="true">
+ type="alertmodal">
+    <unique/>
     <tag>fail</tag>
     <tag>confirm</tag>
     Creation and editing of Classifieds is only available in Advanced mode. Would you like to quit and change modes? The mode selector can be found on the login screen.
   <notification
  name="NoGroupInfo"
  label=""
- type="alertmodal"
- unique="true">
+ type="alertmodal">
+    <unique/>
     <tag>fail</tag>
     <tag>confirm</tag>
     Creation and editing of Groups is only available in Advanced mode. Would you like to quit and change modes? The mode selector can be found on the login screen.
   <notification
  name="NoPlaceInfo"
  label=""
- type="alertmodal"
- unique="true">
+ type="alertmodal">
+    <unique/>
     <tag>fail</tag>
     <tag>confirm</tag>
     Viewing place profile is only available in Advanced mode. Would you like to quit and change modes? The mode selector can be found on the login screen.
   <notification
  name="NoPicks"
  label=""
- type="alertmodal"
- unique="true">
+ type="alertmodal">
+    <unique/>
     <tag>fail</tag>
     <tag>confirm</tag>
     Creation and editing of Picks is only available in Advanced mode. Would you like to quit and change modes? The mode selector can be found on the login screen.
   <notification
  name="NoWorldMap"
  label=""
- type="alertmodal"
- unique="true">
+ type="alertmodal">
+    <unique/>
     <tag>fail</tag>
     <tag>confirm</tag>
     Viewing of the world map is only available in Advanced mode. Would you like to quit and change modes? The mode selector can be found on the login screen.
   <notification
  name="NoVoiceCall"
  label=""
- type="alertmodal"
- unique="true">
+ type="alertmodal">
+    <unique/>
     <tag>fail</tag>
     <tag>confirm</tag>
     Voice calls are only available in Advanced mode. Would you like to logout and change modes?
   <notification
  name="NoAvatarShare"
  label=""
- type="alertmodal"
- unique="true">
+ type="alertmodal">
+    <unique/>
     <tag>fail</tag>
     <tag>confirm</tag>
     Sharing is only available in Advanced mode. Would you like to logout and change modes?
   <notification
  name="NoAvatarPay"
  label=""
- type="alertmodal"
- unique="true">
+ type="alertmodal">
+    <unique/>
     <tag>fail</tag>
     <tag>confirm</tag>
 	  Paying other residents is only available in Advanced mode. Would you like to logout and change modes?
   <notification
  name="NoInventory"
  label=""
- type="alertmodal"
- unique="true">
+ type="alertmodal">
+    <unique/>
     <tag>fail</tag>
     <tag>confirm</tag>
     Viewing inventory is only available in Advanced mode. Would you like to logout and change modes?
   <notification
  name="NoAppearance"
  label=""
- type="alertmodal"
- unique="true">
+ type="alertmodal">
+    <unique/>
     <tag>fail</tag>
     <tag>confirm</tag>
     The appearance editor is only available in Advanced mode. Would you like to logout and change modes?
   <notification
  name="NoSearch"
  label=""
- type="alertmodal"
- unique="true">
+ type="alertmodal">
+    <unique/>
     <tag>fail</tag>
     <tag>confirm</tag>
     Search is only available in Advanced mode. Would you like to logout and change modes?