eris  1.4.0
A WorldForge client library.
Eris::View Class Reference

#include <View.h>

Inheritance diagram for Eris::View:
Collaboration diagram for Eris::View:

Public Types

typedef sigc::slot< void, ViewEntity * > EntitySightSlot
 

Public Member Functions

 View (Avatar &av)
 
ViewEntitygetEntity (const std::string &eid) const
 
AvatargetAvatar () const
 
EntitygetTopLevel () const
 
TypeServicegetTypeService ()
 Gets the TypeService attached to the view. More...
 
TypeServicegetTypeService () const
 Gets the TypeService attached to the view. More...
 
EventServicegetEventService ()
 Gets the EventService used by the view. More...
 
EventServicegetEventService () const
 Gets the EventService used by the view. More...
 
void update ()
 
void registerFactory (std::unique_ptr< Factory > factory)
 
double getSimulationSpeed () const
 
sigc::connection notifyWhenEntitySeen (const std::string &eid, const EntitySightSlot &slot)
 
void dumpLookQueue ()
 
std::size_t lookQueueSize () const
 
void sendLookAt (const std::string &eid)
 
size_t pruneAbandonedPendingEntities ()
 
ConnectiongetConnection () const
 

Public Attributes

sigc::signal< void, ViewEntity * > EntitySeen
 
sigc::signal< void, ViewEntity * > EntityCreated
 
sigc::signal< void, ViewEntity * > EntityDeleted
 
sigc::signal< void > TopLevelEntityChanged
 emitted when the TLVE changes More...
 
sigc::signal< void, ViewEntity * > InitialSightEntity
 

Protected Member Functions

void appear (const std::string &eid, double stamp)
 
void disappear (const std::string &eid)
 
void sight (const Atlas::Objects::Entity::RootEntity &ge)
 
void deleteEntity (const std::string &eid)
 
void unseen (const std::string &eid)
 
bool isPending (const std::string &eid) const
 test if the specified entity ID is pending initial sight on the View More...
 
void addToPrediction (ViewEntity *ent)
 
void removeFromPrediction (ViewEntity *ent)
 
void taskRateChanged (Task *)
 

Friends

class IGRouter
 
class ViewEntity
 
class Avatar
 
class Task
 

Detailed Description

View encapsulates the set of entities currently visible to an Avatar, as well as those that have recently been seen. It receives visibility-affecting ops from the IGRouter, and uses them to update its state and emit signals.

Definition at line 40 of file View.h.

Member Function Documentation

◆ getEntity()

ViewEntity * Eris::View::getEntity ( const std::string &  eid) const

Retrieve an entity in the view by id. Returns nullptr if no such entity exists in the view.

Definition at line 45 of file View.cpp.

Referenced by Eris::ViewEntity::getEntity().

◆ getEventService() [1/2]

EventService & Eris::View::getEventService ( )

Gets the EventService used by the view.

Returns
The main EventService instance.

Definition at line 77 of file View.cpp.

Referenced by getTopLevel().

◆ getEventService() [2/2]

EventService & Eris::View::getEventService ( ) const

Gets the EventService used by the view.

Returns
The main EventService instance.

Definition at line 81 of file View.cpp.

◆ getTopLevel()

Entity* Eris::View::getTopLevel ( ) const
inline

return the current top-level entity. This will return nullptr until the first emission of the TopLevelEntityChanged signal.

Definition at line 59 of file View.h.

References getEventService(), getTypeService(), notifyWhenEntitySeen(), registerFactory(), and update().

◆ getTypeService() [1/2]

TypeService & Eris::View::getTypeService ( )

Gets the TypeService attached to the view.

Returns
A typeservice instance.

Definition at line 69 of file View.cpp.

Referenced by getTopLevel().

◆ getTypeService() [2/2]

TypeService & Eris::View::getTypeService ( ) const

Gets the TypeService attached to the view.

Returns
A typeservice instance.

Definition at line 73 of file View.cpp.

◆ isPending()

bool Eris::View::isPending ( const std::string &  eid) const
protected

test if the specified entity ID is pending initial sight on the View

Definition at line 336 of file View.cpp.

Referenced by lookQueueSize().

◆ lookQueueSize()

std::size_t Eris::View::lookQueueSize ( ) const
inline

Retrieve the current look queue size, for debugging / statistics purposes. Eg, this could be displayed as a bar-chart on screen in a client (optionally)

Definition at line 137 of file View.h.

References isPending(), sendLookAt(), and taskRateChanged().

◆ notifyWhenEntitySeen()

sigc::connection Eris::View::notifyWhenEntitySeen ( const std::string &  eid,
const EntitySightSlot &  slot 
)

Connect up a slot to be fired when an Entity with the specified ID is seen. If the entity is already visible, this is a no-op (and will log an error)

Definition at line 58 of file View.cpp.

Referenced by getTopLevel().

◆ registerFactory()

void Eris::View::registerFactory ( std::unique_ptr< Factory factory)

Register an Entity Factory with this view

Definition at line 54 of file View.cpp.

Referenced by getTopLevel().

◆ sendLookAt()

void Eris::View::sendLookAt ( const std::string &  eid)

Issue a LOOK operation for the specified entity ID. The id may be empty for an anonymous look. The pending sight map will be updated with the appropriate information.

Definition at line 375 of file View.cpp.

References Eris::Entity::getLocation(), and Eris::Entity::observe().

Referenced by lookQueueSize().

◆ taskRateChanged()

void Eris::View::taskRateChanged ( Task t)
protected

Method to register and unregister tasks with with view, so they can have their progress updated automatically by update(). Only certain tasks (those with linear progress) are handled this way, but all tasks are submitted to this method.

Definition at line 134 of file View.cpp.

References Eris::Entity::firstSight(), Eris::Entity::getEntity(), Eris::Entity::getLocation(), Eris::Entity::getStamp(), Eris::TypeService::getTypeForAtlas(), Eris::TypeInfo::isBound(), Eris::Entity::isVisible(), Eris::Entity::m_recentlyCreated, Eris::Entity::setLocation(), and Eris::Entity::setVisible().

Referenced by lookQueueSize(), Eris::ViewEntity::onTaskAdded(), and Eris::ViewEntity::task_ProgressRateChanged().

◆ update()

void Eris::View::update ( )

once-per-frame update of the View - clients should call this method once per game loop (or similar), to allow the View to update Entity state. This includes motion prediction for moving entities, and confidence levels for disappeared entities.

Definition at line 89 of file View.cpp.

References Eris::Entity::isMoving().

Referenced by getTopLevel().

Member Data Documentation

◆ EntityCreated

sigc::signal<void, ViewEntity*> Eris::View::EntityCreated

emitted when a SIGHT(CREATE) op is received for an entity

Definition at line 115 of file View.h.

◆ EntityDeleted

sigc::signal<void, ViewEntity*> Eris::View::EntityDeleted

emitted when a SIGHT(DELETE) op is received for an entity

Definition at line 118 of file View.h.

◆ EntitySeen

sigc::signal<void, ViewEntity*> Eris::View::EntitySeen

emitted whenever the View creates a new Entity instance. This signal is emitted once the entity has been fully bound into the View

Definition at line 112 of file View.h.

◆ InitialSightEntity

sigc::signal<void, ViewEntity*> Eris::View::InitialSightEntity

Emitted after a new Entity has been created and initialized.

This signal is mainly meant for debugging or authoring; normal entity presentation logic should use EntitySeen or EntityCreated instead.

Definition at line 129 of file View.h.

◆ TopLevelEntityChanged

sigc::signal<void> Eris::View::TopLevelEntityChanged

emitted when the TLVE changes

Definition at line 121 of file View.h.


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