00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Side Effects Software Inc 00008 * 123 Front Street West, Suite 1401 00009 * Toronto, Ontario 00010 * Canada M5J 2M2 00011 * 416-504-9876 00012 * 00013 * NAME: IFD_RenderStream.h ( IFD Library, C++) 00014 * 00015 * COMMENTS: Creates a render stream. The stream uses the Scene to query 00016 * information about how the stream should behave (i.e. pipe to a 00017 * command or write to a file, background rendering etc.) 00018 * 00019 * The IFD_Output should simply create a stream when it needs one. 00020 * A new stream should be created for each individual stream. The 00021 * stream should NOT be re-used. 00022 * 00023 * The stream should NOT be deleted as this is handled 00024 * automatically. The stream should NOT be accessed after close() 00025 * is called, except through the stream notification. 00026 * 00027 * The stream gets its information by evaluating several render 00028 * tags defined on the scene. These tags are: 00029 * stream.filename - The script file to generate 00030 * stream.command - The command to run 00031 * stream.binary - Whether the script should be binary 00032 * stream.background - Whether to render in the background 00033 * stream.processgroup - Set to 1 if the renderer is RIB 00034 * This tag is used by windows to set 00035 * the appropriate flag when starting 00036 * the render command. 00037 */ 00038 00039 #ifndef __IFD_RenderStream__ 00040 #define __IFD_RenderStream__ 00041 00042 #include "IFD_API.h" 00043 #include <SYS/SYS_Types.h> 00044 #include <iostream.h> 00045 #include <UT/UT_String.h> 00046 #include "IFD_StreamEvent.h" 00047 00048 class UT_WritePipe; 00049 class UT_Signal; 00050 class IFD_Scene; 00051 00052 class IFD_API IFD_RenderStream { 00053 public: 00054 IFD_RenderStream(); 00055 ~IFD_RenderStream(); 00056 00057 // Methods for iterating over the active list of render streams 00058 static IFD_RenderStream *getStreamList(); 00059 IFD_RenderStream *getNext() { return myNext; } 00060 const IFD_RenderStream *getNext() const { return myNext; } 00061 00062 bool open(IFD_Scene &scene, fpreal now); 00063 bool openCommand(IFD_Scene &scene, const char *cmd, fpreal now); 00064 bool openScript(IFD_Scene &scene, const char *cmd, fpreal now); 00065 ostream *getStream() { return myStream; } 00066 bool close(); 00067 00068 bool isPipe() const { return myPipe != 0; } 00069 00070 void kill(); 00071 void pause(); 00072 void restart(); 00073 00074 int getPid() const { return myPid; } 00075 int getExitStatus() const { return myExitStatus; } 00076 00077 const char *getCommand() const { return myCommand; } 00078 time_t getStartTime() const { return myStartTime; } 00079 bool isPaused() const { return myPaused; } 00080 bool isDone() const { return myDone; } 00081 time_t getDuration() const; 00082 00083 UT_NotifierImpl<IFD_StreamEvent &> 00084 &getEventNotifier() { return myEventNotifier; } 00085 00086 static void pruneList(); 00087 00088 // Sets whether or not finished jobs should be removed from the list. 00089 static void setClearDoneFlag(bool cleardone); 00090 00091 // Removes stream from the list but only if it is done. 00092 static void removeStream(const IFD_RenderStream *stream); 00093 00094 private: 00095 00096 // Called when a job is finished (either killed or terminated normally) 00097 void finishJob(); 00098 00099 UT_NotifierImpl<IFD_StreamEvent &> myEventNotifier; 00100 IFD_RenderStream *myPrev, *myNext; 00101 UT_WritePipe *myPipe; 00102 UT_Signal *mySignal; 00103 ostream *myStream; 00104 UT_String myCommand; 00105 time_t myStartTime; 00106 int myPid; 00107 int myExitStatus; 00108 bool myPaused; 00109 bool myBackground; 00110 bool myDone; // Job is finished. 00111 time_t myDuration; // Job duration. 00112 00113 static bool theClearDoneFlag; // remove entry when job is done 00114 00115 00116 }; 00117 00118 #endif
1.5.9