diff --git a/platform/unix/syspovfilesystem.cpp b/platform/unix/syspovfilesystem.cpp
new file mode 100644
index 000000000..df7b5e4ed
--- /dev/null
+++ b/platform/unix/syspovfilesystem.cpp
@@ -0,0 +1,175 @@
+//******************************************************************************
+///
+/// @file platform/unix/syspovfilesystem.cpp
+///
+/// Unix-specific implementation of file system services.
+///
+/// @copyright
+/// @parblock
+///
+/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
+/// Copyright 1991-2019 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 .
+///
+/// ----------------------------------------------------------------------------
+///
+/// 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.
+///
+/// @endparblock
+///
+//******************************************************************************
+
+// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config)
+#include "base/filesystem.h"
+#include "syspovfilesystem.h"
+
+// C++ variants of C standard header files
+// (none at the moment)
+
+// C++ standard header files
+#include
+
+// POSIX standard header files
+#include
+#include
+
+// POV-Ray header files (base module)
+#include "base/stringutilities.h"
+
+// this must be the last file included
+#include "base/povassert.h"
+#include "base/povdebug.h"
+
+namespace pov_base
+{
+
+namespace Filesystem
+{
+
+//******************************************************************************
+
+#if !POV_USE_DEFAULT_DELETEFILE
+
+bool DeleteFile(const UCS2String& fileName)
+{
+ return (unlink(UCS2toSysString(fileName).c_str()) == 0);
+}
+
+#endif // POV_USE_DEFAULT_DELETEFILE
+
+//******************************************************************************
+
+#if !POV_USE_DEFAULT_LARGEFILE
+
+#ifndef POVUNIX_LSEEK64
+#define POVUNIX_LSEEK64(h,b,o) lseek(h,b,o)
+#endif
+
+using Offset = decltype(POVUNIX_LSEEK64(0,0,0));
+
+static_assert(
+ std::numeric_limits::digits > 32,
+ "Large files (> 2 GiB) not supported, limiting image size to approx. 100 Megapixels. Proceed at your own risk."
+ );
+
+struct LargeFile::Data final
+{
+ int handle;
+ Data() : handle(-1) {}
+};
+
+LargeFile::LargeFile() :
+ mpData(new Data)
+{}
+
+LargeFile::~LargeFile()
+{
+ Close();
+}
+
+bool LargeFile::CreateRW(const UCS2String& fileName)
+{
+ mpData->handle = open(UCS2toSysString(fileName).c_str(),
+ O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR);
+ return (mpData->handle != -1);
+}
+
+bool LargeFile::Seek(std::int_least64_t offset)
+{
+ if (mpData->handle == -1)
+ return false;
+ if ((offset < 0) || (offset > std::numeric_limits::max()))
+ return false;
+ return (POVUNIX_LSEEK64(mpData->handle, Offset(offset), SEEK_SET) == offset);
+}
+
+std::size_t LargeFile::Read(void* data, std::size_t maxSize)
+{
+ if (mpData->handle == -1)
+ return false;
+ return read(mpData->handle, data, int(maxSize));
+}
+
+bool LargeFile::Write(const void* data, std::size_t size)
+{
+ if (mpData->handle == -1)
+ return false;
+ return (write(mpData->handle, data, int(size)) == size);
+}
+
+void LargeFile::Close()
+{
+ if (mpData->handle != -1)
+ {
+ close(mpData->handle);
+ mpData->handle = -1;
+ }
+}
+
+#endif // POV_USE_DEFAULT_LARGEFILE
+
+//******************************************************************************
+
+#if !POV_USE_DEFAULT_TEMPORARYFILE
+
+static UCS2String gTempPath;
+
+void SetTempFilePath(const UCS2String& tempPath)
+{
+ gTempPath = tempPath;
+}
+
+UCS2String TemporaryFile::SuggestName()
+{
+ POV_ASSERT(!gTempPath.empty());
+
+ // TODO FIXME - This allows only one temporary file per process!
+ // TODO FIXME - Avoid converting back and forth between UCS-2 and system-specific encoding.
+ char str [POV_FILENAME_BUFFER_CHARS + 1] = "";
+ std::snprintf(str, POV_FILENAME_BUFFER_CHARS + 1, "%spov%d", UCS2toSysString(gTempPath).c_str(), int(getpid()));
+ return SysToUCS2String(str);
+}
+
+#endif // POV_USE_DEFAULT_TEMPORARYFILE
+
+//******************************************************************************
+
+}
+// end of namespace Filesystem
+
+}
+// end of namespace pov_base
diff --git a/platform/unix/syspovfilesystem.h b/platform/unix/syspovfilesystem.h
new file mode 100644
index 000000000..501fc6fab
--- /dev/null
+++ b/platform/unix/syspovfilesystem.h
@@ -0,0 +1,72 @@
+//******************************************************************************
+///
+/// @file platform/unix/syspovfilesystem.h
+///
+/// Unix-specific declarations related to file system services.
+///
+/// @note
+/// Most of @ref platform/unix/syspovfilesystem.cpp is declared in
+/// @ref base/filesystem.h. This file contains only a few extra
+/// platform-specific declarations.
+///
+/// @copyright
+/// @parblock
+///
+/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
+/// Copyright 1991-2019 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 .
+///
+/// ----------------------------------------------------------------------------
+///
+/// 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.
+///
+/// @endparblock
+///
+//******************************************************************************
+
+#ifndef POVRAY_UNIX_SYSPOVFILESYSTEM_H
+#define POVRAY_UNIX_SYSPOVFILESYSTEM_H
+
+// Module config header file must be the first file included within POV-Ray unit header files
+#include "base/configbase.h"
+
+// C++ variants of C standard header files
+// C++ standard header files
+// (none at the moment)
+
+// POV-Ray header files (base module)
+#include "base/stringtypes.h"
+
+namespace pov_base
+{
+
+namespace Filesystem
+{
+
+#if !POV_USE_DEFAULT_TEMPORARYFILE
+
+void SetTempFilePath(const UCS2String& tempPath);
+
+#endif // POV_USE_DEFAULT_TEMPORARYFILE
+
+}
+// end of namespace Filesystem
+
+}
+// end of namespace pov_base
+
+#endif // POVRAY_UNIX_SYSPOVFILESYSTEM_H
diff --git a/platform/unix/syspovtimer.cpp b/platform/unix/syspovtimer.cpp
index 13184847e..239a59316 100644
--- a/platform/unix/syspovtimer.cpp
+++ b/platform/unix/syspovtimer.cpp
@@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -50,6 +50,7 @@
#include
#endif
+#include "base/povassert.h"
#include "base/types.h"
// this must be the last file included
@@ -305,3 +306,4 @@ bool Timer::HasValidThreadCPUTime () const
//******************************************************************************
}
+// end of namespace pov_base
diff --git a/platform/unix/syspovtimer.h b/platform/unix/syspovtimer.h
index bd5a81e81..b70305ff4 100644
--- a/platform/unix/syspovtimer.h
+++ b/platform/unix/syspovtimer.h
@@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -62,7 +62,7 @@ void Delay(unsigned int msec);
/// in the order of an hour (any system with a 32-bit `clock_t` and a standard `CLOCKS_PER_SEC`
/// of 1,000,000).
///
-class Timer
+class Timer final
{
public:
@@ -105,5 +105,6 @@ class Timer
#endif // !POV_USE_DEFAULT_TIMER
}
+// end of namespace pov_base
#endif // POVRAY_UNIX_SYSPOVTIMER_H
diff --git a/platform/windows/osversioninfo.cpp b/platform/windows/osversioninfo.cpp
index a58eb3b7c..ecf60ebde 100644
--- a/platform/windows/osversioninfo.cpp
+++ b/platform/windows/osversioninfo.cpp
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -60,3 +60,4 @@ bool WindowsVersionDetector::IsVersion (int major, int minor) const
}
}
+// end of namespace pov_base
diff --git a/platform/windows/osversioninfo.h b/platform/windows/osversioninfo.h
index 8e7af9d2c..ee794d33c 100644
--- a/platform/windows/osversioninfo.h
+++ b/platform/windows/osversioninfo.h
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -43,7 +43,7 @@
namespace pov_base
{
-class WindowsVersionDetector
+class WindowsVersionDetector final
{
public:
@@ -74,5 +74,6 @@ class WindowsVersionDetector
};
}
+// end of namespace pov_base
#endif // POVRAY_WINDOWS_OSVERSIONINFO_H
diff --git a/platform/windows/syspovfilesystem.cpp b/platform/windows/syspovfilesystem.cpp
new file mode 100644
index 000000000..8c811f06d
--- /dev/null
+++ b/platform/windows/syspovfilesystem.cpp
@@ -0,0 +1,212 @@
+//******************************************************************************
+///
+/// @file platform/windows/syspovfilesystem.cpp
+///
+/// Windows-specific implementation of file system services.
+///
+/// @copyright
+/// @parblock
+///
+/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
+/// Copyright 1991-2019 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 .
+///
+/// ----------------------------------------------------------------------------
+///
+/// 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.
+///
+/// @endparblock
+///
+//******************************************************************************
+
+// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config)
+#include "base/filesystem.h"
+
+// C++ variants of C standard header files
+#include
+
+// C++ standard header files
+#include
+
+// POSIX standard header files
+#include
+#include
+#include
+
+// Windows API header files
+#include
+
+// POV-Ray header files (base module)
+#include "base/pov_err.h"
+#include "base/stringutilities.h"
+
+// this must be the last file included
+#include "base/povdebug.h"
+
+namespace pov_base
+{
+
+namespace Filesystem
+{
+
+#ifdef DeleteFile
+#undef DeleteFile // Shame on you, Windows!
+#endif
+
+// TODO - Consider using Windows API calls instead of POSIX-style functions
+// (e.g. `CreateFileW()` instead of `_open()` or `_wopen()`).
+
+//******************************************************************************
+
+#if !POV_USE_DEFAULT_DELETEFILE
+
+bool DeleteFile(const UCS2String& fileName)
+{
+ // TODO - use `_wunlink()` instead.
+ return (_unlink(UCS2toSysString(fileName).c_str()) == 0);
+}
+
+#endif // POV_USE_DEFAULT_DELETEFILE
+
+//******************************************************************************
+
+#if !POV_USE_DEFAULT_LARGEFILE
+
+using Offset = decltype(_lseeki64(0,0,0));
+
+static_assert(
+ std::numeric_limits::digits > 32,
+ "Large files (> 2 GiB) not supported, limiting image size to approx. 100 Megapixels. Proceed at your own risk."
+ );
+
+struct LargeFile::Data final
+{
+ int handle;
+ Data() : handle(-1) {}
+};
+
+LargeFile::LargeFile() :
+ mpData(new Data)
+{}
+
+LargeFile::~LargeFile()
+{
+ Close();
+}
+
+bool LargeFile::CreateRW(const UCS2String& fileName)
+{
+ // TODO - use `_wopen()` instead.
+ mpData->handle = _open(UCS2toSysString(fileName).c_str(),
+ _O_CREAT | _O_RDWR | _O_TRUNC | _O_BINARY, _S_IREAD | _S_IWRITE);
+ return (mpData->handle != -1);
+}
+
+bool LargeFile::Seek(std::int_least64_t offset)
+{
+ if (mpData->handle == -1)
+ return false;
+ if ((offset < 0) || (offset > std::numeric_limits::max()))
+ return false;
+ return (_lseeki64(mpData->handle, Offset(offset), SEEK_SET) == offset);
+}
+
+std::size_t LargeFile::Read(void* data, std::size_t maxSize)
+{
+ if (mpData->handle == -1)
+ return false;
+ return _read(mpData->handle, data, int(maxSize));
+}
+
+bool LargeFile::Write(const void* data, std::size_t size)
+{
+ if (mpData->handle == -1)
+ return false;
+ return (_write(mpData->handle, data, int(size)) == size);
+}
+
+void LargeFile::Close()
+{
+ if (mpData->handle != -1)
+ {
+ _close(mpData->handle);
+ mpData->handle = -1;
+ }
+}
+
+#endif // POV_USE_DEFAULT_LARGEFILE
+
+//******************************************************************************
+
+#if !POV_USE_DEFAULT_TEMPORARYFILE
+
+static std::wstring GetTempFilePath()
+{
+ static const auto maxTempPathLength = MAX_PATH - 14; // Leave space for the file names to be created.
+ static const auto* subdir = L"povwin\\";
+ static const auto subdirLength = std::wcslen(subdir);
+
+ // Get a maximum(!) estimate of the buffer size required (excluding terminating NUL).
+ auto bufferSizeRequired = GetTempPathW(0, nullptr);
+ if (bufferSizeRequired == 0)
+ throw POV_EXCEPTION(kUncategorizedError, "Could not get temp dir from Windows API");
+
+ // Now get the actual temp directory path.
+ std::wstring tempPath(bufferSizeRequired - 1, '\0');
+ auto tempPathLength = GetTempPathW(bufferSizeRequired, const_cast(tempPath.c_str()));
+ if (tempPathLength == 0)
+ throw POV_EXCEPTION(kUncategorizedError, "Could not get temp dir from Windows API");
+ if (tempPathLength >= bufferSizeRequired)
+ throw POV_EXCEPTION(kUncategorizedError, "Could not get temp dir from Windows API");
+ tempPath.resize(tempPathLength);
+
+ // Try to create a dedicated sub-directory for POV-Ray.
+ if (tempPathLength <= maxTempPathLength - subdirLength)
+ {
+ // Resulting path should be short enough for a sub-directory.
+ tempPath += subdir;
+ if ((CreateDirectoryW(tempPath.c_str(), nullptr) == 0) && (GetLastError() != ERROR_ALREADY_EXISTS))
+ // We can't create the sub-directory, and it doesn't already exist either.
+ // Well, tough luck - we'll just dump our stuff in the main temp directory then.
+ // Roll back the addition of the sub-directory name.
+ tempPath.resize(tempPathLength);
+ }
+
+ // That's it, we've officially chosen a directory to plonk our temporary files in.
+ return tempPath;
+}
+
+UCS2String TemporaryFile::SuggestName()
+{
+ static const auto* prefix = L"pv";
+
+ static std::wstring tempPath(GetTempFilePath());
+ wchar_t buffer[MAX_PATH];
+ if (GetTempFileNameW(tempPath.c_str(), prefix, 0, buffer) == 0)
+ throw POV_EXCEPTION(kUncategorizedError, "Could not get temp file name from Windows API");
+ return UCS2String(reinterpret_cast(buffer)); // TODO - this is actually UTF-16, not UCS-2.
+}
+
+#endif // POV_USE_DEFAULT_TEMPORARYFILE
+
+//******************************************************************************
+
+}
+// end of namespace Filesystem
+
+}
+// end of namespace pov_base
diff --git a/platform/windows/syspovpath.cpp b/platform/windows/syspovpath.cpp
index d45d864cd..0f92f432f 100644
--- a/platform/windows/syspovpath.cpp
+++ b/platform/windows/syspovpath.cpp
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -38,6 +38,10 @@
// this must be the last file included
#include "base/povdebug.h"
+#include
+
+#include "base/stringtypes.h"
+
namespace pov_base
{
@@ -57,7 +61,7 @@ static inline bool IsParentDir(const UCS2String& s)
return (s.length() == 2) && (s[0] == '.') && (s[1] == '.');
}
-bool Path::ParsePathString (UCS2String& volume, vector& dirnames, UCS2String& filename, const UCS2String& path)
+bool Path::ParsePathString (UCS2String& volume, std::vector& dirnames, UCS2String& filename, const UCS2String& path)
{
UCS2String stash;
@@ -194,3 +198,4 @@ bool Path::ParsePathString (UCS2String& volume, vector& dirnames, UC
//******************************************************************************
}
+// end of namespace pov_base
diff --git a/platform/windows/syspovpath.h b/platform/windows/syspovpath.h
index bf5371958..055d83bce 100644
--- a/platform/windows/syspovpath.h
+++ b/platform/windows/syspovpath.h
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -46,5 +46,6 @@ namespace pov_base
// Currently there are no Windows-specific declarations.
}
+// end of namespace pov_base
#endif // POVRAY_WINDOWS_SYSPOVPATH_H
diff --git a/platform/windows/syspovtask.cpp b/platform/windows/syspovtask.cpp
index 85f8940b7..003f9da16 100644
--- a/platform/windows/syspovtask.cpp
+++ b/platform/windows/syspovtask.cpp
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -52,6 +52,7 @@ void WinMemThreadStartup();
void WinMemThreadCleanup();
}
+// end of namespace povwin
#endif
@@ -75,6 +76,7 @@ static unsigned int GetNumberofCPUs (void)
}
}
+// end of namespace vfeplatform
namespace pov
@@ -116,3 +118,4 @@ void Task::Cleanup ()
//******************************************************************************
}
+// end of namespace pov
diff --git a/platform/windows/syspovtask.h b/platform/windows/syspovtask.h
index 94a274ae6..d960e2dbd 100644
--- a/platform/windows/syspovtask.h
+++ b/platform/windows/syspovtask.h
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -46,5 +46,6 @@ namespace pov
// Currently there are no Windows-specific declarations.
}
+// end of namespace pov
#endif // POVRAY_WINDOWS_SYSPOVTASK_H
diff --git a/platform/windows/syspovtimer.cpp b/platform/windows/syspovtimer.cpp
index c2de78178..e4b793eb0 100644
--- a/platform/windows/syspovtimer.cpp
+++ b/platform/windows/syspovtimer.cpp
@@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -36,12 +36,11 @@
#include "syspovtimer.h"
-#include
-
#include
#include
#include
+#include "base/povassert.h"
#include "base/types.h"
#include "osversioninfo.h"
@@ -177,3 +176,4 @@ bool Timer::HasValidProcessCPUTime () const
}
}
+// end of namespace pov_base
diff --git a/platform/windows/syspovtimer.h b/platform/windows/syspovtimer.h
index 521a46e42..d6610fdd4 100644
--- a/platform/windows/syspovtimer.h
+++ b/platform/windows/syspovtimer.h
@@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -44,7 +44,7 @@ namespace pov_base
void Delay(unsigned int msec);
-class Timer
+class Timer final
{
public:
Timer();
@@ -73,5 +73,6 @@ class Timer
};
}
+// end of namespace pov_base
#endif // POVRAY_WINDOWS_SYSPOVTIMER_H
diff --git a/platform/x86/avx/avxnoise.cpp b/platform/x86/avx/avxnoise.cpp
index 06552a63a..047b28bfb 100644
--- a/platform/x86/avx/avxnoise.cpp
+++ b/platform/x86/avx/avxnoise.cpp
@@ -16,7 +16,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -48,6 +48,8 @@
#include MACHINE_INTRINSICS_H
#endif
+#include "base/povassert.h"
+
#include "core/material/noise.h"
/// @file
@@ -529,6 +531,7 @@ void AVXDNoise(Vector3d& result, const Vector3d& EPoint) { POV_ASSERT(false); }
#endif // DISABLE_OPTIMIZED_NOISE_AVX
}
+// end of namespace pov
#endif // TRY_OPTIMIZED_NOISE_AVX
diff --git a/platform/x86/avx/avxnoise.h b/platform/x86/avx/avxnoise.h
index acaee324b..e7c766c5c 100644
--- a/platform/x86/avx/avxnoise.h
+++ b/platform/x86/avx/avxnoise.h
@@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -58,6 +58,7 @@ DBL AVXNoise(const Vector3d& EPoint, int noise_generator);
void AVXDNoise(Vector3d& result, const Vector3d& EPoint);
}
+// end of namespace pov
#endif // TRY_OPTIMIZED_NOISE_AVX
diff --git a/platform/x86/avx/avxportablenoise.cpp b/platform/x86/avx/avxportablenoise.cpp
index fcb981380..96ffeec81 100644
--- a/platform/x86/avx/avxportablenoise.cpp
+++ b/platform/x86/avx/avxportablenoise.cpp
@@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -37,6 +37,8 @@
// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config)
#include "avxportablenoise.h"
+#include "base/povassert.h"
+
#include "core/material/pattern.h"
#include "core/material/texture.h"
@@ -55,6 +57,7 @@ namespace pov
{
const bool kAVXPortableNoiseEnabled = true;
}
+// end of namespace pov
#define PORTABLE_OPTIMIZED_NOISE
#define PortableNoise AVXPortableNoise
@@ -69,6 +72,7 @@ const bool kAVXPortableNoiseEnabled = false;
DBL AVXPortableNoise(const Vector3d& EPoint, int noise_generator) { POV_ASSERT(false); return 0.0; }
void AVXPortableDNoise(Vector3d& result, const Vector3d& EPoint) { POV_ASSERT(false); }
}
+// end of namespace pov
#endif // DISABLE_OPTIMIZED_NOISE_AVX_PORTABLE
diff --git a/platform/x86/avx/avxportablenoise.h b/platform/x86/avx/avxportablenoise.h
index 870dfc0bd..63a2e8d05 100644
--- a/platform/x86/avx/avxportablenoise.h
+++ b/platform/x86/avx/avxportablenoise.h
@@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -52,6 +52,7 @@ DBL AVXPortableNoise(const Vector3d& EPoint, int noise_generator);
void AVXPortableDNoise(Vector3d& result, const Vector3d& EPoint);
}
+// end of namespace pov
#endif // TRY_OPTIMIZED_NOISE_AVX_PORTABLE
diff --git a/platform/x86/avx2fma3/avx2fma3noise.cpp b/platform/x86/avx2fma3/avx2fma3noise.cpp
index db1e2b578..ba4b5827d 100644
--- a/platform/x86/avx2fma3/avx2fma3noise.cpp
+++ b/platform/x86/avx2fma3/avx2fma3noise.cpp
@@ -16,7 +16,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -48,6 +48,8 @@
#include MACHINE_INTRINSICS_H
#endif
+#include "base/povassert.h"
+
#include "core/material/noise.h"
/// @file
@@ -516,6 +518,7 @@ void AVX2FMA3DNoise(Vector3d& result, const Vector3d& EPoint) { POV_ASSERT(false
#endif // DISABLE_OPTIMIZED_NOISE_AVX2FMA3
}
+// end of namespace pov
#endif // TRY_OPTIMIZED_NOISE_AVX2FMA3
diff --git a/platform/x86/avx2fma3/avx2fma3noise.h b/platform/x86/avx2fma3/avx2fma3noise.h
index 7243fcb3d..4d217ca9c 100644
--- a/platform/x86/avx2fma3/avx2fma3noise.h
+++ b/platform/x86/avx2fma3/avx2fma3noise.h
@@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -58,6 +58,7 @@ DBL AVX2FMA3Noise(const Vector3d& EPoint, int noise_generator);
void AVX2FMA3DNoise(Vector3d& result, const Vector3d& EPoint);
}
+// end of namespace pov
#endif // TRY_OPTIMIZED_NOISE_AVX2FMA3
diff --git a/platform/x86/avxfma4/avxfma4noise.cpp b/platform/x86/avxfma4/avxfma4noise.cpp
index 20db191de..81740989d 100644
--- a/platform/x86/avxfma4/avxfma4noise.cpp
+++ b/platform/x86/avxfma4/avxfma4noise.cpp
@@ -11,7 +11,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -43,6 +43,8 @@
#include MACHINE_INTRINSICS_H
#endif
+#include "base/povassert.h"
+
#include "core/material/noise.h"
/// @file
@@ -417,6 +419,7 @@ void AVXFMA4DNoise(Vector3d& result, const Vector3d& EPoint) { POV_ASSERT(false)
#endif // DISABLE_OPTIMIZED_NOISE_AVXFMA4
}
+// end of namespace pov
#endif // TRY_OPTIMIZED_NOISE_AVXFMA4
diff --git a/platform/x86/avxfma4/avxfma4noise.h b/platform/x86/avxfma4/avxfma4noise.h
index bd71b3aab..541eb40c4 100644
--- a/platform/x86/avxfma4/avxfma4noise.h
+++ b/platform/x86/avxfma4/avxfma4noise.h
@@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -56,6 +56,7 @@ DBL AVXFMA4Noise(const Vector3d& EPoint, int noise_generator);
void AVXFMA4DNoise(Vector3d& result, const Vector3d& EPoint);
}
+// end of namespace pov
#endif // TRY_OPTIMIZED_NOISE_AVXFMA4
diff --git a/platform/x86/cpuid.cpp b/platform/x86/cpuid.cpp
index 5b38296ca..7c86b08ac 100644
--- a/platform/x86/cpuid.cpp
+++ b/platform/x86/cpuid.cpp
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -36,8 +36,13 @@
// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config)
#include "cpuid.h"
+// C++ variants of C standard header files
#include
+// C++ standard header files
+#include
+
+// other 3rd party library header files
#ifdef MACHINE_INTRINSICS_H
#include MACHINE_INTRINSICS_H
#endif
@@ -142,7 +147,7 @@ enum CPUVendorId
kCPUVendor_VM,
};
-struct CPUVendorInfo
+struct CPUVendorInfo final
{
CPUVendorId id;
const char* cpuidString;
@@ -162,7 +167,7 @@ CPUVendorInfo gCPUVendorInfo[] = {
{ kCPUVendor_Unrecognized, nullptr }
};
-struct CPUIDInfo
+struct CPUIDInfo final
{
CPUVendorId vendorId;
bool xsave : 1;
@@ -229,7 +234,7 @@ CPUIDInfo::CPUIDInfo() :
}
}
-struct OSInfo
+struct OSInfo final
{
bool xcr0_sse : 1;
bool xcr0_avx : 1;
@@ -256,7 +261,7 @@ OSInfo::OSInfo(const CPUIDInfo& cpuinfo) :
/// does _not_ depend on the order of member-initializers in the constructor,
/// but rather on the _order of declaration_.
///
-struct CPUInfo::Data
+struct CPUInfo::Data final
{
CPUIDInfo cpuidInfo;
OSInfo osInfo;
diff --git a/platform/x86/cpuid.h b/platform/x86/cpuid.h
index 4824c8ee8..d403dd3f5 100644
--- a/platform/x86/cpuid.h
+++ b/platform/x86/cpuid.h
@@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -39,7 +39,13 @@
#include "base/configbase.h"
-class CPUInfo
+// C++ variants of C standard header files
+// (none at the moment)
+
+// C++ standard header files
+#include
+
+class CPUInfo final
{
public:
static bool SupportsSSE2(); ///< Test whether CPU and OS support SSE2.
diff --git a/platform/x86/optimizednoise.cpp b/platform/x86/optimizednoise.cpp
index 6ea010f9c..cdcda7127 100644
--- a/platform/x86/optimizednoise.cpp
+++ b/platform/x86/optimizednoise.cpp
@@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -125,5 +125,6 @@ OptimizedNoiseInfo gaOptimizedNoiseInfo[] = {
};
}
+// end of namespace pov
#endif // TRY_OPTIMIZED_NOISE
diff --git a/source-doc/styleguide.md b/source-doc/styleguide.md
index c4d50303a..d2c21687e 100644
--- a/source-doc/styleguide.md
+++ b/source-doc/styleguide.md
@@ -41,6 +41,8 @@ POV-Ray is being developed with portability high in mind. In practice and at pre
- _Static Thread-Local Template Members_: Template classes _must not_ have thread-local
static member variables. See the @ref PooledSimpleVector template class for a viable
workaround. [XCode 8 and later, apparently still unresolved as of 2018-04-08]
+ - `std::floorf(float)`: This function _must not_ be used. Substitute `std::floor(float)`
+ instead. [GCC, apparently all versions as of 2019-02-11]
- Source code should use the new features of C++11 with caution, as even some major compiler
brands still have not achieved full compliance yet. The following constructs can be considered
@@ -264,6 +266,14 @@ To test whether a smart pointer is (non-)null, do not unnecessarily clutter your
with `NULL`, as that would lead to compile errors on some (perfectly C++11 compliant) compilers.
+Classes
+=======
+
+ - All classes should be declared `final` unless specifically intended otherwise.
+ - All destructors of polymorphic classes should be declared `virtual`.
+ - All overriding methods (including destructors) should be declared both `virtual` and `override`.
+
+
Miscellaneous Coding Rules
==========================
diff --git a/source/backend/bounding/boundingtask.cpp b/source/backend/bounding/boundingtask.cpp
index 3aa09564a..f05ae93bd 100644
--- a/source/backend/bounding/boundingtask.cpp
+++ b/source/backend/bounding/boundingtask.cpp
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -33,22 +33,33 @@
///
//******************************************************************************
+// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config)
+#include "backend/bounding/boundingtask.h"
+
+// C++ variants of C standard header files
+// (none at the moment)
+
+// C++ standard header files
#include
+#include
+// Boost header files
#include
#include
-// frame.h must always be the first POV file included (pulls in platform config)
-#include "backend/frame.h"
-#include "backend/bounding/boundingtask.h"
+// POV-Ray header files (base module)
+// (none at the moment)
+// POV-Ray header files (core module)
#include "core/bounding/bsptree.h"
#include "core/math/matrix.h"
#include "core/scene/object.h"
#include "core/scene/tracethreaddata.h"
+// POV-Ray header files (POVMS module)
#include "povms/povmsid.h"
+// POV-Ray header files (backend module)
#include "backend/scene/backendscenedata.h"
#include "backend/support/task.h"
@@ -58,7 +69,9 @@
namespace pov
{
-class SceneObjects : public BSPTree::Objects
+using std::vector;
+
+class SceneObjects final : public BSPTree::Objects
{
public:
vector infinite;
@@ -81,28 +94,28 @@ class SceneObjects : public BSPTree::Objects
}
}
- virtual ~SceneObjects()
+ virtual ~SceneObjects() override
{
// nothing to do
}
- virtual unsigned int size() const
+ virtual unsigned int size() const override
{
return finite.size();
}
- virtual float GetMin(unsigned int axis, unsigned int i) const
+ virtual float GetMin(unsigned int axis, unsigned int i) const override
{
return finite[i]->BBox.lowerLeft[axis];
}
- virtual float GetMax(unsigned int axis, unsigned int i) const
+ virtual float GetMax(unsigned int axis, unsigned int i) const override
{
return (finite[i]->BBox.lowerLeft[axis] + finite[i]->BBox.size[axis]);
}
};
-class BSPProgress : public BSPTree::Progress
+class BSPProgress final : public BSPTree::Progress
{
public:
BSPProgress(RenderBackend::SceneId sid, POVMSAddress addr, Task& task) :
@@ -113,7 +126,7 @@ class BSPProgress : public BSPTree::Progress
{
}
- virtual void operator()(unsigned int nodes) const
+ virtual void operator()(unsigned int nodes) const override
{
if((timer.ElapsedRealTime() - lastProgressTime) > 1000) // update progress at most every second
{
@@ -134,11 +147,11 @@ class BSPProgress : public BSPTree::Progress
Timer timer;
mutable POV_LONG lastProgressTime;
- BSPProgress();
+ BSPProgress() = delete;
};
-BoundingTask::BoundingTask(shared_ptr sd, unsigned int bt, size_t seed) :
- SceneTask(new TraceThreadData(dynamic_pointer_cast(sd), seed), boost::bind(&BoundingTask::SendFatalError, this, _1), "Bounding", sd),
+BoundingTask::BoundingTask(std::shared_ptr sd, unsigned int bt, size_t seed) :
+ SceneTask(new TraceThreadData(std::dynamic_pointer_cast(sd), seed), boost::bind(&BoundingTask::SendFatalError, this, _1), "Bounding", sd),
sceneData(sd),
boundingThreshold(bt)
{
@@ -225,3 +238,4 @@ void BoundingTask::SendFatalError(Exception& e)
}
}
+// end of namespace pov
diff --git a/source/backend/bounding/boundingtask.h b/source/backend/bounding/boundingtask.h
index 867a9209c..2c2fca067 100644
--- a/source/backend/bounding/boundingtask.h
+++ b/source/backend/bounding/boundingtask.h
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -36,37 +36,49 @@
#ifndef POVRAY_BACKEND_BOUNDINGTASK_H
#define POVRAY_BACKEND_BOUNDINGTASK_H
-#include
+// Module config header file must be the first file included within POV-Ray unit header files
+#include "backend/configbackend.h"
-#include "backend/frame.h"
-#include "backend/render/rendertask.h"
+// C++ variants of C standard header files
+// (none at the moment)
+
+// C++ standard header files
+#include
+
+// POV-Ray header files (base module)
+#include "base/base_fwd.h"
+
+// POV-Ray header files (core module)
+#include "core/core_fwd.h"
+
+// POV-Ray header files (backend module)
+#include "backend/scene/backendscenedata_fwd.h"
+#include "backend/support/task.h"
namespace pov
{
-class SceneData;
-class TraceThreadData;
-
-class BoundingTask : public SceneTask
+class BoundingTask final : public SceneTask
{
public:
- BoundingTask(shared_ptr sd, unsigned int bt, size_t seed);
- virtual ~BoundingTask();
+ BoundingTask(std::shared_ptr sd, unsigned int bt, size_t seed);
+ virtual ~BoundingTask() override;
- virtual void Run();
- virtual void Stopped();
- virtual void Finish();
+ virtual void Run() override;
+ virtual void Stopped() override;
+ virtual void Finish() override;
void AppendObject(ObjectPtr p);
inline TraceThreadData *GetSceneDataPtr() { return reinterpret_cast(GetDataPtr()); }
private:
- shared_ptr sceneData;
+ std::shared_ptr sceneData;
unsigned int boundingThreshold;
void SendFatalError(pov_base::Exception& e);
};
}
+// end of namespace pov
#endif // POVRAY_BACKEND_BOUNDINGTASK_H
diff --git a/source/backend/configbackend.h b/source/backend/configbackend.h
index f3663242c..1a2c63212 100644
--- a/source/backend/configbackend.h
+++ b/source/backend/configbackend.h
@@ -38,6 +38,7 @@
#ifndef POVRAY_BACKEND_CONFIGBACKEND_H
#define POVRAY_BACKEND_CONFIGBACKEND_H
+// Pull in other compile-time config header files first
#include "base/configbase.h"
#include "syspovconfigbackend.h"
diff --git a/source/backend/control/benchmark.cpp b/source/backend/control/benchmark.cpp
index 6886c24ea..7822e4bb2 100644
--- a/source/backend/control/benchmark.cpp
+++ b/source/backend/control/benchmark.cpp
@@ -9,7 +9,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -34,12 +34,21 @@
///
//******************************************************************************
+// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config)
+#include "backend/control/benchmark.h"
+
+// C++ variants of C standard header files
#include
-// frame.h must always be the first POV file included (pulls in platform config)
-#include "backend/frame.h"
-#include "backend/control/benchmark.h"
+// C++ standard header files
+// (none at the moment)
+// POV-Ray header files (base module)
+// POV-Ray header files (core module)
+// POV-Ray header files (POVMS module)
+// (none at the moment)
+
+// POV-Ray header files (backend module)
#include "backend/control/benchmark_ini.h"
#include "backend/control/benchmark_pov.h"
@@ -78,4 +87,4 @@ unsigned int Get_Benchmark_Version (void)
}
}
-
+// end of namespace pov
diff --git a/source/backend/control/benchmark.h b/source/backend/control/benchmark.h
index 215c5ca97..3bc80de64 100644
--- a/source/backend/control/benchmark.h
+++ b/source/backend/control/benchmark.h
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -33,8 +33,19 @@
///
//******************************************************************************
-#ifndef BENCHMARK_H
-#define BENCHMARK_H
+#ifndef POVRAY_BACKEND_BENCHMARK_H
+#define POVRAY_BACKEND_BENCHMARK_H
+
+// Module config header file must be the first file included within POV-Ray unit header files
+#include "backend/configbackend.h"
+
+// C++ variants of C standard header files
+// C++ standard header files
+// (none at the moment)
+
+// POV-Ray header files (base module)
+// POV-Ray header files (backend module)
+// (none at the moment)
namespace pov
{
@@ -47,5 +58,6 @@ bool Write_Benchmark_File (const char *Scene_File_Name, const char *INI_File_Nam
unsigned int Get_Benchmark_Version (void) ;
}
+// end of namespace pov
-#endif
+#endif // POVRAY_BACKEND_BENCHMARK_H
diff --git a/source/backend/control/messagefactory.cpp b/source/backend/control/messagefactory.cpp
index 9842a86bf..48c8bc6b1 100644
--- a/source/backend/control/messagefactory.cpp
+++ b/source/backend/control/messagefactory.cpp
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -33,17 +33,29 @@
///
//******************************************************************************
+// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config)
+#include "backend/control/messagefactory.h"
+
+// C++ variants of C standard header files
+// C++ standard header files
+// (none at the moment)
+
+// Boost header files
#include
#include
-// frame.h must always be the first POV file included (pulls in platform config)
-#include "backend/frame.h"
-#include "backend/control/messagefactory.h"
+// POV-Ray header files (base module)
+#include "base/povassert.h"
+
+// POV-Ray header files (core module)
+// (none at the moment)
+// POV-Ray header files (POVMS module)
#include "povms/povmscpp.h"
#include "povms/povmsid.h"
-#include "base/pov_err.h"
+// POV-Ray header files (backend module)
+// (none at the moment)
// this must be the last file included
#include "base/povdebug.h"
@@ -130,3 +142,4 @@ void MessageFactory::SendMessage(MessageClass mc, WarningLevel level, const char
}
}
+// end of namespace pov
diff --git a/source/backend/control/messagefactory.h b/source/backend/control/messagefactory.h
index ee5858233..481b0dc79 100644
--- a/source/backend/control/messagefactory.h
+++ b/source/backend/control/messagefactory.h
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -36,11 +36,19 @@
#ifndef POVRAY_BACKEND_MESSAGEFACTORY_H
#define POVRAY_BACKEND_MESSAGEFACTORY_H
-#include "povms/povmscpp.h"
-#include "povms/povmsid.h"
+// Module config header file must be the first file included within POV-Ray unit header files
+#include "backend/configbackend.h"
+#include "backend/control/messagefactory_fwd.h"
+// C++ variants of C standard header files
+// C++ standard header files
+// (none at the moment)
+
+// POV-Ray header files (base module)
+#include "base/stringtypes.h"
#include "base/messenger.h"
+// POV-Ray header files (backend module)
#include "backend/control/renderbackend.h"
namespace pov
@@ -48,12 +56,12 @@ namespace pov
using namespace pov_base;
-class MessageFactory : public GenericMessenger
+class MessageFactory final : public GenericMessenger
{
public:
MessageFactory(unsigned int wl, const char *sn, POVMSAddress saddr, POVMSAddress daddr, RenderBackend::SceneId sid, RenderBackend::ViewId vid);
- virtual ~MessageFactory();
+ virtual ~MessageFactory() override;
private:
@@ -67,5 +75,6 @@ class MessageFactory : public GenericMessenger
};
}
+// end of namespace pov
#endif // POVRAY_BACKEND_MESSAGEFACTORY_H
diff --git a/source/backend/control/messagefactory_fwd.h b/source/backend/control/messagefactory_fwd.h
new file mode 100644
index 000000000..fbc19f26a
--- /dev/null
+++ b/source/backend/control/messagefactory_fwd.h
@@ -0,0 +1,51 @@
+//******************************************************************************
+///
+/// @file backend/control/messagefactory_fwd.h
+///
+/// Forward declarations related to ... what?
+///
+/// @copyright
+/// @parblock
+///
+/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
+/// Copyright 1991-2019 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 .
+///
+/// ----------------------------------------------------------------------------
+///
+/// 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.
+///
+/// @endparblock
+///
+//******************************************************************************
+
+#ifndef POVRAY_BACKEND_MESSAGEFACTORY_FWD_H
+#define POVRAY_BACKEND_MESSAGEFACTORY_FWD_H
+
+/// @file
+/// @note
+/// This file should not pull in any POV-Ray header whatsoever.
+
+namespace pov
+{
+
+class MessageFactory;
+
+}
+// end of namespace pov
+
+#endif // POVRAY_BACKEND_MESSAGEFACTORY_FWD_H
diff --git a/source/backend/control/parsertask.cpp b/source/backend/control/parsertask.cpp
index 03a34d720..a07d44946 100644
--- a/source/backend/control/parsertask.cpp
+++ b/source/backend/control/parsertask.cpp
@@ -39,16 +39,23 @@
// C++ variants of C standard header files
// C++ standard header files
// Boost header files
-// POV-Ray header files (base module)
// (none at the moment)
+// POV-Ray header files (base module)
+#include "base/types.h"
+
// POV-Ray header files (core module)
#include "core/scene/tracethreaddata.h"
// POV-Ray header files (parser module)
#include "parser/parser.h"
+// POV-Ray header files (POVMS module)
+#include "povms/povmscpp.h"
+#include "povms/povmsid.h"
+
// POV-Ray header files (backend module)
+#include "backend/control/messagefactory.h"
#include "backend/scene/backendscenedata.h"
// this must be the last file included
@@ -69,7 +76,7 @@ ParserTask::ParserTask(std::shared_ptr sd, const ParserOptions
void ParserTask::Run()
{
- mpParser.reset(new Parser(mpBackendSceneData, mOptions, messageFactory, *this, *this, *reinterpret_cast(GetDataPtr())));
+ mpParser.reset(new Parser(mpBackendSceneData, mOptions, *mpMessageFactory, *this, *this, *reinterpret_cast(GetDataPtr())));
mpParser->Run();
}
@@ -126,4 +133,5 @@ void ParserTask::ReportProgress(POV_LONG tokenCount)
}
}
-} // end of namespace pov
+}
+// end of namespace pov
diff --git a/source/backend/control/parsertask.h b/source/backend/control/parsertask.h
index 3195f4374..bc8d786d0 100644
--- a/source/backend/control/parsertask.h
+++ b/source/backend/control/parsertask.h
@@ -51,7 +51,8 @@
// (none at the moment)
// POV-Ray header files (parser module)
-#include "parser/parser.h"
+#include "parser/parser_fwd.h"
+#include "parser/parsertypes.h"
// POV-Ray header files (backend module)
#include "backend/support/task.h"
@@ -62,7 +63,7 @@ namespace pov
using namespace pov_base;
using namespace pov;
-class ParserTask : public SceneTask, public pov_parser::Parser::FileResolver, public pov_parser::Parser::ProgressReporter
+class ParserTask final : public SceneTask, public pov_parser::FileResolver, public pov_parser::ProgressReporter
{
public:
@@ -77,7 +78,7 @@ class ParserTask : public SceneTask, public pov_parser::Parser::FileResolver, pu
void SendFatalError(Exception& e);
/// @}
- /// @name @ref Parser::FileResolver related.
+ /// @name @ref pov_parser::FileResolver related.
/// @{
virtual UCS2String FindFile(UCS2String parsedFileName, unsigned int fileType) override;
@@ -85,7 +86,7 @@ class ParserTask : public SceneTask, public pov_parser::Parser::FileResolver, pu
virtual OStream* CreateFile(const UCS2String& parsedFileName, unsigned int fileType, bool append) override;
/// @}
- /// @name @ref Parser::ProgressReporter related.
+ /// @name @ref pov_parser::ProgressReporter related.
/// @{
static constexpr auto kMinProgressReportInterval = 1000; /// Minimum delay between progress reports (in milliseconds).
@@ -101,6 +102,7 @@ class ParserTask : public SceneTask, public pov_parser::Parser::FileResolver, pu
POV_LONG mLastProgressElapsedTime;
};
-} // end of namespace pov
+}
+// end of namespace pov
#endif // POVRAY_BACKEND_PARSERTASK_H
diff --git a/source/backend/control/renderbackend.cpp b/source/backend/control/renderbackend.cpp
index 67c60b133..8f80065fe 100644
--- a/source/backend/control/renderbackend.cpp
+++ b/source/backend/control/renderbackend.cpp
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -33,15 +33,24 @@
///
//******************************************************************************
-// frame.h must always be the first POV file included (pulls in platform config)
-#include "backend/frame.h"
+// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config)
#include "backend/control/renderbackend.h"
-#include "povms/povmscpp.h"
-#include "povms/povmsid.h"
+// C++ variants of C standard header files
+// C++ standard header files
+// (none at the moment)
+// POV-Ray header files (base module)
#include "base/pov_err.h"
+// POV-Ray header files (core module)
+// (none at the moment)
+
+// POV-Ray header files (POVMS module)
+#include "povms/povmscpp.h"
+#include "povms/povmsid.h"
+
+// POV-Ray header files (backend module)
#include "backend/povray.h"
#include "backend/control/scene.h"
#include "backend/scene/view.h"
@@ -107,13 +116,13 @@ void RenderBackend::SendViewOutput(ViewId vid, POVMSAddress addr, POVMSType iden
POVMS_SendMessage(RenderBackend::context, msg, nullptr, kPOVMSSendMode_NoReply); // POVMS context provide for source address access only!
}
-void RenderBackend::SendFindFile(POVMSContext ctx, SceneId sid, POVMSAddress addr, const vector& filenames, POVMSUCS2String& filename)
+void RenderBackend::SendFindFile(POVMSContext ctx, SceneId sid, POVMSAddress addr, const std::vector& filenames, POVMSUCS2String& filename)
{
POVMS_Message msg(kPOVObjectClass_FileData, kPOVMsgClass_FileAccess, kPOVMsgIdent_FindFile);
POVMS_Message result(kPOVObjectClass_FileData, kPOVMsgClass_FileAccess, kPOVMsgIdent_FindFile);
POVMS_List files;
- for(vector::const_iterator i(filenames.begin()); i != filenames.end(); i++)
+ for(std::vector::const_iterator i(filenames.begin()); i != filenames.end(); i++)
{
POVMS_Attribute attr(i->c_str());
files.Append(attr);
@@ -304,7 +313,7 @@ void RenderBackend::CreateScene(POVMS_Message& msg, POVMS_Message& result, int)
if(err != kNoErr)
throw POV_EXCEPTION_CODE (err);
- shared_ptr scene(new Scene(backendAddress, msg.GetSourceAddress(), scenecounter + 1));
+ std::shared_ptr scene(new Scene(backendAddress, msg.GetSourceAddress(), scenecounter + 1));
scenecounter++;
@@ -387,7 +396,7 @@ void RenderBackend::CreateView(POVMS_Message& msg, POVMS_Message& result, int)
if(i == scenes.end())
throw POV_EXCEPTION_CODE(kInvalidIdentifierErr);
- shared_ptr view(i->second->NewView(msg.TryGetInt(kPOVAttrib_Width, 160), msg.TryGetInt(kPOVAttrib_Height, 120), viewcounter + 1));
+ std::shared_ptr view(i->second->NewView(msg.TryGetInt(kPOVAttrib_Width, 160), msg.TryGetInt(kPOVAttrib_Height, 120), viewcounter + 1));
viewcounter++;
@@ -785,3 +794,4 @@ void RenderBackend::MakeDoneResult(POVMS_Message& result)
}
}
+// end of namespace pov
diff --git a/source/backend/control/renderbackend.h b/source/backend/control/renderbackend.h
index 0bd103e84..f65172f69 100644
--- a/source/backend/control/renderbackend.h
+++ b/source/backend/control/renderbackend.h
@@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
-/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd.
+/// Copyright 1991-2019 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
@@ -36,40 +36,52 @@
#ifndef POVRAY_BACKEND_RENDERBACKEND_H
#define POVRAY_BACKEND_RENDERBACKEND_H
+// Module config header file must be the first file included within POV-Ray unit header files
+#include "backend/configbackend.h"
+
+// C++ variants of C standard header files
+// (none at the moment)
+
+// C++ standard header files
#include