Panda3D
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
Loader Class Reference

A convenient class for loading models from disk, in bam or egg format (or any of a number of other formats implemented by a LoaderFileType, such as ptloader). More...

#include "loader.h"

Inheritance diagram for Loader:
TypedReferenceCount Namable TypedObject ReferenceCount MemoryBase MemoryBase MemoryBase

Classes

class  Results
 

Public Member Functions

 Loader (const std::string &name="loader")
 
virtual TypeHandle force_init_type ()
 
const std::string & get_task_chain () const
 Returns the task chain that is used for asynchronous loads. More...
 
AsyncTaskManagerget_task_manager () const
 Returns the task manager that is used for asynchronous loads. More...
 
virtual TypeHandle get_type () const
 
void load_async (AsyncTask *request)
 
 PT (PandaNode) load_sync(const Filename &filename
 
 PT (AsyncTask) make_async_request(const Filename &filename
 
 PT (AsyncTask) make_async_save_request(const Filename &filename
 
bool remove (AsyncTask *task)
 Removes a pending asynchronous load request. More...
 
void save_async (AsyncTask *request)
 Begins an asynchronous save request. More...
 
bool save_sync (const Filename &filename, const LoaderOptions &options, PandaNode *node) const
 Saves the file immediately, waiting for it to complete. More...
 
void set_task_chain (const std::string &task_chain)
 Specifies the task chain that is used for asynchronous loads. More...
 
void set_task_manager (AsyncTaskManager *task_manager)
 Specifies the task manager that is used for asynchronous loads. More...
 
void stop_threads ()
 Stop any threads used for asynchronous loads. More...
 
- Public Member Functions inherited from TypedReferenceCount
 TypedReferenceCount (const TypedReferenceCount &copy)
 
void operator= (const TypedReferenceCount &copy)
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref ()
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 
- Public Member Functions inherited from Namable
 Namable (const std::string &initial_name="")
 
void clear_name ()
 Resets the Namable's name to empty. More...
 
const std::string & get_name () const
 
bool has_name () const
 Returns true if the Namable has a nonempty name set, false if the name is empty. More...
 
void output (std::ostream &out) const
 Outputs the Namable. More...
 
void set_name (const std::string &name)
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static Loaderget_global_ptr ()
 Returns a pointer to the global Loader. More...
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from Namable
static TypeHandle get_class_type ()
 
static void init_type ()
 

Public Attributes

const LoaderOptions PandaNodenode
 
const LoaderOptionsoptions = LoaderOptions()) const
 
- Public Attributes inherited from TypedObject
 get_type
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count. More...
 
- Public Attributes inherited from Namable
 get_name
 
 set_name
 

Friends

class ModelLoadRequest
 

Detailed Description

A convenient class for loading models from disk, in bam or egg format (or any of a number of other formats implemented by a LoaderFileType, such as ptloader).

This class supports synchronous as well as asynchronous loading. In asynchronous loading, the model is loaded in the background by a thread, and an event will be generated when the model is available. If threading is not available, the asynchronous loading interface may be used, but it loads synchronously.

Definition at line 42 of file loader.h.

Member Function Documentation

◆ get_global_ptr()

Loader * Loader::get_global_ptr ( )
inlinestatic

Returns a pointer to the global Loader.

This is the Loader that most code should use for loading models.

Definition at line 212 of file loader.I.

◆ get_task_chain()

const std::string & Loader::get_task_chain ( ) const
inline

Returns the task chain that is used for asynchronous loads.

Definition at line 120 of file loader.I.

◆ get_task_manager()

AsyncTaskManager * Loader::get_task_manager ( ) const
inline

Returns the task manager that is used for asynchronous loads.

Definition at line 103 of file loader.I.

◆ remove()

bool Loader::remove ( AsyncTask task)
inline

Removes a pending asynchronous load request.

Returns true if successful, false otherwise.

Definition at line 141 of file loader.I.

◆ save_async()

void Loader::save_async ( AsyncTask request)
inline

Begins an asynchronous save request.

To use this call, first call make_async_save_request() to create a new ModelSaveRequest object with the filename you wish to load, and then add that object to the Loader with save_async. This function will return immediately, and the model will be loaded in the background.

To determine when the model has completely loaded, you may poll request->is_ready() from time to time, or set the done_event on the request object and listen for that event. When the request is ready, you may retrieve the success or failure via request->get_success().

Definition at line 202 of file loader.I.

References AsyncTask::set_task_chain.

◆ save_sync()

bool Loader::save_sync ( const Filename filename,
const LoaderOptions options,
PandaNode node 
) const
inline

Saves the file immediately, waiting for it to complete.

Definition at line 181 of file loader.I.

◆ set_task_chain()

void Loader::set_task_chain ( const std::string &  task_chain)
inline

Specifies the task chain that is used for asynchronous loads.

The default is the initial name of the Loader object.

Definition at line 112 of file loader.I.

◆ set_task_manager()

void Loader::set_task_manager ( AsyncTaskManager task_manager)
inline

Specifies the task manager that is used for asynchronous loads.

The default is the global task manager.

Definition at line 95 of file loader.I.

◆ stop_threads()

void Loader::stop_threads ( )
inline

Stop any threads used for asynchronous loads.

Definition at line 128 of file loader.I.


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