All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
STY_Target Class Reference

#include <STY_Target.h>

+ Inheritance diagram for STY_Target:

Public Member Functions

 STY_Target (const UT_JSONValue *json, bool is_selftarget)
 STY_Target (const UT_StringHolder &label, const STY_TargetType &type, const STY_TargetHandle &sub_target, const STY_ConstantMap &requirements, const UT_Array< STY_BindingHandle > *pre_bind)
 Construct from requirements and a subtarget. More...
 ~STY_Target ()
bool isEquivalentToNoTarget () const
const UT_StringHoldergetLabel () const
 Returns the label given to this target. More...
const STY_TargetTypegetType () const
const STY_ConstantMapgetTargetRequirements () const
const char * getRequirement (const UT_StringHolder &key) const
const UT_Array
< STY_BindingHandle > * 
getPreBindings () const
const STY_TargetHandlegetSubTarget () const
void saveStyleSheet (UT_JSONValueMap *map, const STY_TargetMatchClosureHandle &closure) const
 Creates a JSON value map for saving to a style sheet. More...
- Public Member Functions inherited from UT_IntrusiveRefCounter< STY_Target >
SYS_FORCE_INLINE UT_IntrusiveRefCounter () noexcept
 Default constructor: Sets counter to 0. More...
SYS_FORCE_INLINE UT_IntrusiveRefCounter (const UT_IntrusiveRefCounter &) noexcept
 Copy constructor: Sets counter to 0. More...
UT_IntrusiveRefCounteroperator= (const UT_IntrusiveRefCounter &) noexcept
 Assignment operator: Does not modify counter. More...
SYS_FORCE_INLINE uint32 use_count () const noexcept
 Return current counter. More...

Additional Inherited Members

- Protected Member Functions inherited from UT_NonCopyableNS::UT_NonCopyable
 UT_NonCopyable ()=default
 ~UT_NonCopyable ()=default
 UT_NonCopyable (const UT_NonCopyable &)=delete
UT_NonCopyableoperator= (const UT_NonCopyable &)=delete
- Protected Member Functions inherited from UT_IntrusiveRefCounter< STY_Target >
SYS_FORCE_INLINE ~UT_IntrusiveRefCounter ()
 Destructor: Only derived classes can destruct this. More...

Detailed Description

The style target represents an abstract description of a style subject to which the overrides should be applied. When a style sheet entry is tested whether its overrides should be applied to a style subject, it asks the given style subject to test its target for a match. Thus, it is up to the style subject to interpret the target's requirement data and decide if it satisfies them or not.

The style target is purposely generic, because if it were specific then each usecase of the targets would need to implement own specific target meeting its needs, and it's hard to write own custom target class because it needs to load from JSON into our style sheet class. In the future, we may provide style target factory registration that uses targetType to choose specific implementation class, but now there is no such mechanism.

The style subject, on the other hand, is easy to subclass from, and thus it is style subject's responsibility to perform the matching and processing of style targets.

Definition at line 42 of file STY_Target.h.

Constructor & Destructor Documentation

STY_Target::STY_Target ( const UT_JSONValue json,
bool  is_selftarget 

Constructor of a target based on JSON encoding. The 'is_selftarget' flag is true for targets that refer to the subjects that provided the style sheet definition (it's false for most cases).

STY_Target::STY_Target ( const UT_StringHolder label,
const STY_TargetType type,
const STY_TargetHandle sub_target,
const STY_ConstantMap requirements,
const UT_Array< STY_BindingHandle > *  pre_bind 

Construct from requirements and a subtarget.

STY_Target::~STY_Target ( )

Member Function Documentation

const UT_StringHolder& STY_Target::getLabel ( ) const

Returns the label given to this target.

Definition at line 67 of file STY_Target.h.

const UT_Array<STY_BindingHandle>* STY_Target::getPreBindings ( ) const

Returns an array of pre-binding, which contain names of the data that should be retrieved from the subject that match this target. The data (source) is usually stored in a match closure object, and is used for input arguments of override scripts.

Definition at line 91 of file STY_Target.h.

const char* STY_Target::getRequirement ( const UT_StringHolder key) const

Convenience getter for requirement string. Returns NULL if the key is not in the requirements. See the STY_REQUIREMENT constants defined in STY_Types.h for the most common cases.

const STY_TargetHandle& STY_Target::getSubTarget ( ) const

Returns this target's sub-target than needs to be matched by subsequent styling subject. Usually, styling subjects are arranged in a hiearchy (eg, crowd geometry object > agent primitive > agent's shape), and it is useful for the style target to mimic this hierarchy so that each subject in the hierarchy has a corresponding target, with its own set of requirements.

Definition at line 100 of file STY_Target.h.

const STY_ConstantMap& STY_Target::getTargetRequirements ( ) const

Returns the target requirements in the form of key-value dictionary. Subjects query data in this dictionary to retrieve the values they deem to necessary to match.

Definition at line 78 of file STY_Target.h.

const STY_TargetType& STY_Target::getType ( ) const

Returns the target type. It's a basic constraint that many style subjects test before proceeding with further tests.

Definition at line 72 of file STY_Target.h.

bool STY_Target::isEquivalentToNoTarget ( ) const

Returns true if this target is a completely default target specification (equivalent to no target specification at all in JSON). This means a self target with no conditions, no bindings, and no sub-target.

void STY_Target::saveStyleSheet ( UT_JSONValueMap map,
const STY_TargetMatchClosureHandle closure 
) const

Creates a JSON value map for saving to a style sheet.

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