reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

Inheritance diagram for ofURLFileLoaderImpl:
ofThread ofBaseURLFileLoader

Public Member Functions

 ofURLFileLoaderImpl ()
 
 ~ofURLFileLoaderImpl ()
 
ofHttpResponse get (const string &url)
 
int getAsync (const string &url, const string &name="")
 
ofHttpResponse saveTo (const string &url, const of::filesystem::path &path)
 
int saveAsync (const string &url, const of::filesystem::path &path)
 
void remove (int id)
 remove an active HTTP request from the queue
 
void clear ()
 clear all active HTTP requests from the queue
 
void stop ()
 stop & remove all active and waiting HTTP requests
 
ofHttpResponse handleRequest (const ofHttpRequest &request)
 low level HTTP request implementation blocks until a response is returned or the request times out
 
int handleRequestAsync (const ofHttpRequest &request)
 
- Public Member Functions inherited from ofThread
 ofThread ()
 Create an ofThread.
 
bool isThreadRunning () const
 Check the running status of the thread.
 
std::thread::id getThreadId () const
 Get the unique thread id.
 
std::string getThreadName () const
 Get the unique thread name, in the form of "Thread id#".
 
void setThreadName (const std::string &name)
 
void startThread ()
 Start the thread.
 
 OF_DEPRECATED_MSG ("Use tryLock instead of setting the type of lock on startThread", void startThread(bool mutexBlocks))
 Start the thread with options.
 
bool lock ()
 Lock the mutex.
 
bool tryLock ()
 Tries to lock the mutex.
 
void unlock ()
 Unlock the mutex.
 
void stopThread ()
 Stop the thread.
 
void waitForThread (bool callStopThread=true, long milliseconds=INFINITE_JOIN_TIMEOUT)
 Wait for the thread to exit (aka "joining" the thread).
 
void sleep (long milliseconds)
 Tell the thread to sleep for a certain amount of milliseconds.
 
void yield ()
 Tell the thread to give up its CPU time other threads.
 
bool isCurrentThread () const
 Query whether the current thread is active.
 
std::thread & getNativeThread ()
 Get a reference to the underlying Poco thread.
 
const std::thread & getNativeThread () const
 Get a const reference to the underlying Poco thread.
 
- Public Member Functions inherited from ofBaseURLFileLoader
virtual ~ofBaseURLFileLoader ()
 
virtual ofHttpResponse get (const std::string &url)=0
 make an HTTP request blocks until a response is returned or the request times out
 
virtual int getAsync (const std::string &url, const std::string &name="")=0
 make an asynchronous HTTP request will not block, placed in a queue and run using a background thread
 
virtual ofHttpResponse saveTo (const std::string &url, const of::filesystem::path &path)=0
 make an HTTP request and save the response data to a file blocks until a response is returned or the request times out
 
virtual int saveAsync (const std::string &url, const of::filesystem::path &path)=0
 make an asynchronous HTTP request and save the response data to a file will not block, placed in a queue and run using a background thread
 

Protected Member Functions

void threadedFunction ()
 The thread's run function.
 
void start ()
 
void update (ofEventArgs &args)
 

Additional Inherited Members

- Public Types inherited from ofThread
enum  { INFINITE_JOIN_TIMEOUT = -1 }
 
- Protected Attributes inherited from ofThread
std::thread thread
 The Poco::Thread that runs the Poco::Runnable.
 
std::mutex mutex
 The internal mutex called through lock() & unlock().
 

Constructor & Destructor Documentation

◆ ofURLFileLoaderImpl()

ofURLFileLoaderImpl::ofURLFileLoaderImpl ( )

◆ ~ofURLFileLoaderImpl()

ofURLFileLoaderImpl::~ofURLFileLoaderImpl ( )

Member Function Documentation

◆ clear()

void ofURLFileLoaderImpl::clear ( )
virtual

clear all active HTTP requests from the queue

Implements ofBaseURLFileLoader.

◆ get()

ofHttpResponse ofURLFileLoaderImpl::get ( const string &  url)

◆ getAsync()

int ofURLFileLoaderImpl::getAsync ( const string &  url,
const string &  name = "" 
)

◆ handleRequest()

ofHttpResponse ofURLFileLoaderImpl::handleRequest ( const ofHttpRequest request)
virtual

low level HTTP request implementation blocks until a response is returned or the request times out

Returns
HTTP response on success or failure

Implements ofBaseURLFileLoader.

◆ handleRequestAsync()

int ofURLFileLoaderImpl::handleRequestAsync ( const ofHttpRequest request)
virtual

Implements ofBaseURLFileLoader.

◆ remove()

void ofURLFileLoaderImpl::remove ( int  id)
virtual

remove an active HTTP request from the queue

Parameters
uniqueHTTP request id

Implements ofBaseURLFileLoader.

◆ saveAsync()

int ofURLFileLoaderImpl::saveAsync ( const string &  url,
const of::filesystem::path &  path 
)

◆ saveTo()

ofHttpResponse ofURLFileLoaderImpl::saveTo ( const string &  url,
const of::filesystem::path &  path 
)

◆ start()

void ofURLFileLoaderImpl::start ( )
protected

◆ stop()

void ofURLFileLoaderImpl::stop ( )
virtual

stop & remove all active and waiting HTTP requests

Implements ofBaseURLFileLoader.

◆ threadedFunction()

void ofURLFileLoaderImpl::threadedFunction ( )
protectedvirtual

The thread's run function.

Users must overide this in your their derived class and then implement their threaded activity inside the loop. If the the users's threadedFunction does not have a loop, the contents of the threadedFunction will be executed once and the thread will then exit.

For tasks that must be repeated, the user can use a while loop that will run repeatedly until the thread's threadRunning is set to false via the stopThread() method.

void MyThreadedClass::threadedFunction()
{
    // Start the loop and continue until
    // isThreadRunning() returns false.
    while(isThreadRunning())
    {
        // Do activity repeatedly here:

        // int j = 1 + 1;

        // This while loop will run as fast as it possibly
        // can, consuming as much processor speed as it can.
        // To help the processor stay cool, users are
        // encouraged to let the while loop sleep via the
        // sleep() method, or call the yield() method to let
        // other threads have a turn.  See the sleep() and
        // yield() methods for more information.

        // sleep(100);
    }
}

Reimplemented from ofThread.

◆ update()

void ofURLFileLoaderImpl::update ( ofEventArgs args)
protected

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