## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# iObjectWatcher Struct Reference
[Crystal Space 3D Engine]

This is a generic object watcher. More...

`#include <iengine/objwatch.h>`

Inheritance diagram for iObjectWatcher:

[legend]
List of all members.

## Public Member Functions

virtual void | AddListener (iObjectWatcherListener *cb)=0
| Add a listener to this object watcher.
virtual iLight * | GetLastLight () const =0
| Get the last light.
virtual iMeshWrapper * | GetLastMeshWrapper () const =0
| Get the last mesh.
virtual iMovable * | GetLastMovable () const =0
| Get the last movable.
virtual int | GetLastOperation () const =0
| Get the last operation that occured.
virtual iSector * | GetLastSector () const =0
| Get the last sector.
virtual iLight * | GetLight (int idx)=0
| Get the specified watched light.
virtual iMovable * | GetMovable (int idx)=0
| Get the specified watched movable.
virtual iSector * | GetSector (int idx)=0
| Get the specified watched sector.
virtual int | GetWatchedLightCount () const =0
| Get the number of watched lights.
virtual int | GetWatchedMovableCount () const =0
| Get the number of watched movables.
virtual int | GetWatchedSectorCount () const =0
| Get the number of watched sectors.
virtual uint32 | GetWatchNumber () const =0
| Get the current number for his watcher.
virtual void | RemoveLight (iLight *light)=0
| Remove a light to watch.
virtual void | RemoveListener (iObjectWatcherListener *cb)=0
| Remove a listener.
virtual void | RemoveMovable (iMovable *movable)=0
| Remove a movable to watch.
virtual void | RemoveSector (iSector *sector)=0
| Remove a sector to watch.
virtual void | Reset ()=0
| Reset. Remove all watched objects from this watcher.
virtual void | WatchLight (iLight *light)=0
| Add a light to watch.
virtual void | WatchMovable (iMovable *movable)=0
| Add a movable to watch.
virtual void | WatchSector (iSector *sector)=0
| Add a sector to watch for meshes.

## Detailed Description

This is a generic object watcher.

Currently it can watch on light and movable changes. You can query if something has changed by examining the 'number' or else you can register a listener and get notified when one of the objects changes. This object will not keep real references to the objects it is watching but it will clean up the watcher for some object if that object is removed.

Definition at line 101 of file objwatch.h.

## Member Function Documentation

virtual void iObjectWatcher::AddListener | ( | iObjectWatcherListener * | cb | ) | `[pure virtual]`

| Add a listener to this object watcher. This will call IncRef() on the listener So make sure you call DecRef() to release your own reference.

virtual iLight* iObjectWatcher::GetLastLight | ( |  | ) | const`[pure virtual]`

| Get the last light. Only valid if the last operation (GetLastOperation()) is one of CS_WATCH_LIGHT_....

virtual iMeshWrapper* iObjectWatcher::GetLastMeshWrapper | ( |  | ) | const`[pure virtual]`

| Get the last mesh. Only valid if the last operation (GetLastOperation()) is one of CS_WATCH_SECTOR_....

virtual iMovable* iObjectWatcher::GetLastMovable | ( |  | ) | const`[pure virtual]`

| Get the last movable. Only valid if the last operation (GetLastOperation()) is one of CS_WATCH_MOVABLE_....

virtual int iObjectWatcher::GetLastOperation | ( |  | ) | const`[pure virtual]`

Get the last operation that occured.

This will be one of:

- CS_WATCH_NONE: nothing happened yet.
- CS_WATCH_LIGHT_DESTROY: light is destroyed.
- CS_WATCH_LIGHT_MOVE: light has moved.
- CS_WATCH_LIGHT_COLOR: light has changed color.
- CS_WATCH_LIGHT_SECTOR: light has changed sector.
- CS_WATCH_LIGHT_RADIUS: light has changed radius.
- CS_WATCH_LIGHT_ATTENUATION: light has changed radius.
- CS_WATCH_MOVABLE_DESTROY: movable is destroyed.
- CS_WATCH_MOVABLE_CHANGED: movable is changed.
- CS_WATCH_SECTOR_NEWMESH: sector has a new mesh.
- CS_WATCH_SECTOR_REMOVEMESH: a mesh got removed from the sector.

virtual iSector* iObjectWatcher::GetLastSector | ( |  | ) | const`[pure virtual]`

| Get the last sector. Only valid if the last operation (GetLastOperation()) is one of CS_WATCH_SECTOR_....

virtual iLight* iObjectWatcher::GetLight | ( | int | idx | ) | `[pure virtual]`

| Get the specified watched light.

virtual iMovable* iObjectWatcher::GetMovable | ( | int | idx | ) | `[pure virtual]`

| Get the specified watched movable.

virtual iSector* iObjectWatcher::GetSector | ( | int | idx | ) | `[pure virtual]`

| Get the specified watched sector.

virtual int iObjectWatcher::GetWatchedLightCount | ( |  | ) | const`[pure virtual]`

| Get the number of watched lights.

virtual int iObjectWatcher::GetWatchedMovableCount | ( |  | ) | const`[pure virtual]`

| Get the number of watched movables.

virtual int iObjectWatcher::GetWatchedSectorCount | ( |  | ) | const`[pure virtual]`

| Get the number of watched sectors.

virtual uint32 iObjectWatcher::GetWatchNumber | ( |  | ) | const`[pure virtual]`

Get the current number for his watcher.

This number will increase as soon as some of the watched objects change. When this happens you can query the last change (only the last change!) by calling GetLastOperation() and/or GetLastLight() or GetLastMovable(). Note that if the operation indicates that something is destroyed then you should no longer use the pointer returned by GetLastLight() or GetLastMovable() as the object will already be gone by then. You can only use the returned pointer to clean up from internal data structures.

virtual void iObjectWatcher::RemoveLight | ( | iLight * | light | ) | `[pure virtual]`

| Remove a light to watch.

virtual void iObjectWatcher::RemoveListener | ( | iObjectWatcherListener * | cb | ) | `[pure virtual]`

| Remove a listener.

virtual void iObjectWatcher::RemoveMovable | ( | iMovable * | movable | ) | `[pure virtual]`

| Remove a movable to watch.

virtual void iObjectWatcher::RemoveSector | ( | iSector * | sector | ) | `[pure virtual]`

| Remove a sector to watch.

virtual void iObjectWatcher::Reset | ( |  | ) | `[pure virtual]`

| Reset. Remove all watched objects from this watcher.

virtual void iObjectWatcher::WatchLight | ( | iLight * | light | ) | `[pure virtual]`

| Add a light to watch.

virtual void iObjectWatcher::WatchMovable | ( | iMovable * | movable | ) | `[pure virtual]`

| Add a movable to watch.

virtual void iObjectWatcher::WatchSector | ( | iSector * | sector | ) | `[pure virtual]`

| Add a sector to watch for meshes.

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

- iengine/objwatch.h