NAP
Public Member Functions | Public Attributes | List of all members
CalendarComponentInstance Class Reference

#include <calendarcomponent.h>

Public Member Functions

 CalendarComponentInstance (EntityInstance &entity, Component &resource)
 
virtual bool init (utility::ErrorState &errorState) override
 
virtual void update (double deltaTime) override
 
void setDirty ()
 
const nap::ICalendargetCalendar () const
 
nap::ICalendargetCalendar ()
 
bool active (const std::string &itemID) const
 
- Public Member Functions inherited from ComponentInstance
 ComponentInstance (EntityInstance &entity, Component &resource)
 
nap::EntityInstancegetEntityInstance () const
 
nap::ComponentgetComponent () const
 
template<typename T >
T * getComponent () const
 
virtual bool init (utility::ErrorState &errorState)
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

nap::Signal< const CalendarEvent & > eventStarted
 Triggered when a calendar event starts, always on the main thread on update() More...
 
nap::Signal< const CalendarEvent & > eventEnded
 Triggered when a calendar event ends, always on the main thread on update() More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

Notifies listeners when a calendar event starts and ends. Listen to the 'eventStarted' and 'eventEnded' signals to get notified of changes. This component also ensures that the eventEnded signal is called when an item is removed or changed, if that item was previously in session. The state change checks are performed at a regular interval, controlled by the CalendarComponent::Frequency property. Time used = local computer time. TODO: Add support for timezones.

Inheritance diagram for CalendarComponentInstance:
[legend]
Collaboration diagram for CalendarComponentInstance:
[legend]

Constructor & Destructor Documentation

◆ CalendarComponentInstance()

CalendarComponentInstance ( EntityInstance entity,
Component resource 
)

Member Function Documentation

◆ active()

bool active ( const std::string &  itemID) const

Checks if a specific calendar item is currently active according to this component. Note that this check is often faster than: CalendarEvent::active(), because the active state is cached by this component, making it faster to query, especially when iterating and 'asking' a large number of calendar items.

for (const auto& item : calendar_component.getCalendar().getItems())
{
c_active = calendar_comp.active(item->mID);
...
}
Parameters
itemIDthe unique id of the calendar item
Returns
if an item is currently active, according to this component.

◆ getCalendar() [1/2]

nap::ICalendar& getCalendar ( )
Returns
the calendar this component monitors

◆ getCalendar() [2/2]

const nap::ICalendar& getCalendar ( ) const
Returns
the calendar this component monitors

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Initialize the component based on the resource

Parameters
errorStatecontains the error when initialization fails
Returns
if the component initialized

Reimplemented from ComponentInstance.

◆ setDirty()

void setDirty ( )

Forces a calendar activity check next update call. Call this after updating a calendar item.

◆ update()

virtual void update ( double  deltaTime)
overridevirtual

Checks for calendar item state changes if time passed or when dirty. Notifies listeners if an event started or ended.

Parameters
deltaTimetime in between frames in seconds

Reimplemented from ComponentInstance.

Member Data Documentation

◆ eventEnded

nap::Signal<const CalendarEvent&> eventEnded

Triggered when a calendar event ends, always on the main thread on update()

◆ eventStarted

nap::Signal<const CalendarEvent&> eventStarted

Triggered when a calendar event starts, always on the main thread on update()