osgEarth 2.1.1
Public Types | Public Member Functions | Protected Attributes

osgEarth::TaskRequest Class Reference

Inheritance diagram for osgEarth::TaskRequest:
Collaboration diagram for osgEarth::TaskRequest:

List of all members.

Public Types

enum  State { STATE_IDLE, STATE_PENDING, STATE_IN_PROGRESS, STATE_COMPLETED }

Public Member Functions

 TaskRequest (float priority=0.0f)
virtual void operator() (ProgressCallback *progress)=0
void run ()
void cancel ()
bool isIdle () const
bool isPending () const
bool isCompleted () const
bool isInProgress () const
bool isRunning () const
bool wasCanceled () const
void setPriority (float value)
float getPriority () const
State getState () const
void setState (State s)
void setStamp (int stamp)
int getStamp () const
osg::Referenced * getResult () const
ProgressCallbackgetProgressCallback ()
void setProgressCallback (ProgressCallback *progress)
const std::string & getName () const
void setName (const std::string &name)
void reset ()
osg::Timer_t startTime () const
osg::Timer_t endTime () const
double runTime () const
void setCompletedEvent (Threading::Event *value)
Threading::EventgetCompletedEvent () const

Protected Attributes

float _priority
volatile State _state
volatile int _stamp
osg::ref_ptr< osg::Referenced > _result
osg::ref_ptr< ProgressCallback_progress
std::string _name
osg::Timer_t _startTime
osg::Timer_t _endTime
Threading::Event_completedEvent

Detailed Description

Definition at line 34 of file TaskService.


Member Enumeration Documentation

Enumerator:
STATE_IDLE 
STATE_PENDING 
STATE_IN_PROGRESS 
STATE_COMPLETED 

Definition at line 37 of file TaskService.


Constructor & Destructor Documentation

TaskRequest::TaskRequest ( float  priority = 0.0f)

Definition at line 29 of file TaskService.cpp.

                                         :
osg::Referenced( true ),
_priority( priority ),
_state( STATE_IDLE )
{
    _progress = new ProgressCallback();
}

Member Function Documentation

void TaskRequest::cancel ( )

Definition at line 53 of file TaskService.cpp.

{
    //OE_INFO << LC << "TR [" << getName() << "] canceled" << std::endl;
    _progress->cancel();
}
osg::Timer_t osgEarth::TaskRequest::endTime ( ) const [inline]

Definition at line 73 of file TaskService.

{ return _endTime; }
Threading::Event* osgEarth::TaskRequest::getCompletedEvent ( ) const [inline]

Definition at line 77 of file TaskService.

{ return _completedEvent; }
const std::string& osgEarth::TaskRequest::getName ( ) const [inline]

Definition at line 69 of file TaskService.

{ return _name; }
float osgEarth::TaskRequest::getPriority ( ) const [inline]

Definition at line 61 of file TaskService.

{ return _priority; }

Here is the caller graph for this function:

ProgressCallback* osgEarth::TaskRequest::getProgressCallback ( ) [inline]

Definition at line 67 of file TaskService.

{ return _progress.get(); }

Here is the caller graph for this function:

osg::Referenced* osgEarth::TaskRequest::getResult ( ) const [inline]

Definition at line 66 of file TaskService.

{ return _result.get(); }
int osgEarth::TaskRequest::getStamp ( ) const [inline]

Definition at line 65 of file TaskService.

{ return _stamp; }
State osgEarth::TaskRequest::getState ( ) const [inline]

Definition at line 62 of file TaskService.

{ return _state; }
bool osgEarth::TaskRequest::isCompleted ( ) const [inline]

Definition at line 54 of file TaskService.

{ return _state == STATE_COMPLETED; }
bool osgEarth::TaskRequest::isIdle ( ) const [inline]

Definition at line 52 of file TaskService.

{ return _state == STATE_IDLE; }
bool osgEarth::TaskRequest::isInProgress ( ) const [inline]

Definition at line 55 of file TaskService.

{ return _state == STATE_IN_PROGRESS; }
bool osgEarth::TaskRequest::isPending ( ) const [inline]

Definition at line 53 of file TaskService.

{ return _state == STATE_PENDING; }
bool osgEarth::TaskRequest::isRunning ( ) const [inline]

Definition at line 56 of file TaskService.

{ return isPending() || isInProgress(); }
virtual void osgEarth::TaskRequest::operator() ( ProgressCallback progress) [pure virtual]
void osgEarth::TaskRequest::reset ( ) [inline]

Definition at line 71 of file TaskService.

{ _result = 0L; }
void TaskRequest::run ( )

Definition at line 38 of file TaskService.cpp.

{
    if ( _state == STATE_IN_PROGRESS )
    {
        _startTime = osg::Timer::instance()->tick();
        (*this)( _progress.get() );        
        _endTime = osg::Timer::instance()->tick();
    }
    else
    {
        _progress->cancel();
    }
}
double osgEarth::TaskRequest::runTime ( ) const [inline]

Definition at line 74 of file TaskService.

{ return osg::Timer::instance()->delta_s(_startTime,_endTime); }
void osgEarth::TaskRequest::setCompletedEvent ( Threading::Event value) [inline]

Definition at line 76 of file TaskService.

{ _completedEvent = value; }
void osgEarth::TaskRequest::setName ( const std::string &  name) [inline]

Definition at line 70 of file TaskService.

{ _name = name; }

Here is the caller graph for this function:

void osgEarth::TaskRequest::setPriority ( float  value) [inline]

Definition at line 60 of file TaskService.

{ _priority = value; }

Here is the caller graph for this function:

void osgEarth::TaskRequest::setProgressCallback ( ProgressCallback progress) [inline]

Definition at line 68 of file TaskService.

{ _progress = progress? progress : new ProgressCallback(); }

Here is the caller graph for this function:

void osgEarth::TaskRequest::setStamp ( int  stamp) [inline]

Definition at line 64 of file TaskService.

{ _stamp = stamp; }
void osgEarth::TaskRequest::setState ( State  s) [inline]

Definition at line 63 of file TaskService.

{ _state = s; }

Here is the caller graph for this function:

osg::Timer_t osgEarth::TaskRequest::startTime ( ) const [inline]

Definition at line 72 of file TaskService.

{ return _startTime; }
bool TaskRequest::wasCanceled ( ) const

Definition at line 60 of file TaskService.cpp.

{
    return _progress->isCanceled();
}

Member Data Documentation

Definition at line 88 of file TaskService.

osg::Timer_t osgEarth::TaskRequest::_endTime [protected]

Definition at line 87 of file TaskService.

std::string osgEarth::TaskRequest::_name [protected]

Definition at line 85 of file TaskService.

Definition at line 80 of file TaskService.

Definition at line 84 of file TaskService.

osg::ref_ptr<osg::Referenced> osgEarth::TaskRequest::_result [protected]

Reimplemented in ImageRequest.

Definition at line 83 of file TaskService.

volatile int osgEarth::TaskRequest::_stamp [protected]

Definition at line 82 of file TaskService.

osg::Timer_t osgEarth::TaskRequest::_startTime [protected]

Definition at line 86 of file TaskService.

volatile State osgEarth::TaskRequest::_state [protected]

Definition at line 81 of file TaskService.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines