Panda3D
 All Classes Functions Variables Enumerations
modelSaveRequest.cxx
1 // Filename: modelSaveRequest.cxx
2 // Created by: drose (19Dec12)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "modelSaveRequest.h"
16 #include "loader.h"
17 #include "config_pgraph.h"
18 
19 TypeHandle ModelSaveRequest::_type_handle;
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: ModelSaveRequest::Constructor
23 // Access: Published
24 // Description: Create a new ModelSaveRequest, and add it to the loader
25 // via save_async(), to begin an asynchronous save.
26 ////////////////////////////////////////////////////////////////////
28 ModelSaveRequest(const string &name,
29  const Filename &filename, const LoaderOptions &options,
30  PandaNode *node, Loader *loader) :
31  AsyncTask(name),
32  _filename(filename),
33  _options(options),
34  _node(node),
35  _loader(loader),
36  _is_ready(false),
37  _success(false)
38 {
39 }
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function: ModelSaveRequest::do_task
43 // Access: Protected, Virtual
44 // Description: Performs the task: that is, saves the one model.
45 ////////////////////////////////////////////////////////////////////
46 AsyncTask::DoneStatus ModelSaveRequest::
47 do_task() {
48  double delay = async_load_delay;
49  if (delay != 0.0) {
50  Thread::sleep(delay);
51  }
52 
53  _success = _loader->save_sync(_filename, _options, _node);
54  _is_ready = true;
55 
56  // Don't continue the task; we're done.
57  return DS_done;
58 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
Specifies parameters that may be passed to the loader.
Definition: loaderOptions.h:26
A convenient class for loading models from disk, in bam or egg format (or any of a number of other fo...
Definition: loader.h:47
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
static void sleep(double seconds)
Suspends the current thread for at least the indicated amount of time.
Definition: thread.I:236
ModelSaveRequest(const string &name, const Filename &filename, const LoaderOptions &options, PandaNode *node, Loader *loader)
Create a new ModelSaveRequest, and add it to the loader via save_async(), to begin an asynchronous sa...
This class represents a concrete task performed by an AsyncManager.
Definition: asyncTask.h:43
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85