1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
/*******************************************************************************
* vfeplatform.h
*
* Defines a *nix platform-specific session class derived from vfeSession.
*
* Based on vfe/win/vfeplatform.h by Christopher J. Cason
*
* ---------------------------------------------------------------------------
* Persistence of Vision Ray Tracer ('POV-Ray') version 3.7.
* Copyright 1991-2013 Persistence of Vision Raytracer Pty. Ltd.
*
* POV-Ray is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* POV-Ray is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------------
* POV-Ray is based on the popular DKB raytracer version 2.12.
* DKBTrace was originally written by David K. Buck.
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/povray/smp/vfe/unix/vfeplatform.h $
* $Revision: #12 $
* $Change: 6132 $
* $DateTime: 2013/11/25 14:23:41 $
* $Author: clipka $
*******************************************************************************/
#ifndef __VFEPLATFORM_H__
#define __VFEPLATFORM_H__
#include <boost/shared_ptr.hpp>
namespace vfePlatform
{
using namespace vfe;
class UnixOptionsProcessor;
class UnixShelloutProcessing: public ShelloutProcessing
{
public:
UnixShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height);
~UnixShelloutProcessing();
virtual int ProcessID(void);
virtual bool ShelloutsSupported(void) { return true; }
protected:
virtual bool ExecuteCommand(const string& cmd, const string& params);
virtual bool KillCommand(int timeout, bool force = false);
virtual bool CommandRunning(void);
virtual int CollectCommand(string& output);
virtual int CollectCommand(void);
virtual bool CommandPermitted(const string& command, const string& parameters);
bool m_ProcessRunning;
string m_Command;
string m_Params;
unsigned long m_ExitCode;
unsigned long m_LastError;
unsigned long m_ProcessId;
private:
UnixShelloutProcessing();
};
///////////////////////////////////////////////////////////////////////
// most of the methods in vfeUnixSession are derived from vfeSession.
// see vfeSession for documentation for those cases.
class vfeUnixSession : public vfeSession
{
public:
vfeUnixSession(int id = 0);
virtual ~vfeUnixSession() {}
virtual UCS2String GetTemporaryPath(void) const;
virtual UCS2String CreateTemporaryFile(void) const;
virtual void DeleteTemporaryFile(const UCS2String& filename) const;
virtual POV_LONG GetTimestamp(void) const ;
virtual void NotifyCriticalError(const char *message, const char *file, int line);
virtual int RequestNewOutputPath(int CallCount, const string& Reason, const UCS2String& OldPath, UCS2String& NewPath);
virtual bool TestAccessAllowed(const Path& file, bool isWrite) const;
virtual ShelloutProcessing *CreateShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height)
{ return new UnixShelloutProcessing(opts, scene, width, height); }
shared_ptr<UnixOptionsProcessor> GetUnixOptions(void) { return m_OptionsProc; }
protected:
virtual void WorkerThreadStartup();
virtual void WorkerThreadShutdown();
///////////////////////////////////////////////////////////////////////
// return true if the path component of file is equal to the path component
// of path. will also return true if recursive is true and path is a parent
// of file. does not support relative paths, and will convert UCS2 paths to
// ASCII and perform case-insensitive comparisons.
virtual bool TestPath(const Path& path, const Path& file, bool recursive) const;
///////////////////////////////////////////////////////////////////////
// perform case-sensitive UCS2 string comparison. does not take code-
// page into account.
virtual bool StrCompare (const UCS2String& lhs, const UCS2String& rhs) const;
///////////////////////////////////////////////////////////////////////
// used to detect wall clock changes to prevent GetTimeStamp()
// returning a value less than that of a previous call during the
// current session.
mutable POV_LONG m_LastTimestamp;
mutable POV_LONG m_TimestampOffset;
// platform specific configuration options
shared_ptr<UnixOptionsProcessor> m_OptionsProc;
} ;
///////////////////////////////////////////////////////////////////////
// return a number that uniquely identifies the calling thread amongst
// all other running threads in the process (and preferably in the OS).
POVMS_Sys_Thread_Type GetThreadId();
}
#endif
|