Page Speed Optimization Libraries
1.2.24.1
|
#include "rewrite_options.h"
Public Types | |
typedef T | ValueType |
Public Member Functions | |
virtual bool | was_set () const |
void | set (const T &val) |
void | set_default (const T &val) |
const T & | value () const |
virtual void | Merge (const OptionBase *src) |
void | MergeHelper (const OptionTemplateBase *src) |
void | set_property (const Property< T > *property) |
The static properties of an Option are held in a Property<T>*. | |
virtual const Property< T > * | property () const |
void | set_global_default (const T &val) |
void | DoNotUseForSignatureComputation () |
Helper class to represent an Option, whose value is held in some class T. An option is explicitly initialized with its default value, although the default value can be altered later. It keeps track of whether a value has been explicitly set (independent of whether that happens to coincide with the default value).
It can use this knowledge to intelligently merge a 'base' option value into a 'new' option value, allowing explicitly set values from 'base' to override default values from 'new'.
void net_instaweb::RewriteOptions::OptionTemplateBase< T >::DoNotUseForSignatureComputation | ( | ) | [inline] |
Sets a the option's participation in Signatures globally. This is thread-unsafe, and reaches into the option property_ field via a const-cast to mutate it. Note that this method does not affect the current value of the instantiated option.
virtual void net_instaweb::RewriteOptions::OptionTemplateBase< T >::Merge | ( | const OptionBase * | src | ) | [inline, virtual] |
The signature of the Merge implementation must match the base-class. The caller is responsible for ensuring that only the same typed Options are compared. In RewriteOptions::Merge this is guaranteed because the vector<OptionBase*> all_options_ is sorted on option_enum(). We DCHECK that the option_enum of this and src are the same.
Implements net_instaweb::RewriteOptions::OptionBase.
Reimplemented in net_instaweb::RewriteOptions::MutexedOptionInt64MergeWithMax.
void net_instaweb::RewriteOptions::OptionTemplateBase< T >::MergeHelper | ( | const OptionTemplateBase< T > * | src | ) | [inline] |
Even if !src->was_set, the default value needs to be transferred over in case it was changed with set_default or SetDefaultRewriteLevel.
void net_instaweb::RewriteOptions::OptionTemplateBase< T >::set_global_default | ( | const T & | val | ) | [inline] |
Sets a the option default value globally. This is thread-unsafe, and reaches into the option property_ field via a const-cast to mutate it. Note that this method does not affect the current value of the instantiated option.
void net_instaweb::RewriteOptions::OptionTemplateBase< T >::set_property | ( | const Property< T > * | property | ) | [inline] |
The static properties of an Option are held in a Property<T>*.
Note that the copying of default values here is only required to support SetDefaultRewriteLevel, which it should be possible to remove. Otherwise we could just pull the default value out of properties_ when !was_set_;