AudienceVisibility.h header

#include <ew/app/AudienceVisibility.h>

Namespace ew::app

AudienceLens class

class ew::app::AudienceLens

A reader's lens on the project: built once for a pass over many objects, then asked about each one.

The one place the audience question is asked, so the six read paths that used to test ContentObject::isVisibleTo directly – the document tree, the codex tree, embedded callouts, the codex and manuscript exports, and the map view – share a single answer that comes from ew::core::policy::authorize.

An EMPTY audience means no reader lens is applied and everything is visible. That is the ordinary editing view, not a blind one; every call site already worked this way and the gate agrees, which is what makes routing them through it a no-op.

Why a lens and not just a function. The gate's vocabulary is a value per question (ew::core::policy::Principal plus an ObjectPolicy), which is right for one question and wasteful for fifty thousand: building the principal per object allocates a std::set per object, and measured 136 ns of the 213 ns the naive form added to each read – ~88% of the Project::find + dynamic_cast those same loops already pay. Holding the principal makes a whole tree rebuild allocate it once. See the changelist for the measurement.

Members

ew::app::policy::AudienceLens::AudienceLens(const QString &audience)

Creates a lens for audience. An empty audience is the author's view: everything is visible.

bool ew::app::policy::AudienceLens::canSee(const ew::core::content::ContentObject &object) const

Returns whether the reader this lens represents may see object.

Returns the same answer ContentObject::isVisibleTo did (no audiences listed, or this audience among them) – deliberately, because A4's acceptance is zero behaviour change – except that an empty audience is the unrestricted view rather than a name to match, which is the guard each caller used to carry separately.

Functions

bool ew::app::policy::isVisibleToReader(const ew::core::content::ContentObject &object, const QString &audience)

Returns whether a reader viewing the project through audience may see object.

A convenience for a one-off question – it builds an AudienceLens and throws it away. In a loop, build the lens once instead; that is what it is for.