-
Notifications
You must be signed in to change notification settings - Fork 260
What is a Context
A context is the environment or interrelated conditions in which something exists or occurs. A context can also be seen as a set of circumstances or certain situations in an application.
A context can have various aspects or "logical views" of an application and its data. For example, a context may have items that can be viewed, or it may have items that can be positioned and sized, or both. Some contexts have transactions that can be undone and redone, such as editing data.
An application can have a variety of contexts. These contexts may be active at different times, typically depending on which controls are active. The current active context is usually associated with the current active window in the user interface. For instance, a text editing application could have an active context in which text can be modified while a text window is active. This application would have an altogether different context active when a dialog is open to edit the application's preferences.
ATF has interfaces and classes to provide services for an application's data and operations in various contexts. These interfaces can apply to different types of contexts or aspects of contexts. For example, the IViewingContext interface applies to contexts with items that can be viewed, whereas ILayoutContext works with contexts containing items that can be positioned and sized. ITransactionContext works with contexts in which transactions can occur.
The term context is often used to refer to an instance of a context interface or class.
Interfaces and classes that work with contexts have names that end with "Context", such as IViewingContext and EditingContext.
A context interface may also have a standard ATF implementation class. It may implement more than one context interface, as TransactionContext does:
public class TransactionContext : DomNodeAdapter, ITransactionContext, IValidationContextMore than one context can apply to a certain environment, so a class may implement several context interfaces. A few context interfaces even derive from each other. For instance:
public interface ILayeringContext : IVisibilityContext, ITreeView, IItemViewSome of the context classes also have a chain of derivation. For instance, EditingContext has this derivation ancestry: EditingContext, HistoryContext, and TransactionContext.
Data is important in some contexts, for instance, where data objects are selectable. The IEnumerableContext interface is for a context that can provide an enumeration of all its items. It complements ISelectionContext for contexts where items can be selected.
A context interface can be very general, working with different kinds of data. For instance, ILockingContext is for contexts where items may be locked so they can't be modified. Such items could be text or graphical elements — anything lockable. And ISelectionContext supports a context where items can be selected — any kind of items.
Some context classes, such as TransactionContext, are also DOM adapters. Because many contexts involve application data, the ability to adapt the data to a context's interface is very useful.
An application can define DOM adapters that implement context interfaces for its root DomNode type and other types. The DomNodes of those types can then use these context interfaces.
For example, the ATF Simple DOM Editor Sample defines several DOM adapters in its SchemaLoader class:
Schema.eventSequenceType.Type.Define(new ExtensionInfo<EventSequenceDocument>());
Schema.eventSequenceType.Type.Define(new ExtensionInfo<EventSequenceContext>());
Schema.eventSequenceType.Type.Define(new ExtensionInfo<MultipleHistoryContext>());
Schema.eventSequenceType.Type.Define(new ExtensionInfo<EventSequence>());
Schema.eventSequenceType.Type.Define(new ExtensionInfo<ReferenceValidator>());
Schema.eventSequenceType.Type.Define(new ExtensionInfo<UniqueIdValidator>());
Schema.eventSequenceType.Type.Define(new ExtensionInfo<DomNodeQueryable>());
Schema.eventType.Type.Define(new ExtensionInfo<Event>());
Schema.eventType.Type.Define(new ExtensionInfo<EventContext>());This application's data model defines two main data types: eventType for events, and eventSequenceType, which is a sequence of eventType objects.
The type eventSequenceType has several DOM adapters defined. EventSequenceContext derives from EditingContext, which implements ISelectionContext and several other context interfaces through its ancestor classes, such as IHistoryContext and ITransactionContext. DomNodeQueryable implements IQueryableContext, IQueryableResultContext, and IQueryableReplaceContext. This means that this application's document objects can use all of these context interfaces. Note that the EventSequenceDocument DOM adapter is also defined for this type.
The type eventType has the defined DOM adapter EventContext, which also implements EditingContext, so event objects can also use all EditingContext's context interfaces.
- What is a Context: Define contexts and discuss how ATF provides services for them.
-
Context Registry: The
ContextRegistrycomponent tracks all context objects in an application. - Context Interfaces: ATF's context interfaces and their usage.
- Context Classes: Classes that implement services for a context.
- Context Related Classes: Classes that use context interfaces and classes for their operation.
- Implementing a Context Interface: Implementing context interfaces.
- Home
- Getting Started
- Features & Benefits
- Requirements & Dependencies
- Gallery
- Technology & Samples
- Adoption
- News
- Release Notes
- ATF Community
- Searching Documentation
- Using Documentation
- Videos
- Tutorials
- How To
- Programmer's Guide
- Reference
- Code Samples
- Documentation Files
© 2014-2015, Sony Computer Entertainment America LLC