Page Speed Optimization Libraries  1.12.34.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
net_instaweb::RewriteOptions::OptionTemplateBase< T > Class Template Reference

#include "rewrite_options.h"

Inheritance diagram for net_instaweb::RewriteOptions::OptionTemplateBase< T >:
net_instaweb::RewriteOptions::OptionBase net_instaweb::RewriteOptions::Option< T >

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
 
T & mutable_value ()
 
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>*. More...
 
virtual const PropertyBaseproperty () const
 
void set_global_default (const T &val)
 
void DoNotUseForSignatureComputation ()
 
- Public Member Functions inherited from net_instaweb::RewriteOptions::OptionBase
virtual bool SetFromString (StringPiece value_string, GoogleString *error_detail)=0
 
virtual GoogleString Signature (const Hasher *hasher) const =0
 
virtual GoogleString ToString () const =0
 
const char * id () const
 
const char * help_text () const
 
OptionScope scope () const
 
StringPiece option_name () const
 
bool is_used_for_signature_computation () const
 

Detailed Description

template<class T>
class net_instaweb::RewriteOptions::OptionTemplateBase< T >

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'.

Member Function Documentation

template<class T>
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.

Todo:
TODO(jmarantz): consider an alternate structure where the Property<T>* can be easily located programmatically rather than going through a dummy Option object.
template<class T>
virtual void net_instaweb::RewriteOptions::OptionTemplateBase< T >::Merge ( const OptionBase src)
inlinevirtual

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_name(). We DCHECK that the option_name of this and src are the same.

Implements net_instaweb::RewriteOptions::OptionBase.

template<class T>
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.

template<class T>
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.

Todo:
TODO(jmarantz): consider an alternate structure where the Property<T>* can be easily located programmatically rather than going through a dummy Option object.
template<class T>
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_;


The documentation for this class was generated from the following file: