From 005893b250ec377f5660b23eeb7d1963b5a50911 Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Mon, 14 Jan 2019 21:58:29 +0100 Subject: [PATCH 01/13] [parser] Clean up some messed-up source code indentations. --- source/parser/scanner.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/parser/scanner.cpp b/source/parser/scanner.cpp index d065fa1ec..0ea6da8f3 100644 --- a/source/parser/scanner.cpp +++ b/source/parser/scanner.cpp @@ -518,14 +518,14 @@ struct AutoDetectEncoding final : CharacterEncoding static inline bool IsASCIIEndOfLine(Scanner::Character c) { return ((c == 0x0A) || // ASCII LF ("New Line") - (c == 0x0D)); // ASCII CR ("Carriage Return") + (c == 0x0D)); // ASCII CR ("Carriage Return") } /// Test whether character qualifies as ASCII whitespace. static inline bool IsASCIIWhitespace(Scanner::Character c) { return ((c == 0x09) || // ASCII HT ("Tab") - (c == 0x0A) || // ASCII LF ("New Line") + (c == 0x0A) || // ASCII LF ("New Line") (c == 0x0D) || // ASCII CR ("Carriage Return") (c == 0x1A) || // DOS EOF character (c == 0x20)); // ASCII SP ("Space") @@ -548,7 +548,7 @@ static bool IsDecimalDigit(Scanner::Character c) static bool IsASCIIIdentifierChar1(Scanner::Character c) { return (((c >= 'a') && (c <= 'z')) || - ((c >= 'A') && (c <= 'Z')) || + ((c >= 'A') && (c <= 'Z')) || (c == '_')); } @@ -556,7 +556,7 @@ static bool IsASCIIIdentifierChar1(Scanner::Character c) static bool IsASCIIIdentifierChar2(Scanner::Character c) { return IsASCIIIdentifierChar1(c) || - IsDecimalDigit(c); + IsDecimalDigit(c); } //****************************************************************************** From 054e75c8fc1ccf1167d9645d7fbae2a514c8db5d Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Wed, 16 Jan 2019 21:22:01 +0100 Subject: [PATCH 02/13] Change AppVeyor config to no longer build 32-bit versions for mere build testing. 32-bit versions are still built on branches intended for automated binary creation. --- appveyor.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1c581509e..6f6b58728 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -27,14 +27,6 @@ environment: platform: x64 bin_dir: bin64 artifact_suffix: -Win64 - - configuration: Release-SSE2 - platform: Win32 - bin_dir: bin32 - artifact_suffix: -Win32-sse2 - - configuration: Release - platform: Win32 - bin_dir: bin32 - artifact_suffix: -Win32 before_build: @@ -58,6 +50,19 @@ for: environment: PovBuildDefs: secure: dQ/GBBYlkqKDmBEgJfgajfBn58ziSh1JPXsiWtnBL1dE3/s4QZJutGdDtLxiG3eNq0DXMVhDIbGqyPSma9Q9xazlpRZkuU7Gl8rXCw7c03A/oliLoR6q/0Jb+Q9LNH5R/oYiDCHhNP8Cx6OXys4d5A== + matrix: + - configuration: Release + platform: x64 + bin_dir: bin64 + artifact_suffix: -Win64 + - configuration: Release-SSE2 + platform: Win32 + bin_dir: bin32 + artifact_suffix: -Win32-sse2 + - configuration: Release + platform: Win32 + bin_dir: bin32 + artifact_suffix: -Win32 after_build: - ps: | From 8824108fa67883e9d6d97087de83b8d9f9ff5922 Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Thu, 17 Jan 2019 01:30:40 +0100 Subject: [PATCH 03/13] Fix AppVeyor building 64-bit version twice in auto-build branches. --- appveyor.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6f6b58728..53eb5e706 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -51,10 +51,6 @@ for: PovBuildDefs: secure: dQ/GBBYlkqKDmBEgJfgajfBn58ziSh1JPXsiWtnBL1dE3/s4QZJutGdDtLxiG3eNq0DXMVhDIbGqyPSma9Q9xazlpRZkuU7Gl8rXCw7c03A/oliLoR6q/0Jb+Q9LNH5R/oYiDCHhNP8Cx6OXys4d5A== matrix: - - configuration: Release - platform: x64 - bin_dir: bin64 - artifact_suffix: -Win64 - configuration: Release-SSE2 platform: Win32 bin_dir: bin32 From 7d04c132d48d6ecf13ae407c470f68d962666d62 Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Tue, 22 Jan 2019 02:34:24 +0100 Subject: [PATCH 04/13] [parser] Modify token ID handling. --- source/parser/fncode.cpp | 13 +- source/parser/parser.cpp | 570 +++++++------------ source/parser/parser.h | 166 +++--- source/parser/parser_expressions.cpp | 390 ++++++------- source/parser/parser_functions.cpp | 86 ++- source/parser/parser_functions_utilities.cpp | 30 +- source/parser/parser_materials.cpp | 535 +++++++---------- source/parser/parser_tokenizer.cpp | 364 ++++-------- source/parser/rawtokenizer.cpp | 48 +- source/parser/rawtokenizer.h | 11 +- source/parser/reservedwords.cpp | 28 +- source/parser/reservedwords.h | 20 +- source/parser/symboltable.cpp | 10 +- windows/pvedit.cpp | 3 +- 14 files changed, 898 insertions(+), 1376 deletions(-) diff --git a/source/parser/fncode.cpp b/source/parser/fncode.cpp index 10ecf90eb..8ff603418 100644 --- a/source/parser/fncode.cpp +++ b/source/parser/fncode.cpp @@ -10,7 +10,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 @@ -169,17 +169,18 @@ FNCode::FNCode(Parser *pa, FunctionCode *f, bool is_local, const char *n) void FNCode::Parameter() { parser->Get_Token(); - if(parser->CurrentTokenId() == LEFT_PAREN_TOKEN) + if(parser->CurrentTrueTokenId() == LEFT_PAREN_TOKEN) { for(function->parameter_cnt = 0; - ((parser->CurrentTokenId() != RIGHT_PAREN_TOKEN) || (function->parameter_cnt == 0)) && (function->parameter_cnt < MAX_FUNCTION_PARAMETER_LIST); + ((parser->CurrentTrueTokenId() != RIGHT_PAREN_TOKEN) || (function->parameter_cnt == 0)) && + (function->parameter_cnt < MAX_FUNCTION_PARAMETER_LIST); function->parameter_cnt++) { parser->Get_Token(); - if((parser->CurrentTokenFunctionId() != IDENTIFIER_TOKEN) && (parser->CurrentTokenFunctionId() != X_TOKEN) && - (parser->CurrentTokenFunctionId() != Y_TOKEN) && (parser->CurrentTokenFunctionId() != Z_TOKEN) && - (parser->CurrentTokenFunctionId() != U_TOKEN) && (parser->CurrentTokenFunctionId() != V_TOKEN)) + if((parser->CurrentTrueTokenId() != IDENTIFIER_TOKEN) && (parser->CurrentTrueTokenId() != X_TOKEN) && + (parser->CurrentTrueTokenId() != Y_TOKEN) && (parser->CurrentTrueTokenId() != Z_TOKEN) && + (parser->CurrentTrueTokenId() != U_TOKEN) && (parser->CurrentTrueTokenId() != V_TOKEN)) parser->Expectation_Error("parameter identifier"); function->parameter[function->parameter_cnt] = POV_STRDUP(parser->CurrentTokenText().c_str()); diff --git a/source/parser/parser.cpp b/source/parser/parser.cpp index ba7ca4ee6..c2f16a009 100644 --- a/source/parser/parser.cpp +++ b/source/parser/parser.cpp @@ -722,7 +722,7 @@ bool Parser::Parse_Begin (TokenId tokenId, bool mandatory) { Get_Token(); - if(CurrentTokenId() == tokenId) + if(CurrentTrueTokenId() == tokenId) { maBraceStack.emplace_back(mToken); return true; @@ -761,7 +761,7 @@ void Parser::Parse_End(TokenId openTokenId, TokenId expectTokenId) { Get_Token(); - if(CurrentTokenId() == expectTokenId) + if(CurrentTrueTokenId() == expectTokenId) { POV_PARSER_ASSERT(!maBraceStack.empty()); POV_PARSER_ASSERT(openTokenId == maBraceStack.back().openToken); @@ -770,7 +770,7 @@ void Parser::Parse_End(TokenId openTokenId, TokenId expectTokenId) { BraceStackEntry& braceStackEntry = maBraceStack.back(); // Include file has closed more braces/parentheses/etc. than it has opened. - Warning("Unbalanced %s in include file", Get_Token_String(CurrentTokenId())); + Warning("Unbalanced %s in include file", Get_Token_String(CurrentTrueTokenId())); } maBraceStack.pop_back(); @@ -778,7 +778,7 @@ void Parser::Parse_End(TokenId openTokenId, TokenId expectTokenId) } ErrorInfo(maBraceStack.back(), "Unmatched %s", Get_Token_String(maBraceStack.back().openToken)); - Error("No matching %s, %s found instead", Get_Token_String(expectTokenId), Get_Token_String(CurrentTokenId())); + Error("No matching %s, %s found instead", Get_Token_String(expectTokenId), Get_Token_String(CurrentTrueTokenId())); } /***************************************************************************** @@ -814,7 +814,7 @@ ObjectPtr Parser::Parse_Bicubic_Patch () Object = new BicubicPatch(); - EXPECT + EXPECT_CAT CASE_FLOAT_UNGET VersionWarning(150, "Should use keywords for bicubic parameters."); Object->Patch_Type = (int)Parse_Float(); @@ -1311,7 +1311,7 @@ void Parser::Parse_Mesh_Camera (Camera& Cam) END_EXPECT ALLOW(SMOOTH_TOKEN); - Cam.Smooth = (CurrentTokenId() == SMOOTH_TOKEN); + Cam.Smooth = (CurrentTrueTokenId() == SMOOTH_TOKEN); if (Cam.Smooth && Cam.Face_Distribution_Method != 3) Error("Smooth can only be used with distribution method #3"); @@ -1455,17 +1455,12 @@ void Parser::Parse_Camera (Camera& Cam) Parse_Begin (); - EXPECT_ONE - CASE (CAMERA_ID_TOKEN) - Cam = CurrentTokenData(); - if (sceneData->EffectiveLanguageVersion() >= 350) - only_mods = true; - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(CAMERA_ID_TOKEN)) + { + Cam = CurrentTokenData(); + if (sceneData->EffectiveLanguageVersion() >= 350) + only_mods = true; + } Camera& New = Cam; @@ -1634,6 +1629,7 @@ void Parser::Parse_Camera (Camera& Cam) END_CASE END_EXPECT break; + case ORTHOGRAPHIC_CAMERA: EXPECT CASE (ANGLE_TOKEN) @@ -1654,6 +1650,7 @@ void Parser::Parse_Camera (Camera& Cam) END_CASE END_EXPECT break; + case FISHEYE_CAMERA: EXPECT CASE (ANGLE_TOKEN) @@ -1674,6 +1671,7 @@ void Parser::Parse_Camera (Camera& Cam) END_CASE END_EXPECT break; + case ULTRA_WIDE_ANGLE_CAMERA: EXPECT CASE (ANGLE_TOKEN) @@ -1694,6 +1692,7 @@ void Parser::Parse_Camera (Camera& Cam) END_CASE END_EXPECT break; + case OMNIMAX_CAMERA: EXPECT CASE (ANGLE_TOKEN) @@ -1714,6 +1713,7 @@ void Parser::Parse_Camera (Camera& Cam) END_CASE END_EXPECT break; + case PANORAMIC_CAMERA: EXPECT CASE (ANGLE_TOKEN) @@ -1734,6 +1734,7 @@ void Parser::Parse_Camera (Camera& Cam) END_CASE END_EXPECT break; + case CYL_1_CAMERA: case CYL_2_CAMERA: case CYL_3_CAMERA: @@ -1757,6 +1758,7 @@ void Parser::Parse_Camera (Camera& Cam) END_CASE END_EXPECT break; + case SPHERICAL_CAMERA: EXPECT CASE (ANGLE_TOKEN) @@ -1781,6 +1783,7 @@ void Parser::Parse_Camera (Camera& Cam) END_CASE END_EXPECT break; + case MESH_CAMERA: EXPECT CASE6(PERSPECTIVE_TOKEN, ORTHOGRAPHIC_TOKEN, FISHEYE_TOKEN, ULTRA_WIDE_ANGLE_TOKEN, OMNIMAX_TOKEN, PANORAMIC_TOKEN) @@ -1795,6 +1798,7 @@ void Parser::Parse_Camera (Camera& Cam) END_CASE END_EXPECT break; + case USER_DEFINED_CAMERA: EXPECT CASE (ANGLE_TOKEN) @@ -2410,15 +2414,8 @@ ObjectPtr Parser::Parse_Cone () Parse_Vector(Object->base); Parse_Comma (); Object->base_radius = Parse_Float(); - EXPECT_ONE - CASE(OPEN_TOKEN) - Clear_Flag(Object, CLOSED_FLAG); - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(OPEN_TOKEN)) + Clear_Flag(Object, CLOSED_FLAG); /* Compute run-time values for the cone */ Object->Compute_Cone_Data(); @@ -2467,15 +2464,8 @@ ObjectPtr Parser::Parse_Cylinder () Object->apex_radius = Parse_Float(); Object->base_radius = Object->apex_radius; - EXPECT_ONE - CASE(OPEN_TOKEN) - Clear_Flag(Object, CLOSED_FLAG); - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(OPEN_TOKEN)) + Clear_Flag(Object, CLOSED_FLAG); Object->Compute_Cylinder_Data(); @@ -2525,7 +2515,7 @@ ObjectPtr Parser::Parse_Disc () tmpf = Parse_Float(); Parse_Comma (); Object->oradius2 = tmpf * tmpf; - EXPECT_ONE + EXPECT_ONE_CAT CASE_FLOAT_UNGET tmpf = Parse_Float(); Object->iradius2 = tmpf * tmpf; @@ -2653,9 +2643,7 @@ ObjectPtr Parser::Parse_Isosurface() Object = new IsoSurface(); - Get_Token(); - if(CurrentTokenId() != FUNCTION_TOKEN) - Parse_Error(FUNCTION_TOKEN); + GET(FUNCTION_TOKEN); Object->Function = new FunctionVM::CustomFunction(fnVMContext->functionvm.get(), Parse_Function()); @@ -2889,59 +2877,61 @@ ObjectPtr Parser::Parse_Julia_Fractal () Object->Precision = 1.0 / P; END_CASE - CASE(FLOAT_FUNCT_TOKEN) - switch(CurrentTokenFunctionId()) - { - case EXP_TOKEN: - Object->Sub_Type = EXP_STYPE; - break; - case LN_TOKEN: - Object->Sub_Type = LN_STYPE; - break; - case SIN_TOKEN: - Object->Sub_Type = SIN_STYPE; - break; - case ASIN_TOKEN: - Object->Sub_Type = ASIN_STYPE; - break; - case COS_TOKEN: - Object->Sub_Type = COS_STYPE; - break; - case ACOS_TOKEN: - Object->Sub_Type = ACOS_STYPE; - break; - case TAN_TOKEN: - Object->Sub_Type = TAN_STYPE; - break; - case ATAN_TOKEN: - Object->Sub_Type = ATAN_STYPE; - break; - case COSH_TOKEN: - Object->Sub_Type = COSH_STYPE; - break; - case SINH_TOKEN: - Object->Sub_Type = SINH_STYPE; - break; - case TANH_TOKEN: - Object->Sub_Type = TANH_STYPE; - break; - case ATANH_TOKEN: - Object->Sub_Type = ATANH_STYPE; - break; - case ACOSH_TOKEN: - Object->Sub_Type = ACOSH_STYPE; - break; - case ASINH_TOKEN: - Object->Sub_Type = ASINH_STYPE; - break; - default: Expectation_Error ("fractal keyword"); - } + CASE(EXP_TOKEN) + Object->Sub_Type = EXP_STYPE; END_CASE - /* if any of the next become supported by the expression parser, - * then their handling would need to move above to the FLOAT_FUNCT_TOKEN - * case above. - */ + CASE(LN_TOKEN) + Object->Sub_Type = LN_STYPE; + END_CASE + + CASE(SIN_TOKEN) + Object->Sub_Type = SIN_STYPE; + END_CASE + + CASE(ASIN_TOKEN) + Object->Sub_Type = ASIN_STYPE; + END_CASE + + CASE(COS_TOKEN) + Object->Sub_Type = COS_STYPE; + END_CASE + + CASE(ACOS_TOKEN) + Object->Sub_Type = ACOS_STYPE; + END_CASE + + CASE(TAN_TOKEN) + Object->Sub_Type = TAN_STYPE; + END_CASE + + CASE(ATAN_TOKEN) + Object->Sub_Type = ATAN_STYPE; + END_CASE + + CASE(COSH_TOKEN) + Object->Sub_Type = COSH_STYPE; + END_CASE + + CASE(SINH_TOKEN) + Object->Sub_Type = SINH_STYPE; + END_CASE + + CASE(TANH_TOKEN) + Object->Sub_Type = TANH_STYPE; + END_CASE + + CASE(ATANH_TOKEN) + Object->Sub_Type = ATANH_STYPE; + END_CASE + + CASE(ACOSH_TOKEN) + Object->Sub_Type = ACOSH_STYPE; + END_CASE + + CASE(ASINH_TOKEN) + Object->Sub_Type = ASINH_STYPE; + END_CASE CASE(SQR_TOKEN) Object->Sub_Type = SQR_STYPE; @@ -3247,15 +3237,8 @@ ObjectPtr Parser::Parse_Lemon () Error("All radii must be positive"); } - EXPECT_ONE - CASE(OPEN_TOKEN) - Clear_Flag(Object, CLOSED_FLAG); - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(OPEN_TOKEN)) + Clear_Flag(Object, CLOSED_FLAG); /* Compute run-time values for the lemon */ Object->Compute_Lemon_Data(mMessageFactory, CurrentTokenMessageContext()); @@ -3434,6 +3417,7 @@ ObjectPtr Parser::Parse_Light_Group() END_EXPECT Parse_End(); END_CASE + OTHERWISE UNGET EXIT @@ -3961,7 +3945,7 @@ void Parser::Parse_Mesh1 (Mesh* Object) Triangles[number_of_triangles].P3 = Object->Mesh_Hash_Vertex(&number_of_vertices, &max_vertices, &Vertices, P3); /* NK 1998 */ - Parse_Three_UVCoords(UV1,UV2,UV3); + (void)Parse_Three_UVCoords(UV1,UV2,UV3); Triangles[number_of_triangles].UV1 = Object->Mesh_Hash_UV(&number_of_uvcoords, &max_uvcoords, &UVCoords, UV1); Triangles[number_of_triangles].UV2 = Object->Mesh_Hash_UV(&number_of_uvcoords, &max_uvcoords, &UVCoords, UV2); Triangles[number_of_triangles].UV3 = Object->Mesh_Hash_UV(&number_of_uvcoords, &max_uvcoords, &UVCoords, UV3); @@ -3992,7 +3976,7 @@ void Parser::Parse_Mesh1 (Mesh* Object) away. why? if not we get a parse error - we should just ignore the degenerate triangle */ t2 = t3 = nullptr; - Parse_Three_UVCoords(UV1,UV2,UV3); + (void)Parse_Three_UVCoords(UV1,UV2,UV3); Parse_Mesh_Texture(&t2,&t3); } @@ -4069,7 +4053,7 @@ void Parser::Parse_Mesh1 (Mesh* Object) l2 = D2.lengthSqr(); /* NK 1998 */ - Parse_Three_UVCoords(UV1,UV2,UV3); + (void)Parse_Three_UVCoords(UV1,UV2,UV3); Triangles[number_of_triangles].UV1 = Object->Mesh_Hash_UV(&number_of_uvcoords, &max_uvcoords, &UVCoords, UV1); Triangles[number_of_triangles].UV2 = Object->Mesh_Hash_UV(&number_of_uvcoords, &max_uvcoords, &UVCoords, UV2); Triangles[number_of_triangles].UV3 = Object->Mesh_Hash_UV(&number_of_uvcoords, &max_uvcoords, &UVCoords, UV3); @@ -4115,19 +4099,16 @@ void Parser::Parse_Mesh1 (Mesh* Object) away. why? if not we get a parse error - we should just ignore the degenerate triangle */ t2 = t3 = nullptr; - Parse_Three_UVCoords(UV1,UV2,UV3); + (void)Parse_Three_UVCoords(UV1,UV2,UV3); Parse_Mesh_Texture(&t2,&t3); } Parse_End(); END_CASE - /* NK 1998 */ CASE(INSIDE_VECTOR_TOKEN) Parse_Vector(Inside_Vect); - END_CASE - /* NK ---- */ OTHERWISE UNGET @@ -4541,7 +4522,7 @@ void Parser::Parse_Mesh2 (Mesh* Object) Triangles[i].P3 = c; /* look for a texture index */ - EXPECT_ONE + EXPECT_ONE_CAT CASE_FLOAT_UNGET Triangles[i].Texture = Parse_Float(); Parse_Comma(); if (Triangles[i].Texture >= number_of_textures || @@ -4556,7 +4537,7 @@ void Parser::Parse_Mesh2 (Mesh* Object) END_CASE END_EXPECT /* look for a texture index */ - EXPECT_ONE + EXPECT_ONE_CAT CASE_FLOAT_UNGET Triangles[i].Texture2 = Parse_Float(); Parse_Comma(); if (Triangles[i].Texture2 >= number_of_textures || @@ -4570,7 +4551,7 @@ void Parser::Parse_Mesh2 (Mesh* Object) END_CASE END_EXPECT /* look for a texture index */ - EXPECT_ONE + EXPECT_ONE_CAT CASE_FLOAT_UNGET Triangles[i].Texture3 = Parse_Float(); Parse_Comma(); if (Triangles[i].Texture3 >= number_of_textures || @@ -5191,54 +5172,18 @@ ObjectPtr Parser::Parse_Parametric(void) PrecompDepth= Parse_Float(); Parse_Comma(); - EXPECT_ONE - CASE(VECTOR_FUNCT_TOKEN) - if(CurrentTokenFunctionId() != X_TOKEN) - { - UNGET - } - else - PrecompFlag |= 1; - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(X_TOKEN)) + PrecompFlag |= 1; Parse_Comma(); - EXPECT_ONE - CASE(VECTOR_FUNCT_TOKEN) - if(CurrentTokenFunctionId() != Y_TOKEN) - { - UNGET - } - else - PrecompFlag |= 2; - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(Y_TOKEN)) + PrecompFlag |= 2; Parse_Comma(); - EXPECT_ONE - CASE(VECTOR_FUNCT_TOKEN) - if(CurrentTokenFunctionId() != Z_TOKEN) - { - UNGET - } - else - PrecompFlag |= 4; - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(Z_TOKEN)) + PrecompFlag |= 4; END_CASE CASE(CONTAINED_BY_TOKEN) @@ -5698,15 +5643,8 @@ ObjectPtr Parser::Parse_Prism() /* Closed or not closed that's the question. */ - EXPECT_ONE - CASE(OPEN_TOKEN) - Clear_Flag(Object, CLOSED_FLAG); - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(OPEN_TOKEN)) + Clear_Flag(Object, CLOSED_FLAG); /* Check for closed prism. */ @@ -6054,15 +5992,8 @@ ObjectPtr Parser::Parse_Sor() /* Closed or not closed that's the question. */ - EXPECT_ONE - CASE(OPEN_TOKEN) - Clear_Flag(Object, CLOSED_FLAG); - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(OPEN_TOKEN)) + Clear_Flag(Object, CLOSED_FLAG); /* There are Number-3 segments! */ @@ -6232,14 +6163,8 @@ ObjectPtr Parser::Parse_Sphere_Sweep() Parse_Comma(); } - EXPECT_ONE - CASE(TOLERANCE_TOKEN) - Object->Depth_Tolerance = Parse_Float(); - END_CASE - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(TOLERANCE_TOKEN)) + Object->Depth_Tolerance = Parse_Float(); Object->Compute(); @@ -6553,31 +6478,23 @@ ObjectPtr Parser::Parse_TrueType () cmap = TrueTypeFont::kAnyCMAP; charset = CharsetID::kUndefined; - EXPECT_ONE - CASE(CMAP_TOKEN) - Warning("Text primitive 'cmap' extension is experimental and may be " - "subject to future changes."); - Parse_Begin(); - cmap = POV_UINT16(Parse_Float()) << 16; - Parse_Comma(); - cmap += POV_UINT16(Parse_Float()); - charset = CharsetID::kUCS4; - EXPECT_ONE - CASE(CHARSET_TOKEN) - charset = CharsetID(POV_UINT16(Parse_Float())); - if (Charset::Get(charset) == nullptr) - Error("Unknown character set %i", int(charset)); - END_CASE - OTHERWISE - UNGET - END_CASE - END_EXPECT - Parse_End(); - END_CASE - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(CMAP_TOKEN)) + { + Warning("Text primitive 'cmap' extension is experimental and may be " + "subject to future changes."); + Parse_Begin(); + cmap = POV_UINT16(Parse_Float()) << 16; + Parse_Comma(); + cmap += POV_UINT16(Parse_Float()); + charset = CharsetID::kUCS4; + if (AllowToken(CHARSET_TOKEN)) + { + charset = CharsetID(POV_UINT16(Parse_Float())); + if (Charset::Get(charset) == nullptr) + Error("Unknown character set %i", int(charset)); + } + Parse_End(); + } /*** Object = Create_TTF(); */ Parse_Comma(); @@ -7145,20 +7062,10 @@ void Parser::Parse_Frame () Open_Include(); END_CASE - CASE (FLOAT_FUNCT_TOKEN) - switch(CurrentTokenFunctionId()) - { - case VERSION_TOKEN: - VersionWarning(295,"Should have '#' before 'version'."); - POV_EXPERIMENTAL_ASSERT(IsOkToDeclare()); - Parse_Version(); - break; - - default: - UNGET - Expectation_Error ("object or directive"); - break; - } + CASE (VERSION_TOKEN) + VersionWarning(295,"Should have '#' before 'version'."); + POV_EXPERIMENTAL_ASSERT(IsOkToDeclare()); + Parse_Version(); END_CASE CASE (MAX_TRACE_LEVEL_TOKEN) @@ -7749,7 +7656,7 @@ ObjectPtr Parser::Parse_Object_Mods (ObjectPtr Object) TransColour Local_Colour; char *s; - EXPECT + EXPECT_CAT CASE(UV_MAPPING_TOKEN) /* if no texture than allow uv_mapping otherwise, warn user */ @@ -7894,18 +7801,14 @@ ObjectPtr Parser::Parse_Object_Mods (ObjectPtr Object) if(Object->Clip == Object->Bound) Error ("Cannot add bounds after linking bounds and clips."); - EXPECT_ONE - CASE (CLIPPED_BY_TOKEN) - if(!Object->Bound.empty()) - Error ("Cannot link clips with previous bounds."); - Object->Bound = Object->Clip; - END_CASE - - OTHERWISE - UNGET - Parse_Bound_Clip(Object->Bound); - END_CASE - END_EXPECT + if (AllowToken(CLIPPED_BY_TOKEN)) + { + if (!Object->Bound.empty()) + Error("Cannot link clips with previous bounds."); + Object->Bound = Object->Clip; + } + else + Parse_Bound_Clip(Object->Bound); Parse_End (); END_CASE @@ -7916,28 +7819,26 @@ ObjectPtr Parser::Parse_Object_Mods (ObjectPtr Object) if(Object->Clip == Object->Bound) Error ("Cannot add clips after linking bounds and clips."); - EXPECT_ONE - CASE (BOUNDED_BY_TOKEN) - if(!Object->Clip.empty()) - Error ("Cannot link bounds with previous clips."); - Object->Clip = Object->Bound; - END_CASE - - OTHERWISE - UNGET - Parse_Bound_Clip(Object->Clip); + if (AllowToken(BOUNDED_BY_TOKEN)) + { + if (!Object->Clip.empty()) + Error("Cannot link bounds with previous clips."); + Object->Clip = Object->Bound; + } + else + { + Parse_Bound_Clip(Object->Clip); - /* Compute quadric bounding box before transformations. [DB 8/94] */ + /* Compute quadric bounding box before transformations. [DB 8/94] */ - if (dynamic_cast(Object) != nullptr) - { - Min = Vector3d(-BOUND_HUGE); - Max = Vector3d(BOUND_HUGE); + if (dynamic_cast(Object) != nullptr) + { + Min = Vector3d(-BOUND_HUGE); + Max = Vector3d(BOUND_HUGE); - (dynamic_cast(Object))->Compute_BBox(Min, Max); - } - END_CASE - END_EXPECT + (dynamic_cast(Object))->Compute_BBox(Min, Max); + } + } Parse_End (); END_CASE @@ -8273,7 +8174,7 @@ void Parser::Parse_Matrix(MATRIX Matrix) TRANSFORM *Parser::Parse_Transform(TRANSFORM *Trans) { Get_Token(); - if(CurrentTokenId() == TRANSFORM_ID_TOKEN) + if(CurrentTrueTokenId() == TRANSFORM_ID_TOKEN) { /* using old "transform TRANS_IDENT" syntax */ if (Trans == nullptr) @@ -8501,30 +8402,22 @@ void Parser::Parse_Bound_Clip(vector& dest, bool notexture) * ******************************************************************************/ -int Parser::Parse_Three_UVCoords(Vector2d& UV1, Vector2d& UV2, Vector2d& UV3) +bool Parser::Parse_Three_UVCoords(Vector2d& UV1, Vector2d& UV2, Vector2d& UV3) { - int Return_Value; - - EXPECT_ONE - CASE(UV_VECTORS_TOKEN) - Parse_UV_Vect(UV1); Parse_Comma(); - Parse_UV_Vect(UV2); Parse_Comma(); - Parse_UV_Vect(UV3); - - Return_Value = 1; - END_CASE - - OTHERWISE - UV1[0] = UV1[1] = 0.0; - UV2[0] = UV2[1] = 0.0; - UV3[0] = UV3[1] = 0.0; - Return_Value = 0; - UNGET - END_CASE - - END_EXPECT - - return(Return_Value); + if (AllowToken(UV_VECTORS_TOKEN)) + { + Parse_UV_Vect(UV1); Parse_Comma(); + Parse_UV_Vect(UV2); Parse_Comma(); + Parse_UV_Vect(UV3); + return true; + } + else + { + UV1[0] = UV1[1] = 0.0; + UV2[0] = UV2[1] = 0.0; + UV3[0] = UV3[1] = 0.0; + return false; + } } @@ -8549,7 +8442,7 @@ int Parser::Parse_Three_UVCoords(Vector2d& UV1, Vector2d& UV2, Vector2d& UV3) bool Parser::Parse_Comma (void) { Get_Token(); - if (CurrentTokenId() != COMMA_TOKEN) + if (CurrentTrueTokenId() != COMMA_TOKEN) { UNGET return false; @@ -8563,8 +8456,7 @@ bool Parser::Parse_Comma (void) bool Parser::AllowToken(TokenId tokenId) { Get_Token(); - bool tokenMatches = ((CurrentTokenId() == tokenId) || - (CurrentTokenFunctionId() == tokenId)); + bool tokenMatches = (CurrentTrueTokenId() == tokenId); if (!tokenMatches) Unget_Token(); return tokenMatches; @@ -8575,8 +8467,7 @@ bool Parser::AllowToken(TokenId tokenId) bool Parser::Peek_Token (TokenId tokenId) { Get_Token(); - bool tokenMatches = ((CurrentTokenId() == tokenId) || - (CurrentTokenFunctionId() == tokenId)); + bool tokenMatches = (CurrentTrueTokenId() == tokenId); Unget_Token(); return tokenMatches; } @@ -8603,7 +8494,7 @@ bool Parser::Peek_Token (TokenId tokenId) void Parser::Parse_Semi_Colon (bool force_semicolon) { Get_Token(); - if (CurrentTokenId() != SEMI_COLON_TOKEN) + if (CurrentTrueTokenId() != SEMI_COLON_TOKEN) { UNGET if ((sceneData->EffectiveLanguageVersion() >= 350) && (force_semicolon == true)) @@ -8676,20 +8567,14 @@ void Parser::Parse_Coeffs(int order, DBL *Coeffs) ObjectPtr Parser::Parse_Object_Id () { - ObjectPtr Object; - - EXPECT_ONE - CASE (OBJECT_ID_TOKEN) - Warn_State(OBJECT_ID_TOKEN, OBJECT_TOKEN); - Object = Copy_Object(CurrentTokenDataPtr()); - Object = Parse_Object_Mods (Object); - END_CASE + ObjectPtr Object = nullptr; - OTHERWISE - Object = nullptr; - UNGET - END_CASE - END_EXPECT + if (AllowToken(OBJECT_ID_TOKEN)) + { + Warn_State(OBJECT_TOKEN); + Object = Copy_Object(CurrentTokenDataPtr()); + Object = Parse_Object_Mods(Object); + } return (Object); } @@ -8793,7 +8678,7 @@ void Parser::Parse_Declare(bool is_local, bool after_hash) CASE (DEPRECATED_TOKEN) deprecated = true; ALLOW(ONCE_TOKEN); - if (CurrentTokenId() == ONCE_TOKEN) + if (CurrentTrueTokenId() == ONCE_TOKEN) deprecated_once = true; deprecation_message = Parse_String(false, false); END_CASE @@ -8819,7 +8704,7 @@ void Parser::Parse_Declare(bool is_local, bool after_hash) { numberPtr = mToken.NumberPtr; dataPtr = mToken.DataPtr; - Previous = CurrentTokenId(); + Previous = CurrentTrueTokenId(); } else { @@ -8832,8 +8717,8 @@ void Parser::Parse_Declare(bool is_local, bool after_hash) else Temp_Entry = mSymbolStack.Add_Symbol (Local_Index, CurrentTokenText(), IDENTIFIER_TOKEN); numberPtr = &(Temp_Entry->Token_Number); - dataPtr = &(Temp_Entry->Data); - Previous = CurrentTokenId(); + dataPtr = &(Temp_Entry->Data); + Previous = CurrentTrueTokenId(); if (deprecated) { Temp_Entry->deprecated = true;; @@ -8876,6 +8761,7 @@ void Parser::Parse_Declare(bool is_local, bool after_hash) CASE4 (DENSITY_MAP_ID_TOKEN, ARRAY_ID_TOKEN, DENSITY_ID_TOKEN, UV_ID_TOKEN) CASE4 (VECTOR_4D_ID_TOKEN, RAINBOW_ID_TOKEN, FOG_ID_TOKEN, SKYSPHERE_ID_TOKEN) CASE3 (MATERIAL_ID_TOKEN, SPLINE_ID_TOKEN, DICTIONARY_ID_TOKEN) + CASE2 (VECTOR_ID_TOKEN, FLOAT_ID_TOKEN) if (is_local && !mSymbolStack.IsLocalTableIndex(mToken.context)) { if (CurrentTokenIsContainerElement()) @@ -8891,7 +8777,7 @@ void Parser::Parse_Declare(bool is_local, bool after_hash) allow_redefine = !CurrentTokenIsHomogenousArrayElement(); numberPtr = mToken.NumberPtr; dataPtr = mToken.DataPtr; - Previous = CurrentTokenId(); + Previous = CurrentTrueTokenId(); } END_CASE @@ -8900,37 +8786,7 @@ void Parser::Parse_Declare(bool is_local, bool after_hash) allow_redefine = true; // should actually be irrelevant downstream, thanks to Previous==EMPTY_ARRAY_TOKEN numberPtr = mToken.NumberPtr; dataPtr = mToken.DataPtr; - Previous = CurrentTokenId(); - END_CASE - - CASE2 (VECTOR_FUNCT_TOKEN, FLOAT_FUNCT_TOKEN) - switch(CurrentTokenFunctionId()) - { - case VECTOR_ID_TOKEN: - case FLOAT_ID_TOKEN: - if (is_local && !mSymbolStack.IsLocalTableIndex(mToken.context)) - { - if (CurrentTokenIsContainerElement()) - Error("Cannot use '#local' to assign a non-local array or dictionary element."); - allow_redefine = true; // should actually be irrelevant downstream, thanks to Previous==IDENTIFIER_TOKEN - Temp_Entry = mSymbolStack.Add_Symbol (Local_Index, CurrentTokenText(), IDENTIFIER_TOKEN); - numberPtr = &(Temp_Entry->Token_Number); - dataPtr = &(Temp_Entry->Data); - Previous = IDENTIFIER_TOKEN; - } - else - { - allow_redefine = !CurrentTokenIsHomogenousArrayElement(); - numberPtr = mToken.NumberPtr; - dataPtr = mToken.DataPtr; - Previous = CurrentTokenFunctionId(); - } - break; - - default: - Parse_Error(IDENTIFIER_TOKEN); - break; - } + Previous = CurrentTrueTokenId(); END_CASE CASE4 (COMMA_TOKEN, RIGHT_PAREN_TOKEN, RIGHT_ANGLE_TOKEN, RIGHT_CURLY_TOKEN) @@ -8971,19 +8827,7 @@ void Parser::Parse_Declare(bool is_local, bool after_hash) if (lvectorDeclare && (lvalues.size() >= 5)) more = false; else if (tupleDeclare || lvectorDeclare || larrayDeclare) - { - EXPECT_ONE - CASE (COMMA_TOKEN) - more = true; - END_CASE - - OTHERWISE - more = false; - UNGET - END_CASE - END_EXPECT - - } + more = AllowToken(COMMA_TOKEN); else more = false; } @@ -9128,7 +8972,7 @@ void Parser::Parse_Declare(bool is_local, bool after_hash) { POV_EXPERIMENTAL_ASSERT(IsOkToDeclare()); SetOkToDeclare(false); - ALLOW( SEMI_COLON_TOKEN ); + ALLOW(SEMI_COLON_TOKEN); SetOkToDeclare(true); } } @@ -9175,7 +9019,7 @@ bool Parser::Parse_RValue (TokenId Previous, TokenId *NumberPtr, void **DataPtr, bool oldParseOptionalRVaue = parseOptionalRValue; parseOptionalRValue = allowUndefined; - EXPECT_ONE + EXPECT_ONE_CAT CASE4 (NORMAL_ID_TOKEN, FINISH_ID_TOKEN, TEXTURE_ID_TOKEN, OBJECT_ID_TOKEN) CASE4 (COLOUR_MAP_ID_TOKEN, TRANSFORM_ID_TOKEN, CAMERA_ID_TOKEN, PIGMENT_ID_TOKEN) CASE4 (SLOPE_MAP_ID_TOKEN,NORMAL_MAP_ID_TOKEN,TEXTURE_MAP_ID_TOKEN,ARRAY_ID_TOKEN) @@ -9214,7 +9058,7 @@ bool Parser::Parse_RValue (TokenId Previous, TokenId *NumberPtr, void **DataPtr, END_CASE CASE_COLOUR_RAW // no UNGET here - if((CurrentTokenId() != COLOUR_ID_TOKEN) || (sceneData->EffectiveLanguageVersion() < 350)) + if ((CurrentTrueTokenId() != COLOUR_ID_TOKEN) || (sceneData->EffectiveLanguageVersion() < 350)) { UNGET Local_Colour = Create_Colour(); @@ -9244,8 +9088,10 @@ bool Parser::Parse_RValue (TokenId Previous, TokenId *NumberPtr, void **DataPtr, // [2] Who is "me" anyway? [CLi] // determine the type of the first identifier - function_identifier = (CurrentTokenId()==FUNCT_ID_TOKEN) || (CurrentTokenId()==VECTFUNCT_ID_TOKEN); - callable_identifier = (CurrentTokenId()==FUNCT_ID_TOKEN) || (CurrentTokenId()==VECTFUNCT_ID_TOKEN) || (CurrentTokenId()==SPLINE_ID_TOKEN); + function_identifier = (CurrentTrueTokenId() == FUNCT_ID_TOKEN) || + (CurrentTrueTokenId() == VECTFUNCT_ID_TOKEN); + callable_identifier = function_identifier || + (CurrentTrueTokenId() == SPLINE_ID_TOKEN); // don't allow #declares from here SetOkToDeclare(false); @@ -9255,10 +9101,11 @@ bool Parser::Parse_RValue (TokenId Previous, TokenId *NumberPtr, void **DataPtr, // of a float, vector or color then count the tokens // found between now and the time when the function // Parse_Unknown_Vector returns - if (callable_identifier || (ParFlag && - (((CurrentTokenId()==FLOAT_FUNCT_TOKEN) && (CurrentTokenFunctionId()==FLOAT_ID_TOKEN)) || - ((CurrentTokenId()==VECTOR_FUNCT_TOKEN) && (CurrentTokenFunctionId()==VECTOR_ID_TOKEN)) || - (CurrentTokenId()==VECTOR_4D_ID_TOKEN) || (CurrentTokenId()==UV_ID_TOKEN) || (CurrentTokenId()==COLOUR_ID_TOKEN)))) + if (callable_identifier || (ParFlag && ((CurrentTrueTokenId()==FLOAT_ID_TOKEN) || + (CurrentTrueTokenId()==VECTOR_ID_TOKEN) || + (CurrentTrueTokenId()==VECTOR_4D_ID_TOKEN) || + (CurrentTrueTokenId()==UV_ID_TOKEN) || + (CurrentTrueTokenId()==COLOUR_ID_TOKEN)))) { Temp_Count = mTokenCount; } @@ -9270,8 +9117,9 @@ bool Parser::Parse_RValue (TokenId Previous, TokenId *NumberPtr, void **DataPtr, // so we claim dibs on it until we're done. // TODO - this is a bit hackish; ideally, if the Token is a symbol we should have it store the SYM_ENTRY pointer, // so we don't need to look it up again via name. - if ((CurrentTokenId()==FUNCT_ID_TOKEN) || (CurrentTokenId()==VECTFUNCT_ID_TOKEN) || (CurrentTokenId()==SPLINE_ID_TOKEN) || - (CurrentTokenId()==UV_ID_TOKEN) || (CurrentTokenId()==VECTOR_4D_ID_TOKEN) || (CurrentTokenId()==COLOUR_ID_TOKEN)) + if ((CurrentTrueTokenId() == FUNCT_ID_TOKEN) || (CurrentTrueTokenId() == VECTFUNCT_ID_TOKEN) || + (CurrentTrueTokenId() == SPLINE_ID_TOKEN) || (CurrentTrueTokenId() == UV_ID_TOKEN) || + (CurrentTrueTokenId() == VECTOR_4D_ID_TOKEN) || (CurrentTrueTokenId() == COLOUR_ID_TOKEN)) { symbol_entry = mToken.table->Find_Symbol (CurrentTokenText().c_str()); if (symbol_entry) @@ -9785,25 +9633,25 @@ void Parser::Found_Instead_Error(const char *exstr, const char *extokstr) { const char *found; - switch(CurrentTokenId()) + switch (CurrentCategorizedTokenId()) { case IDENTIFIER_TOKEN: Error("%s '%s', undeclared identifier '%s' found instead", exstr, extokstr, CurrentTokenText().c_str()); break; - case VECTOR_FUNCT_TOKEN: - found = Get_Token_String(CurrentTokenFunctionId()); + case VECTOR_TOKEN_CATEGORY: + found = Get_Token_String(CurrentTrueTokenId()); Error("%s '%s', vector function '%s' found instead", exstr, extokstr, found); break; - case FLOAT_FUNCT_TOKEN: - found = Get_Token_String(CurrentTokenFunctionId()); + case FLOAT_TOKEN_CATEGORY: + found = Get_Token_String(CurrentTrueTokenId()); Error("%s '%s', float function '%s' found instead", exstr, extokstr, found); break; - case COLOUR_KEY_TOKEN: - found = Get_Token_String(CurrentTokenFunctionId()); + case COLOUR_TOKEN_CATEGORY: + found = Get_Token_String(CurrentTrueTokenId()); Error("%s '%s', color keyword '%s' found instead", exstr, extokstr, found); break; default: - found = Get_Token_String(CurrentTokenId()); + found = Get_Token_String(CurrentTrueTokenId()); Error("%s '%s', %s found instead", exstr, extokstr, found); } } @@ -9827,7 +9675,7 @@ void Parser::Found_Instead_Error(const char *exstr, const char *extokstr) * ******************************************************************************/ -void Parser::Warn_State(TokenId Token_Id, TokenId Type) +void Parser::Warn_State(TokenId Type) { char *str; @@ -9837,7 +9685,7 @@ void Parser::Warn_State(TokenId Token_Id, TokenId Type) str = reinterpret_cast(POV_MALLOC(160, "global setting warning string")); strcpy(str, "Found '"); - strcat(str, Get_Token_String (Token_Id)); + strcat(str, Get_Token_String (CurrentTrueTokenId())); strcat(str, "' that should be in '"); strcat(str, Get_Token_String (Type)); strcat(str, "' statement."); diff --git a/source/parser/parser.h b/source/parser/parser.h index d561be36e..4bfa6ac42 100644 --- a/source/parser/parser.h +++ b/source/parser/parser.h @@ -93,64 +93,66 @@ const int TOKEN_OVERFLOW_RESET_COUNT = 2500; /* Here we create our own little language for doing the parsing. It makes the code easier to read. */ -#define GET(x) Get_Token(); \ - if (CurrentTokenId() != x) \ - Parse_Error (x); - -#define ALLOW(x) Get_Token(); \ - if (CurrentTokenId() != x) \ - Unget_Token(); - -#define UNGET Unget_Token(); - -#define EXPECT { \ - int Exit_Flag; \ - Exit_Flag = false; \ - while (!Exit_Flag) \ - { \ - Get_Token(); \ - switch (CurrentTokenId()) \ - { - -#define EXPECT_ONE { \ - int Exit_Flag; \ - Exit_Flag = false; \ - { \ - Get_Token(); \ - switch (CurrentTokenId()) \ - { - -#define CASE(x) case x: -#define CASE2(x, y) case x: case y: -#define CASE3(x, y, z) case x: case y: case z: -#define CASE4(w, x, y, z) case w: case x: case y: case z: -#define CASE5(v, w, x, y, z) case v: case w: case x: case y: case z: -#define CASE6(u, v, w, x, y, z) case u: case v: case w: case x: case y: case z: -#define OTHERWISE default: - -#define CASE_FLOAT_RAW CASE2 (LEFT_PAREN_TOKEN,FLOAT_FUNCT_TOKEN) \ - CASE4 (PLUS_TOKEN,DASH_TOKEN,FUNCT_ID_TOKEN,EXCLAMATION_TOKEN) - -#define CASE_VECTOR_RAW CASE3 (VECTFUNCT_ID_TOKEN,VECTOR_FUNCT_TOKEN,LEFT_ANGLE_TOKEN) \ - CASE5 (U_TOKEN,V_TOKEN,UV_ID_TOKEN,VECTOR_4D_ID_TOKEN,SPLINE_ID_TOKEN) \ - CASE_FLOAT_RAW - -#define CASE_COLOUR_RAW CASE3 (COLOUR_TOKEN,COLOUR_KEY_TOKEN,COLOUR_ID_TOKEN) - -#define CASE_EXPRESS_RAW CASE_VECTOR_RAW CASE_COLOUR_RAW - -#define CASE_FLOAT_UNGET CASE_FLOAT_RAW UNGET -#define CASE_VECTOR_UNGET CASE_VECTOR_RAW UNGET -#define CASE_COLOUR_UNGET CASE_COLOUR_RAW UNGET -#define CASE_EXPRESS_UNGET CASE_EXPRESS_RAW UNGET - -#define END_CASE break; -#define FALLTHROUGH_CASE // FALLTHROUGH -#define EXIT Exit_Flag = true; - -#define END_EXPECT } \ - } \ - } +#define GET(x) Get_Token(); \ + if (CurrentTrueTokenId() != x) \ + Parse_Error (x); + +#define ALLOW(x) Get_Token(); \ + if (CurrentTrueTokenId() != x) \ + Unget_Token(); + +#define UNGET Unget_Token(); + +#define EXPECT EXPECT_(CurrentTrueTokenId()) +#define EXPECT_CAT EXPECT_(CurrentCategorizedTokenId()) +#define EXPECT_ONE EXPECT_ONE_(CurrentTrueTokenId()) +#define EXPECT_ONE_CAT EXPECT_ONE_(CurrentCategorizedTokenId()) + +#define EXPECT_(x) { \ + bool exitExpect = false; \ + while (!exitExpect) \ + { \ + Get_Token(); \ + switch (x) \ + { + +#define EXPECT_ONE_(x) { \ + { \ + Get_Token(); \ + switch (x) \ + { + +#define CASE(x) case x: +#define CASE2(x, y) case x: case y: +#define CASE3(x, y, z) case x: case y: case z: +#define CASE4(w, x, y, z) case w: case x: case y: case z: +#define CASE5(v, w, x, y, z) case v: case w: case x: case y: case z: +#define CASE6(u, v, w, x, y, z) case u: case v: case w: case x: case y: case z: +#define OTHERWISE default: + +#define CASE_FLOAT_RAW CASE2 (LEFT_PAREN_TOKEN,FLOAT_TOKEN_CATEGORY) \ + CASE4 (PLUS_TOKEN,DASH_TOKEN,FUNCT_ID_TOKEN,EXCLAMATION_TOKEN) + +#define CASE_VECTOR_RAW CASE3 (VECTFUNCT_ID_TOKEN,VECTOR_TOKEN_CATEGORY,LEFT_ANGLE_TOKEN) \ + CASE5 (U_TOKEN,V_TOKEN,UV_ID_TOKEN,VECTOR_4D_ID_TOKEN,SPLINE_ID_TOKEN) \ + CASE_FLOAT_RAW + +#define CASE_COLOUR_RAW CASE3 (COLOUR_TOKEN,COLOUR_TOKEN_CATEGORY,COLOUR_ID_TOKEN) + +#define CASE_EXPRESS_RAW CASE_VECTOR_RAW CASE_COLOUR_RAW + +#define CASE_FLOAT_UNGET CASE_FLOAT_RAW UNGET +#define CASE_VECTOR_UNGET CASE_VECTOR_RAW UNGET +#define CASE_COLOUR_UNGET CASE_COLOUR_RAW UNGET +#define CASE_EXPRESS_UNGET CASE_EXPRESS_RAW UNGET + +#define END_CASE break; +#define FALLTHROUGH_CASE // FALLTHROUGH +#define EXIT exitExpect = true; + +#define END_EXPECT } \ + } \ + } struct ExperimentalFlags @@ -232,25 +234,37 @@ class Parser { RawToken raw; ConstStreamPtr sourceFile; - TokenId Token_Id; ///< reserved token (or token group) ID, or unique identifier ID - TokenId Function_Id; ///< token type ID, in case Token_Id is an identifier ID - int context; ///< context the token is local to (i.e., table index) - DBL Token_Float; ///< token value (if it is a float literal) - void *Data; ///< reference to token value (if it is a non-float identifier) + int context; ///< Context the token is local to (i.e., table index). + DBL Token_Float; ///< Token value (if it is a float literal). + void *Data; ///< Reference to token value (if it is a non-float identifier). TokenId *NumberPtr; void **DataPtr; - SymbolTable* table; ///< table or dictionary the token references an element of - bool Unget_Token : 1; ///< `true` if @ref Get_Token() must re-issue this token as-is. - bool ungetRaw : 1; ///< `true` if @ref Get_Token() must re-evaluate this token from raw. + SymbolTable* table; ///< Table or dictionary the token references an element of. + bool Unget_Token : 1; ///< `true` if @ref Get_Token() must re-issue this token as-is. + bool ungetRaw : 1; ///< `true` if @ref Get_Token() must re-evaluate this token from raw. bool End_Of_File : 1; - bool is_array_elem : 1; ///< true if token is actually an array element reference - bool is_mixed_array_elem : 1; ///< true if token is actually a mixed-type array element reference - bool is_dictionary_elem : 1; ///< true if token is actually a dictionary element reference + bool is_array_elem : 1; ///< `true` if token is an array element reference. + bool is_mixed_array_elem : 1; ///< `true` if token is a mixed-type array element reference. + bool is_dictionary_elem : 1; ///< `true` if token is a dictionary element reference. + + void SetTokenId(const RawToken& rawToken); + void SetTokenId(TokenId tokenId); + + /// Token ID, or identifier type ID (`XXX_ID_TOKEN`) in case of identifier token. + TokenId GetTrueTokenId() const; + + /// Token category if applicable, otherwise equal to @ref mTrueTokenId. + TokenId GetCategorizedTokenId() const; virtual UCS2String GetFileName() const override { return sourceFile->Name(); } virtual POV_LONG GetLine() const override { return raw.lexeme.position.line; } virtual POV_LONG GetColumn() const override { return raw.lexeme.position.column; } virtual POV_OFF_T GetOffset() const override { return raw.lexeme.position.offset; } + + private: + + TokenId mTrueTokenId; ///< Token ID, or identifier type ID in case of identifier token. + TokenId mCategorizedTokenId; ///< Token category if applicable, otherwise equal to @ref mTrueTokenId. }; struct LValue @@ -395,7 +409,7 @@ class Parser void Parse_Semi_Colon (bool force_semicolon); void Destroy_Frame (void); void MAError (const char *str, long size); - void Warn_State (TokenId Token_Id, TokenId Type); + void Warn_State (TokenId Type); void Only_In (const char *s1,const char *s2); void Not_With (const char *s1,const char *s2); void Warn_Compat (bool definite, const char *sym); @@ -416,7 +430,6 @@ class Parser void Expectation_Error(const char *); TRANSFORM *Parse_Transform(TRANSFORM *Trans = nullptr); TRANSFORM *Parse_Transform_Block(TRANSFORM *New = nullptr); - char *Get_Reserved_Words (const char *additional_words); void SendFatalError(Exception& e); @@ -448,8 +461,8 @@ class Parser void Get_Token (void); void Unget_Token (void); - TokenId CurrentTokenId() const; - TokenId CurrentTokenFunctionId() const; + TokenId CurrentCategorizedTokenId() const; + TokenId CurrentTrueTokenId() const; const UTF8String& CurrentTokenText() const; const MessageContext& CurrentTokenMessageContext() const; void InitCurrentToken(); @@ -607,7 +620,8 @@ class Parser { TokenId openToken; ConstStreamPtr file; - BraceStackEntry(const Token_Struct& token) : LexemePosition(token.raw.lexeme.position), openToken(token.Token_Id), file(token.sourceFile) {} + BraceStackEntry(const Token_Struct& token) : + LexemePosition(token.raw.lexeme.position), openToken(token.GetTrueTokenId()), file(token.sourceFile) {} virtual UCS2String GetFileName() const override { return file->Name(); } virtual POV_LONG GetLine() const override { return line; } virtual POV_LONG GetColumn() const override { return column; } @@ -694,8 +708,6 @@ class Parser bool Got_EOF; // WARNING: Changes to the use of this variable are very dangerous as it is used in many places assuming certain non-obvious side effects! [trf] - TokenId Conversion_Util_Table[TOKEN_COUNT]; - RawTokenizer mTokenizer; RawToken mPendingRawToken; bool mHavePendingRawToken; @@ -792,7 +804,7 @@ class Parser void ParseContainedBy(shared_ptr& container, ObjectPtr obj); ObjectPtr Parse_Sphere_Sweep(void); - int Parse_Three_UVCoords(Vector2d& UV1, Vector2d& UV2, Vector2d& UV3); + bool Parse_Three_UVCoords(Vector2d& UV1, Vector2d& UV2, Vector2d& UV3); // tokenize.h/tokenize.cpp void UngetRawToken(const RawToken& rawToken); diff --git a/source/parser/parser_expressions.cpp b/source/parser/parser_expressions.cpp index 4c56781ae..8065485d4 100644 --- a/source/parser/parser_expressions.cpp +++ b/source/parser/parser_expressions.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 @@ -84,7 +84,7 @@ using namespace pov; * Local preprocessor defines ******************************************************************************/ -#define ftrue(f) ((int)(fabs(f)>EPSILON)) +#define FTRUE(f) ((int)(fabs(f)>EPSILON)) /***************************************************************************** @@ -241,7 +241,7 @@ void Parser::Parse_Vector_Param2(Vector3d& Val1, Vector3d& Val2) void Parser::Parse_Trace(Vector3d& Res) { - ObjectPtr Object; + ObjectPtr Object = nullptr; Intersection intersect; TraceTicket ticket(1, 0.0); Ray ray(ticket); @@ -249,16 +249,8 @@ void Parser::Parse_Trace(Vector3d& Res) Parse_Paren_Begin(); - EXPECT_ONE - CASE (OBJECT_ID_TOKEN) - Object = CurrentTokenDataPtr(); - END_CASE - - OTHERWISE - Object = nullptr; - UNGET - END_CASE - END_EXPECT + if (AllowToken(OBJECT_ID_TOKEN)) + Object = CurrentTokenDataPtr(); if (Object == nullptr) Error ("Object identifier expected."); @@ -287,23 +279,8 @@ void Parser::Parse_Trace(Vector3d& Res) Local_Normal = Vector3d(0.0, 0.0, 0.0); } - EXPECT_ONE - CASE (VECTOR_FUNCT_TOKEN) - /* All of these functions return a VECTOR result */ - if(mToken.Function_Id == VECTOR_ID_TOKEN) - { - SetCurrentTokenData(Local_Normal); - } - else - { - UNGET - } - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(VECTOR_ID_TOKEN)) + SetCurrentTokenData(Local_Normal); Parse_Paren_End(); } @@ -328,26 +305,18 @@ void Parser::Parse_Trace(Vector3d& Res) int Parser::Parse_Inside() { - ObjectPtr Object; + ObjectPtr Object = nullptr; Vector3d Local_Vector; int Result = 0; Parse_Paren_Begin(); - EXPECT_ONE - CASE (OBJECT_ID_TOKEN) - Object = CurrentTokenDataPtr(); - END_CASE - - OTHERWISE - Object = nullptr; - UNGET - END_CASE - END_EXPECT + if (AllowToken(OBJECT_ID_TOKEN)) + Object = CurrentTokenDataPtr(); if (Object == nullptr) Error ("Object identifier expected."); - if((Object->Type & PATCH_OBJECT) == PATCH_OBJECT) + if ((Object->Type & PATCH_OBJECT) == PATCH_OBJECT) Error ("Solid object identifier expected."); Parse_Comma(); @@ -593,7 +562,7 @@ void Parser::Parse_Spline_Call(EXPRESS& Express, int *Terms) Val=Parse_Float(); Get_Token(); - if (CurrentTokenId() == COMMA_TOKEN) + if (CurrentTrueTokenId() == COMMA_TOKEN) { /*If there is a second parameter, make a copy of the spline with a new type and evaluate that.*/ @@ -602,7 +571,7 @@ void Parser::Parse_Spline_Call(EXPRESS& Express, int *Terms) Release_Spline_Reference(spline); Get_Token(); - switch (CurrentTokenId()) + switch (CurrentTrueTokenId()) { case LINEAR_SPLINE_TOKEN: spline = new LinearSpline(*spline); @@ -685,10 +654,10 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) END_CASE END_EXPECT - EXPECT_ONE - CASE (FLOAT_FUNCT_TOKEN) + EXPECT_ONE_CAT + CASE (FLOAT_TOKEN_CATEGORY) /* All of these functions return a DBL result */ - switch(mToken.Function_Id) + switch(CurrentTrueTokenId()) { case ABS_TOKEN: Val = Parse_Float_Param(); @@ -747,7 +716,7 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) case ATAN2_TOKEN: Parse_Float_Param2(&Val,&Val2); - if (ftrue(Val) || ftrue(Val2)) + if (FTRUE(Val) || FTRUE(Val2)) Val = atan2(Val,Val2); else Error("Domain error in atan2!"); @@ -756,21 +725,27 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) case COSH_TOKEN: Val = cosh(Parse_Float_Param()); break; + case SINH_TOKEN: Val = sinh(Parse_Float_Param()); break; + case TANH_TOKEN: Val = tanh(Parse_Float_Param()); break; + case ACOSH_TOKEN: Val = acosh(Parse_Float_Param()); break; + case ASINH_TOKEN: Val = asinh(Parse_Float_Param()); break; + case ATANH_TOKEN: Val = atanh(Parse_Float_Param()); break; + case CEIL_TOKEN: Val = ceil(Parse_Float_Param()); break; @@ -949,25 +924,23 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) less_val = Parse_Float(); Parse_Comma(); equal_val = Parse_Float(); - EXPECT_ONE - CASE(COMMA_TOKEN) - greater_val = Parse_Float(); - if(Val < 0.0) - Val = less_val; - else if(Val == 0.0) - Val = equal_val; - else - Val = greater_val; - END_CASE - - OTHERWISE - UNGET - if(Val < 0.0) - Val = less_val; - else - Val = equal_val; - END_CASE - END_EXPECT + if (AllowToken(COMMA_TOKEN)) + { + greater_val = Parse_Float(); + if (Val < 0.0) + Val = less_val; + else if (Val == 0.0) + Val = equal_val; + else + Val = greater_val; + } + else + { + if (Val < 0.0) + Val = less_val; + else + Val = equal_val; + } Parse_Paren_End(); break; @@ -1122,9 +1095,9 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) Express[0]=Val; END_CASE - CASE (VECTOR_FUNCT_TOKEN) + CASE (VECTOR_TOKEN_CATEGORY) /* All of these functions return a VECTOR result */ - switch(mToken.Function_Id) + switch(CurrentTrueTokenId()) { case VAXIS_ROTATE_TOKEN: Parse_Paren_Begin(); @@ -1201,19 +1174,17 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) case MIN_EXTENT_TOKEN: Parse_Paren_Begin(); - EXPECT_ONE - CASE (OBJECT_ID_TOKEN) - Object = CurrentTokenDataPtr(); - if ( Object ) - Vect = Vector3d(Object->BBox.lowerLeft); - END_CASE - - OTHERWISE - Object = nullptr; - Vect = Vector3d(0.0,0.0,0.0); - UNGET - END_CASE - END_EXPECT + if (AllowToken(OBJECT_ID_TOKEN)) + { + Object = CurrentTokenDataPtr(); + if (Object) + Vect = Vector3d(Object->BBox.lowerLeft); + } + else + { + Object = nullptr; + Vect = Vector3d(0.0,0.0,0.0); + } Parse_Paren_End(); break; @@ -1338,7 +1309,7 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) oldOkToDeclare = IsOkToDeclare(); SetOkToDeclare(true); for (i=0; i<*Terms; i++) - Express[i] = ftrue(Express[i])?0.0:1.0; + Express[i] = FTRUE(Express[i])?0.0:1.0; END_CASE CASE (LEFT_PAREN_TOKEN) @@ -1361,17 +1332,17 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) Express[Y] = Parse_Float(); Parse_Comma(); *Terms=2; - EXPECT_ONE + EXPECT_ONE_CAT CASE_EXPRESS_UNGET /* If a 3rd float is found, parse it. */ Express[2] = Parse_Float(); Parse_Comma(); *Terms=3; - EXPECT_ONE + EXPECT_ONE_CAT CASE_EXPRESS_UNGET /* If a 4th float is found, parse it. */ Express[3] = Parse_Float(); Parse_Comma(); *Terms=4; - EXPECT_ONE + EXPECT_ONE_CAT CASE_EXPRESS_UNGET /* If a 5th float is found, parse it. */ Express[4] = Parse_Float(); @@ -1410,89 +1381,68 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) SetOkToDeclare(oldOkToDeclare); /* Parse VECTOR.x or COLOR.red type things */ - EXPECT_ONE - CASE(PERIOD_TOKEN) - EXPECT_ONE - CASE (VECTOR_FUNCT_TOKEN) - switch(mToken.Function_Id) - { - case X_TOKEN: - i=X; - break; - - case Y_TOKEN: - i=Y; - break; - - case Z_TOKEN: - i=Z; - break; - - default: - Expectation_Error ("x, y, or z"); - } - END_CASE - - CASE (COLOUR_KEY_TOKEN) - switch(mToken.Function_Id) - { - case RED_TOKEN: - i=pRED; - break; - - case GREEN_TOKEN: - i=pGREEN; - break; - - case BLUE_TOKEN: - i=pBLUE; - break; - - case FILTER_TOKEN: - i=pFILTER; - break; - - case TRANSMIT_TOKEN: - i=pTRANSM; - break; - - case GRAY_TOKEN: - *Terms=1; - Express[0]=PreciseRGBFTColour(Express).Greyscale(); - return; - - default: - Expectation_Error ("red, green, blue, filter, transmit, gray or vector component"); - } - END_CASE - - CASE(U_TOKEN) - i=U; - END_CASE - - CASE(V_TOKEN) - i=V; - END_CASE - - CASE(T_TOKEN) - i=T; - END_CASE - - OTHERWISE - Expectation_Error ("x, y, z, u, v, t or color component"); - END_CASE - END_EXPECT - - if (i>=*Terms) - Error("Bad operands for period operator."); - *Terms=1; - Express[0]=Express[i]; - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(PERIOD_TOKEN)) + { + EXPECT_ONE + CASE(X_TOKEN) + i=X; + END_CASE + + CASE(Y_TOKEN) + i=Y; + END_CASE + + CASE(Z_TOKEN) + i=Z; + END_CASE + + CASE(RED_TOKEN) + i=pRED; + END_CASE + + CASE(GREEN_TOKEN) + i=pGREEN; + END_CASE + + CASE(BLUE_TOKEN) + i=pBLUE; + END_CASE + + CASE(FILTER_TOKEN) + i=pFILTER; + END_CASE + + CASE(TRANSMIT_TOKEN) + i=pTRANSM; + END_CASE + + CASE(GRAY_TOKEN) + Express[0]=PreciseRGBFTColour(Express).Greyscale(); + i=1; + END_CASE + + CASE(U_TOKEN) + i=U; + END_CASE + + CASE(V_TOKEN) + i=V; + END_CASE + + CASE(T_TOKEN) + i=T; + END_CASE + + OTHERWISE + Expectation_Error ("x, y, z, u, v, t or color component"); + END_CASE + END_EXPECT + + if (i>=*Terms) + Error("Bad operands for period operator."); + *Terms=1; + Express[0]=Express[i]; + } } @@ -1828,7 +1778,7 @@ void Parser::Parse_Rel_Term (EXPRESS& Express,int *Terms) Promote_Express(Express,Terms,Local_Terms); for(i=0;i<*Terms;i++) - Express[i] = (DBL)((Express[i] <= Local_Express[i]) || (!ftrue(Express[i]-Local_Express[i]))); + Express[i] = (DBL)((Express[i] <= Local_Express[i]) || (!FTRUE(Express[i]-Local_Express[i]))); END_CASE CASE (EQUALS_TOKEN) @@ -1836,7 +1786,7 @@ void Parser::Parse_Rel_Term (EXPRESS& Express,int *Terms) Promote_Express(Express,Terms,Local_Terms); for(i=0;i<*Terms;i++) - Express[i] = (DBL)(!ftrue(Express[i]-Local_Express[i])); + Express[i] = (DBL)(!FTRUE(Express[i]-Local_Express[i])); END_CASE CASE (REL_NE_TOKEN) @@ -1844,7 +1794,7 @@ void Parser::Parse_Rel_Term (EXPRESS& Express,int *Terms) Promote_Express(Express,Terms,Local_Terms); for(i=0;i<*Terms;i++) - Express[i] = (DBL)ftrue(Express[i]-Local_Express[i]); + Express[i] = (DBL)FTRUE(Express[i]-Local_Express[i]); END_CASE CASE (REL_GE_TOKEN) @@ -1852,7 +1802,7 @@ void Parser::Parse_Rel_Term (EXPRESS& Express,int *Terms) Promote_Express(Express,Terms,Local_Terms); for(i=0;i<*Terms;i++) - Express[i] = (DBL)((Express[i] >= Local_Express[i]) || (!ftrue(Express[i]-Local_Express[i]))); + Express[i] = (DBL)((Express[i] >= Local_Express[i]) || (!FTRUE(Express[i]-Local_Express[i]))); END_CASE CASE (RIGHT_ANGLE_TOKEN) @@ -1905,7 +1855,7 @@ void Parser::Parse_Logical (EXPRESS& Express,int *Terms) Promote_Express(Express,Terms,Local_Terms); for(i=0;i<*Terms;i++) - Express[i] = (DBL)(ftrue(Express[i]) && ftrue(Local_Express[i])); + Express[i] = (DBL)(FTRUE(Express[i]) && FTRUE(Local_Express[i])); END_CASE CASE (BAR_TOKEN) @@ -1913,7 +1863,7 @@ void Parser::Parse_Logical (EXPRESS& Express,int *Terms) Promote_Express(Express,Terms,Local_Terms); for(i=0;i<*Terms;i++) - Express[i] = (DBL)(ftrue(Express[i]) || ftrue(Local_Express[i])); + Express[i] = (DBL)(FTRUE(Express[i]) || FTRUE(Local_Express[i])); END_CASE OTHERWISE @@ -1952,33 +1902,30 @@ void Parser::Parse_Express (EXPRESS& Express,int *Terms) Parse_Logical(Express,&Local_Terms1); - EXPECT_ONE - CASE (QUESTION_TOKEN) - if (Local_Terms1 != 1) - Error("Conditional must evaluate to a float."); - Parse_Express(Local_Express1,&Local_Terms1); - GET(COLON_TOKEN); - Parse_Express(Local_Express2,&Local_Terms2); - if (ftrue(Express[0])) - { - Chosen = &Local_Express1; - *Terms = Local_Terms1; - } - else - { - Chosen = &Local_Express2; - *Terms = Local_Terms2; - } - POV_MEMCPY(Express,Chosen,sizeof(EXPRESS)); - END_CASE - - OTHERWISE - /* Not a (c)?a:b expression. */ - *Terms=Local_Terms1; - UNGET - END_CASE - END_EXPECT - + if (AllowToken(QUESTION_TOKEN)) + { + if (Local_Terms1 != 1) + Error("Conditional must evaluate to a float."); + Parse_Express(Local_Express1, &Local_Terms1); + GET(COLON_TOKEN); + Parse_Express(Local_Express2, &Local_Terms2); + if (FTRUE(Express[0])) + { + Chosen = &Local_Express1; + *Terms = Local_Terms1; + } + else + { + Chosen = &Local_Express2; + *Terms = Local_Terms2; + } + POV_MEMCPY(Express, Chosen, sizeof(EXPRESS)); + } + else + { + /* Not a (c)?a:b expression. */ + *Terms = Local_Terms1; + } } @@ -2105,7 +2052,7 @@ DBL Parser::Allow_Float (DBL defval) { DBL retval; - EXPECT_ONE + EXPECT_ONE_CAT CASE_EXPRESS_UNGET retval = Parse_Float(); END_CASE @@ -2142,7 +2089,7 @@ int Parser::Allow_Vector (Vector3d& Vect) { int retval; - EXPECT_ONE + EXPECT_ONE_CAT CASE_EXPRESS_UNGET Parse_Vector(Vect); retval = true; @@ -2435,9 +2382,9 @@ void Parser::Parse_Colour (RGBFTColour& colour, bool expectFT) ALLOW(COLOUR_TOKEN) - EXPECT - CASE (COLOUR_KEY_TOKEN) - switch(mToken.Function_Id) + EXPECT_CAT + CASE (COLOUR_TOKEN_CATEGORY) + switch(CurrentTrueTokenId()) { case ALPHA_TOKEN: VersionWarning(155, "Keyword ALPHA discontinued. Use FILTER instead."); @@ -2677,7 +2624,7 @@ void Parser::Parse_Colour (RGBFTColour& colour, bool expectFT) // five value color vector. Any single float will be promoted to the full // 'tgtTerms' value. This usually results in filter and trasmit values >0, // which caused shadow artifacts back to at least version v3.6.1. - if ((CurrentTokenId() == FLOAT_FUNCT_TOKEN) || (CurrentTokenId() == FUNCT_ID_TOKEN)) + if ((CurrentCategorizedTokenId() == FLOAT_TOKEN_CATEGORY) || (CurrentTrueTokenId() == FUNCT_ID_TOKEN)) sawFloatOrFloatFnct = true; else sawFloatOrFloatFnct = false; @@ -3103,7 +3050,7 @@ shared_ptr Parser::Parse_Blend_List (int Count, ColourBlendMapConstPtr De switch(Blend_Type) { case kBlendMapType_Colour: - EXPECT + EXPECT_CAT CASE_EXPRESS_UNGET Parse_BlendListData(Blend_Type,tempList[i].Vals); Parse_Comma (); @@ -3435,7 +3382,7 @@ ColourBlendMapPtr Parser::Parse_Colour_Map () Temp_Ent.value = Parse_Float(); Parse_Comma(); - EXPECT_ONE + EXPECT_ONE_CAT /* After [ must be a float. If 2nd thing found is another float then this is an old style color_map. */ @@ -3605,21 +3552,16 @@ GenericSpline *Parser::Parse_Spline() MaxTerms = 2; /*Check for spline identifier*/ - EXPECT_ONE - CASE(SPLINE_ID_TOKEN) - Old = CurrentTokenDataPtr(); - i = Old->SplineEntries.size(); - MaxTerms = Old->Terms; - keepOld = true; - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(SPLINE_ID_TOKEN)) + { + Old = CurrentTokenDataPtr(); + i = Old->SplineEntries.size(); + MaxTerms = Old->Terms; + keepOld = true; + } /* Determine kind of spline */ - EXPECT + EXPECT // TODO should probably be EXPECT_ONE CASE(LINEAR_SPLINE_TOKEN) if (Old) New = new LinearSpline(*Old); @@ -3678,7 +3620,7 @@ GenericSpline *Parser::Parse_Spline() New = new LinearSpline(); } - EXPECT + EXPECT_CAT CASE_FLOAT_UNGET /* Entry has the form float,vector */ par = Parse_Float(); diff --git a/source/parser/parser_functions.cpp b/source/parser/parser_functions.cpp index ce28753d9..122b83907 100644 --- a/source/parser/parser_functions.cpp +++ b/source/parser/parser_functions.cpp @@ -11,7 +11,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 @@ -392,62 +392,42 @@ TokenId Parser::expr_get_token() { Get_Token(); - if(CurrentTokenFunctionId() == X_TOKEN) - return FLOAT_ID_TOKEN; - else if(CurrentTokenFunctionId() == Y_TOKEN) - return FLOAT_ID_TOKEN; - else if(CurrentTokenFunctionId() == Z_TOKEN) - return FLOAT_ID_TOKEN; - else if(CurrentTokenFunctionId() == U_TOKEN) - return FLOAT_ID_TOKEN; - else if(CurrentTokenFunctionId() == V_TOKEN) - return FLOAT_ID_TOKEN; - else if(CurrentTokenFunctionId() == IDENTIFIER_TOKEN) - return FLOAT_ID_TOKEN; - else if(CurrentTokenFunctionId() == CLOCK_TOKEN) + switch (CurrentTrueTokenId()) { - mToken.Token_Float = clockValue; - return FLOAT_TOKEN; - } - else if(CurrentTokenFunctionId() == PI_TOKEN) - { - mToken.Token_Float = M_PI; - return FLOAT_TOKEN; - } - else if(CurrentTokenFunctionId() == TAU_TOKEN) - { - mToken.Token_Float = M_TAU; - return FLOAT_TOKEN; - } - else if(CurrentTokenFunctionId() == RED_TOKEN) - return RED_TOKEN; - else if(CurrentTokenFunctionId() == GREEN_TOKEN) - return GREEN_TOKEN; - else if(CurrentTokenFunctionId() == BLUE_TOKEN) - return BLUE_TOKEN; - else if(CurrentTokenFunctionId() == FILTER_TOKEN) - return FILTER_TOKEN; - else if(CurrentTokenFunctionId() == TRANSMIT_TOKEN) - return TRANSMIT_TOKEN; - else if(CurrentTokenFunctionId() == T_TOKEN) - return T_TOKEN; - else if(CurrentTokenFunctionId() == GRAY_TOKEN) - return GRAY_TOKEN; - - if(CurrentTokenId() == FLOAT_FUNCT_TOKEN) - { - if(CurrentTokenFunctionId() == FLOAT_TOKEN) + case X_TOKEN: + case Y_TOKEN: + case Z_TOKEN: + case U_TOKEN: + case V_TOKEN: + case IDENTIFIER_TOKEN: + return FLOAT_ID_TOKEN; + + case CLOCK_TOKEN: + mToken.Token_Float = clockValue; return FLOAT_TOKEN; - else if(CurrentTokenFunctionId() == FLOAT_ID_TOKEN) - { + + case PI_TOKEN: + mToken.Token_Float = M_PI; + return FLOAT_TOKEN; + + case TAU_TOKEN: + mToken.Token_Float = M_TAU; + return FLOAT_TOKEN; + + case FLOAT_TOKEN: + // mToken.Token_Float already set + return FLOAT_TOKEN; + + case FLOAT_ID_TOKEN: mToken.Token_Float = CurrentTokenData(); return FLOAT_TOKEN; - } - return FUNCT_ID_TOKEN; + default: + if (CurrentCategorizedTokenId() == FLOAT_TOKEN_CATEGORY) + return FUNCT_ID_TOKEN; + else + return CurrentTrueTokenId(); } - - return CurrentTokenId(); } @@ -682,7 +662,7 @@ bool Parser::expr_call(ExprNode *¤t, int stage, int op) } else node->call.fn = 0; - node->call.token = CurrentTokenFunctionId(); + node->call.token = CurrentTrueTokenId(); node->call.name = POV_STRDUP(CurrentTokenText().c_str()); while (current->child != nullptr) current = current->child; @@ -702,7 +682,7 @@ bool Parser::expr_call(ExprNode *¤t, int stage, int op) node = node->next; } - if(CurrentTokenId() != RIGHT_PAREN_TOKEN) + if(CurrentTrueTokenId() != RIGHT_PAREN_TOKEN) Expectation_Error(")"); return true; diff --git a/source/parser/parser_functions_utilities.cpp b/source/parser/parser_functions_utilities.cpp index 508447a88..89d6e6d04 100644 --- a/source/parser/parser_functions_utilities.cpp +++ b/source/parser/parser_functions_utilities.cpp @@ -153,14 +153,10 @@ FUNCTION_PTR Parser::Parse_FunctionContent(void) FUNCTION_PTR Parser::Parse_FunctionOrContent(void) { FUNCTION_PTR result; - EXPECT_ONE - CASE(FUNCTION_TOKEN) - result = Parse_Function(); - END_CASE - OTHERWISE - result = Parse_FunctionContent(); - END_CASE - END_EXPECT + if (AllowToken(FUNCTION_TOKEN)) + result = Parse_Function(); + else + result = Parse_FunctionContent(); return result; } @@ -225,12 +221,12 @@ FUNCTION_PTR Parser::Parse_DeclareFunction(TokenId *token_id, const char *fn_nam Parse_Begin(); Get_Token(); - if(CurrentTokenId() == INTERNAL_TOKEN) + if(CurrentTrueTokenId() == INTERNAL_TOKEN) { Parse_Paren_Begin(); Get_Token(); - if(CurrentTokenFunctionId() != FLOAT_TOKEN) + if(CurrentTrueTokenId() != FLOAT_TOKEN) Expectation_Error("internal function identifier"); expression = FNSyntax_GetTrapExpression((unsigned int)(mToken.Token_Float)); @@ -238,7 +234,7 @@ FUNCTION_PTR Parser::Parse_DeclareFunction(TokenId *token_id, const char *fn_nam Parse_Paren_End(); } - else if(CurrentTokenId() == TRANSFORM_TOKEN) + else if(CurrentTrueTokenId() == TRANSFORM_TOKEN) { if(function.parameter_cnt != 0) Error("Function parameters for transform functions are not allowed."); @@ -255,7 +251,7 @@ FUNCTION_PTR Parser::Parse_DeclareFunction(TokenId *token_id, const char *fn_nam // function type is vector function *token_id = VECTFUNCT_ID_TOKEN; } - else if(CurrentTokenId() == SPLINE_TOKEN) + else if(CurrentTrueTokenId() == SPLINE_TOKEN) { if(function.parameter_cnt != 0) Error("Function parameters for spline functions are not allowed."); @@ -276,7 +272,7 @@ FUNCTION_PTR Parser::Parse_DeclareFunction(TokenId *token_id, const char *fn_nam // function type is vector function *token_id = VECTFUNCT_ID_TOKEN; } - else if(CurrentTokenId() == PIGMENT_TOKEN) + else if(CurrentTrueTokenId() == PIGMENT_TOKEN) { if(function.parameter_cnt != 0) Error("Function parameters for pigment functions are not allowed."); @@ -297,7 +293,7 @@ FUNCTION_PTR Parser::Parse_DeclareFunction(TokenId *token_id, const char *fn_nam // function type is vector function *token_id = VECTFUNCT_ID_TOKEN; } - else if(CurrentTokenId() == PATTERN_TOKEN) + else if(CurrentTrueTokenId() == PATTERN_TOKEN) { if(function.parameter_cnt != 0) Error("Function parameters for pattern functions are not allowed."); @@ -313,16 +309,16 @@ FUNCTION_PTR Parser::Parse_DeclareFunction(TokenId *token_id, const char *fn_nam Parse_End(); Post_Pigment(reinterpret_cast(function.private_data)); } - else if(CurrentTokenId() == STRING_LITERAL_TOKEN) + else if(CurrentTrueTokenId() == STRING_LITERAL_TOKEN) { #if (DEBUG_FLOATFUNCTION == 1) f.SetFlag(2, CurrentTokenText().c_str()); #endif Get_Token(); - if(CurrentTokenId() == COMMA_TOKEN) + if(CurrentTrueTokenId() == COMMA_TOKEN) { Get_Token(); - if(CurrentTokenId() != STRING_LITERAL_TOKEN) + if(CurrentTrueTokenId() != STRING_LITERAL_TOKEN) Expectation_Error("valid function expression"); #if (DEBUG_FLOATFUNCTION == 1) f.SetFlag(1, CurrentTokenText().c_str()); diff --git a/source/parser/parser_materials.cpp b/source/parser/parser_materials.cpp index efe349a0c..52ec4311d 100644 --- a/source/parser/parser_materials.cpp +++ b/source/parser/parser_materials.cpp @@ -205,7 +205,7 @@ ImageData *Parser::Parse_Image(int Legal, bool GammaCorrect) if(Legal & GRAD_FILE) { - EXPECT + EXPECT_CAT CASE_VECTOR_UNGET VersionWarning(150, "Old style orientation vector or map type not supported. Ignoring value."); Parse_Vector(Local_Vector); @@ -225,7 +225,7 @@ ImageData *Parser::Parse_Image(int Legal, bool GammaCorrect) image->height = (SNGL)int(Parse_Float() + 0.5); Get_Token(); - if (CurrentTokenId() != LEFT_CURLY_TOKEN) + if (CurrentTrueTokenId() != LEFT_CURLY_TOKEN) Found_Instead_Error("Missing { after", "expression"); Unget_Token(); @@ -505,12 +505,7 @@ SimpleGammaCurvePtr Parser::Parse_Gamma (void) { SimpleGammaCurvePtr gamma; EXPECT_ONE - CASE (COLOUR_KEY_TOKEN) - if (mToken.Function_Id != SRGB_TOKEN) - { - UNGET - END_CASE - } + CASE (SRGB_TOKEN) gamma = SRGBGammaCurve::Get(); END_CASE CASE (BT709_TOKEN) @@ -631,120 +626,110 @@ void Parser::Parse_Image_Map (PIGMENT *Pigment) VersionWarning(155, "Keyword ALPHA discontinued. Use FILTER instead."); // FALLTHROUGH - CASE (COLOUR_KEY_TOKEN) - switch(mToken.Function_Id) - { - case FILTER_TOKEN: - EXPECT_ONE - CASE (ALL_TOKEN) + CASE (FILTER_TOKEN) + EXPECT_ONE + CASE (ALL_TOKEN) + { + DBL filter; + filter = Parse_Float(); + image->AllFilter = filter; + if (image->data->IsIndexed()) + { + if (image->data->HasFilterTransmit() == false) { - DBL filter; - filter = Parse_Float(); - image->AllFilter = filter; - if (image->data->IsIndexed()) - { - if (image->data->HasFilterTransmit() == false) - { - vector map; - image->data->GetColourMap (map); - image->data->SetColourMap (map); - } - for(reg = 0; reg < image->data->GetColourMapSize(); reg++) - { - float r, g, b, f, t; - - image->data->GetRGBFTIndexedValue(reg, r, g, b, f, t); - image->data->SetRGBFTIndexedValue(reg, r, g, b, filter, t); - } - } + vector map; + image->data->GetColourMap (map); + image->data->SetColourMap (map); } - END_CASE - - OTHERWISE - UNGET - reg = (int)(Parse_Float() + 0.01); - if (image->data->IsIndexed() == false) - Not_With ("filter","non color-mapped image"); - if ((reg < 0) || (reg >= image->data->GetColourMapSize())) - Error ("FILTER color register value out of range."); - - Parse_Comma(); + for(reg = 0; reg < image->data->GetColourMapSize(); reg++) { float r, g, b, f, t; - if (image->data->HasFilterTransmit() == false) - { - vector map; - image->data->GetColourMap (map); - image->data->SetColourMap (map); - } image->data->GetRGBFTIndexedValue(reg, r, g, b, f, t); - image->data->SetRGBFTIndexedValue(reg, r, g, b, Parse_Float(), t); + image->data->SetRGBFTIndexedValue(reg, r, g, b, filter, t); } - END_CASE + } + } + END_CASE - END_EXPECT - Pigment->Flags |= HAS_FILTER; - break; + OTHERWISE + UNGET + reg = (int)(Parse_Float() + 0.01); + if (image->data->IsIndexed() == false) + Not_With ("filter","non color-mapped image"); + if ((reg < 0) || (reg >= image->data->GetColourMapSize())) + Error ("FILTER color register value out of range."); - case TRANSMIT_TOKEN: - EXPECT_ONE - CASE (ALL_TOKEN) - { - DBL transmit; - transmit = Parse_Float(); - image->AllTransmit = transmit; - if (image->data->IsIndexed()) - { - if (image->data->HasFilterTransmit() == false) - { - vector map; - image->data->GetColourMap (map); - image->data->SetColourMap (map); - } - for(reg = 0; reg < image->data->GetColourMapSize(); reg++) - { - float r, g, b, f, t; - - image->data->GetRGBFTIndexedValue(reg, r, g, b, f, t); - image->data->SetRGBFTIndexedValue(reg, r, g, b, f, transmit); - } - } - } - END_CASE + Parse_Comma(); + { + float r, g, b, f, t; - OTHERWISE - UNGET - reg = (int)(Parse_Float() + 0.01); - if (image->data->IsIndexed() == false) - Not_With ("transmit","non color-mapped image"); - if ((reg < 0) || (reg >= image->data->GetColourMapSize())) - Error ("TRANSMIT color register value out of range."); + if (image->data->HasFilterTransmit() == false) + { + vector map; + image->data->GetColourMap (map); + image->data->SetColourMap (map); + } + image->data->GetRGBFTIndexedValue(reg, r, g, b, f, t); + image->data->SetRGBFTIndexedValue(reg, r, g, b, Parse_Float(), t); + } + END_CASE - Parse_Comma(); + END_EXPECT + Pigment->Flags |= HAS_FILTER; + END_CASE + + CASE (TRANSMIT_TOKEN) + EXPECT_ONE + CASE (ALL_TOKEN) + { + DBL transmit; + transmit = Parse_Float(); + image->AllTransmit = transmit; + if (image->data->IsIndexed()) + { + if (image->data->HasFilterTransmit() == false) + { + vector map; + image->data->GetColourMap (map); + image->data->SetColourMap (map); + } + for(reg = 0; reg < image->data->GetColourMapSize(); reg++) { float r, g, b, f, t; - if (image->data->HasFilterTransmit() == false) - { - vector map; - image->data->GetColourMap (map); - image->data->SetColourMap (map); - } image->data->GetRGBFTIndexedValue(reg, r, g, b, f, t); - image->data->SetRGBFTIndexedValue(reg, r, g, b, f, Parse_Float()); + image->data->SetRGBFTIndexedValue(reg, r, g, b, f, transmit); } - END_CASE - - END_EXPECT - Pigment->Flags |= HAS_FILTER; - break; + } + } + END_CASE - default: + OTHERWISE UNGET - Expectation_Error ("filter or transmit"); - break; - } + reg = (int)(Parse_Float() + 0.01); + if (image->data->IsIndexed() == false) + Not_With ("transmit","non color-mapped image"); + if ((reg < 0) || (reg >= image->data->GetColourMapSize())) + Error ("TRANSMIT color register value out of range."); + + Parse_Comma(); + { + float r, g, b, f, t; + + if (image->data->HasFilterTransmit() == false) + { + vector map; + image->data->GetColourMap (map); + image->data->SetColourMap (map); + } + image->data->GetRGBFTIndexedValue(reg, r, g, b, f, t); + image->data->SetRGBFTIndexedValue(reg, r, g, b, f, Parse_Float()); + } + END_CASE + + END_EXPECT + Pigment->Flags |= HAS_FILTER; END_CASE OTHERWISE @@ -1058,7 +1043,7 @@ PatternPtr Parser::ParseSlopePattern() shared_ptr pattern(new SlopePattern()); - EXPECT_ONE + EXPECT_ONE_CAT /* simple syntax */ CASE_EXPRESS_UNGET Parse_Vector (pattern->slopeDirection); @@ -1069,14 +1054,8 @@ PatternPtr Parser::ParseSlopePattern() UNGET Parse_Begin(); - EXPECT_ONE - CASE(POINT_AT_TOKEN) - pattern->pointAt = true; - END_CASE - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(POINT_AT_TOKEN)) + pattern->pointAt = true; /* parse the vector */ Parse_Vector (pattern->slopeDirection); @@ -1291,16 +1270,11 @@ void Parser::VerifyPattern(PatternPtr basicPattern) void Parser::Parse_Pigment (PIGMENT **Pigment_Ptr) { - EXPECT_ONE /* Look for [pigment_id] */ - CASE (PIGMENT_ID_TOKEN) - Destroy_Pigment(*Pigment_Ptr); - *Pigment_Ptr = Copy_Pigment (CurrentTokenDataPtr()); - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT /* End pigment_id */ + if (AllowToken(PIGMENT_ID_TOKEN)) + { + Destroy_Pigment(*Pigment_Ptr); + *Pigment_Ptr = Copy_Pigment(CurrentTokenDataPtr()); + } Parse_Pattern(*Pigment_Ptr,kBlendMapType_Pigment); @@ -1343,7 +1317,7 @@ void Parser::Parse_Pattern (PATTERN_T *New, BlendMapTypeId TPat_Type) TraceThreadData *Thread = GetParserDataPtr(); ContinuousPattern* pContinuousPattern; - EXPECT_ONE + EXPECT_ONE_CAT CASE (AGATE_TOKEN) New->Type = GENERIC_PATTERN; New->pattern = PatternPtr(new AgatePattern()); @@ -2195,16 +2169,11 @@ void Parser::Parse_Pattern (PATTERN_T *New, BlendMapTypeId TPat_Type) void Parser::Parse_Tnormal (TNORMAL **Tnormal_Ptr) { - EXPECT_ONE /* Look for [tnormal_id] */ - CASE (NORMAL_ID_TOKEN) - Destroy_Tnormal(*Tnormal_Ptr); - *Tnormal_Ptr = Copy_Tnormal (CurrentTokenDataPtr()); - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT /* End [tnormal_id] */ + if (AllowToken(NORMAL_ID_TOKEN)) + { + Destroy_Tnormal(*Tnormal_Ptr); + *Tnormal_Ptr = Copy_Tnormal(CurrentTokenDataPtr()); + } if (*Tnormal_Ptr == nullptr) { @@ -2258,17 +2227,12 @@ void Parser::Parse_Finish (FINISH **Finish_Ptr) Parse_Begin (); - EXPECT_ONE /* Look for zero or one finish_id */ - CASE (FINISH_ID_TOKEN) - if (*Finish_Ptr) - delete *Finish_Ptr; - *Finish_Ptr = Copy_Finish (CurrentTokenDataPtr()); - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT /* End finish_id */ + if (AllowToken(FINISH_ID_TOKEN)) + { + if (*Finish_Ptr) + delete *Finish_Ptr; + *Finish_Ptr = Copy_Finish(CurrentTokenDataPtr()); + } New = *Finish_Ptr; @@ -2296,16 +2260,7 @@ void Parser::Parse_Finish (FINISH **Finish_Ptr) END_CASE CASE (DIFFUSE_TOKEN) - EXPECT - CASE (ALBEDO_TOKEN) - diffuseAdjust = true; - END_CASE - OTHERWISE - UNGET - EXIT - END_CASE - END_EXPECT - + diffuseAdjust = AllowToken(ALBEDO_TOKEN); New->Diffuse = Parse_Float (); Parse_Comma(); New->DiffuseBack = Allow_Float(0.0); @@ -2316,7 +2271,7 @@ void Parser::Parse_Finish (FINISH **Finish_Ptr) CASE (REFLECTION_TOKEN) { bool found_second_color = false; - EXPECT_ONE + EXPECT_ONE_CAT /* old syntax */ CASE_EXPRESS_UNGET Parse_Colour(New->Reflection_Max); @@ -2335,7 +2290,7 @@ void Parser::Parse_Finish (FINISH **Finish_Ptr) Parse_Comma(); /* look for a second color */ - EXPECT_ONE + EXPECT_ONE_CAT CASE_EXPRESS_UNGET Parse_Colour(New->Reflection_Max); found_second_color = true; @@ -2388,16 +2343,7 @@ void Parser::Parse_Finish (FINISH **Finish_Ptr) END_CASE CASE (PHONG_TOKEN) - EXPECT - CASE (ALBEDO_TOKEN) - phongAdjust = true; - END_CASE - OTHERWISE - UNGET - EXIT - END_CASE - END_EXPECT - + phongAdjust = AllowToken(ALBEDO_TOKEN); New->Phong = Parse_Float (); END_CASE @@ -2406,16 +2352,7 @@ void Parser::Parse_Finish (FINISH **Finish_Ptr) END_CASE CASE (SPECULAR_TOKEN) - EXPECT - CASE (ALBEDO_TOKEN) - specularAdjust = true; - END_CASE - OTHERWISE - UNGET - EXIT - END_CASE - END_EXPECT - + specularAdjust = AllowToken(ALBEDO_TOKEN); New->Specular = Parse_Float (); END_CASE @@ -2429,7 +2366,7 @@ void Parser::Parse_Finish (FINISH **Finish_Ptr) CASE (METALLIC_TOKEN) New->Metallic = 1.0; - EXPECT_ONE + EXPECT_ONE_CAT CASE_FLOAT_UNGET New->Metallic = Parse_Float(); END_CASE @@ -2616,22 +2553,18 @@ TEXTURE *Parser::Parse_Texture () Modified_Pnf = false; - EXPECT_ONE /* First allow a texture identifier */ - CASE (TEXTURE_ID_TOKEN) - Texture = Copy_Textures(CurrentTokenDataPtr()); - Modified_Pnf = true; - END_CASE - - OTHERWISE - UNGET - Texture = Copy_Textures (Default_Texture); - END_CASE - END_EXPECT + if (AllowToken(TEXTURE_ID_TOKEN)) + { + Texture = Copy_Textures(CurrentTokenDataPtr()); + Modified_Pnf = true; + } + else + Texture = Copy_Textures(Default_Texture); - /* If the texture identifer or the default texture was a PLAIN_PATTERN + /* If the texture identifier or the default texture was a PLAIN_PATTERN then allow its pigment, normal or finish to be overridden by pigment identifier, normal identifier and finish identifiers. - This is a consession to backwards compatibility so that + This is a concession to backwards compatibility so that "texture{PIGMENT_IDENTIFIER}" etc. is legal even though it should be "texture{pigment{PIGMENT_IDENTIFIER}}" */ @@ -2641,21 +2574,21 @@ TEXTURE *Parser::Parse_Texture () { EXPECT /* Look for [pnf_ids] */ CASE (PIGMENT_ID_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Destroy_Pigment(Texture->Pigment); Texture->Pigment = Copy_Pigment (CurrentTokenDataPtr()); Modified_Pnf = true; END_CASE CASE (NORMAL_ID_TOKEN) - Warn_State(CurrentTokenId(), NORMAL_TOKEN); + Warn_State(NORMAL_TOKEN); Destroy_Tnormal(Texture->Tnormal); Texture->Tnormal = Copy_Tnormal (CurrentTokenDataPtr()); Modified_Pnf = true; END_CASE CASE (FINISH_ID_TOKEN) - Warn_State(CurrentTokenId(), FINISH_TOKEN); + Warn_State(FINISH_TOKEN); if (Texture->Finish) delete Texture->Finish; Texture->Finish = Copy_Finish (CurrentTokenDataPtr()); @@ -3068,7 +3001,7 @@ TEXTURE *Parser::Parse_Vers1_Texture () Tnormal = Texture->Tnormal; Finish = Texture->Finish; - EXPECT + EXPECT_CAT CASE (PIGMENT_TOKEN) Parse_Begin (); Parse_Pigment ( &(Texture->Pigment) ); @@ -3090,64 +3023,64 @@ PIGMENT STUFF OUTSIDE PIGMENT{} NOTE: Do not add new keywords to this section. Use 1.0 syntax only. ***********************************************************************/ CASE (AGATE_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; Pigment->pattern = PatternPtr(new AgatePattern()); Check_Turb(Pigment->pattern->warps, Pigment->pattern->HasSpecialTurbulenceHandling()); // agate needs Octaves, Lambda etc., and handles the pattern itself END_CASE CASE (BOZO_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; Pigment->pattern = PatternPtr(new BozoPattern()); END_CASE CASE (GRANITE_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; Pigment->pattern = PatternPtr(new GranitePattern()); END_CASE CASE (LEOPARD_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; Pigment->pattern = PatternPtr(new LeopardPattern()); END_CASE CASE (MARBLE_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; Pigment->pattern = PatternPtr(new MarblePattern()); // TODO REVIEW - proper syntax sets waveType END_CASE CASE (MANDEL_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; Pigment->pattern = ParseMandelPattern(); END_CASE CASE (ONION_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; Pigment->pattern = PatternPtr(new OnionPattern()); END_CASE CASE (SPOTTED_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; Pigment->pattern = PatternPtr(new SpottedPattern()); END_CASE CASE (WOOD_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; Pigment->pattern = PatternPtr(new WoodPattern()); END_CASE CASE (GRADIENT_TOKEN) { - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; shared_ptr pattern(new GradientPattern()); Parse_Vector (Local_Vector); @@ -3158,42 +3091,42 @@ NOTE: Do not add new keywords to this section. Use 1.0 syntax only. END_CASE CASE_COLOUR_UNGET - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = PLAIN_PATTERN; Pigment->pattern = PatternPtr(new PlainPattern()); Parse_Colour (Pigment->colour); END_CASE CASE (CHECKER_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; Pigment->pattern = PatternPtr(new CheckerPattern()); Pigment->Blend_Map = Parse_Blend_List(2,Pigment->pattern->GetDefaultBlendMap(),kBlendMapType_Colour); END_CASE CASE (HEXAGON_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; Pigment->pattern = PatternPtr(new HexagonPattern()); Pigment->Blend_Map = Parse_Blend_List(3,Pigment->pattern->GetDefaultBlendMap(),kBlendMapType_Colour); END_CASE CASE (SQUARE_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; Pigment->pattern = PatternPtr(new SquarePattern()); Pigment->Blend_Map = Parse_Blend_List(4,Pigment->pattern->GetDefaultBlendMap(),kBlendMapType_Colour); END_CASE CASE (TRIANGULAR_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = GENERIC_PATTERN; Pigment->pattern = PatternPtr(new TriangularPattern()); Pigment->Blend_Map = Parse_Blend_List(6,Pigment->pattern->GetDefaultBlendMap(),kBlendMapType_Colour); END_CASE CASE (IMAGE_MAP_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Pigment->Type = IMAGE_MAP_PATTERN; Pigment->pattern = PatternPtr(new ColourImagePattern()); Parse_Image_Map (Pigment); @@ -3205,14 +3138,14 @@ NOTE: Do not add new keywords to this section. Use 1.0 syntax only. END_CASE CASE (COLOUR_MAP_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); if (!Pigment->pattern->CanMap()) VersionWarning(150, "Cannot use color map with this pigment type."); Pigment->Blend_Map = Parse_Colour_Map (); END_CASE CASE (QUICK_COLOUR_TOKEN) - Warn_State(CurrentTokenId(), PIGMENT_TOKEN); + Warn_State(PIGMENT_TOKEN); Parse_Colour (Pigment->Quick_Colour); END_CASE @@ -3240,7 +3173,7 @@ TNORMAL STUFF OUTSIDE NORMAL{} NOTE: Do not add new keywords to this section. Use 1.0 syntax only. ***********************************************************************/ CASE (BUMPS_TOKEN) - Warn_State(CurrentTokenId(), NORMAL_TOKEN); + Warn_State(NORMAL_TOKEN); ADD_TNORMAL Tnormal->Type = BUMPS_PATTERN; Tnormal->pattern = PatternPtr(new BumpsPattern()); @@ -3248,7 +3181,7 @@ NOTE: Do not add new keywords to this section. Use 1.0 syntax only. END_CASE CASE (DENTS_TOKEN) - Warn_State(CurrentTokenId(), NORMAL_TOKEN); + Warn_State(NORMAL_TOKEN); ADD_TNORMAL Tnormal->Type = DENTS_PATTERN; Tnormal->pattern = PatternPtr(new DentsPattern()); @@ -3256,7 +3189,7 @@ NOTE: Do not add new keywords to this section. Use 1.0 syntax only. END_CASE CASE (RIPPLES_TOKEN) - Warn_State(CurrentTokenId(), NORMAL_TOKEN); + Warn_State(NORMAL_TOKEN); ADD_TNORMAL Tnormal->Type = RIPPLES_PATTERN; Tnormal->pattern = PatternPtr(new RipplesPattern()); @@ -3264,7 +3197,7 @@ NOTE: Do not add new keywords to this section. Use 1.0 syntax only. END_CASE CASE (WAVES_TOKEN) - Warn_State(CurrentTokenId(), NORMAL_TOKEN); + Warn_State(NORMAL_TOKEN); ADD_TNORMAL Tnormal->Type = WAVES_PATTERN; Tnormal->pattern = PatternPtr(new WavesPattern()); @@ -3272,7 +3205,7 @@ NOTE: Do not add new keywords to this section. Use 1.0 syntax only. END_CASE CASE (WRINKLES_TOKEN) - Warn_State(CurrentTokenId(), NORMAL_TOKEN); + Warn_State(NORMAL_TOKEN); ADD_TNORMAL Tnormal->Type = WRINKLES_PATTERN; Tnormal->pattern = PatternPtr(new WrinklesPattern()); @@ -3281,7 +3214,7 @@ NOTE: Do not add new keywords to this section. Use 1.0 syntax only. CASE (BUMP_MAP_TOKEN) { - Warn_State(CurrentTokenId(), NORMAL_TOKEN); + Warn_State(NORMAL_TOKEN); ADD_TNORMAL Tnormal->Type = BITMAP_PATTERN; shared_ptr pattern(new ImagePattern()); @@ -3292,7 +3225,7 @@ NOTE: Do not add new keywords to this section. Use 1.0 syntax only. END_CASE CASE (FREQUENCY_TOKEN) - Warn_State(CurrentTokenId(), NORMAL_TOKEN); + Warn_State(NORMAL_TOKEN); ADD_TNORMAL pContinuousPattern = dynamic_cast(Tnormal->pattern.get()); if (pContinuousPattern != nullptr) @@ -3306,7 +3239,7 @@ NOTE: Do not add new keywords to this section. Use 1.0 syntax only. END_CASE CASE (PHASE_TOKEN) - Warn_State(CurrentTokenId(), NORMAL_TOKEN); + Warn_State(NORMAL_TOKEN); ADD_TNORMAL pContinuousPattern = dynamic_cast(Tnormal->pattern.get()); if (pContinuousPattern != nullptr) @@ -3325,44 +3258,44 @@ FINISH STUFF OUTSIDE FINISH{} NOTE: Do not add new keywords to this section. Use 1.0 syntax only. ***********************************************************************/ CASE (AMBIENT_TOKEN) - Warn_State(CurrentTokenId(), FINISH_TOKEN); + Warn_State(FINISH_TOKEN); Finish->Ambient = MathColour(Parse_Float ()); END_CASE CASE (BRILLIANCE_TOKEN) - Warn_State(CurrentTokenId(), FINISH_TOKEN); + Warn_State(FINISH_TOKEN); Finish->Brilliance = Parse_Float (); END_CASE CASE (DIFFUSE_TOKEN) - Warn_State(CurrentTokenId(), FINISH_TOKEN); + Warn_State(FINISH_TOKEN); Finish->Diffuse = Parse_Float (); END_CASE CASE (REFLECTION_TOKEN) - Warn_State(CurrentTokenId(), FINISH_TOKEN); + Warn_State(FINISH_TOKEN); Finish->Reflection_Max = MathColour(Parse_Float ()); Finish->Reflection_Min = Finish->Reflection_Max; Finish->Reflection_Falloff = 1; END_CASE CASE (PHONG_TOKEN) - Warn_State(CurrentTokenId(), FINISH_TOKEN); + Warn_State(FINISH_TOKEN); Finish->Phong = Parse_Float (); END_CASE CASE (PHONG_SIZE_TOKEN) - Warn_State(CurrentTokenId(), FINISH_TOKEN); + Warn_State(FINISH_TOKEN); Finish->Phong_Size = Parse_Float (); END_CASE CASE (SPECULAR_TOKEN) - Warn_State(CurrentTokenId(), FINISH_TOKEN); + Warn_State(FINISH_TOKEN); Finish->Specular = Parse_Float (); END_CASE CASE (ROUGHNESS_TOKEN) - Warn_State(CurrentTokenId(), FINISH_TOKEN); + Warn_State(FINISH_TOKEN); Finish->Roughness = Parse_Float (); if (Finish->Roughness != 0.0) Finish->Roughness = 1.0/Finish->Roughness; /* CEY 12/92 */ @@ -3371,12 +3304,12 @@ NOTE: Do not add new keywords to this section. Use 1.0 syntax only. END_CASE CASE (METALLIC_TOKEN) - Warn_State(CurrentTokenId(), FINISH_TOKEN); + Warn_State(FINISH_TOKEN); Finish->Metallic = 1.0; END_CASE CASE (CRAND_TOKEN) - Warn_State(CurrentTokenId(), FINISH_TOKEN); + Warn_State(FINISH_TOKEN); Finish->Crand = Parse_Float(); END_CASE @@ -3386,13 +3319,13 @@ NOTE: Do not add new keywords to this section. Use 1.0 syntax only. END_CASE CASE (IOR_TOKEN) - Warn_State(CurrentTokenId(), INTERIOR_TOKEN); + Warn_State(INTERIOR_TOKEN); Finish->Temp_IOR = Parse_Float(); Warn_Compat(false, "Index of refraction value should be specified in 'interior{...}' statement."); END_CASE CASE (REFRACTION_TOKEN) - Warn_State(CurrentTokenId(), INTERIOR_TOKEN); + Warn_State(INTERIOR_TOKEN); Finish->Temp_Refract = Parse_Float(); Warn_Compat(false, "Refraction value unnecessary to turn on refraction.\nTo attenuate, the fade_power and fade_distance keywords should be specified in 'interior{...}' statement."); END_CASE @@ -3559,23 +3492,19 @@ void Parser::Parse_Media(vector& medialist) Parse_Begin(); - EXPECT_ONE - CASE(MEDIA_ID_TOKEN) - IMediaObj = CurrentTokenData(); - END_CASE - - OTHERWISE - UNGET - /* as of v3.5, the default media method is now 3 */ - if(sceneData->EffectiveLanguageVersion() >= 350) - { - IMedia->Intervals = 1; - IMedia->Min_Samples = 10; - IMedia->Max_Samples = 10; - IMedia->Sample_Method = 3; - } - END_CASE - END_EXPECT + if (AllowToken(MEDIA_ID_TOKEN)) + IMediaObj = CurrentTokenData(); + else + { + /* as of v3.5, the default media method is now 3 */ + if (sceneData->EffectiveLanguageVersion() >= 350) + { + IMedia->Intervals = 1; + IMedia->Min_Samples = 10; + IMedia->Max_Samples = 10; + IMedia->Sample_Method = 3; + } + } EXPECT CASE (INTERVALS_TOKEN) @@ -3763,18 +3692,13 @@ void Parser::Parse_Interior(InteriorPtr& interior) { Parse_Begin(); - EXPECT_ONE - CASE(INTERIOR_ID_TOKEN) - if (HaveCurrentTokenData()) - interior = InteriorPtr(new Interior(*CurrentTokenData())); - else - interior = InteriorPtr(new Interior()); - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(INTERIOR_ID_TOKEN)) + { + if (HaveCurrentTokenData()) + interior = InteriorPtr(new Interior(*CurrentTokenData())); + else + interior = InteriorPtr(new Interior()); + } if(!interior) interior = InteriorPtr(new Interior()); @@ -3856,16 +3780,10 @@ void Parser::Parse_Interior(InteriorPtr& interior) void Parser::Parse_Media_Density_Pattern(PIGMENT** Density) { - EXPECT_ONE - CASE (DENSITY_ID_TOKEN) - *Density = Copy_Pigment (CurrentTokenDataPtr()); - END_CASE - - OTHERWISE - *Density = Create_Pigment(); - UNGET - END_CASE - END_EXPECT + if (AllowToken(DENSITY_ID_TOKEN)) + *Density = Copy_Pigment(CurrentTokenDataPtr()); + else + *Density = Create_Pigment(); Parse_Pattern(*Density,kBlendMapType_Density); } @@ -3914,18 +3832,12 @@ FOG *Parser::Parse_Fog() Parse_Begin(); - EXPECT_ONE - CASE(FOG_ID_TOKEN) - Fog = Copy_Fog (CurrentTokenDataPtr()); - END_CASE - - OTHERWISE - UNGET - Fog = Create_Fog(); - END_CASE - END_EXPECT + if (AllowToken(FOG_ID_TOKEN)) + Fog = Copy_Fog(CurrentTokenDataPtr()); + else + Fog = Create_Fog(); - EXPECT + EXPECT_CAT CASE_COLOUR_UNGET Parse_Colour(Fog->colour); END_CASE @@ -4079,16 +3991,10 @@ RAINBOW *Parser::Parse_Rainbow() Parse_Begin(); - EXPECT_ONE - CASE(RAINBOW_ID_TOKEN) - Rainbow = Copy_Rainbow (CurrentTokenDataPtr()); - END_CASE - - OTHERWISE - UNGET - Rainbow = Create_Rainbow(); - END_CASE - END_EXPECT + if (AllowToken(RAINBOW_ID_TOKEN)) + Rainbow = Copy_Rainbow(CurrentTokenDataPtr()); + else + Rainbow = Create_Rainbow(); EXPECT CASE (ANGLE_TOKEN) @@ -4257,16 +4163,10 @@ SKYSPHERE *Parser::Parse_Skysphere() Parse_Begin(); - EXPECT_ONE - CASE(SKYSPHERE_ID_TOKEN) - Skysphere = Copy_Skysphere(CurrentTokenDataPtr()); - END_CASE - - OTHERWISE - UNGET - Skysphere = Create_Skysphere(); - END_CASE - END_EXPECT + if (AllowToken(SKYSPHERE_ID_TOKEN)) + Skysphere = Copy_Skysphere(CurrentTokenDataPtr()); + else + Skysphere = Create_Skysphere(); EXPECT CASE (PIGMENT_TOKEN) @@ -4715,23 +4615,18 @@ void Parser::Parse_Material(MATERIAL *Material) Parse_Begin(); - EXPECT_ONE - CASE(MATERIAL_ID_TOKEN) - Temp = CurrentTokenDataPtr(); - Texture = Copy_Textures(Temp->Texture); - Int_Texture = Copy_Textures(Temp->Interior_Texture); - Link_Textures(&(Material->Texture),Texture); - Link_Textures(&(Material->Interior_Texture),Int_Texture); - if (Temp->interior != nullptr) - Material->interior = InteriorPtr(new Interior(*(Temp->interior))); - else - Material->interior.reset(); - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + if (AllowToken(MATERIAL_ID_TOKEN)) + { + Temp = CurrentTokenDataPtr(); + Texture = Copy_Textures(Temp->Texture); + Int_Texture = Copy_Textures(Temp->Interior_Texture); + Link_Textures(&(Material->Texture), Texture); + Link_Textures(&(Material->Interior_Texture), Int_Texture); + if (Temp->interior != nullptr) + Material->interior = InteriorPtr(new Interior(*(Temp->interior))); + else + Material->interior.reset(); + } EXPECT CASE (TEXTURE_TOKEN) diff --git a/source/parser/parser_tokenizer.cpp b/source/parser/parser_tokenizer.cpp index 1965838d7..eef040b8a 100644 --- a/source/parser/parser_tokenizer.cpp +++ b/source/parser/parser_tokenizer.cpp @@ -137,7 +137,7 @@ void Parser::CheckFileSignature() RawToken signature; if (GetRawToken(signature, false)) { - if (signature.expressionId == SIGNATURE_FUNCT_TOKEN) + if (signature.expressionId == SIGNATURE_TOKEN_CATEGORY) { // Found a signature. Switch to the corresponding encoding automatically. switch (signature.id) @@ -172,8 +172,6 @@ void Parser::CheckFileSignature() void Parser::pre_init_tokenizer () { - int i; - InitCurrentToken(); mTokensSinceLastProgressReport = 0; @@ -190,25 +188,6 @@ void Parser::pre_init_tokenizer () parseOptionalRValue = false; POV_EXPERIMENTAL_ASSERT(mSymbolStack.GetLocalTableIndex() == -1); - // TODO - on modern machines it may be faster to do the comparisons for each token - // than to access the conversion table. - for(i = 0; i < TOKEN_COUNT; i++) - { - Conversion_Util_Table[i] = TokenId(i); - if(i < FLOAT_FUNCT_TOKEN) - Conversion_Util_Table[i] = FLOAT_FUNCT_TOKEN; - else - { - if(i < VECTOR_FUNCT_TOKEN) - Conversion_Util_Table[i] = VECTOR_FUNCT_TOKEN; - else - { - if(i < COLOUR_KEY_TOKEN) - Conversion_Util_Table[i] = COLOUR_KEY_TOKEN; - } - } - } - // TODO - implement a mechanism to expose to user MaxCachedMacroSize = POV_PARSER_MAX_CACHED_MACRO_SIZE; } @@ -288,7 +267,7 @@ void Parser::Get_Token () InvalidateCurrentToken(); - while (CurrentTokenId() == END_OF_FILE_TOKEN) + while (CurrentTrueTokenId() == END_OF_FILE_TOKEN) { bool fastForwardToDirective = (Skipping && !Parsing_Directive); @@ -364,7 +343,7 @@ void Parser::Get_Token () // Re-issue the hash token to trigger an expectation error downstream. // Hash tokens normally never get processed into high-level tokens, // so we need to construct one now. - mToken.Token_Id = HASH_TOKEN; + mToken.SetTokenId(HASH_TOKEN); mToken.is_array_elem = false; mToken.is_mixed_array_elem = false; mToken.is_dictionary_elem = false; @@ -497,7 +476,7 @@ void Parser::Read_Symbol(const RawToken& rawToken) { if (pseudoDictionary >= 0) { - mToken.Token_Id = DICTIONARY_ID_TOKEN; + mToken.SetTokenId(DICTIONARY_ID_TOKEN); mToken.is_array_elem = false; mToken.is_mixed_array_elem = false; mToken.is_dictionary_elem = false; @@ -527,20 +506,19 @@ void Parser::Read_Symbol(const RawToken& rawToken) } else { - mToken.Token_Id=MACRO_ID_TOKEN; mToken.is_array_elem = false; mToken.is_mixed_array_elem = false; mToken.is_dictionary_elem = false; mToken.NumberPtr = &(Temp_Entry->Token_Number); mToken.DataPtr = &(Temp_Entry->Data); - Write_Token (mToken.Token_Id, rawToken, mSymbolStack.GetTable(Local_Index)); + Write_Token (MACRO_ID_TOKEN, rawToken, mSymbolStack.GetTable(Local_Index)); mToken.context = Local_Index; } return; } - mToken.Token_Id = Temp_Entry->Token_Number; + mToken.SetTokenId(Temp_Entry->Token_Number); mToken.is_array_elem = false; mToken.is_mixed_array_elem = false; mToken.is_dictionary_elem = false; @@ -556,7 +534,7 @@ void Parser::Read_Symbol(const RawToken& rawToken) bool breakLoop = false; while (!breakLoop) { - switch (mToken.Token_Id) + switch (mToken.GetTrueTokenId()) { case ARRAY_ID_TOKEN: { @@ -619,7 +597,7 @@ void Parser::Read_Symbol(const RawToken& rawToken) mToken.DataPtr = &(a->DataPtrs[j]); mToken.is_mixed_array_elem = a->mixedType; mToken.NumberPtr = &(a->ElementType(j)); - mToken.Token_Id = *mToken.NumberPtr; + mToken.SetTokenId(*mToken.NumberPtr); mToken.is_array_elem = true; mToken.is_dictionary_elem = false; } @@ -670,7 +648,7 @@ void Parser::Read_Symbol(const RawToken& rawToken) Get_Token (); parseRawIdentifiers = oldParseRawIdentifiers; - if (mToken.Token_Id != IDENTIFIER_TOKEN) + if (mToken.GetTrueTokenId() != IDENTIFIER_TOKEN) Expectation_Error ("dictionary element identifier"); Temp_Entry = table->Find_Symbol (CurrentTokenText().c_str()); @@ -698,21 +676,21 @@ void Parser::Read_Symbol(const RawToken& rawToken) if (Temp_Entry) { - mToken.Token_Id = Temp_Entry->Token_Number; - mToken.NumberPtr = &(Temp_Entry->Token_Number); - mToken.DataPtr = &(Temp_Entry->Data); + mToken.SetTokenId(Temp_Entry->Token_Number); + mToken.NumberPtr = &(Temp_Entry->Token_Number); + mToken.DataPtr = &(Temp_Entry->Data); } else { if (!LValue_Ok && !Inside_Ifdef && !parseOptionalRValue) Error ("Attempt to access uninitialized dictionary element."); - mToken.Token_Id = IDENTIFIER_TOKEN; - mToken.DataPtr = nullptr; - mToken.NumberPtr = nullptr; + mToken.SetTokenId(IDENTIFIER_TOKEN); + mToken.DataPtr = nullptr; + mToken.NumberPtr = nullptr; } - mToken.is_array_elem = false; - mToken.is_mixed_array_elem = false; - mToken.is_dictionary_elem = true; + mToken.is_array_elem = false; + mToken.is_mixed_array_elem = false; + mToken.is_dictionary_elem = true; } break; @@ -721,13 +699,13 @@ void Parser::Read_Symbol(const RawToken& rawToken) if (dictIndex) POV_FREE(dictIndex); - Par = reinterpret_cast(Temp_Entry->Data); - mToken.Token_Id = *(Par->NumberPtr); - mToken.is_array_elem = false; - mToken.is_mixed_array_elem = false; - mToken.is_dictionary_elem = false; - mToken.NumberPtr = Par->NumberPtr; - mToken.DataPtr = Par->DataPtr; + Par = reinterpret_cast(Temp_Entry->Data); + mToken.SetTokenId(*(Par->NumberPtr)); + mToken.is_array_elem = false; + mToken.is_mixed_array_elem = false; + mToken.is_dictionary_elem = false; + mToken.NumberPtr = Par->NumberPtr; + mToken.DataPtr = Par->DataPtr; } break; @@ -737,7 +715,7 @@ void Parser::Read_Symbol(const RawToken& rawToken) } } - Write_Token (mToken.Token_Id, rawToken, table); + Write_Token (mToken.GetTrueTokenId(), rawToken, table); // TODO - We shouldn't have to re-write the token here. if (mToken.DataPtr != nullptr) mToken.Data = *(mToken.DataPtr); @@ -754,34 +732,58 @@ void Parser::Read_Symbol(const RawToken& rawToken) inline void Parser::Write_Token(const RawToken& rawToken, SymbolTable* table) { POV_EXPERIMENTAL_ASSERT(mToken.sourceFile == mTokenizer.GetInputStream()); - mToken.raw = rawToken; - mToken.Data = nullptr; - mToken.Token_Id = rawToken.expressionId; - mToken.Function_Id = rawToken.GetTokenId(); - mToken.table = table; + mToken.raw = rawToken; + mToken.Data = nullptr; + mToken.SetTokenId(rawToken); + mToken.table = table; } inline void Parser::Write_Token(TokenId Token_Id, const RawToken& rawToken, SymbolTable* table) { POV_EXPERIMENTAL_ASSERT(mToken.sourceFile == mTokenizer.GetInputStream()); - mToken.raw = rawToken; - mToken.Data = nullptr; - mToken.Token_Id = Conversion_Util_Table[Token_Id]; - mToken.Function_Id = Token_Id; - mToken.table = table; + mToken.raw = rawToken; + mToken.Data = nullptr; + mToken.SetTokenId(Token_Id); + mToken.table = table; } //****************************************************************************** -TokenId Parser::CurrentTokenId() const +void Parser::Token_Struct::SetTokenId(const RawToken& rawToken) +{ + mTrueTokenId = rawToken.GetTokenId(); + mCategorizedTokenId = rawToken.expressionId; + POV_EXPERIMENTAL_ASSERT(mCategorizedTokenId == pov_parser::GetCategorizedTokenId(mTrueTokenId)); +} + +void Parser::Token_Struct::SetTokenId(TokenId tokenId) +{ + mTrueTokenId = tokenId; + mCategorizedTokenId = pov_parser::GetCategorizedTokenId(tokenId); +} + +TokenId Parser::Token_Struct::GetTrueTokenId() const { - return mToken.Token_Id; + return mTrueTokenId; } -TokenId Parser::CurrentTokenFunctionId() const +TokenId Parser::Token_Struct::GetCategorizedTokenId() const +{ + POV_EXPERIMENTAL_ASSERT(mCategorizedTokenId == pov_parser::GetCategorizedTokenId(mTrueTokenId)); + return mCategorizedTokenId; +} + +//------------------------------------------------------------------------------ + +TokenId Parser::CurrentCategorizedTokenId() const { - return mToken.Function_Id; + return mToken.GetCategorizedTokenId(); +} + +TokenId Parser::CurrentTrueTokenId() const +{ + return mToken.GetTrueTokenId(); } const UTF8String& Parser::CurrentTokenText() const @@ -810,7 +812,7 @@ void Parser::InitCurrentToken() void Parser::InvalidateCurrentToken() { POV_EXPERIMENTAL_ASSERT(!mToken.Unget_Token); - mToken.Token_Id = END_OF_FILE_TOKEN; + mToken.SetTokenId(END_OF_FILE_TOKEN); mToken.is_array_elem = false; mToken.is_mixed_array_elem = false; mToken.is_dictionary_elem = false; @@ -818,7 +820,7 @@ void Parser::InvalidateCurrentToken() void Parser::StopSkipping() { - mToken.Token_Id = HASH_TOKEN; // TODO FIXME + mToken.SetTokenId(HASH_TOKEN); // TODO FIXME mToken.is_array_elem = false; mToken.is_mixed_array_elem = false; mToken.is_dictionary_elem = false; @@ -826,7 +828,7 @@ void Parser::StopSkipping() bool Parser::IsEndOfSkip() const { - return (mToken.Token_Id == HASH_TOKEN); // TODO FIXME + return (mToken.GetTrueTokenId() == HASH_TOKEN); // TODO FIXME } bool Parser::CurrentTokenIsArrayElement() const @@ -941,71 +943,6 @@ const char *Parser::Get_Token_String (TokenId Token_Id) -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* Return a list of keywords seperated with a '\n'. The last keyword does not -* have a LF after it. The caller is responsible for freeing the memory. This -* function is intended to be used by GUI implementations that need a keyword -* list for syntax-coloring edit windows. -* -* CHANGES -* -******************************************************************************/ - -char *Parser::Get_Reserved_Words (const char *additional_words) -{ - int length = 0; - int i; - - // Compute the length required for the buffer. - - for (i = 0; Reserved_Words[i].Token_Name != nullptr; i++) - { - if (!isalpha (Reserved_Words [i].Token_Name [0])) - continue; - if (strchr (Reserved_Words [i].Token_Name, ' ') != nullptr) - continue; - length += (int)strlen (Reserved_Words[i].Token_Name) + 1; - } - length += (int)strlen (additional_words); - - // Create the buffer. - - char *result = reinterpret_cast(POV_MALLOC (++length, "Keyword List")); - - // Copy the caller-supplied additional words into the buffer. - - strcpy (result, additional_words); - char *s = result + strlen (additional_words); - - // Copy our own keywords into the buffer. - - for (i = 0; Reserved_Words[i].Token_Name != nullptr; i++) - { - if (!isalpha (Reserved_Words [i].Token_Name [0])) - continue; - if (strchr (Reserved_Words [i].Token_Name, ' ') != nullptr) - continue; - s += sprintf (s, "%s\n", Reserved_Words[i].Token_Name); - } - *--s = '\0'; - - return (result); -} - - /***************************************************************************** * * FUNCTION @@ -1334,7 +1271,7 @@ void Parser::Parse_Directive() if (!Cond_Stack.back().Switch_Case_Ok_Flag) Error("#switch not followed by #case or #range."); - if (CurrentTokenId() == CASE_TOKEN) + if (CurrentTrueTokenId() == CASE_TOKEN) { Value=Parse_Cond_Param(); Flag = (fabs(Value-Cond_Stack.back().Switch_Value)Remove_Symbol (CurrentTokenText().c_str(), mToken.is_array_elem, mToken.DataPtr, CurrentTokenId()); + CASE2 (VECTOR_ID_TOKEN, FLOAT_ID_TOKEN) + mToken.table->Remove_Symbol (CurrentTokenText().c_str(), mToken.is_array_elem, mToken.DataPtr, CurrentTrueTokenId()); if (mToken.is_mixed_array_elem) *mToken.NumberPtr = IDENTIFIER_TOKEN; END_CASE - CASE2 (VECTOR_FUNCT_TOKEN, FLOAT_FUNCT_TOKEN) - switch(CurrentTokenFunctionId()) - { - case VECTOR_ID_TOKEN: - case FLOAT_ID_TOKEN: - mToken.table->Remove_Symbol (CurrentTokenText().c_str(), mToken.is_array_elem, mToken.DataPtr, CurrentTokenId()); - if (mToken.is_mixed_array_elem) - *mToken.NumberPtr = IDENTIFIER_TOKEN; - break; - - default: - Parse_Error(IDENTIFIER_TOKEN); - break; - } - END_CASE - OTHERWISE Parse_Error(IDENTIFIER_TOKEN); END_CASE @@ -1862,20 +1774,16 @@ void Parser::Parse_Version() SetOkToDeclare(false); bool wasParsingVersionDirective = parsingVersionDirective; parsingVersionDirective = true; - EXPECT_ONE - CASE(UNOFFICIAL_TOKEN) + if (AllowToken(UNOFFICIAL_TOKEN)) + { #if POV_RAY_IS_OFFICIAL - Get_Token(); - Error("This file was created for an unofficial version and\ncannot work as-is with this official version."); + Get_Token(); + Error("This file was created for an unofficial version and\ncannot work as-is with this official version."); #else - // PATCH AUTHORS - you should not enable any extra features unless the - // 'unofficial' keyword is set in the scene file. + // PATCH AUTHORS - you should not enable any extra features unless the + // 'unofficial' keyword is set in the scene file. #endif - END_CASE - OTHERWISE - Unget_Token(); - END_CASE - END_EXPECT + } sceneData->languageVersion = (int)(Parse_Float() * 100 + 0.5); @@ -2169,29 +2077,13 @@ Parser::Macro *Parser::Parse_Macro() CASE4 (DENSITY_ID_TOKEN, ARRAY_ID_TOKEN, DENSITY_MAP_ID_TOKEN, UV_ID_TOKEN) CASE4 (VECTOR_4D_ID_TOKEN, RAINBOW_ID_TOKEN, FOG_ID_TOKEN, SKYSPHERE_ID_TOKEN) CASE3 (MATERIAL_ID_TOKEN, SPLINE_ID_TOKEN, DICTIONARY_ID_TOKEN) + CASE2 (VECTOR_ID_TOKEN, FLOAT_ID_TOKEN) newParameter.name = POV_STRDUP(CurrentTokenText().c_str()); New->parameters.push_back(newParameter); Parse_Comma(); newParameter.optional = false; END_CASE - CASE2 (VECTOR_FUNCT_TOKEN, FLOAT_FUNCT_TOKEN) - switch(CurrentTokenFunctionId()) - { - case VECTOR_ID_TOKEN: - case FLOAT_ID_TOKEN: - newParameter.name = POV_STRDUP(CurrentTokenText().c_str()); - New->parameters.push_back(newParameter); - Parse_Comma(); - newParameter.optional = false; - break; - - default: - Expectation_Error ("identifier"); - break; - } - END_CASE - CASE(RIGHT_PAREN_TOKEN) UNGET if (newParameter.optional) @@ -2496,7 +2388,7 @@ SymbolTable* Parser::Parse_Dictionary_Declare() parseRawIdentifiers = true; Get_Token(); parseRawIdentifiers = oldParseRawIdentifiers; - if (CurrentTokenId() != IDENTIFIER_TOKEN) + if (CurrentTrueTokenId() != IDENTIFIER_TOKEN) Expectation_Error ("dictionary element identifier"); newEntry = newDictionary->Add_Symbol (CurrentTokenText(), IDENTIFIER_TOKEN); @@ -2538,17 +2430,8 @@ SymbolTable* Parser::Parse_Dictionary_Declare() void Parser::Parse_Initalizer (int Sub, size_t Base, POV_ARRAY *a) { int i; - bool optional = false; - EXPECT_ONE - CASE(OPTIONAL_TOKEN) - optional = true; - END_CASE - - OTHERWISE - UNGET - END_CASE - END_EXPECT + bool optional = AllowToken(OPTIONAL_TOKEN); Parse_Begin(); if (Sub < a->maxDim) @@ -2737,7 +2620,7 @@ void Parser::Parse_Read() if (!End_File) { Temp_Entry = mSymbolStack.GetGlobalTable()->Add_Symbol (CurrentTokenText(), IDENTIFIER_TOKEN); - End_File = Parse_Read_Value (User_File, CurrentTokenId(), &(Temp_Entry->Token_Number), &(Temp_Entry->Data)); + End_File = Parse_Read_Value (User_File, CurrentTrueTokenId(), &(Temp_Entry->Token_Number), &(Temp_Entry->Data)); mToken.is_array_elem = false; mToken.is_mixed_array_elem = false; mToken.is_dictionary_elem = false; @@ -2748,7 +2631,9 @@ void Parser::Parse_Read() CASE (STRING_ID_TOKEN) if (!End_File) { - End_File = Parse_Read_Value (User_File, CurrentTokenId(), mToken.NumberPtr, mToken.DataPtr); + End_File = Parse_Read_Value (User_File, CurrentTrueTokenId(), mToken.NumberPtr, mToken.DataPtr); + // TODO - Why are we clearing the array/dictionary related flags in this case + // but not in case of VECTOR_ID_TOKEN and FLOAT_ID_TOKEN? mToken.is_array_elem = false; mToken.is_mixed_array_elem = false; mToken.is_dictionary_elem = false; @@ -2756,21 +2641,13 @@ void Parser::Parse_Read() } END_CASE - CASE2 (VECTOR_FUNCT_TOKEN,FLOAT_FUNCT_TOKEN) - switch(CurrentTokenFunctionId()) + CASE2 (VECTOR_ID_TOKEN, FLOAT_ID_TOKEN) + if (!End_File) { - case VECTOR_ID_TOKEN: - case FLOAT_ID_TOKEN: - if (!End_File) - { - End_File = Parse_Read_Value (User_File, CurrentTokenFunctionId(), mToken.NumberPtr, mToken.DataPtr); - Parse_Comma(); /* Scene file comma between 2 idents */ - } - break; - - default: - Parse_Error(IDENTIFIER_TOKEN); - break; + End_File = Parse_Read_Value (User_File, CurrentTrueTokenId(), mToken.NumberPtr, mToken.DataPtr); + // TODO - Why are we not clearing the array/dictionary related flags in this case, + // as we do in case of STRING_ID_TOKEN? + Parse_Comma(); /* Scene file comma between 2 idents */ } END_CASE @@ -2953,7 +2830,7 @@ void Parser::Parse_Write(void) Parse_Comma(); - EXPECT + EXPECT_CAT CASE5 (SINT8_TOKEN,SINT16BE_TOKEN,SINT16LE_TOKEN,SINT32BE_TOKEN,SINT32LE_TOKEN) CASE3 (UINT8_TOKEN,UINT16BE_TOKEN,UINT16LE_TOKEN) { @@ -2961,7 +2838,7 @@ void Parser::Parse_Write(void) POV_INT32 val_max; int num_bytes; bool big_endian = false; - switch (CurrentTokenId()) + switch (CurrentTrueTokenId()) { case SINT8_TOKEN: val_min = SIGNED8_MIN; val_max = SIGNED8_MAX; num_bytes = 1; break; case UINT8_TOKEN: val_min = 0; val_max = UNSIGNED8_MAX; num_bytes = 1; break; @@ -2972,7 +2849,7 @@ void Parser::Parse_Write(void) case SINT32BE_TOKEN: val_min = SIGNED32_MIN; val_max = SIGNED32_MAX; num_bytes = 4; big_endian = true; break; case SINT32LE_TOKEN: val_min = SIGNED32_MIN; val_max = SIGNED32_MAX; num_bytes = 4; big_endian = false; break; } - EXPECT + EXPECT_CAT CASE_VECTOR_UNGET Terms = Parse_Unknown_Vector (Express); if ((Terms >= 1) && (Terms <= 5)) @@ -3123,7 +3000,7 @@ bool Parser::Parse_Ifdef_Param () if (mToken.is_array_elem) retval = (*mToken.DataPtr != nullptr); else - retval = (CurrentTokenId() != IDENTIFIER_TOKEN); + retval = (CurrentTrueTokenId() != IDENTIFIER_TOKEN); Parse_Paren_End(); @@ -3147,7 +3024,7 @@ int Parser::Parse_For_Param (UTF8String& identifierName, DBL* EndPtr, DBL* StepP Temp_Entry = mSymbolStack.GetLocalTable()->Add_Symbol (CurrentTokenText(), IDENTIFIER_TOKEN); mToken.NumberPtr = &(Temp_Entry->Token_Number); mToken.DataPtr = &(Temp_Entry->Data); - Previous = CurrentTokenId(); + Previous = CurrentTrueTokenId(); END_CASE CASE3 (FILE_ID_TOKEN, MACRO_ID_TOKEN, PARAMETER_ID_TOKEN) @@ -3171,6 +3048,7 @@ int Parser::Parse_For_Param (UTF8String& identifierName, DBL* EndPtr, DBL* StepP CASE4 (DENSITY_ID_TOKEN, ARRAY_ID_TOKEN, DENSITY_MAP_ID_TOKEN, UV_ID_TOKEN) CASE4 (VECTOR_4D_ID_TOKEN, RAINBOW_ID_TOKEN, FOG_ID_TOKEN, SKYSPHERE_ID_TOKEN) CASE3 (MATERIAL_ID_TOKEN, SPLINE_ID_TOKEN, DICTIONARY_ID_TOKEN) + CASE2 (VECTOR_ID_TOKEN, FLOAT_ID_TOKEN) // A symbol with this name exists (and it is not a function). if (CurrentTokenIsContainerElement()) Error("#for loop variable must not be an array or dictionary element"); @@ -3186,44 +3064,14 @@ int Parser::Parse_For_Param (UTF8String& identifierName, DBL* EndPtr, DBL* StepP else { // A local symbol with this name exists. Overwrite it. - Previous = CurrentTokenId(); + Previous = CurrentTrueTokenId(); } END_CASE CASE (EMPTY_ARRAY_TOKEN) POV_PARSER_ASSERT (CurrentTokenIsHomogenousArrayElement()); Error("#for loop variable must not be an array element"); - Previous = CurrentTokenId(); - END_CASE - - CASE2 (VECTOR_FUNCT_TOKEN, FLOAT_FUNCT_TOKEN) - // A symbol with this name exists (and it is a function). - if (CurrentTokenIsContainerElement()) - Error("#for loop variable must not be an array or dictionary element"); - switch(CurrentTokenFunctionId()) - { - case VECTOR_ID_TOKEN: - case FLOAT_ID_TOKEN: - if (!mSymbolStack.IsLocalTableIndex(mToken.context)) - { - // A symbol with this name exists, but it is not local. - // Create an additional local symbol. - Temp_Entry = mSymbolStack.GetLocalTable()->Add_Symbol (CurrentTokenText(), IDENTIFIER_TOKEN); - mToken.NumberPtr = &(Temp_Entry->Token_Number); - mToken.DataPtr = &(Temp_Entry->Data); - Previous = IDENTIFIER_TOKEN; - } - else - { - // A local symbol with this name exists. Overwrite it. - Previous = CurrentTokenFunctionId(); - } - break; - - default: - Parse_Error(IDENTIFIER_TOKEN); - break; - } + Previous = CurrentTrueTokenId(); END_CASE OTHERWISE diff --git a/source/parser/rawtokenizer.cpp b/source/parser/rawtokenizer.cpp index a29f57239..40591afbd 100644 --- a/source/parser/rawtokenizer.cpp +++ b/source/parser/rawtokenizer.cpp @@ -96,11 +96,11 @@ RawTokenizer::RawTokenizer() : continue; if (strchr(i->Token_Name, ' ') != nullptr) continue; - KnownWordInfo& knownWord = mKnownWords[i->Token_Name]; - knownWord.id = i->Token_Number; - knownWord.expressionId = GetExpressionId(i->Token_Number); - knownWord.isReservedWord = true; - knownWord.isPseudoIdentifier = ((knownWord.id == GLOBAL_TOKEN) || (knownWord.id == LOCAL_TOKEN)); + KnownWordInfo& knownWord = mKnownWords[i->Token_Name]; + knownWord.id = i->Token_Number; + knownWord.expressionId = GetCategorizedTokenId(i->Token_Number); + knownWord.isReservedWord = true; + knownWord.isPseudoIdentifier = ((knownWord.id == GLOBAL_TOKEN) || (knownWord.id == LOCAL_TOKEN)); } } @@ -179,7 +179,7 @@ bool RawTokenizer::ProcessFloatLiteralLexeme(RawToken& token) POV_PARSER_ASSERT(token.lexeme.category == Lexeme::kFloatLiteral); token.id = int(FLOAT_TOKEN); - token.expressionId = FLOAT_FUNCT_TOKEN; + token.expressionId = FLOAT_TOKEN_CATEGORY; if (sscanf(token.lexeme.text.c_str(), POV_DBL_FORMAT_STRING, &token.floatValue) == 0) return false; @@ -395,11 +395,13 @@ bool RawTokenizer::ProcessOtherLexeme(RawToken& token) else POV_PARSER_PANIC(); // Should not have been produced by scanner. - token.id = int(tokenId); - token.expressionId = GetExpressionId(tokenId); - token.value = nullptr; - token.isReservedWord = false; - token.isPseudoIdentifier = false; + token.id = int(tokenId); + token.expressionId = tokenId; + token.value = nullptr; + token.isReservedWord = false; + token.isPseudoIdentifier = false; + + POV_EXPERIMENTAL_ASSERT(GetCategorizedTokenId(tokenId) == tokenId); return true; } @@ -416,29 +418,15 @@ bool RawTokenizer::ProcessSignatureLexeme(RawToken& token) default: POV_PARSER_PANIC(); break; } - token.id = int(tokenId); - token.expressionId = GetExpressionId(tokenId); - token.value = nullptr; - token.isReservedWord = false; - token.isPseudoIdentifier = false; + token.id = int(tokenId); + token.expressionId = SIGNATURE_TOKEN_CATEGORY; + token.value = nullptr; + token.isReservedWord = false; + token.isPseudoIdentifier = false; return true; } -TokenId pov_parser::RawTokenizer::GetExpressionId(TokenId tokenId) -{ - if (tokenId <= SIGNATURE_FUNCT_TOKEN) - return SIGNATURE_FUNCT_TOKEN; - else if (tokenId <= FLOAT_FUNCT_TOKEN) - return FLOAT_FUNCT_TOKEN; - else if (tokenId <= VECTOR_FUNCT_TOKEN) - return VECTOR_FUNCT_TOKEN; - else if (tokenId <= COLOUR_KEY_TOKEN) - return COLOUR_KEY_TOKEN; - else - return tokenId; -} - //------------------------------------------------------------------------------ bool RawTokenizer::GetRaw(unsigned char* buffer, size_t size) diff --git a/source/parser/rawtokenizer.h b/source/parser/rawtokenizer.h index df0354f94..e9e42fb88 100644 --- a/source/parser/rawtokenizer.h +++ b/source/parser/rawtokenizer.h @@ -124,11 +124,12 @@ struct RawToken int id; /// A numeric ID representing the "expression type" of the token. - /// For tokens that may occur at the start of a numeric expression, this is - /// @ref FLOAT_FUNC_TOKEN. For tokens that may occur at the start of a - /// vector expression, this is @ref VECTOR_FUNC_TOKEN. For tokens that may + /// For reserved word tokens (but not operators) that may occur at the start of a numeric expression, this is + /// @ref FLOAT_TOKEN_CATEGORY. For reserved word tokens (but not operators) that may occur at the start of a + /// vector expression, this is @ref VECTOR_TOKEN_CATEGORY. For reserved word tokens that may /// occur at the start of a colour expression, this is - /// @ref COLOUR_KEY_TOKEN. For identifiers, this is @ref IDENTIFIER_TOKEN. + /// @ref COLOUR_TOKEN_CATEGORY. For identifiers, this is @ref IDENTIFIER_TOKEN. + /// For file signature tokens, this is @ref SIGNATURE_TOKEN_CATEGORY. /// For other tokens, this is the corresponding value from @ref TokenId. TokenId expressionId; @@ -254,8 +255,6 @@ class RawTokenizer bool ProcessSignatureLexeme(RawToken& token); bool ProcessUCSEscapeDigits(UCS4& c, UTF8String::const_iterator& i, UTF8String::const_iterator& escapeSequenceEnd, unsigned int digits); - - TokenId GetExpressionId(TokenId tokenId); }; } diff --git a/source/parser/reservedwords.cpp b/source/parser/reservedwords.cpp index 1cab648e5..356cd2c42 100644 --- a/source/parser/reservedwords.cpp +++ b/source/parser/reservedwords.cpp @@ -641,7 +641,7 @@ const RESERVED_WORD Reserved_Words[] = { { BACK_SLASH_TOKEN, "\\" }, { BAR_TOKEN, "|" }, { COLON_TOKEN, ":" }, - { COMMA_TOKEN, ", " }, // TODO REVIEW - is there a reason for the trailing blank? + { COMMA_TOKEN, "," }, { DASH_TOKEN, "-" }, { DOLLAR_TOKEN, "$" }, { EQUALS_TOKEN, "=" }, @@ -653,7 +653,7 @@ const RESERVED_WORD Reserved_Words[] = { { LEFT_PAREN_TOKEN, "(" }, { LEFT_SQUARE_TOKEN, "[" }, { PERCENT_TOKEN, "%" }, - { PERIOD_TOKEN, ". (period)" }, // TODO REVIEW - is there a reason for the plaintext? + { PERIOD_TOKEN, "." }, { PLUS_TOKEN, "+" }, { QUESTION_TOKEN, "?" }, { REL_GE_TOKEN, ">=" }, @@ -672,10 +672,10 @@ const RESERVED_WORD Reserved_Words[] = { //------------------------------------------------------------------------------ // Category Pseudo-Tokens. - { COLOUR_KEY_TOKEN, "color keyword" }, - { FLOAT_FUNCT_TOKEN, "float function" }, - { SIGNATURE_FUNCT_TOKEN, "signature function" }, - { VECTOR_FUNCT_TOKEN, "vector function" }, + { COLOUR_TOKEN_CATEGORY, "colour keyword" }, + { FLOAT_TOKEN_CATEGORY, "float function" }, + { SIGNATURE_TOKEN_CATEGORY, "file signature" }, + { VECTOR_TOKEN_CATEGORY, "vector function" }, //------------------------------------------------------------------------------ // Identifier Pseudo-Tokens. @@ -737,4 +737,18 @@ const RESERVED_WORD Reserved_Words[] = { { TOKEN_COUNT_, nullptr } }; -} // end of pov namespace +TokenId GetCategorizedTokenId(TokenId tokenId) +{ + if (tokenId <= SIGNATURE_TOKEN_CATEGORY) + return SIGNATURE_TOKEN_CATEGORY; + else if (tokenId <= FLOAT_TOKEN_CATEGORY) + return FLOAT_TOKEN_CATEGORY; + else if (tokenId <= VECTOR_TOKEN_CATEGORY) + return VECTOR_TOKEN_CATEGORY; + else if (tokenId <= COLOUR_TOKEN_CATEGORY) + return COLOUR_TOKEN_CATEGORY; + else + return tokenId; +} + +} // end of namespace pov_parser diff --git a/source/parser/reservedwords.h b/source/parser/reservedwords.h index 5d053706f..9bb1dd081 100644 --- a/source/parser/reservedwords.h +++ b/source/parser/reservedwords.h @@ -68,12 +68,12 @@ enum TokenId : int UTF8_SIGNATURE_TOKEN, - SIGNATURE_FUNCT_TOKEN, // must be last in this section + SIGNATURE_TOKEN_CATEGORY, // must be last in this section //------------------------------------------------------------------------------ // Float Tokens. // - // All tokens that may start a float expression must go here. + // All keyword tokens that may start a float expression must go here. // // Please keep this section neatly sorted by the token identifier name, // sorting underscore characters before digits, digits before letters, @@ -136,18 +136,18 @@ enum TokenId : int TANH_TOKEN, TAU_TOKEN, TRUE_TOKEN, - VDOT_TOKEN, VAL_TOKEN, + VDOT_TOKEN, VERSION_TOKEN, VLENGTH_TOKEN, YES_TOKEN, - FLOAT_FUNCT_TOKEN, // must be last in this section + FLOAT_TOKEN_CATEGORY, // must be last in this section //------------------------------------------------------------------------------ // Vector Tokens. // - // All tokens that may start a vector expression must go here. + // All keyword tokens that may start a vector expression must go here. // // Please keep this section neatly sorted by the token identifier name, // sorting underscore characters before digits, digits before letters, @@ -167,12 +167,12 @@ enum TokenId : int Y_TOKEN, Z_TOKEN, - VECTOR_FUNCT_TOKEN, // must be last in this section + VECTOR_TOKEN_CATEGORY, // must be last in this section //------------------------------------------------------------------------------ // Colour Tokens. // - // Tokens that may start a colour expression must typically go here. + // Keyword tokens that may start a colour expression must typically go here. // // Please keep this section neatly sorted by the token identifier name, // sorting underscore characters before digits, digits before letters, @@ -200,7 +200,7 @@ enum TokenId : int SRGBT_TOKEN, TRANSMIT_TOKEN, - COLOUR_KEY_TOKEN, // must be last in this section + COLOUR_TOKEN_CATEGORY, // must be last in this section //------------------------------------------------------------------------------ // More Colour Tokens. @@ -755,6 +755,8 @@ constexpr int TOKEN_COUNT = int(TokenId::TOKEN_COUNT_); extern const RESERVED_WORD Reserved_Words[]; -} +TokenId GetCategorizedTokenId(TokenId tokenId); + +} // end of namespace pov_parser #endif // POVRAY_PARSER_RESERVEDWORDS_H diff --git a/source/parser/symboltable.cpp b/source/parser/symboltable.cpp index 41bbd2f5a..dbeab7976 100644 --- a/source/parser/symboltable.cpp +++ b/source/parser/symboltable.cpp @@ -431,12 +431,10 @@ void SymbolTable::Remove_Symbol(const char *Name, bool is_array_elem, void **Dat { POV_EXPERIMENTAL_ASSERT(DataPtr != nullptr); - if (ttype == FLOAT_FUNCT_TOKEN) - ttype = FLOAT_ID_TOKEN; - else if (ttype == VECTOR_FUNCT_TOKEN) - ttype = VECTOR_ID_TOKEN; - else if (ttype == COLOUR_KEY_TOKEN) - ttype = COLOUR_ID_TOKEN; + POV_EXPERIMENTAL_ASSERT((ttype != FLOAT_TOKEN_CATEGORY) && + (ttype != FLOAT_ID_TOKEN) && + (ttype != VECTOR_TOKEN_CATEGORY) && + (ttype != COLOUR_TOKEN_CATEGORY)); Destroy_Ident_Data(*DataPtr, ttype); *DataPtr = nullptr; diff --git a/windows/pvedit.cpp b/windows/pvedit.cpp index 9ebf76f1f..f719c9140 100644 --- a/windows/pvedit.cpp +++ b/windows/pvedit.cpp @@ -10,7 +10,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 @@ -258,7 +258,6 @@ bool LoadEditorDLL (char *path, bool errorOK) return (true) ; } -// TODO FIXME - This is almost identical to Parser::Get_Reserved_Words() in parser/parser_tokenizer.cpp. char *Get_Reserved_Words (const char *additional_words) { int length = 0 ; From c79d34817ce34ce4800dc8cdd859a2fe76bda67c Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Wed, 23 Jan 2019 20:53:33 +0100 Subject: [PATCH 05/13] Fix some misnomers related to conversion to/from "ASCII" (but really platform-specific). --- source/backend/scene/backendscenedata.cpp | 6 ++-- source/base/fileinputoutput.cpp | 20 ++++++------ source/base/fileutil.cpp | 4 +-- source/base/image/image.cpp | 4 +-- source/base/image/jpeg.cpp | 2 +- source/base/image/openexr.cpp | 12 +++---- source/base/image/png.cpp | 4 +-- source/base/path.cpp | 24 +++++++------- source/base/path.h | 12 +++---- source/base/platformbase.cpp | 12 +++---- source/base/stringutilities.cpp | 40 +++++++++++++++++++---- source/base/stringutilities.h | 7 ++-- source/base/textstream.cpp | 6 ++-- source/core/bounding/bsptree.cpp | 10 +++--- source/core/scene/object.cpp | 2 +- source/frontend/imageprocessing.cpp | 26 +++++++-------- source/frontend/processoptions.cpp | 6 ++-- source/frontend/processrenderoptions.cpp | 8 ++--- source/frontend/renderfrontend.cpp | 22 ++++++------- source/frontend/renderfrontend.h | 4 +-- source/frontend/simplefrontend.h | 4 +-- source/parser/fncode.cpp | 4 +-- source/parser/parser.cpp | 16 ++++----- source/parser/parser.h | 2 +- source/parser/parser_expressions.cpp | 2 +- source/parser/parser_materials.cpp | 6 ++-- source/parser/parser_obj.cpp | 34 +++++++++---------- source/parser/parser_strings.cpp | 8 ++--- source/parser/parser_tokenizer.cpp | 20 ++++++------ source/povmain.cpp | 4 +-- source/povms/povmscpp.cpp | 12 +++---- source/povms/povmscpp.h | 6 ++-- vfe/unix/unixconsole.cpp | 8 ++--- vfe/unix/vfeplatform.cpp | 14 ++++---- vfe/unix/vfeplatform.h | 6 ++-- vfe/vfe.cpp | 24 +++++++------- vfe/vfecontrol.cpp | 14 ++++---- vfe/vfesession.cpp | 4 +-- vfe/vfesession.h | 10 +++--- vfe/win/vfeplatform.cpp | 18 +++++----- vfe/win/vfeplatform.h | 4 +-- windows/pvengine.cpp | 8 ++--- 42 files changed, 244 insertions(+), 215 deletions(-) diff --git a/source/backend/scene/backendscenedata.cpp b/source/backend/scene/backendscenedata.cpp index 49dd777eb..e5e2a0c45 100644 --- a/source/backend/scene/backendscenedata.cpp +++ b/source/backend/scene/backendscenedata.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 @@ -71,7 +71,7 @@ UCS2String BackendSceneData::FindFile(POVMSContext ctx, const UCS2String& filena for (size_t i = 0; i < POV_FILE_EXTENSIONS_PER_TYPE; i++) { if ( ( strlen(gPOV_File_Extensions[stype].ext[i]) > 0 ) && - ( filename.compare(pos,filename.length()-pos, ASCIItoUCS2String(gPOV_File_Extensions[stype].ext[i])) == 0 ) ) + ( filename.compare(pos,filename.length()-pos, SysToUCS2String(gPOV_File_Extensions[stype].ext[i])) == 0 ) ) { // match tryExactFirst = true; @@ -90,7 +90,7 @@ UCS2String BackendSceneData::FindFile(POVMSContext ctx, const UCS2String& filena if (strlen(gPOV_File_Extensions[stype].ext[i]) > 0) { UCS2String fn(filename); - fn += ASCIItoUCS2String(gPOV_File_Extensions[stype].ext[i]); + fn += SysToUCS2String(gPOV_File_Extensions[stype].ext[i]); filenames.push_back(fn); } } diff --git a/source/base/fileinputoutput.cpp b/source/base/fileinputoutput.cpp index f27753f10..97a6f423e 100644 --- a/source/base/fileinputoutput.cpp +++ b/source/base/fileinputoutput.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 @@ -80,12 +80,12 @@ IStream::~IStream() IFileStream::IFileStream(const UCS2String& name) : IStream(name), f(nullptr) { - if(pov_stricmp(UCS2toASCIIString(name).c_str(), "stdin") == 0) + if(pov_stricmp(UCS2toSysString(name).c_str(), "stdin") == 0) { f = stdin; } - else if((pov_stricmp(UCS2toASCIIString(name).c_str(), "stdout") == 0) || - (pov_stricmp(UCS2toASCIIString(name).c_str(), "stderr") == 0)) + else if((pov_stricmp(UCS2toSysString(name).c_str(), "stdout") == 0) || + (pov_stricmp(UCS2toSysString(name).c_str(), "stderr") == 0)) { f = nullptr; } @@ -186,7 +186,7 @@ bool IFileStream::getline(char *s, size_t buflen) } IMemStream::IMemStream(const unsigned char* data, size_t size, const char* formalName, POV_OFF_T formalStart) : - IStream(ASCIItoUCS2String(formalName)), size(size), pos(0), formalStart(formalStart), start(data), mUngetBuffer(EOF) + IStream(SysToUCS2String(formalName)), size(size), pos(0), formalStart(formalStart), start(data), mUngetBuffer(EOF) { fail = false; } @@ -219,18 +219,18 @@ OStream::OStream(const UCS2String& name, unsigned int Flags) : IOBase(name), f(n mode = "r+b"; } - if(pov_stricmp(UCS2toASCIIString(name).c_str(), "stdin") == 0) + if(pov_stricmp(UCS2toSysString(name).c_str(), "stdin") == 0) { f = nullptr; } - else if(pov_stricmp(UCS2toASCIIString(name).c_str(), "stdout") == 0) + else if(pov_stricmp(UCS2toSysString(name).c_str(), "stdout") == 0) { if((Flags & append) != 0) f = nullptr; else f = stdout; } - else if(pov_stricmp(UCS2toASCIIString(name).c_str(), "stderr") == 0) + else if(pov_stricmp(UCS2toSysString(name).c_str(), "stderr") == 0) { if((Flags & append) != 0) f = nullptr; @@ -324,7 +324,7 @@ IStream *NewIStream(const Path& p, unsigned int stype) if (!PlatformBase::GetInstance().AllowLocalFileAccess(p(), stype, false)) { string str ("IO Restrictions prohibit read access to '") ; - str += UCS2toASCIIString(p()); + str += UCS2toSysString(p()); str += "'"; throw POV_EXCEPTION(kCannotOpenFileErr, str); } @@ -342,7 +342,7 @@ OStream *NewOStream(const Path& p, unsigned int stype, bool sappend) if (!PlatformBase::GetInstance().AllowLocalFileAccess(p(), stype, true)) { string str ("IO Restrictions prohibit write access to '") ; - str += UCS2toASCIIString(p()); + str += UCS2toSysString(p()); str += "'"; throw POV_EXCEPTION(kCannotOpenFileErr, str); } diff --git a/source/base/fileutil.cpp b/source/base/fileutil.cpp index 47e3587b4..cfefabe13 100644 --- a/source/base/fileutil.cpp +++ b/source/base/fileutil.cpp @@ -10,7 +10,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 @@ -173,7 +173,7 @@ int InferFileTypeFromExt(const UCS2String& ext) { // TODO FIXME - better compare in the string domain - string str = UCS2toASCIIString(ext); + string str = UCS2toSysString(ext); for (int i = 0; i < POV_File_Count; i++) { diff --git a/source/base/image/image.cpp b/source/base/image/image.cpp index 4900187e8..3418aff79 100644 --- a/source/base/image/image.cpp +++ b/source/base/image/image.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 @@ -3066,7 +3066,7 @@ class FileBackedPixelContainer FileBackedPixelContainer(size_type width, size_type height, size_type bs): m_File(-1), m_Width(width), m_Height(height), m_xPos(0), m_yPos(0), m_Dirty(false), m_Path(PlatformBase::GetInstance().CreateTemporaryFile()) { - if ((m_File = open(UCS2toASCIIString(m_Path).c_str(), O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) == -1) + if ((m_File = open(UCS2toSysString(m_Path).c_str(), O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) == -1) throw POV_EXCEPTION(kCannotOpenFileErr, "Cannot open backing file for intermediate image storage."); m_Blocksize = bs; m_Buffer.resize(m_Blocksize); diff --git a/source/base/image/jpeg.cpp b/source/base/image/jpeg.cpp index 6f6aba002..aa5041f13 100644 --- a/source/base/image/jpeg.cpp +++ b/source/base/image/jpeg.cpp @@ -498,7 +498,7 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option if (!meta.getComment4().empty()) comment += meta.getComment4() + "\n"; - const JOCTET *pcom(reinterpret_cast(&comment[0])); /* lack of converter, cast, old-style (bad, go mixing C & C++!) */ + const JOCTET *pcom(reinterpret_cast(comment.c_str())); // The comment marker must be here, before the image data jpeg_write_marker(&writebuf.cinfo, JPEG_COM, pcom,comment.length()); diff --git a/source/base/image/openexr.cpp b/source/base/image/openexr.cpp index d26cf74c5..bdc8bd951 100644 --- a/source/base/image/openexr.cpp +++ b/source/base/image/openexr.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 @@ -87,7 +87,7 @@ struct Messages class POV_EXR_OStream : public Imf::OStream { public: - POV_EXR_OStream(pov_base::OStream& pov_stream) : Imf::OStream(UCS2toASCIIString(pov_stream.Name()).c_str()), os(pov_stream) { } + POV_EXR_OStream(pov_base::OStream& pov_stream) : Imf::OStream(UCS2toSysString(pov_stream.Name()).c_str()), os(pov_stream) { } virtual ~POV_EXR_OStream() { } void write(const char *c, int n) @@ -119,7 +119,7 @@ class POV_EXR_OStream : public Imf::OStream class POV_EXR_IStream : public Imf::IStream { public: - POV_EXR_IStream(pov_base::IStream& pov_stream) : Imf::IStream(UCS2toASCIIString(pov_stream.Name()).c_str()), is(pov_stream) + POV_EXR_IStream(pov_base::IStream& pov_stream) : Imf::IStream(UCS2toSysString(pov_stream.Name()).c_str()), is(pov_stream) { is.seekg(0, IOBase::seek_end); fsize = is.tellg(); @@ -274,12 +274,12 @@ void Write(OStream *file, const Image *image, const Image::WriteOptions& options comments += meta.getComment4() + "\n"; if (!comments.empty()) - hdr.insert("comments",StringAttribute(comments.c_str())); + hdr.insert("comments",StringAttribute(comments)); string software= meta.getSoftware(); string datetime= meta.getDateTime(); - hdr.insert("software",StringAttribute(software.c_str())); - hdr.insert("creation",StringAttribute(datetime.c_str())); + hdr.insert("software",StringAttribute(software)); + hdr.insert("creation",StringAttribute(datetime)); RgbaOutputFile rof(os, hdr, channels); rof.setFrameBuffer(pixels.get(), 1, width); diff --git a/source/base/image/png.cpp b/source/base/image/png.cpp index 98f38de0b..1151bbbae 100644 --- a/source/base/image/png.cpp +++ b/source/base/image/png.cpp @@ -197,7 +197,7 @@ extern "C" { Messages *m = reinterpret_cast(png_get_error_ptr(png_ptr)); if (m) - m->error = string("Cannot read PNG data"); + m->error = "Cannot read PNG data"; throw POV_EXCEPTION(kFileDataErr, "Cannot read PNG data"); } } @@ -231,7 +231,7 @@ extern "C" { Messages *m = reinterpret_cast(png_get_error_ptr(png_ptr)); if (m) - m->error = string("Cannot write PNG data"); + m->error = "Cannot write PNG data"; throw POV_EXCEPTION(kFileDataErr, "Cannot write PNG data"); } } diff --git a/source/base/path.cpp b/source/base/path.cpp index 11e5f8b0d..bcef1a8c4 100644 --- a/source/base/path.cpp +++ b/source/base/path.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 @@ -54,16 +54,16 @@ Path::Path() /// Path::Path(const char *p, Encoding e) { - if(e == ASCII) - ParsePathString(ASCIItoUCS2String(p)); + if(e == Encoding::kSystem) + ParsePathString(SysToUCS2String(p)); else ParsePathString(URLToUCS2String(p)); } Path::Path(const string& p, Encoding e) { - if(e == ASCII) - ParsePathString(ASCIItoUCS2String(p.c_str())); + if(e == Encoding::kSystem) + ParsePathString(SysToUCS2String(p)); else ParsePathString(URLToUCS2String(p)); } @@ -170,12 +170,12 @@ UCS2String Path::GetFile() const void Path::SetVolume(const char *p) { - volume = ASCIItoUCS2String(p); + volume = SysToUCS2String(p); } void Path::SetVolume(const string& p) { - volume = ASCIItoUCS2String(p.c_str()); + volume = SysToUCS2String(p); } void Path::SetVolume(const UCS2 *p) @@ -190,12 +190,12 @@ void Path::SetVolume(const UCS2String& p) void Path::AppendFolder(const char *p) { - folders.push_back(ASCIItoUCS2String(p)); + folders.push_back(SysToUCS2String(p)); } void Path::AppendFolder(const string& p) { - folders.push_back(ASCIItoUCS2String(p.c_str())); + folders.push_back(SysToUCS2String(p)); } void Path::AppendFolder(const UCS2 *p) @@ -220,12 +220,12 @@ void Path::RemoveAllFolders() void Path::SetFile(const char *p) { - file = ASCIItoUCS2String(p); + file = SysToUCS2String(p); } void Path::SetFile(const string& p) { - file = ASCIItoUCS2String(p.c_str()); + file = SysToUCS2String(p); } void Path::SetFile(const UCS2 *p) @@ -323,7 +323,7 @@ UCS2String Path::URLToUCS2String(const char *p) const UCS2String Path::URLToUCS2String(const string& p) const { - return ASCIItoUCS2String(p.c_str()); // TODO FIXME + return SysToUCS2String(p); // TODO FIXME } } diff --git a/source/base/path.h b/source/base/path.h index 822b84730..9cd756a3a 100644 --- a/source/base/path.h +++ b/source/base/path.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 @@ -61,15 +61,15 @@ class Path { public: - enum Encoding + enum class Encoding { - ASCII, - URL + kSystem, + kURL }; Path(); - Path(const char *p, Encoding e = ASCII); - Path(const string& p, Encoding e = ASCII); + Path(const char *p, Encoding e = Encoding::kSystem); + Path(const std::string& p, Encoding e = Encoding::kSystem); Path(const UCS2 *p); Path(const UCS2String& p); diff --git a/source/base/platformbase.cpp b/source/base/platformbase.cpp index ef9c84913..f46953384 100644 --- a/source/base/platformbase.cpp +++ b/source/base/platformbase.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 @@ -62,7 +62,7 @@ DefaultPlatformBase::~DefaultPlatformBase() UCS2String DefaultPlatformBase::GetTemporaryPath() { - return ASCIItoUCS2String("/tmp/"); + return u"/tmp/"; } UCS2String DefaultPlatformBase::CreateTemporaryFile() @@ -77,12 +77,12 @@ UCS2String DefaultPlatformBase::CreateTemporaryFile() if (f != nullptr) fclose(f); - return UCS2String(ASCIItoUCS2String(buffer)); + return ASCIItoUCS2String(buffer); } void DefaultPlatformBase::DeleteTemporaryFile(const UCS2String& filename) { - remove(UCS2toASCIIString(filename).c_str()); + remove(UCS2toSysString(filename).c_str()); } bool DefaultPlatformBase::ReadFileFromURL(OStream *, const UCS2String&, const UCS2String&) @@ -92,12 +92,12 @@ bool DefaultPlatformBase::ReadFileFromURL(OStream *, const UCS2String&, const UC FILE* DefaultPlatformBase::OpenLocalFile(const UCS2String& name, const char *mode) { - return fopen(UCS2toASCIIString(UCS2String(name)).c_str(), mode); + return fopen(UCS2toSysString(name).c_str(), mode); } void DefaultPlatformBase::DeleteLocalFile(const UCS2String& name) { - POV_DELETE_FILE(UCS2toASCIIString(UCS2String(name)).c_str()); + POV_DELETE_FILE(UCS2toSysString(name).c_str()); } bool DefaultPlatformBase::AllowLocalFileAccess(const UCS2String& name, const unsigned int fileType, bool write) diff --git a/source/base/stringutilities.cpp b/source/base/stringutilities.cpp index de96249a7..5881a3872 100644 --- a/source/base/stringutilities.cpp +++ b/source/base/stringutilities.cpp @@ -55,14 +55,27 @@ namespace pov_base { -UCS2String ASCIItoUCS2String(const char *s) +UCS2String ASCIItoUCS2String(const std::string& s) +{ + UCS2String r; + r.reserve(s.length()); + + for(std::size_t i = 0; i < s.length(); i++) + { + r += (UCS2)(s[i]); + } + + return r; +} + +UCS2String SysToUCS2String(const char *s) { UCS2String r; unsigned char ch; if (s != nullptr) { - while(*s != 0) + while(*s != u'\0') { ch = *s++; r += (UCS2)(ch); @@ -72,14 +85,27 @@ UCS2String ASCIItoUCS2String(const char *s) return r; } -std::string UCS2toASCIIString(const UCS2String& s) +UCS2String SysToUCS2String(const std::string& s) +{ + UCS2String r; + r.reserve(s.length()); + + for(std::size_t i = 0; i < s.length(); i++) + { + r += (UCS2)(s[i]); + } + + return r; +} + +std::string UCS2toSysString(const UCS2String& s) { std::string r; r.reserve(s.length()); for(std::size_t i = 0; i < s.length(); i++) { - if(s[i] >= 256) + if(s[i] > 0xFFu) r += ' '; // TODO - according to most encoding conventions, this should be '?' else r += (char)(s[i]); @@ -201,7 +227,7 @@ int pov_stricmp(const char *s1, const char *s2) { char c1, c2; - while((*s1 != 0) && (*s2 != 0)) + while((*s1 != '\0') && (*s2 != '\0')) { c1 = *s1++; c2 = *s2++; @@ -215,9 +241,9 @@ int pov_stricmp(const char *s1, const char *s2) return 1; } - if(*s1 == 0) + if(*s1 == '\0') { - if(*s2 == 0) + if(*s2 == '\0') return 0; else return -1; diff --git a/source/base/stringutilities.h b/source/base/stringutilities.h index 9fe2a0602..bbc22a776 100644 --- a/source/base/stringutilities.h +++ b/source/base/stringutilities.h @@ -59,8 +59,11 @@ namespace pov_base /// /// @{ -UCS2String ASCIItoUCS2String(const char *s); -std::string UCS2toASCIIString(const UCS2String& s); +UCS2String ASCIItoUCS2String(const std::string& s); + +UCS2String SysToUCS2String(const char *s); +UCS2String SysToUCS2String(const std::string& s); +std::string UCS2toSysString(const UCS2String& s); UCS2String UTF8toUCS2String(const UTF8String& s); diff --git a/source/base/textstream.cpp b/source/base/textstream.cpp index e7db1d4bb..0383b7db1 100644 --- a/source/base/textstream.cpp +++ b/source/base/textstream.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 @@ -66,7 +66,7 @@ IBufferedTextStream::IBufferedTextStream(const UCS2 *sname, unsigned int stype) stream = NewIStream(sname, stype); if (stream == nullptr) - throw POV_EXCEPTION(kCannotOpenFileErr, string("Cannot open file '") + UCS2toASCIIString(sname) + "' for input."); + throw POV_EXCEPTION(kCannotOpenFileErr, std::string("Cannot open file '") + UCS2toSysString(sname) + "' for input."); filename = UCS2String(sname); bufferoffset = 0; @@ -427,7 +427,7 @@ OTextStream::OTextStream(const UCS2 *sname, unsigned int stype, bool append) stream = NewOStream(sname, stype, append); if (stream == nullptr) - throw POV_EXCEPTION(kCannotOpenFileErr, string("Cannot open file '") + UCS2toASCIIString(sname) + "' for output."); + throw POV_EXCEPTION(kCannotOpenFileErr, std::string("Cannot open file '") + UCS2toSysString(sname) + "' for output."); filename = UCS2String(sname); } diff --git a/source/core/bounding/bsptree.cpp b/source/core/bounding/bsptree.cpp index 4e4d11f2f..241788229 100644 --- a/source/core/bounding/bsptree.cpp +++ b/source/core/bounding/bsptree.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 @@ -281,7 +281,7 @@ void BSPTree::build(const Progress& progress, const Objects& objects, splits[Z].resize(objects.size() * 2); #if BSP_WRITEBOUNDS || BSP_READNODES || BSP_WRITETREE - string tempstr = UCS2toASCIIString(inputFile); + string tempstr = UCS2toSysString(inputFile); if (tempstr.empty() == true) tempstr = "default"; string::size_type pos = tempstr.find_last_of('.'); @@ -290,7 +290,7 @@ void BSPTree::build(const Progress& progress, const Objects& objects, #endif #if BSP_WRITEBOUNDS - FILE *bb = fopen(string(tempstr + ".bounds").c_str(), "w"); + FILE *bb = fopen((tempstr + ".bounds").c_str(), "w"); if (bb != nullptr) fprintf(bb, "%d\n", objects.size()); @@ -332,7 +332,7 @@ void BSPTree::build(const Progress& progress, const Objects& objects, bmax = Vector3d(bbox.pmax[X], bbox.pmax[Y], bbox.pmax[Z]); #if BSP_WRITETREE - gFile = fopen(string(tempstr + ".tree").c_str(), "w"); + gFile = fopen((tempstr + ".tree").c_str(), "w"); if (gFile != nullptr) { @@ -345,7 +345,7 @@ void BSPTree::build(const Progress& progress, const Objects& objects, nodes.push_back(Node()); #if BSP_READNODES - FILE *infile = fopen(string(tempstr + ".nodes").c_str(), "r"); + FILE *infile = fopen((tempstr + ".nodes").c_str(), "r"); if (infile == nullptr) throw POV_EXCEPTION(kCannotOpenFileErr, "Cannot open BSP nodes file (BSP_READNODES == true, tree generation disabled)"); try diff --git a/source/core/scene/object.cpp b/source/core/scene/object.cpp index 7d546d2f1..ccc7b6c84 100644 --- a/source/core/scene/object.cpp +++ b/source/core/scene/object.cpp @@ -68,7 +68,7 @@ std::string& ObjectDebugHelper::SimpleDesc(std::string& result) result = str; if(IsCopy) result += "Copy of "; - if(Tag == "") + if(Tag.empty()) result += "Unnamed object"; else result += Tag; diff --git a/source/frontend/imageprocessing.cpp b/source/frontend/imageprocessing.cpp index cc5007105..7ea34bde3 100644 --- a/source/frontend/imageprocessing.cpp +++ b/source/frontend/imageprocessing.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 @@ -209,8 +209,8 @@ bool ImageProcessing::OutputIsStdout(POVMS_Object& ropts) { UCS2String path(ropts.TryGetUCS2String(kPOVAttrib_OutputFile, "")); - toStdout = path == POVMS_ASCIItoUCS2String("-") || path == POVMS_ASCIItoUCS2String("stdout"); - toStderr = path == POVMS_ASCIItoUCS2String("stderr"); + toStdout = (path == u"-") || (path == u"stdout"); + toStderr = (path == u"stderr"); return toStdout; } @@ -231,43 +231,43 @@ UCS2String ImageProcessing::GetOutputFilename(POVMS_Object& ropts, POVMSInt fram { case kPOVList_FileType_Targa: case kPOVList_FileType_CompressedTarga: - ext = ASCIItoUCS2String(".tga"); + ext = u".tga"; imagetype = Image::TGA; break; case kPOVList_FileType_PNG: - ext = ASCIItoUCS2String(".png"); + ext = u".png"; imagetype = Image::PNG; break; case kPOVList_FileType_JPEG: - ext = ASCIItoUCS2String(".jpg"); + ext = u".jpg"; imagetype = Image::JPEG; break; case kPOVList_FileType_PPM: - ext = ASCIItoUCS2String(".ppm"); // TODO FIXME - in case of greyscale output, extension should default to ".pgm" + ext = u".ppm"; // TODO FIXME - in case of greyscale output, extension should default to ".pgm" imagetype = Image::PPM; break; case kPOVList_FileType_BMP: - ext = ASCIItoUCS2String(".bmp"); + ext = u".bmp"; imagetype = Image::BMP; break; case kPOVList_FileType_OpenEXR: - ext = ASCIItoUCS2String(".exr"); + ext = u".exr"; imagetype = Image::EXR; break; case kPOVList_FileType_RadianceHDR: - ext = ASCIItoUCS2String(".hdr"); + ext = u".hdr"; imagetype = Image::HDR; break; #ifdef POV_SYS_IMAGE_TYPE case kPOVList_FileType_System: - ext = ASCIItoUCS2String(POV_SYS_IMAGE_EXTENSION); + ext = u"" POV_SYS_IMAGE_EXTENSION; imagetype = Image::POV_SYS_IMAGE_TYPE; break; #endif @@ -290,7 +290,7 @@ UCS2String ImageProcessing::GetOutputFilename(POVMS_Object& ropts, POVMSInt fram default: throw POV_EXCEPTION_STRING("Output to STDOUT/STDERR not supported for selected file format"); } - return POVMS_ASCIItoUCS2String(OutputIsStdout() ? "stdout" : "stderr"); + return (OutputIsStdout() ? u"stdout" : u"stderr"); } // we disallow an output filename that consists purely of the default extension @@ -308,7 +308,7 @@ UCS2String ImageProcessing::GetOutputFilename(POVMS_Object& ropts, POVMSInt fram // if the input file name ends with '.' or '.anything', we remove it UCS2String::size_type pos = filename.find_last_of('.'); - if(pos != string::npos) + if(pos != UCS2String::npos) filename.erase(pos); } else if ((path.HasVolume() == false) && (path.Empty() == false)) diff --git a/source/frontend/processoptions.cpp b/source/frontend/processoptions.cpp index e43b88dcc..807a354d5 100644 --- a/source/frontend/processoptions.cpp +++ b/source/frontend/processoptions.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 @@ -361,7 +361,7 @@ int ProcessOptions::WriteFile(const char *filename, POVMSObjectPtr obj) OTextStream *ini_file; int err = kNoErr; - if(!pov_base::PlatformBase::GetInstance().AllowLocalFileAccess (ASCIItoUCS2String(filename), POV_File_Text_INI, true)) + if(!pov_base::PlatformBase::GetInstance().AllowLocalFileAccess (SysToUCS2String(filename), POV_File_Text_INI, true)) return kCannotOpenFileErr; ini_file = OpenFileForWrite(filename, obj); @@ -558,7 +558,7 @@ void ProcessOptions::ParseErrorAt(ITextStream *file, const char *format, ...) std::vsnprintf(error_buffer, sizeof(error_buffer), format, marker); va_end(marker); - fprintf(stderr, "%s\nFile '%s' at line '%u'", error_buffer, UCS2toASCIIString(file->name()).c_str(), (unsigned int) file->line()); + fprintf(stderr, "%s\nFile '%s' at line '%u'", error_buffer, UCS2toSysString(file->name()).c_str(), (unsigned int) file->line()); } void ProcessOptions::WriteError(const char *format, ...) diff --git a/source/frontend/processrenderoptions.cpp b/source/frontend/processrenderoptions.cpp index 162d58734..f3b264b20 100644 --- a/source/frontend/processrenderoptions.cpp +++ b/source/frontend/processrenderoptions.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 @@ -932,7 +932,7 @@ ITextStream *ProcessRenderOptions::OpenFileForRead(const char *filename, POVMSOb OTextStream *ProcessRenderOptions::OpenFileForWrite(const char *filename, POVMSObjectPtr) { - return new OTextStream(ASCIItoUCS2String(filename).c_str(), pov_base::POV_File_Text_INI); + return new OTextStream(SysToUCS2String(filename).c_str(), pov_base::POV_File_Text_INI); } ITextStream *ProcessRenderOptions::OpenINIFileStream(const char *filename, unsigned int stype, POVMSObjectPtr obj) // TODO FIXME - Use new Path class! @@ -952,7 +952,7 @@ ITextStream *ProcessRenderOptions::OpenINIFileStream(const char *filename, unsig // TODO - the following statement may need reviewing; before it was changed from a macro to a PlatformBase call, // it carried a comment "TODO FIXME - Remove dependency on this macro!!! [trf]". - if (!PlatformBase::GetInstance().AllowLocalFileAccess (ASCIItoUCS2String(filename),stype, false)) + if (!PlatformBase::GetInstance().AllowLocalFileAccess (SysToUCS2String(filename), stype, false)) return nullptr; for(i = 0; i < POV_FILE_EXTENSIONS_PER_TYPE; i++) @@ -968,7 +968,7 @@ ITextStream *ProcessRenderOptions::OpenINIFileStream(const char *filename, unsig if((hasextension == true) && (CheckIfFileExists(filename) == true)) { - return new IBufferedTextStream(ASCIItoUCS2String(filename).c_str(), stype); + return new IBufferedTextStream(SysToUCS2String(filename).c_str(), stype); } for(i = 0; i < POV_FILE_EXTENSIONS_PER_TYPE; i++) diff --git a/source/frontend/renderfrontend.cpp b/source/frontend/renderfrontend.cpp index 4c9aa1adb..a3a5f4319 100644 --- a/source/frontend/renderfrontend.cpp +++ b/source/frontend/renderfrontend.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 @@ -257,8 +257,8 @@ RenderFrontendBase::SceneId RenderFrontendBase::CreateScene(SceneData& shd, POVM if(obj.Exist(gStreamTypeUtilData[i]) == true) { shd.streamnames[gStreamNumber[i]] = obj.GetUCS2String(gStreamTypeUtilData[i]); - if(ProcessOptions::IsTrue(UCS2toASCIIString(shd.streamnames[gStreamNumber[i]]).c_str()) == true) - shd.streamnames[gStreamNumber[i]] = ASCIItoUCS2String(gStreamDefaultFile[i]); + if(ProcessOptions::IsTrue(UCS2toSysString(shd.streamnames[gStreamNumber[i]]).c_str()) == true) + shd.streamnames[gStreamNumber[i]] = SysToUCS2String(gStreamDefaultFile[i]); } } @@ -600,7 +600,7 @@ void RenderFrontendBase::MakeBackupPath(POVMS_Object& ropts, ViewData& vd, const if(vd.imageBackupFile.GetFile().empty() == true) vd.imageBackupFile.SetFile(ropts.TryGetUCS2String(kPOVAttrib_InputFile, "object.pov")); - vd.imageBackupFile.SetFile(GetFileName(Path(vd.imageBackupFile.GetFile())) + ASCIItoUCS2String(".pov-state")); + vd.imageBackupFile.SetFile(GetFileName(Path(vd.imageBackupFile.GetFile())) + u".pov-state"); } void RenderFrontendBase::NewBackup(POVMS_Object& ropts, ViewData& vd, const Path& outputpath) @@ -957,9 +957,9 @@ void ParserOptions(POVMS_Object& cppmsg, TextStreamBuffer *tsb) ucs2buf[0] = 0; (void)POVMSUtil_GetUCS2String(msg, kPOVAttrib_InputFile, ucs2buf, &l); if(POVMSUtil_GetFloat(msg, kPOVAttrib_Version, &f) != kNoErr) - tsb->printf(" Input file: %s\n", UCS2toASCIIString(ucs2buf).c_str()); + tsb->printf(" Input file: %s\n", UCS2toSysString(ucs2buf).c_str()); else - tsb->printf(" Input file: %s (compatible to version %1.2f)\n", UCS2toASCIIString(ucs2buf).c_str(), (double)f); + tsb->printf(" Input file: %s (compatible to version %1.2f)\n", UCS2toSysString(ucs2buf).c_str(), (double)f); tsb->printf(" Remove bounds.......%s\n Split unions........%s\n", GetOptionSwitchString(msg, kPOVAttrib_RemoveBounds, true), GetOptionSwitchString(msg, kPOVAttrib_SplitUnions, false)); @@ -981,7 +981,7 @@ void ParserOptions(POVMS_Object& cppmsg, TextStreamBuffer *tsb) l = sizeof(ucs2buf); ucs2buf[0] = 0; (void)POVMSAttr_Get(&item, kPOVMSType_UCS2String, ucs2buf, &l); - tsb->printf(" %s\n", UCS2toASCIIString(ucs2buf).c_str()); + tsb->printf(" %s\n", UCS2toSysString(ucs2buf).c_str()); (void)POVMSAttr_Delete(&item); } @@ -1152,11 +1152,11 @@ void OutputOptions(POVMS_Object& cppmsg, TextStreamBuffer *tsb) } if(outputFormat == kPOVList_FileType_JPEG) - tsb->printf(" Output file..........%s, %d bpp, quality %d%s%s %s\n", UCS2toASCIIString(ucs2buf).c_str(), outputQuality, outputCompression, "%", al, t); + tsb->printf(" Output file..........%s, %d bpp, quality %d%s%s %s\n", UCS2toSysString(ucs2buf).c_str(), outputQuality, outputCompression, "%", al, t); else if (outputGrayscale) - tsb->printf(" Output file..........%s, grayscale%s %s\n", UCS2toASCIIString(ucs2buf).c_str(), al, t); + tsb->printf(" Output file..........%s, grayscale%s %s\n", UCS2toSysString(ucs2buf).c_str(), al, t); else - tsb->printf(" Output file..........%s, %d bpp%s %s\n", UCS2toASCIIString(ucs2buf).c_str(), outputQuality, al, t); + tsb->printf(" Output file..........%s, %d bpp%s %s\n", UCS2toSysString(ucs2buf).c_str(), outputQuality, al, t); if ((outputFormat != kPOVList_FileType_JPEG) && (outputFormat != kPOVList_FileType_OpenEXR)) { @@ -1766,7 +1766,7 @@ void FileMessage(TextStreamBuffer *tsb, int stream, POVMSObjectPtr msg) { // TODO FIXME: we ought to support UCS2 string output. POVMSUCS2String fn(filename); - string asciiFN(UCS2toASCIIString(fn)); + std::string asciiFN(UCS2toSysString(fn)); if((POVMSUtil_GetLong(msg, kPOVAttrib_Line, &ll) == kNoErr) && ((stream == WARNING_STREAM) || (stream == FATAL_STREAM))) { diff --git a/source/frontend/renderfrontend.h b/source/frontend/renderfrontend.h index 92ff2db22..63ac87518 100644 --- a/source/frontend/renderfrontend.h +++ b/source/frontend/renderfrontend.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 @@ -622,7 +622,7 @@ void RenderFrontend::StartRender(ViewId { Path outputpath(obj.TryGetUCS2String(kPOVAttrib_OutputPath, "")); UCS2String filename = obj.TryGetUCS2String(kPOVAttrib_OutputFile, ""); - string fn(UCS2toASCIIString(filename)); + std::string fn(UCS2toSysString(filename)); bool to_stdout = fn == "-" || fn == "stdout" || fn == "stderr"; if(obj.TryGetBool(kPOVAttrib_ContinueTrace, false) == true) diff --git a/source/frontend/simplefrontend.h b/source/frontend/simplefrontend.h index 6e39fcceb..65d2f0aed 100644 --- a/source/frontend/simplefrontend.h +++ b/source/frontend/simplefrontend.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 @@ -177,7 +177,7 @@ bool SimpleFrontend::Start(POVMS_Object } Path ip (opts.TryGetString(kPOVAttrib_InputFile, "")); - shelloutProcessing.reset(new ShelloutProcessing(opts, UCS2toASCIIString(ip.GetFile()), width, height)); + shelloutProcessing.reset(new ShelloutProcessing(opts, UCS2toSysString(ip.GetFile()), width, height)); state = kStarting; diff --git a/source/parser/fncode.cpp b/source/parser/fncode.cpp index 8ff603418..9032dda71 100644 --- a/source/parser/fncode.cpp +++ b/source/parser/fncode.cpp @@ -125,7 +125,7 @@ FNCode::FNCode(Parser *pa, FunctionCode *f, bool is_local, const char *n) if (n != nullptr) function->sourceInfo.name = n; else - function->sourceInfo.name = ""; + function->sourceInfo.name.clear(); function->sourceInfo.fileName = parser->CurrentFileName(); function->sourceInfo.position = parser->CurrentFilePosition(); function->flags = 0; @@ -1700,7 +1700,7 @@ void FNCode::compile_variable(char *name) unsigned int i = 0, found = MAX_K; // first, handle register parameters x,y,z,u and v - if(name[1] == 0) + if(name[1] == '\0') { if((name[0] == 'x') || (name[0] == 'u')) { diff --git a/source/parser/parser.cpp b/source/parser/parser.cpp index c2f16a009..4dbeb5a0b 100644 --- a/source/parser/parser.cpp +++ b/source/parser/parser.cpp @@ -6573,7 +6573,7 @@ TrueTypeFont *Parser::OpenFontFile(const char *asciifn, const int font_id, POV_U if (asciifn != nullptr) { - formalFilename = ASCIItoUCS2String(asciifn); + formalFilename = SysToUCS2String(asciifn); // First look to see if we have already opened this font (with the same character mapping). @@ -7346,7 +7346,7 @@ void Parser::Parse_Global_Settings() else VersionWarning(100,"Cannot both load and save photon map. Now switching to load mode."); } - sceneData->photonSettings.fileName = Parse_ASCIIString(true); + sceneData->photonSettings.fileName = Parse_SysString(true); sceneData->photonSettings.loadFile = true; END_CASE @@ -7358,7 +7358,7 @@ void Parser::Parse_Global_Settings() else VersionWarning(100,"Cannot both load and save photon map. Now switching to save mode."); } - sceneData->photonSettings.fileName = Parse_ASCIIString(true); + sceneData->photonSettings.fileName = Parse_SysString(true); sceneData->photonSettings.loadFile = false; END_CASE @@ -8728,7 +8728,7 @@ void Parser::Parse_Declare(bool is_local, bool after_hash) { UCS2String str(deprecation_message); POV_FREE(deprecation_message); - Temp_Entry->Deprecation_Message = POV_STRDUP(UCS2toASCIIString(str).c_str()); + Temp_Entry->Deprecation_Message = POV_STRDUP(UCS2toSysString(str).c_str()); } else { @@ -10720,7 +10720,7 @@ shared_ptr Parser::Locate_File(const UCS2String& filename, unsigned int if(foundfile.empty() == true) { if(err_flag == true) - PossibleError("Cannot find file '%s', even after trying to append file type extension.", UCS2toASCIIString(fn).c_str()); + PossibleError("Cannot find file '%s', even after trying to append file type extension.", UCS2toSysString(fn).c_str()); return nullptr; } @@ -10740,7 +10740,7 @@ shared_ptr Parser::Locate_File(const UCS2String& filename, unsigned int shared_ptr result(mFileResolver.ReadFile(fn, foundfile.c_str(), stype)); if ((result == nullptr) && (err_flag == true)) - PossibleError("Cannot open file '%s'.", UCS2toASCIIString(foundfile).c_str()); + PossibleError("Cannot open file '%s'.", UCS2toSysString(foundfile).c_str()); buffer = foundfile; @@ -10754,7 +10754,7 @@ shared_ptr Parser::Locate_File(const UCS2String& filename, unsigned int if(foundfile.empty() == true) { if(err_flag == true) - PossibleError("Cannot find file '%s', even after trying to append file type extension.", UCS2toASCIIString(filename).c_str()); + PossibleError("Cannot find file '%s', even after trying to append file type extension.", UCS2toSysString(filename).c_str()); return nullptr; } @@ -10762,7 +10762,7 @@ shared_ptr Parser::Locate_File(const UCS2String& filename, unsigned int shared_ptr result(mFileResolver.ReadFile(foundfile.c_str(), stype)); if ((result == nullptr) && (err_flag == true)) - PossibleError("Cannot open file '%s'.", UCS2toASCIIString(foundfile).c_str()); + PossibleError("Cannot open file '%s'.", UCS2toSysString(foundfile).c_str()); buffer = foundfile; diff --git a/source/parser/parser.h b/source/parser/parser.h index 4bfa6ac42..a882ec5bf 100644 --- a/source/parser/parser.h +++ b/source/parser/parser.h @@ -580,7 +580,7 @@ class Parser char *Parse_C_String(bool pathname = false); void ParseString(UTF8String& s, bool pathname = false); UCS2 *Parse_String(bool pathname = false, bool require = true); - std::string Parse_ASCIIString(bool pathname = false, bool require = true); + std::string Parse_SysString(bool pathname = false, bool require = true); UCS2 *String_Literal_To_UCS2(const std::string& str); UCS2 *String_To_UCS2(const char *str); diff --git a/source/parser/parser_expressions.cpp b/source/parser/parser_expressions.cpp index 8065485d4..96cfb3b9e 100644 --- a/source/parser/parser_expressions.cpp +++ b/source/parser/parser_expressions.cpp @@ -784,7 +784,7 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) Local_C_String=Parse_C_String(); - f = Locate_File(UCS2String(ASCIItoUCS2String(Local_C_String)), POV_File_Text_User, ign, false); + f = Locate_File(SysToUCS2String(Local_C_String), POV_File_Text_User, ign, false); Val = (f == nullptr) ? 0.0 : 1.0; f = nullptr; diff --git a/source/parser/parser_materials.cpp b/source/parser/parser_materials.cpp index 52ec4311d..9852661f6 100644 --- a/source/parser/parser_materials.cpp +++ b/source/parser/parser_materials.cpp @@ -304,7 +304,7 @@ ImageData *Parser::Parse_Image(int Legal, bool GammaCorrect) { UNGET Name = Parse_C_String(true); - UCS2String filename = ASCIItoUCS2String(Name); + UCS2String filename = SysToUCS2String(Name); UCS2String ext = GetFileExtension(Path(filename)); if (ext.empty() == false) @@ -363,7 +363,7 @@ ImageData *Parser::Parse_Image(int Legal, bool GammaCorrect) if(!(filetype & Legal)) Error("File type not supported here."); - UCS2String filename = ASCIItoUCS2String(Name); + UCS2String filename = SysToUCS2String(Name); Image::ReadOptions options; switch (sceneData->gammaMode) @@ -842,7 +842,7 @@ PatternPtr Parser::ParseDensityFilePattern() pattern->densityFile = Create_Density_File(); GET(DF3_TOKEN); pattern->densityFile->Data->Name = Parse_C_String(true); - shared_ptr dfile = Locate_File(ASCIItoUCS2String(pattern->densityFile->Data->Name).c_str(), POV_File_Data_DF3, dummy, true); + shared_ptr dfile = Locate_File(SysToUCS2String(pattern->densityFile->Data->Name).c_str(), POV_File_Data_DF3, dummy, true); if (dfile == nullptr) Error("Cannot read media density file."); Read_Density_File(dfile.get(), pattern->densityFile); diff --git a/source/parser/parser_obj.cpp b/source/parser/parser_obj.cpp index 76e9d4e86..c67c5d5da 100644 --- a/source/parser/parser_obj.cpp +++ b/source/parser/parser_obj.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 @@ -265,7 +265,7 @@ void Parser::Parse_Obj (Mesh* mesh) if (stream != nullptr) textStream = new IBufferedTextStream (fileName, stream.get()); if (!textStream) - Error ("Cannot open obj file %s.", UCS2toASCIIString(fileName).c_str()); + Error ("Cannot open obj file %s.", UCS2toSysString(fileName).c_str()); // mark end of buffer with a non-null character to identify situations where a word may not have fit entirely inside the buffer. wordBuffer[kMaxObjBufferSize-1] = '*'; @@ -302,13 +302,13 @@ void Parser::Parse_Obj (Mesh* mesh) while (HasMoreWords (textStream)) { if (!ReadFaceVertex (face.vertexList[vertex], wordBuffer, textStream)) - Error ("Invalid or unsupported face index data '%s' in obj file %s line %i", wordBuffer, UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + Error ("Invalid or unsupported face index data '%s' in obj file %s line %i", wordBuffer, UCS2toSysString(fileName).c_str(), (int)textStream->line()); if (face.vertexList[vertex].vertexId > vertexList.size()) - Error ("Vertex index out of range in obj file %s line %i", UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + Error ("Vertex index out of range in obj file %s line %i", UCS2toSysString(fileName).c_str(), (int)textStream->line()); if (face.vertexList[vertex].uvId > uvList.size()) - Error ("UV index out of range in obj file %s line %i", UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + Error ("UV index out of range in obj file %s line %i", UCS2toSysString(fileName).c_str(), (int)textStream->line()); if (face.vertexList[vertex].normalId > normalList.size()) - Error ("Normal index out of range in obj file %s line %i", UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + Error ("Normal index out of range in obj file %s line %i", UCS2toSysString(fileName).c_str(), (int)textStream->line()); ++haveVertices; if (face.vertexList[vertex].uvId > 0) ++haveUV; @@ -328,15 +328,15 @@ void Parser::Parse_Obj (Mesh* mesh) } if ((haveVertices > 3) && !havePolygonFaces) { - Warning ("Non-triangular faces found in obj file %s. Faces will only import properly if they are convex and planar.", UCS2toASCIIString(fileName).c_str()); + Warning ("Non-triangular faces found in obj file %s. Faces will only import properly if they are convex and planar.", UCS2toSysString(fileName).c_str()); havePolygonFaces = true; } if (haveVertices < 3) - Error ("Insufficient number of vertices per face in obj file %s line %i", UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + Error ("Insufficient number of vertices per face in obj file %s line %i", UCS2toSysString(fileName).c_str(), (int)textStream->line()); if ((haveUV != 0) && (haveUV != haveVertices)) - Error ("Inconsistent use of UV indices in obj file %s line %i", UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + Error ("Inconsistent use of UV indices in obj file %s line %i", UCS2toSysString(fileName).c_str(), (int)textStream->line()); if ((haveNormal != 0) && (haveNormal != haveVertices)) - Error ("Inconsistent use of normal indices in obj file %s line %i", UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + Error ("Inconsistent use of normal indices in obj file %s line %i", UCS2toSysString(fileName).c_str(), (int)textStream->line()); if (haveNormal > 0) faceList.push_back (face); else @@ -358,7 +358,7 @@ void Parser::Parse_Obj (Mesh* mesh) if (strcmp (wordBuffer, "usemtl") == 0) { if (!ReadWord (wordBuffer, textStream)) - Error ("Invalid material name '%s' in obj file %s line %i", wordBuffer, UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + Error ("Invalid material name '%s' in obj file %s line %i", wordBuffer, UCS2toSysString(fileName).c_str(), (int)textStream->line()); for (materialId = 0; materialId < materialList.size(); ++materialId) { if (materialList[materialId].mtlName.compare (wordBuffer) == 0) @@ -391,7 +391,7 @@ void Parser::Parse_Obj (Mesh* mesh) for (int dimension = X; dimension <= Z; ++dimension) { if (!ReadFloat (v3[dimension], wordBuffer, textStream)) - Error ("Invalid coordinate value '%s' in obj file %s line %i", wordBuffer, UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + Error ("Invalid coordinate value '%s' in obj file %s line %i", wordBuffer, UCS2toSysString(fileName).c_str(), (int)textStream->line()); } vertexList.push_back (v3); break; @@ -400,7 +400,7 @@ void Parser::Parse_Obj (Mesh* mesh) for (int dimension = X; dimension <= Z; ++dimension) { if (!ReadFloat (v3[dimension], wordBuffer, textStream)) - Error ("Invalid coordinate value '%s' in obj file %s line %i", wordBuffer, UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + Error ("Invalid coordinate value '%s' in obj file %s line %i", wordBuffer, UCS2toSysString(fileName).c_str(), (int)textStream->line()); } normalList.push_back (v3); break; @@ -409,7 +409,7 @@ void Parser::Parse_Obj (Mesh* mesh) for (int dimension = X; dimension <= Y; ++dimension) { if (!ReadFloat (v2[dimension], wordBuffer, textStream)) - Error ("Invalid coordinate value '%s' in obj file %s line %i", wordBuffer, UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + Error ("Invalid coordinate value '%s' in obj file %s line %i", wordBuffer, UCS2toSysString(fileName).c_str(), (int)textStream->line()); } uvList.push_back (v2); break; @@ -421,18 +421,18 @@ void Parser::Parse_Obj (Mesh* mesh) if (unsupportedCmd) { - Warning("Unsupported command '%s' skipped in obj file %s line %i.", wordBuffer, UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + Warning("Unsupported command '%s' skipped in obj file %s line %i.", wordBuffer, UCS2toSysString(fileName).c_str(), (int)textStream->line()); skipLine = true; } if (!skipLine && HasMoreWords (textStream)) - PossibleError("Unexpected extra data skipped in obj file %s line %i.", UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + PossibleError("Unexpected extra data skipped in obj file %s line %i.", UCS2toSysString(fileName).c_str(), (int)textStream->line()); // skip remainder of line AdvanceLine (textStream); if (wordBuffer[kMaxObjBufferSize-1] == '\0') - PossibleError("Excessively long data in obj file %s line %i.", UCS2toASCIIString(fileName).c_str(), (int)textStream->line()); + PossibleError("Excessively long data in obj file %s line %i.", UCS2toSysString(fileName).c_str(), (int)textStream->line()); } // close obj file diff --git a/source/parser/parser_strings.cpp b/source/parser/parser_strings.cpp index 8fa3173c3..a7de2f5f9 100644 --- a/source/parser/parser_strings.cpp +++ b/source/parser/parser_strings.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 @@ -242,10 +242,10 @@ UCS2 *Parser::Parse_String(bool pathname, bool require) //**************************************************************************** -std::string Parser::Parse_ASCIIString(bool pathname, bool require) +std::string Parser::Parse_SysString(bool pathname, bool require) { UCS2 *cstr = Parse_String(pathname, require); - std::string ret(UCS2toASCIIString(cstr)); + std::string ret(UCS2toSysString(cstr)); POV_FREE(cstr); return ret; } @@ -1185,7 +1185,7 @@ UCS2 *Parser::UCS2_strdup(const UCS2 *s) { UCS2 *New; - New=reinterpret_cast(POV_MALLOC((UCS2_strlen(s)+1) * sizeof(UCS2), UCS2toASCIIString(s).c_str())); + New=reinterpret_cast(POV_MALLOC((UCS2_strlen(s)+1) * sizeof(UCS2), UCS2toSysString(s).c_str())); UCS2_strcpy(New,s); return (New); } diff --git a/source/parser/parser_tokenizer.cpp b/source/parser/parser_tokenizer.cpp index eef040b8a..06f17366b 100644 --- a/source/parser/parser_tokenizer.cpp +++ b/source/parser/parser_tokenizer.cpp @@ -1875,7 +1875,7 @@ void Parser::Open_Include() UCS2String formalFileName; // Name the file is known by to the user. asciiFileName = Parse_C_String(true); - formalFileName = ASCIItoUCS2String(asciiFileName); + formalFileName = SysToUCS2String(asciiFileName); POV_FREE(asciiFileName); IncludeHeader(formalFileName); @@ -2225,7 +2225,7 @@ void Parser::Invoke_Macro() { is = Locate_File (PMac->source.fileName, POV_File_Text_Macro, ign, true); if (is == nullptr) - Error ("Cannot open macro file '%s'.", UCS2toASCIIString(PMac->source.fileName).c_str()); + Error ("Cannot open macro file '%s'.", UCS2toSysString(PMac->source.fileName).c_str()); } mTokenizer.SetInputStream(is); } @@ -2521,7 +2521,7 @@ void Parser::Parse_Fopen(void) Entry->Data=reinterpret_cast(New); asciiFileName = Parse_C_String(true); - fileName = ASCIItoUCS2String(asciiFileName); + fileName = SysToUCS2String(asciiFileName); POV_FREE(asciiFileName); EXPECT_ONE @@ -2531,7 +2531,7 @@ void Parser::Parse_Fopen(void) if (rfile != nullptr) New->inTokenizer->SetInputStream(rfile); else - Error ("Cannot open user file %s (read).", UCS2toASCIIString(fileName).c_str()); + Error ("Cannot open user file %s (read).", UCS2toSysString(fileName).c_str()); END_CASE CASE(WRITE_TOKEN) @@ -2542,7 +2542,7 @@ void Parser::Parse_Fopen(void) New->Out_File = nullptr; if (New->Out_File == nullptr) - Error ("Cannot open user file %s (write).", UCS2toASCIIString(fileName).c_str()); + Error ("Cannot open user file %s (write).", UCS2toSysString(fileName).c_str()); END_CASE CASE(APPEND_TOKEN) @@ -2553,7 +2553,7 @@ void Parser::Parse_Fopen(void) New->Out_File = nullptr; if (New->Out_File == nullptr) - Error ("Cannot open user file %s (append).", UCS2toASCIIString(fileName).c_str()); + Error ("Cannot open user file %s (append).", UCS2toSysString(fileName).c_str()); END_CASE OTHERWISE @@ -2605,7 +2605,7 @@ void Parser::Parse_Read() Error ("Can't nest directives accessing the same file."); File_Id = POV_STRDUP(CurrentTokenText().c_str()); if (User_File->inTokenizer == nullptr) - Error("Cannot read from file %s because the file is open for writing only.", UCS2toASCIIString(UCS2String(User_File->Out_File->name())).c_str()); + Error("Cannot read from file %s because the file is open for writing only.", UCS2toSysString(UCS2String(User_File->Out_File->name())).c_str()); // Safeguard against accidental nesting of other file access directives inside the `#fopen` // directive (or the user forgetting portions of the directive). @@ -2692,7 +2692,7 @@ int Parser::Parse_Read_Value(DATA_FILE *User_File, TokenId Previous, TokenId *Nu bool ungetToken = false; if (User_File->inTokenizer == nullptr) - Error("Cannot read from file '%s' because the file is open for writing only.", UCS2toASCIIString(UCS2String(User_File->Out_File->name())).c_str()); + Error("Cannot read from file '%s' because the file is open for writing only.", UCS2toSysString(UCS2String(User_File->Out_File->name())).c_str()); if (User_File->ReadNextToken()) { @@ -2822,7 +2822,7 @@ void Parser::Parse_Write(void) if (User_File->busyParsing) Error ("Can't nest directives accessing the same file."); if (User_File->Out_File == nullptr) - Error("Cannot write to file %s because the file is open for reading only.", UCS2toASCIIString(User_File->inTokenizer->GetInputStreamName()).c_str()); + Error("Cannot write to file %s because the file is open for reading only.", UCS2toSysString(User_File->inTokenizer->GetInputStreamName()).c_str()); // Safeguard against accidental nesting of other file access directives inside the `#fopen` // directive (or the user forgetting portions of the directive). @@ -3135,7 +3135,7 @@ void Parser::IncludeHeader(const UCS2String& formalFileName) shared_ptr is = Locate_File (formalFileName.c_str(),POV_File_Text_INC,actualFileName,true); if (is == nullptr) - Error ("Cannot open include file %s.", UCS2toASCIIString(formalFileName).c_str()); + Error ("Cannot open include file %s.", UCS2toSysString(formalFileName).c_str()); SetInputStream(is); diff --git a/source/povmain.cpp b/source/povmain.cpp index 6e0eb3a0c..acf16adfd 100644 --- a/source/povmain.cpp +++ b/source/povmain.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 @@ -187,7 +187,7 @@ int main(int argc, char **argv) { UCS2 *outputini = new UCS2[l]; if(POVMSUtil_GetUCS2String(&obj, kPOVAttrib_CreateIni, outputini, &l) == kNoErr) - renderoptions.WriteFile(UCS2toASCIIString(outputini).c_str(), &obj); + renderoptions.WriteFile(UCS2toSysString(outputini).c_str(), &obj); } POVMS_Object optionsobj(obj); diff --git a/source/povms/povmscpp.cpp b/source/povms/povmscpp.cpp index 88d2cbd33..f1ceafcbd 100644 --- a/source/povms/povmscpp.cpp +++ b/source/povms/povmscpp.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 @@ -48,14 +48,14 @@ const POVMSType kPOVMSRawStreamEncoding = 'RAWS'; const POVMSType kPOVMSGZipStreamEncoding = 'GZIP'; -POVMSUCS2String POVMS_ASCIItoUCS2String(const char *s) +POVMSUCS2String POVMS_SysToUCS2String(const char *s) { POVMSUCS2String r; unsigned char ch; if (s != nullptr) { - while(*s != 0) + while(*s != '\0') { ch = *s++; r += (POVMSUCS2)(ch); @@ -65,13 +65,13 @@ POVMSUCS2String POVMS_ASCIItoUCS2String(const char *s) return r; } -std::string POVMS_UCS2toASCIIString(const POVMSUCS2String& s) +std::string POVMS_UCS2toSysString(const POVMSUCS2String& s) { std::string r; for(std::size_t i = 0; i < s.length(); i++) { - if(s[i] >= 256) + if(s[i] > 0xFFu) r += ' '; else r += (char)(s[i]); @@ -1267,7 +1267,7 @@ POVMSUCS2String POVMS_Object::TryGetUCS2String(POVMSType key, const char *alt) if(Exist(key) == true) return GetUCS2String(key); - return POVMS_ASCIItoUCS2String(alt); + return POVMS_SysToUCS2String(alt); } POVMSUCS2String POVMS_Object::TryGetUCS2String(POVMSType key, const POVMSUCS2String& alt) diff --git a/source/povms/povmscpp.h b/source/povms/povmscpp.h index f0e7c44f4..685437282 100644 --- a/source/povms/povmscpp.h +++ b/source/povms/povmscpp.h @@ -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 @@ -55,8 +55,8 @@ class POVMS_MessageReceiver; typedef std::basic_string POVMSUCS2String; -POVMSUCS2String POVMS_ASCIItoUCS2String(const char *s); -std::string POVMS_UCS2toASCIIString(const POVMSUCS2String& s); +POVMSUCS2String POVMS_SysToUCS2String(const char *s); +std::string POVMS_UCS2toSysString(const POVMSUCS2String& s); class POVMS_Container { diff --git a/vfe/unix/unixconsole.cpp b/vfe/unix/unixconsole.cpp index f35a283a9..7d821f5a3 100644 --- a/vfe/unix/unixconsole.cpp +++ b/vfe/unix/unixconsole.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 @@ -372,7 +372,7 @@ Press to continue or to abort.\n\ Delay(20); } - string basename = UCS2toASCIIString(session->CreateTemporaryFile()); + string basename = UCS2toSysString(session->CreateTemporaryFile()); ini = basename + ".ini"; pov = basename + ".pov"; if (pov::Write_Benchmark_File(pov.c_str(), ini.c_str())) @@ -393,9 +393,9 @@ Press to continue or to abort.\n\ static void CleanupBenchmark(vfeUnixSession *session, string& ini, string& pov) { fprintf(stderr, "%s: removing %s\n", PACKAGE, ini.c_str()); - session->DeleteTemporaryFile(ASCIItoUCS2String(ini.c_str())); + session->DeleteTemporaryFile(SysToUCS2String(ini.c_str())); fprintf(stderr, "%s: removing %s\n", PACKAGE, pov.c_str()); - session->DeleteTemporaryFile(ASCIItoUCS2String(pov.c_str())); + session->DeleteTemporaryFile(SysToUCS2String(pov.c_str())); } int main (int argc, char **argv) diff --git a/vfe/unix/vfeplatform.cpp b/vfe/unix/vfeplatform.cpp index 322ca9856..828270c58 100644 --- a/vfe/unix/vfeplatform.cpp +++ b/vfe/unix/vfeplatform.cpp @@ -10,7 +10,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 @@ -137,7 +137,7 @@ namespace vfePlatform // *nix platforms might want to just return "/tmp/" here. UCS2String vfeUnixSession::GetTemporaryPath(void) const { - return ASCIItoUCS2String (m_OptionsProc->GetTemporaryPath().c_str()); + return SysToUCS2String(m_OptionsProc->GetTemporaryPath()); } ///////////////////////////////////////////////////////////////////////// @@ -151,7 +151,7 @@ namespace vfePlatform std::snprintf(str, sizeof(str), "%spov%d", m_OptionsProc->GetTemporaryPath().c_str(), getpid ()); POV_DELETE_FILE (str); - return ASCIItoUCS2String (str); + return SysToUCS2String(str); } ///////////////////////////////////////////////////////////////////////// @@ -160,7 +160,7 @@ namespace vfePlatform // example doesn't do that but it's not a bad idea to add. void vfeUnixSession::DeleteTemporaryFile(const UCS2String& filename) const { - POV_DELETE_FILE (UCS2toASCIIString (filename).c_str()); + POV_DELETE_FILE (UCS2toSysString (filename).c_str()); } ////////////////////////////////////////////////////////////// @@ -289,7 +289,7 @@ namespace vfePlatform if (!m_OptionsProc->isIORestrictionsEnabled(isWrite)) return true; - string FullFnm = m_OptionsProc->CanonicalizePath(UCS2toASCIIString(file())); + string FullFnm = m_OptionsProc->CanonicalizePath(UCS2toSysString(file())); if(FullFnm.length() == 0) return false; @@ -302,7 +302,7 @@ namespace vfePlatform { if (TestPath(it->GetPath(), fullPath, it->IsRecursive())) { - m_OptionsProc->IORestrictionsError(UCS2toASCIIString(file()), isWrite, false); + m_OptionsProc->IORestrictionsError(UCS2toSysString(file()), isWrite, false); return (false) ; } } @@ -322,7 +322,7 @@ namespace vfePlatform if (TestPath(it->GetPath(), fullPath, it->IsRecursive())) return (true) ; - m_OptionsProc->IORestrictionsError(UCS2toASCIIString(file()), isWrite, true); + m_OptionsProc->IORestrictionsError(UCS2toSysString(file()), isWrite, true); return (false); } diff --git a/vfe/unix/vfeplatform.h b/vfe/unix/vfeplatform.h index ff9fbf05f..866370dd7 100644 --- a/vfe/unix/vfeplatform.h +++ b/vfe/unix/vfeplatform.h @@ -10,7 +10,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 @@ -110,8 +110,8 @@ namespace vfePlatform /////////////////////////////////////////////////////////////////////// // 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. + // of file. does not support relative paths, and will + // perform case-sensitive comparisons. virtual bool TestPath(const Path& path, const Path& file, bool recursive) const; /////////////////////////////////////////////////////////////////////// diff --git a/vfe/vfe.cpp b/vfe/vfe.cpp index e02c528a1..5c3811d28 100644 --- a/vfe/vfe.cpp +++ b/vfe/vfe.cpp @@ -10,7 +10,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 @@ -97,12 +97,12 @@ POVMSMessageDetails::POVMSMessageDetails (POVMS_Object& Obj) Line = Col = 0 ; Offset = -1 ; - ubuffer[0] = 0 ; + ubuffer[0] = '\0'; if (POVMSUtil_GetUCS2String (msg, kPOVAttrib_FileName, ubuffer, &l) == kNoErr) { UCS2File = ubuffer ; - File = UCS2toASCIIString (UCS2File); + File = UCS2toSysString(UCS2File); } if (POVMSUtil_GetLong (msg, kPOVAttrib_Line, &ll) == kNoErr) Line = POVMSInt(ll) ; @@ -631,7 +631,7 @@ bool VirtualFrontEnd::Start(POVMS_Object& opts) m_PostPauseState = kReady; Path ip (m_Session->GetInputFilename()); - shelloutProcessing.reset(m_Session->CreateShelloutProcessing(opts, UCS2toASCIIString(ip.GetFile()), m_Session->GetRenderWidth(), m_Session->GetRenderHeight())) ; + shelloutProcessing.reset(m_Session->CreateShelloutProcessing(opts, UCS2toSysString(ip.GetFile()), m_Session->GetRenderWidth(), m_Session->GetRenderHeight())) ; shelloutProcessing->SetCancelMessage("Render halted because the %1% shell-out ('%6%') requested POV-Ray to %5%."); shelloutProcessing->SetSkipMessage("The %1% shell-out ('%3%') requested POV-Ray to %2%."); @@ -651,7 +651,7 @@ bool VirtualFrontEnd::Start(POVMS_Object& opts) POVMS_Object input_file_name(kPOVMSType_WildCard); input_file_name.SetString(kPOVAttrib_Identifier, "input_file_name"); - input_file_name.SetString(kPOVAttrib_Value, UCS2toASCIIString(ip.GetFile()).c_str()); + input_file_name.SetString(kPOVAttrib_Value, UCS2toSysString(ip.GetFile()).c_str()); declares.Append(input_file_name); int initialFrame = opts.TryGetInt (kPOVAttrib_InitialFrame, 0) ; @@ -716,11 +716,11 @@ bool VirtualFrontEnd::Start(POVMS_Object& opts) if (imageProcessing->OutputIsStdout() == false && imageProcessing->OutputIsStderr() == false && m_Session->TestAccessAllowed(filename, true) == false) { string str ("IO Restrictions prohibit write access to '") ; - str += UCS2toASCIIString(filename); + str += UCS2toSysString(filename); str += "'"; throw POV_EXCEPTION(kCannotOpenFileErr, str); } - shelloutProcessing->SetOutputFile(UCS2toASCIIString(filename)); + shelloutProcessing->SetOutputFile(UCS2toSysString(filename)); m_Session->AdviseOutputFilename (filename); } } @@ -954,11 +954,11 @@ State VirtualFrontEnd::Process() if (m_Session->TestAccessAllowed(filename, true) == false) { string str ("IO Restrictions prohibit write access to '"); - str += UCS2toASCIIString(filename); + str += UCS2toSysString(filename); str += "'"; throw POV_EXCEPTION(kCannotOpenFileErr, str); } - shelloutProcessing->SetOutputFile(UCS2toASCIIString(filename)); + shelloutProcessing->SetOutputFile(UCS2toSysString(filename)); m_Session->AdviseOutputFilename (filename); } m_Session->AppendAnimationStatus (frameId, frame, animationProcessing->GetTotalFramesToRender(), filename); @@ -1397,7 +1397,7 @@ bool VirtualFrontEnd::Paused (void) int Allow_File_Write (const UCS2 *Filename, const unsigned int FileType) { - if (strcmp(UCS2toASCIIString(Filename).c_str(), "stdout") == 0 || strcmp(UCS2toASCIIString(Filename).c_str(), "stderr") == 0) + if (strcmp(UCS2toSysString(Filename).c_str(), "stdout") == 0 || strcmp(UCS2toSysString(Filename).c_str(), "stderr") == 0) return true; return (vfeSession::GetSessionFromThreadID()->TestAccessAllowed(Filename, true)); } @@ -1409,12 +1409,12 @@ int Allow_File_Read (const UCS2 *Filename, const unsigned int FileType) FILE *vfeFOpen (const UCS2String& name, const char *mode) { - return (fopen (UCS2toASCIIString (name).c_str(), mode)) ; + return (fopen (UCS2toSysString (name).c_str(), mode)) ; } bool vfeRemove(const UCS2String& Filename) { - return (POV_DELETE_FILE (UCS2toASCIIString (Filename).c_str()) == 0); + return (POV_DELETE_FILE (UCS2toSysString (Filename).c_str()) == 0); } } diff --git a/vfe/vfecontrol.cpp b/vfe/vfecontrol.cpp index da146621d..91531aeae 100644 --- a/vfe/vfecontrol.cpp +++ b/vfe/vfecontrol.cpp @@ -10,7 +10,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 @@ -68,7 +68,7 @@ static int GetUCS2String(POVMSObjectPtr object, POVMSType key, char *result, int UCS2 *str = new UCS2 [*maxlen] ; int err = POVMSUtil_GetUCS2String (object, key, str, maxlen) ; if (err == kNoErr) - strcpy (result, UCS2toASCIIString (str).c_str ()) ; + strcpy (result, UCS2toSysString (str).c_str ()) ; delete[] str ; return err ; } @@ -240,7 +240,7 @@ int vfeSession::SetOptions (vfeRenderOptions& opts) if (!TestAccessAllowed (Path(*i), false)) return (m_LastError = vfeIORestrictionDeny); - if ((err = options.ParseFile (UCS2toASCIIString(*i).c_str(), &obj)) != kNoErr) + if ((err = options.ParseFile (UCS2toSysString(*i).c_str(), &obj)) != kNoErr) return (m_LastError = vfeFailedToParseINI) ; // we keep this up to date since the IO permissions feature will use the current input @@ -292,7 +292,7 @@ int vfeSession::SetOptions (vfeRenderOptions& opts) // we use the Path equivalence operator rather than a string compare since // using Path should handle platform-specific issues like case-sensitivity (or, // rather, lack thereof). note that at the time of writing, the Path class did - // not yet implement case-insensitive comparisions. + // not yet implement case-insensitive comparisons. // // NB while it would of course be more efficient to sort the list so searches are // faster, we'd have to make a copy of it to do that, as we can't change the order @@ -390,8 +390,8 @@ int vfeSession::SetOptions (vfeRenderOptions& opts) } n = sizeof (str) ; - if ((err = POVMSUtil_GetUCS2String (&obj, kPOVAttrib_CreateIni, str, &n)) == kNoErr && str [0] != 0) - if ((err = options.WriteFile (UCS2toASCIIString(str).c_str(), &obj)) != kNoErr) + if ((err = POVMSUtil_GetUCS2String (&obj, kPOVAttrib_CreateIni, str, &n)) == kNoErr && str [0] != '\0') + if ((err = options.WriteFile (UCS2toSysString(str).c_str(), &obj)) != kNoErr) return (m_LastError = vfeFailedToWriteINI); opts.m_Options = ropts; @@ -497,7 +497,7 @@ int vfeSession::StartRender() { vfeProcessRenderOptions options(this); POVMSObject obj = *m_RenderOptions.GetOptions(); - if (options.WriteFile (UCS2toASCIIString(fn).c_str(), &obj) != kNoErr) + if (options.WriteFile (UCS2toSysString(fn).c_str(), &obj) != kNoErr) return (m_LastError = vfeFailedToWriteINI); } } diff --git a/vfe/vfesession.cpp b/vfe/vfesession.cpp index 2a5c79603..9d8f4a638 100644 --- a/vfe/vfesession.cpp +++ b/vfe/vfesession.cpp @@ -10,7 +10,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 @@ -427,7 +427,7 @@ bool vfeSession::GetNextNonStatusMessage (MessageType &Type, string& Message, st UCS2String str; bool result = GetNextNonStatusMessage (Type, Message, str, Line, Col); if (result) - File = UCS2toASCIIString(str); + File = UCS2toSysString(str); return result; } diff --git a/vfe/vfesession.h b/vfe/vfesession.h index e5a4c0988..023c33f9a 100644 --- a/vfe/vfesession.h +++ b/vfe/vfesession.h @@ -11,7 +11,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 @@ -71,7 +71,7 @@ namespace vfe IOPath(const Path& path, bool recursive) : m_Path(path), m_Recursive(recursive) {} // construct an IOPath given a std::string path and a recursion flag. - IOPath(const string& path, bool recursive) : m_Path(Path(ASCIItoUCS2String(path.c_str()))), m_Recursive(recursive) {} + IOPath(const string& path, bool recursive) : m_Path(Path(SysToUCS2String(path))), m_Recursive(recursive) {} // construct an IOPath given a UCS2String Path and a recursion flag. IOPath(const UCS2String& path, bool recursive) : m_Path(path), m_Recursive(recursive) {} @@ -150,7 +150,7 @@ namespace vfe void ClearLibraryPaths() { m_LibraryPaths.clear(); } // Add a library path given a std::string. - void AddLibraryPath(const string& Path) { m_LibraryPaths.push_back(ASCIItoUCS2String(Path.c_str())); } + void AddLibraryPath(const string& Path) { m_LibraryPaths.push_back(SysToUCS2String(Path)); } // Add a library path given a UCS2String. void AddLibraryPath(const UCS2String& Path) { m_LibraryPaths.push_back(Path); } @@ -171,7 +171,7 @@ namespace vfe // Set the source file to be parsed (must be an SDL file, INI not // permitted). The file is specified as a std::string full or relative // path, with optional extension. - void SetSourceFile(const string& File) { m_SourceFile = ASCIItoUCS2String(File.c_str()); } + void SetSourceFile(const string& File) { m_SourceFile = SysToUCS2String(File); } // Returns a const reference to the currently set source file (may be // an empty string). Return type is a const reference to a UCS2String. @@ -183,7 +183,7 @@ namespace vfe // Adds the supplied std::string to the list of INI files to be read // prior to the start of the render. The files are processed in the // order in which they are added to this list. - void AddINI(const string& File) { m_IniFiles.push_back(ASCIItoUCS2String(File.c_str())); } + void AddINI(const string& File) { m_IniFiles.push_back(SysToUCS2String(File)); } // Adds the supplied UCS2String to the list of INI files to be read // prior to the start of the render. The files are processed in the diff --git a/vfe/win/vfeplatform.cpp b/vfe/win/vfeplatform.cpp index 790399574..d81569554 100644 --- a/vfe/win/vfeplatform.cpp +++ b/vfe/win/vfeplatform.cpp @@ -10,7 +10,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 @@ -147,7 +147,7 @@ namespace vfePlatform // *nix platforms might want to just return "/tmp/" here. UCS2String vfeWinSession::GetTemporaryPath(void) const { - return ASCIItoUCS2String(m_TempPathString.c_str()); + return SysToUCS2String(m_TempPathString); } ///////////////////////////////////////////////////////////////////////// @@ -161,7 +161,7 @@ namespace vfePlatform GetTempFileName (m_TempPathString.c_str(), "pv", 0, str) ; remove (str) ; m_TempFilenames.push_back(str); - return (ASCIItoUCS2String (str)) ; + return SysToUCS2String(str); } ///////////////////////////////////////////////////////////////////////// @@ -170,7 +170,7 @@ namespace vfePlatform // example doesn't do that but it's not a bad idea to add. void vfeWinSession::DeleteTemporaryFile(const UCS2String& filename) const { - remove (UCS2toASCIIString (filename).c_str()); + remove (UCS2toSysString (filename).c_str()); } ////////////////////////////////////////////////////////////// @@ -255,17 +255,17 @@ namespace vfePlatform ///////////////////////////////////////////////////////////////////////// // this really should take the codepage into consideration and not convert - // to an ASCII string. + // to an ASCII/Latin-1 string. bool vfeWinSession::StrCompareIC (const UCS2String& lhs, const UCS2String& rhs) const { - return (_stricmp (UCS2toASCIIString(lhs).c_str(), UCS2toASCIIString(rhs).c_str()) == 0); + return (_stricmp (UCS2toSysString(lhs).c_str(), UCS2toSysString(rhs).c_str()) == 0); } ///////////////////////////////////////////////////////////////////////// // 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. + // Latin-1 and perform case-insensitive comparisons. bool vfeWinSession::TestPath (const Path& path, const Path& file, bool recursive) const { // we don't support relative paths @@ -307,7 +307,7 @@ namespace vfePlatform if (isWrite == false && GetReadPaths().empty() == true) returnOK = true; - int n = GetFullPathName (UCS2toASCIIString(file()).c_str(), sizeof (buf), buf, &s); + int n = GetFullPathName (UCS2toSysString(file()).c_str(), sizeof (buf), buf, &s); if ((n == 0) || (n > sizeof(buf)) || (s == nullptr) || (s == buf)) { if (returnOK == true) @@ -393,7 +393,7 @@ namespace vfePlatform } } else - n = GetFullPathName (UCS2toASCIIString(m_InputFilename).c_str(), sizeof (buf), buf, &s); + n = GetFullPathName (UCS2toSysString(m_InputFilename).c_str(), sizeof (buf), buf, &s); if ((n == 0) || (n > sizeof(buf)) || (s == nullptr) || (s == buf)) { // TODO: issue appropriate error message diff --git a/vfe/win/vfeplatform.h b/vfe/win/vfeplatform.h index 1b73faf79..cbf76b89c 100644 --- a/vfe/win/vfeplatform.h +++ b/vfe/win/vfeplatform.h @@ -10,7 +10,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 @@ -111,7 +111,7 @@ namespace vfePlatform // 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. + // Latin-1 and perform case-insensitive comparisons. virtual bool TestPath(const Path& path, const Path& file, bool recursive) const; /////////////////////////////////////////////////////////////////////// diff --git a/windows/pvengine.cpp b/windows/pvengine.cpp index 54bb5730e..174425856 100644 --- a/windows/pvengine.cpp +++ b/windows/pvengine.cpp @@ -10,7 +10,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 @@ -1882,7 +1882,7 @@ int GetUCS2String(POVMSObjectPtr object, POVMSType key, char *result, int *maxle int err = POVMSUtil_GetUCS2String (object, key, str, maxlen) ; if (err == kNoErr) { - string abc = UCS2toASCIIString (str) ; + std::string abc = UCS2toSysString (str) ; strcpy (result, abc.c_str ()) ; } delete str ; @@ -2175,7 +2175,7 @@ bool start_rendering (bool ignore_source_file) if (opts.GetOptions().TryGetInt(kPOVAttrib_RenderBlockSize, 32) < 4) throw POV_EXCEPTION (kParseErr, "Minimum permitted render block size is 4 (+BS4 or Render_Block_Size=4)") ; - InputFileName = UCS2toASCIIString (Session.GetInputFilename()); + InputFileName = UCS2toSysString (Session.GetInputFilename()); output_to_file = opts.GetOptions().TryGetBool(kPOVAttrib_OutputToFile, true) ; render_width = Session.GetRenderWidth(); render_height = Session.GetRenderHeight(); @@ -2417,7 +2417,7 @@ void render_stopped (void) } if (!running_demo && !demo_mode && !benchmark_mode && !rendering_insert_menu && !running_benchmark && !was_insert_render) { - string ofn = UCS2toASCIIString (Session.GetOutputFilename()); + string ofn = UCS2toSysString (Session.GetOutputFilename()); if (output_to_file && ofn.size () != 0) { sprintf (str, "Output -> '%s'", ofn.c_str ()) ; From 1fa6d36054863b4920b487235d9e76be473aa26c Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Tue, 29 Jan 2019 23:37:16 +0100 Subject: [PATCH 06/13] [parser] Fix "uncategorized error" in nested array initializers. --- source/parser/parser_tokenizer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/parser/parser_tokenizer.cpp b/source/parser/parser_tokenizer.cpp index 06f17366b..49cb6a218 100644 --- a/source/parser/parser_tokenizer.cpp +++ b/source/parser/parser_tokenizer.cpp @@ -2302,7 +2302,7 @@ Parser::POV_ARRAY *Parser::Parse_Array_Declare (void) i=0; j=1; - POV_EXPERIMENTAL_ASSERT(IsOkToDeclare()); + bool oldOkToDeclare = IsOkToDeclare(); SetOkToDeclare(false); while (Parse_Square_Begin(false)) @@ -2363,7 +2363,7 @@ Parser::POV_ARRAY *Parser::Parse_Array_Declare (void) END_CASE END_EXPECT - SetOkToDeclare(true); + SetOkToDeclare(oldOkToDeclare); return(New); }; From 5219e71cf09f586faa3cee013468f5083231ecff Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Fri, 1 Feb 2019 04:02:08 +0100 Subject: [PATCH 07/13] Miscellaneous code cleanup / modernization. - Make liberal use of C++11 `override` and `final` specifiers. - Replace various `typedef struct` with plain structs and `using` declarations. - Change include hierarchy, now using dedicated forward declaration headers. - Refactor (non-)portable portions of radiosity octree code, and add truly portable alternative implementations. - Some odds and ends. --- platform/unix/syspovfilesystem.cpp | 175 ++ platform/unix/syspovfilesystem.h | 72 + platform/unix/syspovtimer.cpp | 4 +- platform/unix/syspovtimer.h | 5 +- platform/windows/osversioninfo.cpp | 3 +- platform/windows/osversioninfo.h | 5 +- platform/windows/syspovfilesystem.cpp | 212 +++ platform/windows/syspovpath.cpp | 9 +- platform/windows/syspovpath.h | 3 +- platform/windows/syspovtask.cpp | 5 +- platform/windows/syspovtask.h | 3 +- platform/windows/syspovtimer.cpp | 6 +- platform/windows/syspovtimer.h | 5 +- platform/x86/avx/avxnoise.cpp | 5 +- platform/x86/avx/avxnoise.h | 3 +- platform/x86/avx/avxportablenoise.cpp | 6 +- platform/x86/avx/avxportablenoise.h | 3 +- platform/x86/avx2fma3/avx2fma3noise.cpp | 5 +- platform/x86/avx2fma3/avx2fma3noise.h | 3 +- platform/x86/avxfma4/avxfma4noise.cpp | 5 +- platform/x86/avxfma4/avxfma4noise.h | 3 +- platform/x86/cpuid.cpp | 15 +- platform/x86/cpuid.h | 10 +- platform/x86/optimizednoise.cpp | 3 +- source-doc/styleguide.md | 10 + source/backend/bounding/boundingtask.cpp | 42 +- source/backend/bounding/boundingtask.h | 40 +- source/backend/configbackend.h | 1 + source/backend/control/benchmark.cpp | 19 +- source/backend/control/benchmark.h | 20 +- source/backend/control/messagefactory.cpp | 23 +- source/backend/control/messagefactory.h | 19 +- source/backend/control/messagefactory_fwd.h | 51 + source/backend/control/parsertask.cpp | 14 +- source/backend/control/parsertask.h | 12 +- source/backend/control/renderbackend.cpp | 28 +- source/backend/control/renderbackend.h | 39 +- source/backend/control/scene.cpp | 47 +- source/backend/control/scene.h | 43 +- source/backend/control/scene_fwd.h | 51 + source/backend/frame.h | 167 -- .../backend/lighting/photonestimationtask.cpp | 24 +- .../backend/lighting/photonestimationtask.h | 41 +- .../lighting/photonshootingstrategy.cpp | 25 +- .../backend/lighting/photonshootingstrategy.h | 43 +- .../lighting/photonshootingstrategy_fwd.h | 51 + .../backend/lighting/photonshootingtask.cpp | 22 +- source/backend/lighting/photonshootingtask.h | 47 +- source/backend/lighting/photonsortingtask.cpp | 40 +- source/backend/lighting/photonsortingtask.h | 51 +- .../backend/lighting/photonstrategytask.cpp | 30 +- source/backend/lighting/photonstrategytask.h | 46 +- source/backend/povray.cpp | 29 +- source/backend/povray.h | 14 +- source/backend/precomp.h | 10 +- source/backend/render/radiositytask.cpp | 31 +- source/backend/render/radiositytask.h | 35 +- source/backend/render/rendertask.cpp | 27 +- source/backend/render/rendertask.h | 30 +- source/backend/render/tracetask.cpp | 52 +- source/backend/render/tracetask.h | 42 +- source/backend/scene/backendscenedata.cpp | 31 +- source/backend/scene/backendscenedata.h | 27 +- source/backend/scene/backendscenedata_fwd.h | 51 + source/backend/scene/view.cpp | 31 +- source/backend/scene/view.h | 70 +- source/backend/scene/view_fwd.h | 52 + source/backend/scene/viewthreaddata.cpp | 21 +- source/backend/scene/viewthreaddata.h | 33 +- source/backend/scene/viewthreaddata_fwd.h | 51 + source/backend/support/task.cpp | 32 +- source/backend/support/task.h | 43 +- source/backend/support/taskqueue.cpp | 27 +- source/backend/support/taskqueue.h | 38 +- source/base/animation/animation.cpp | 28 +- source/base/animation/animation.h | 33 +- source/base/animation/moov.cpp | 37 +- source/base/animation/moov.h | 31 +- source/base/base_fwd.h | 59 + source/base/colour.cpp | 10 +- source/base/colour.h | 114 +- source/base/configbase.h | 171 +- source/base/fileinputoutput.cpp | 24 +- source/base/fileinputoutput.h | 80 +- source/base/fileinputoutput_fwd.h | 52 + source/base/filesystem.cpp | 208 +++ source/base/filesystem.h | 217 +++ source/base/filesystem_fwd.h | 61 + source/base/fileutil.cpp | 19 +- source/base/fileutil.h | 20 +- source/base/image/bmp.cpp | 40 +- source/base/image/bmp.h | 17 +- source/base/image/colourspace.cpp | 21 +- source/base/image/colourspace.h | 122 +- source/base/image/colourspace_fwd.h | 60 + source/base/image/dither.cpp | 15 +- source/base/image/dither.h | 42 +- source/base/image/dither_fwd.h | 55 + source/base/image/encoding.cpp | 44 +- source/base/image/encoding.h | 53 +- source/base/image/gif.cpp | 37 +- source/base/image/gif.h | 15 +- source/base/image/gifdecod.cpp | 28 +- source/base/image/hdr.cpp | 34 +- source/base/image/hdr.h | 17 +- source/base/image/iff.cpp | 52 +- source/base/image/iff.h | 15 +- source/base/image/image.cpp | 1515 ++++++++--------- source/base/image/image.h | 430 +++-- source/base/image/image_fwd.h | 53 + source/base/image/jpeg.cpp | 51 +- source/base/image/jpeg_pov.h | 17 +- source/base/image/metadata.cpp | 39 +- source/base/image/metadata.h | 28 +- source/base/image/openexr.cpp | 67 +- source/base/image/openexr.h | 17 +- source/base/image/png.cpp | 97 +- source/base/image/png_pov.h | 17 +- source/base/image/ppm.cpp | 36 +- source/base/image/ppm.h | 17 +- source/base/image/targa.cpp | 53 +- source/base/image/targa.h | 17 +- source/base/image/tiff.cpp | 39 +- source/base/image/tiff_pov.h | 15 +- source/base/mathutil.cpp | 34 +- source/base/mathutil.h | 22 +- source/base/messenger.cpp | 9 +- source/base/messenger.h | 17 +- source/base/messenger_fwd.h | 52 + source/base/path.cpp | 11 +- source/base/path.h | 30 +- source/base/path_fwd.h | 51 + source/base/platformbase.cpp | 35 +- source/base/platformbase.h | 51 +- source/base/pov_err.cpp | 11 +- source/base/pov_err.h | 50 +- source/base/pov_mem.cpp | 12 +- source/base/pov_mem.h | 19 +- source/base/povassert.h | 119 ++ source/base/precomp.h | 14 +- source/base/safemath.h | 11 +- source/base/stringtypes.h | 163 ++ source/base/stringutilities.cpp | 27 +- source/base/stringutilities.h | 10 +- source/base/textstream.cpp | 14 +- source/base/textstream.h | 65 +- source/base/textstream_fwd.h | 52 + source/base/textstreambuffer.cpp | 12 +- source/base/textstreambuffer.h | 24 +- source/base/textstreambuffer_fwd.h | 51 + source/base/timer.cpp | 9 +- source/base/timer.h | 13 +- source/base/types.h | 101 +- source/core/bounding/bounding.cpp | 11 +- source/core/bounding/bounding.h | 11 +- source/core/bounding/boundingbox.cpp | 19 +- source/core/bounding/boundingbox.h | 40 +- source/core/bounding/boundingbox_fwd.h | 55 + source/core/bounding/boundingcylinder.cpp | 15 +- source/core/bounding/boundingcylinder.h | 28 +- source/core/bounding/boundingcylinder_fwd.h | 53 + source/core/bounding/boundingsphere.cpp | 20 +- source/core/bounding/boundingsphere.h | 18 +- source/core/bounding/bsptree.cpp | 41 +- source/core/bounding/bsptree.h | 70 +- source/core/colour/spectral.cpp | 15 +- source/core/colour/spectral.h | 14 +- source/core/configcore.h | 56 +- source/core/core_fwd.h | 65 + source/core/coretypes.h | 134 +- source/core/lighting/lightgroup.cpp | 15 +- source/core/lighting/lightgroup.h | 14 +- source/core/lighting/lightsource.cpp | 11 +- source/core/lighting/lightsource.h | 17 +- source/core/lighting/photons.cpp | 21 +- source/core/lighting/photons.h | 51 +- source/core/lighting/photons_fwd.h | 53 + source/core/lighting/radiosity.cpp | 33 +- source/core/lighting/radiosity.h | 62 +- source/core/lighting/subsurface.cpp | 13 +- source/core/lighting/subsurface.h | 22 +- source/core/material/blendmap.cpp | 15 +- source/core/material/blendmap.h | 24 +- source/core/material/interior.cpp | 22 +- source/core/material/interior.h | 11 +- source/core/material/media.cpp | 15 +- source/core/material/media.h | 21 +- source/core/material/noise.cpp | 20 +- source/core/material/noise.h | 20 +- source/core/material/normal.cpp | 17 +- source/core/material/normal.h | 56 +- source/core/material/pattern.cpp | 20 +- source/core/material/pattern.h | 467 ++--- source/core/material/pattern_fwd.h | 51 + source/core/material/pigment.cpp | 24 +- source/core/material/pigment.h | 69 +- source/core/material/portablenoise.cpp | 11 +- source/core/material/portablenoise.h | 10 +- source/core/material/texture.cpp | 12 +- source/core/material/texture.h | 31 +- source/core/material/warp.cpp | 9 +- source/core/material/warp.h | 123 +- source/core/math/chi2.cpp | 11 +- source/core/math/chi2.h | 11 +- source/core/math/hypercomplex.cpp | 11 +- source/core/math/hypercomplex.h | 55 +- source/core/math/jitter.cpp | 11 +- source/core/math/jitter.h | 11 +- source/core/math/matrix.cpp | 11 +- source/core/math/matrix.h | 16 +- source/core/math/polynomialsolver.cpp | 13 +- source/core/math/polynomialsolver.h | 11 +- source/core/math/quaternion.cpp | 11 +- source/core/math/quaternion.h | 36 +- source/core/math/randcosweighted.cpp | 12 +- source/core/math/randcosweighted.h | 13 +- source/core/math/randomsequence.cpp | 104 +- source/core/math/randomsequence.h | 62 +- source/core/math/spline.cpp | 10 +- source/core/math/spline.h | 43 +- source/core/math/vector.cpp | 100 ++ source/core/math/vector.h | 66 +- source/core/precomp.h | 9 +- source/core/render/ray.cpp | 11 +- source/core/render/ray.h | 17 +- source/core/render/ray_fwd.h | 51 + source/core/render/trace.cpp | 30 +- source/core/render/trace.h | 77 +- source/core/render/tracepixel.cpp | 24 +- source/core/render/tracepixel.h | 31 +- source/core/scene/atmosphere.cpp | 15 +- source/core/scene/atmosphere.h | 32 +- source/core/scene/atmosphere_fwd.h | 57 + source/core/scene/camera.cpp | 11 +- source/core/scene/camera.h | 23 +- source/core/scene/object.cpp | 15 +- source/core/scene/object.h | 92 +- source/core/scene/scenedata.cpp | 14 +- source/core/scene/scenedata.h | 39 +- source/core/scene/tracethreaddata.cpp | 19 +- source/core/scene/tracethreaddata.h | 45 +- source/core/shape/bezier.cpp | 12 +- source/core/shape/bezier.h | 63 +- source/core/shape/blob.cpp | 14 +- source/core/shape/blob.h | 61 +- source/core/shape/box.cpp | 9 +- source/core/shape/box.h | 37 +- source/core/shape/cone.cpp | 9 +- source/core/shape/cone.h | 37 +- source/core/shape/csg.cpp | 16 +- source/core/shape/csg.h | 52 +- source/core/shape/csg_fwd.h | 51 + source/core/shape/disc.cpp | 11 +- source/core/shape/disc.h | 35 +- source/core/shape/fractal.cpp | 9 +- source/core/shape/fractal.h | 35 +- source/core/shape/heightfield.cpp | 16 +- source/core/shape/heightfield.h | 33 +- source/core/shape/isosurface.cpp | 21 +- source/core/shape/isosurface.h | 51 +- source/core/shape/lathe.cpp | 19 +- source/core/shape/lathe.h | 48 +- source/core/shape/lemon.cpp | 9 +- source/core/shape/lemon.h | 43 +- source/core/shape/mesh.cpp | 9 +- source/core/shape/mesh.h | 98 +- source/core/shape/ovus.cpp | 11 +- source/core/shape/ovus.h | 35 +- source/core/shape/parametric.cpp | 18 +- source/core/shape/parametric.h | 46 +- source/core/shape/plane.cpp | 11 +- source/core/shape/plane.h | 43 +- source/core/shape/polygon.cpp | 9 +- source/core/shape/polygon.h | 40 +- source/core/shape/polynomial.cpp | 11 +- source/core/shape/polynomial.h | 35 +- source/core/shape/prism.cpp | 12 +- source/core/shape/prism.h | 42 +- source/core/shape/quadric.cpp | 17 +- source/core/shape/quadric.h | 35 +- source/core/shape/sor.cpp | 19 +- source/core/shape/sor.h | 47 +- source/core/shape/sphere.cpp | 53 +- source/core/shape/sphere.h | 36 +- source/core/shape/spheresweep.cpp | 13 +- source/core/shape/spheresweep.h | 46 +- source/core/shape/superellipsoid.cpp | 15 +- source/core/shape/superellipsoid.h | 37 +- source/core/shape/torus.cpp | 11 +- source/core/shape/torus.h | 53 +- source/core/shape/triangle.cpp | 9 +- source/core/shape/triangle.h | 51 +- source/core/shape/truetype.cpp | 80 +- source/core/shape/truetype.h | 50 +- source/core/support/imageutil.cpp | 13 +- source/core/support/imageutil.h | 17 +- source/core/support/octree.cpp | 537 ++++-- source/core/support/octree.h | 60 +- source/core/support/octree_fwd.h | 62 + source/core/support/simplevector.h | 21 +- source/core/support/statisticids.cpp | 11 +- source/core/support/statisticids.h | 16 +- source/core/support/statistics.cpp | 12 +- source/core/support/statistics.h | 25 +- source/frontend/animationprocessing.cpp | 26 +- source/frontend/animationprocessing.h | 16 +- source/frontend/configfrontend.h | 3 +- source/frontend/console.cpp | 16 +- source/frontend/console.h | 23 +- source/frontend/console_fwd.h | 51 + source/frontend/display.cpp | 12 +- source/frontend/display.h | 20 +- source/frontend/filemessagehandler.cpp | 16 +- source/frontend/filemessagehandler.h | 27 +- source/frontend/imagemessagehandler.cpp | 16 +- source/frontend/imagemessagehandler.h | 17 +- source/frontend/imageprocessing.cpp | 22 +- source/frontend/imageprocessing.h | 33 +- source/frontend/parsermessagehandler.cpp | 16 +- source/frontend/parsermessagehandler.h | 15 +- source/frontend/precomp.h | 10 +- source/frontend/processoptions.cpp | 18 + source/frontend/processoptions.h | 30 +- source/frontend/processrenderoptions.cpp | 13 + source/frontend/processrenderoptions.h | 27 +- source/frontend/renderfrontend.cpp | 36 +- source/frontend/renderfrontend.h | 135 +- source/frontend/renderfrontend_fwd.h | 52 + source/frontend/rendermessagehandler.cpp | 12 +- source/frontend/rendermessagehandler.h | 19 +- source/frontend/shelloutprocessing.cpp | 40 +- source/frontend/shelloutprocessing.h | 106 +- source/frontend/simplefrontend.h | 55 +- source/parser/configparser.h | 3 +- source/parser/fncode.cpp | 14 +- source/parser/fncode.h | 34 +- source/parser/parser.cpp | 1004 ++--------- source/parser/parser.h | 157 +- source/parser/parser_expressions.cpp | 491 +----- source/parser/parser_functions.cpp | 24 +- source/parser/parser_functions_utilities.cpp | 15 +- source/parser/parser_fwd.h | 51 + source/parser/parser_materials.cpp | 32 +- source/parser/parser_obj.cpp | 21 +- source/parser/parser_strings.cpp | 369 +--- source/parser/parser_tokenizer.cpp | 218 +-- source/parser/parsertypes.cpp | 3 + source/parser/parsertypes.h | 52 +- source/parser/precomp.h | 9 +- source/parser/rawtokenizer.cpp | 19 +- source/parser/rawtokenizer.h | 25 +- source/parser/reservedwords.cpp | 12 +- source/parser/reservedwords.h | 17 +- source/parser/scanner.cpp | 14 +- source/parser/scanner.h | 22 +- source/parser/symboltable.cpp | 5 +- source/parser/symboltable.h | 18 +- source/povmain.cpp | 17 +- source/povms/configpovms.h | 5 +- source/povms/povmscpp.h | 49 +- source/povms/povmsutil.cpp | 3 +- source/povms/povmsutil.h | 5 +- source/povms/precomp.h | 11 +- source/vm/configvm.h | 3 +- source/vm/fnintern.cpp | 13 +- source/vm/fnintern.h | 30 +- source/vm/fnpovfpu.cpp | 20 +- source/vm/fnpovfpu.h | 55 +- source/vm/fnpovfpu_fwd.h | 57 + source/vm/precomp.h | 9 +- unix/configure.ac | 47 +- unix/disp.h | 18 +- unix/disp_sdl.cpp | 9 +- unix/disp_sdl.h | 41 +- unix/disp_text.cpp | 3 +- unix/disp_text.h | 29 +- unix/install.txt | 14 +- unix/povconfig/syspovconfig.h | 69 +- unix/povconfig/syspovconfig_bsd.h | 30 +- unix/povconfig/syspovconfig_gnu.h | 11 +- unix/povconfig/syspovconfig_osx.h | 7 +- unix/povconfig/syspovconfig_posix.h | 30 +- unix/povconfig/syspovconfigbase.h | 9 +- vfe/unix/unixconsole.cpp | 23 +- vfe/unix/unixoptions.cpp | 18 +- vfe/unix/unixoptions.h | 94 +- vfe/unix/vfeplatform.cpp | 46 +- vfe/unix/vfeplatform.h | 66 +- vfe/vfe.cpp | 23 +- vfe/vfe.h | 154 +- vfe/vfeconf.h | 23 +- vfe/vfecontrol.cpp | 14 +- vfe/vfedisplay.cpp | 4 +- vfe/vfepovms.cpp | 9 +- vfe/vfepovms.h | 20 +- vfe/vfeprecomp.h | 140 +- vfe/vfesession.cpp | 16 +- vfe/vfesession.h | 84 +- vfe/win/console/winconsole.cpp | 3 +- vfe/win/syspovimage.h | 7 +- vfe/win/vfeplatform.cpp | 73 +- vfe/win/vfeplatform.h | 75 +- windows/povconfig/syspovconfig.h | 91 +- windows/povconfig/syspovconfig_msvc.h | 15 +- windows/povconfig/syspovconfigbase.h | 8 +- windows/pvbitmap.cpp | 3 +- windows/pvbitmap.h | 3 +- windows/pvdemo.h | 3 +- windows/pvdialog.cpp | 3 +- windows/pvdialog.h | 3 +- windows/pvdisplay.cpp | 6 +- windows/pvdisplay.h | 47 +- windows/pvedit.cpp | 4 +- windows/pvedit.h | 3 +- windows/pvengine.cpp | 54 +- windows/pvengine.h | 11 +- windows/pvfiles.cpp | 4 +- windows/pvfrontend.cpp | 26 +- windows/pvfrontend.h | 3 +- windows/pvguiext.cpp | 3 +- windows/pvguiext.h | 4 +- windows/pvlegal.h | 3 +- windows/pvmem.cpp | 5 +- windows/pvmem.h | 15 +- windows/pvmenu.cpp | 3 +- windows/pvmisc.cpp | 10 +- windows/pvtext.cpp | 3 +- windows/pvupdate.cpp | 13 +- windows/rtrsupport/rtrsupport.cpp | 7 +- windows/rtrsupport/rtrsupport.h | 6 +- windows/rtrsupport/vidcapimpl.cpp | 7 +- windows/vs2015/povbackend.vcxproj | 7 +- windows/vs2015/povbackend.vcxproj.filters | 21 +- windows/vs2015/povbase.vcxproj | 14 + windows/vs2015/povbase.vcxproj.filters | 42 + windows/vs2015/povcore.vcxproj | 10 + windows/vs2015/povcore.vcxproj.filters | 30 + windows/vs2015/povfrontend.vcxproj | 2 + windows/vs2015/povfrontend.vcxproj.filters | 6 + windows/vs2015/povparser.vcxproj | 1 + windows/vs2015/povparser.vcxproj.filters | 3 + windows/vs2015/povplatform.vcxproj | 1 + windows/vs2015/povvm.vcxproj | 1 + windows/vs2015/povvm.vcxproj.filters | 3 + windows/winprecomp.h | 14 +- 445 files changed, 11370 insertions(+), 7679 deletions(-) create mode 100644 platform/unix/syspovfilesystem.cpp create mode 100644 platform/unix/syspovfilesystem.h create mode 100644 platform/windows/syspovfilesystem.cpp create mode 100644 source/backend/control/messagefactory_fwd.h create mode 100644 source/backend/control/scene_fwd.h delete mode 100644 source/backend/frame.h create mode 100644 source/backend/lighting/photonshootingstrategy_fwd.h create mode 100644 source/backend/scene/backendscenedata_fwd.h create mode 100644 source/backend/scene/view_fwd.h create mode 100644 source/backend/scene/viewthreaddata_fwd.h create mode 100644 source/base/base_fwd.h create mode 100644 source/base/fileinputoutput_fwd.h create mode 100644 source/base/filesystem.cpp create mode 100644 source/base/filesystem.h create mode 100644 source/base/filesystem_fwd.h create mode 100644 source/base/image/colourspace_fwd.h create mode 100644 source/base/image/dither_fwd.h create mode 100644 source/base/image/image_fwd.h create mode 100644 source/base/messenger_fwd.h create mode 100644 source/base/path_fwd.h create mode 100644 source/base/povassert.h create mode 100644 source/base/stringtypes.h create mode 100644 source/base/textstream_fwd.h create mode 100644 source/base/textstreambuffer_fwd.h create mode 100644 source/core/bounding/boundingbox_fwd.h create mode 100644 source/core/bounding/boundingcylinder_fwd.h create mode 100644 source/core/core_fwd.h create mode 100644 source/core/lighting/photons_fwd.h create mode 100644 source/core/material/pattern_fwd.h create mode 100644 source/core/math/vector.cpp create mode 100644 source/core/render/ray_fwd.h create mode 100644 source/core/scene/atmosphere_fwd.h create mode 100644 source/core/shape/csg_fwd.h create mode 100644 source/core/support/octree_fwd.h create mode 100644 source/frontend/console_fwd.h create mode 100644 source/frontend/renderfrontend_fwd.h create mode 100644 source/parser/parser_fwd.h create mode 100644 source/vm/fnpovfpu_fwd.h 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 +#include #include +#include +// POV-Ray header files (base module) +#include "base/stringtypes.h" + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" -#include "base/stringutilities.h" +// POV-Ray header files (backend module) +#include "backend/control/scene_fwd.h" +#include "backend/scene/view_fwd.h" namespace pov { using namespace pov_base; -class Scene; -class View; - /** * RenderBackend class receives render control messages from the * RenderFrontend class. Thee control messages are processed and * parsing, rendering or other operations are performed as * requested by the frontend. */ -class RenderBackend : public POVMS_MessageReceiver +class RenderBackend final : public POVMS_MessageReceiver { public: typedef POVMSInt SceneId; typedef POVMSInt ViewId; RenderBackend(POVMSContext ctx, bool (*val)(POVMSAddress)); - ~RenderBackend(); + virtual ~RenderBackend() override; static void SendSceneOutput(SceneId sid, POVMSAddress addr, POVMSType ident, POVMS_Object& obj); static void SendViewOutput(ViewId vid, POVMSAddress addr, POVMSType ident, POVMS_Object& obj); - static void SendFindFile(POVMSContext ctx, SceneId sid, POVMSAddress addr, const vector& filenames, UCS2String& filename); + static void SendFindFile(POVMSContext ctx, SceneId sid, POVMSAddress addr, const std::vector& filenames, UCS2String& filename); static void SendReadFile(POVMSContext ctx, SceneId sid, POVMSAddress addr, const UCS2String& filename, UCS2String& localfile, UCS2String& fileurl); static void SendCreatedFile(POVMSContext ctx, SceneId sid, POVMSAddress addr, const UCS2String& filename); @@ -113,11 +125,11 @@ class RenderBackend : public POVMS_MessageReceiver SceneId scenecounter; ViewId viewcounter; - typedef std::set ViewIdSet; - typedef std::map > SceneMap; - typedef std::map > ViewMap; - typedef std::map Scene2ViewsMap; - typedef std::map View2SceneMap; + typedef std::set ViewIdSet; + typedef std::map> SceneMap; + typedef std::map> ViewMap; + typedef std::map Scene2ViewsMap; + typedef std::map View2SceneMap; SceneMap scenes; ViewMap views; @@ -133,5 +145,6 @@ class RenderBackend : public POVMS_MessageReceiver }; } +// end of namespace pov #endif // POVRAY_BACKEND_RENDERBACKEND_H diff --git a/source/backend/control/scene.cpp b/source/backend/control/scene.cpp index 7b513abe2..f4dc518b9 100644 --- a/source/backend/control/scene.cpp +++ b/source/backend/control/scene.cpp @@ -33,21 +33,37 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/control/scene.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/control/parsertask.h" -#include "backend/control/scene.h" +// POV-Ray header files (base module) +#include "base/image/colourspace.h" +// POV-Ray header files (core module) #include "core/scene/tracethreaddata.h" +// POV-Ray header files (POVMS module) +#include "povms/povmscpp.h" +#include "povms/povmsid.h" + +// POV-Ray header files (parser module) #include "parser/parsertypes.h" +// POV-Ray header files (backend module) #include "backend/bounding/boundingtask.h" +#include "backend/control/parsertask.h" +#include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" // this must be the last file included @@ -56,6 +72,9 @@ namespace pov { +using std::min; +using std::max; + Scene::Scene(POVMSAddress backendAddr, POVMSAddress frontendAddr, RenderBackend::SceneId sid) : sceneData(new BackendSceneData()), stopRequsted(false), @@ -76,7 +95,7 @@ Scene::~Scene() parserControlThread->join(); delete parserControlThread; - for(vector::iterator i(sceneThreadData.begin()); i != sceneThreadData.end(); i++) + for(std::vector::iterator i(sceneThreadData.begin()); i != sceneThreadData.end(); i++) delete (*i); sceneThreadData.clear(); } @@ -163,7 +182,7 @@ void Scene::StartParser(POVMS_Object& parseOptions) } // do parsing - sceneThreadData.push_back(dynamic_cast(parserTasks.AppendTask(new pov_parser::ParserTask( + sceneThreadData.push_back(dynamic_cast(parserTasks.AppendTask(new ParserTask( sceneData, pov_parser::ParserOptions(bool(parseOptions.Exist(kPOVAttrib_Clock)), parseOptions.TryGetFloat(kPOVAttrib_Clock, 0.0), seed) )))); @@ -223,7 +242,7 @@ bool Scene::Failed() return parserTasks.Failed(); } -shared_ptr Scene::NewView(unsigned int width, unsigned int height, RenderBackend::ViewId vid) +std::shared_ptr Scene::NewView(unsigned int width, unsigned int height, RenderBackend::ViewId vid) { if(parserTasks.IsDone() == false) throw POV_EXCEPTION_CODE(kNotNowErr); @@ -231,12 +250,17 @@ shared_ptr Scene::NewView(unsigned int width, unsigned int height, RenderB if((parserTasks.IsDone() == false) || (parserTasks.Failed() == true)) throw POV_EXCEPTION_CODE(kNotNowErr); - return shared_ptr(new View(sceneData, width, height, vid)); + return std::shared_ptr(new View(sceneData, width, height, vid)); +} + +POVMSAddress Scene::GetFrontendAddress() const +{ + return sceneData->frontendAddress; } void Scene::GetStatistics(POVMS_Object& parserStats) { - struct TimeData + struct TimeData final { POV_LONG cpuTime; POV_LONG realTime; @@ -247,7 +271,7 @@ void Scene::GetStatistics(POVMS_Object& parserStats) TimeData timeData[TraceThreadData::kMaxTimeType]; - for(vector::iterator i(sceneThreadData.begin()); i != sceneThreadData.end(); i++) + for(std::vector::iterator i(sceneThreadData.begin()); i != sceneThreadData.end(); i++) { timeData[(*i)->timeType].realTime = max(timeData[(*i)->timeType].realTime, (*i)->realTime); timeData[(*i)->timeType].cpuTime += (*i)->cpuTime; @@ -309,7 +333,7 @@ void Scene::SendStatistics(TaskQueue&) POVMS_SendMessage(parserStats); - for(vector::iterator i(sceneThreadData.begin()); i != sceneThreadData.end(); i++) + for(std::vector::iterator i(sceneThreadData.begin()); i != sceneThreadData.end(); i++) delete (*i); sceneThreadData.clear(); } @@ -352,3 +376,4 @@ void Scene::ParserControlThread() } } +// end of namespace pov diff --git a/source/backend/control/scene.h b/source/backend/control/scene.h index 0997702f4..f5c5f7826 100644 --- a/source/backend/control/scene.h +++ b/source/backend/control/scene.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,16 +36,30 @@ #ifndef POVRAY_BACKEND_SCENE_H #define POVRAY_BACKEND_SCENE_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" +#include "backend/control/scene_fwd.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include -#include -#include +// Boost header files #include -#include "core/scene/tracethreaddata.h" +// POV-Ray header files (base module) +// (none at the moment) +// POV-Ray header files (core module) +#include "core/core_fwd.h" + +// POV-Ray header files (backend module) #include "backend/control/renderbackend.h" -#include "backend/scene/backendscenedata.h" +#include "backend/scene/backendscenedata_fwd.h" +#include "backend/scene/view_fwd.h" #include "backend/support/taskqueue.h" namespace pov @@ -53,13 +67,11 @@ namespace pov using namespace pov_base; -class View; - /// Class governing the rendering of a scene. /// /// @todo Change the class name into something more expressive. /// -class Scene +class Scene final { public: /** @@ -71,7 +83,7 @@ class Scene * each scene,once parsed, many views many be created, and * each view may specify different render quality, size and * camera parameters. This limitation may be lifted in the - * future to better support animationss and for example + * future to better support animations and for example * motion blur, but this can only be supported in POV-Ray * 4.0 when all the rendering code is rewritten! * @param backendAddr Address of the backend that owns this scene. @@ -93,7 +105,7 @@ class Scene * The frontend is notified by messages of the state * of parsing and all warnings and errors found. * Options shall be in a kPOVObjectClass_ParserOptions - * POVMS obect, which is created when parsing the INI + * POVMS object, which is created when parsing the INI * file or command line in the frontend. * @param parseOptions Options to use for parsing. */ @@ -120,7 +132,7 @@ class Scene /** * Resume parsing that has previously been stopped. - * If parsing is not paussed, no action is taken. + * If parsing is not paused, no action is taken. */ void ResumeParser(); @@ -153,13 +165,13 @@ class Scene * POVMS messages sent to the frontend. * @return New view bound to the scene's data. */ - shared_ptr NewView(unsigned int width, unsigned int height, RenderBackend::ViewId vid); + std::shared_ptr NewView(unsigned int width, unsigned int height, RenderBackend::ViewId vid); /** * Get the POVMS frontend address to send messages to the frontend. * @return Frontend address. */ - POVMSAddress GetFrontendAddress() const { return sceneData->frontendAddress; } + POVMSAddress GetFrontendAddress() const; /** * Get the current parser statistics for the scene. @@ -172,9 +184,9 @@ class Scene /// running and pending parser tasks for this scene TaskQueue parserTasks; /// scene thread data (e.g. statistics) - vector sceneThreadData; + std::vector sceneThreadData; /// scene data - shared_ptr sceneData; + std::shared_ptr sceneData; /// stop request flag bool stopRequsted; /// parser control thread @@ -199,5 +211,6 @@ class Scene }; } +// end of namespace pov #endif // POVRAY_BACKEND_SCENE_H diff --git a/source/backend/control/scene_fwd.h b/source/backend/control/scene_fwd.h new file mode 100644 index 000000000..62d5308c0 --- /dev/null +++ b/source/backend/control/scene_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file backend/control/scene_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_SCENE_FWD_H +#define POVRAY_BACKEND_SCENE_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class Scene; + +} +// end of namespace pov + +#endif // POVRAY_BACKEND_SCENE_FWD_H diff --git a/source/backend/frame.h b/source/backend/frame.h deleted file mode 100644 index ace5c20d2..000000000 --- a/source/backend/frame.h +++ /dev/null @@ -1,167 +0,0 @@ -//****************************************************************************** -/// -/// @file backend/frame.h -/// -/// Generic header for all back-end modules. -/// -/// This header file is included by all C++ modules in the POV-Ray back-end. -/// It defines various ubiquitous types and constants. -/// -/// @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 FRAME_H -#define FRAME_H - -/// @file -/// -/// @todo The size of this file, and it being grouped into various thematical subsections, -/// indicate that its content should be split up into multiple files, to be included from -/// this one; furthermore, some contents may not really be that ubiquitous to warrant -/// including them in every module. - -#include - -#include -#include -#include - -#include - -#include "base/configbase.h" -#include "base/colour.h" -#include "base/types.h" - -#include "core/coretypes.h" -#include "core/bounding/boundingbox.h" - -#include "backend/configbackend.h" - -namespace pov -{ - -using namespace pov_base; - -// from ; we don't want to always type the namespace for these. -using std::min; -using std::max; - -// from ; we don't want to always type the namespace for these. -using std::abs; -using std::acos; -using std::asin; -using std::atan; -using std::atan2; -using std::ceil; -using std::cos; -using std::cosh; -using std::exp; -using std::fabs; -using std::floor; -using std::fmod; -using std::frexp; -using std::ldexp; -using std::log; -using std::log10; -using std::modf; -using std::pow; -using std::sin; -using std::sinh; -using std::sqrt; -using std::tan; -using std::tanh; - -//****************************************************************************** -/// -/// @name Forward Declarations -/// @{ - -class CompoundObject; - -class Intersection; -class Ray; - - -/// @} -/// -//****************************************************************************** -/// -/// @name Scalar, Colour and Vector Stuff -/// -/// @{ - -inline void Destroy_Float(DBL *x) -{ - if (x != nullptr) - delete x; -} - -/// @} -/// -//****************************************************************************** -/// -/// @name Object Stuff -/// -/// @{ - -#ifndef DUMP_OBJECT_DATA -#define DUMP_OBJECT_DATA 0 -#endif - -typedef struct Project_Struct PROJECT; -typedef struct Project_Tree_Node_Struct PROJECT_TREE_NODE; - -struct Project_Struct -{ - int x1, y1, x2, y2; -}; - -/* - * The following structure represent the bounding box hierarchy in 2d space. - * Because is_leaf, Object and Project are the first elements in both - * structures they can be accessed without knowing at which structure - * a pointer is pointing. - */ - -struct Project_Tree_Node_Struct -{ - unsigned short is_leaf; - BBOX_TREE *Node; - PROJECT Project; - unsigned short Entries; - PROJECT_TREE_NODE **Entry; -}; - -/// @} -/// -//****************************************************************************** - -} - -#endif diff --git a/source/backend/lighting/photonestimationtask.cpp b/source/backend/lighting/photonestimationtask.cpp index e2a0b9fbc..3a21510f1 100644 --- a/source/backend/lighting/photonestimationtask.cpp +++ b/source/backend/lighting/photonestimationtask.cpp @@ -10,7 +10,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 @@ -35,12 +35,19 @@ /// //****************************************************************************** -#include - -// 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/lighting/photonestimationtask.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" #include "core/lighting/lightsource.h" @@ -49,10 +56,12 @@ #include "core/shape/csg.h" #include "core/support/octree.h" +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" #include "povms/povmsid.h" #include "povms/povmsutil.h" +// POV-Ray header files (backend module) #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" #include "backend/scene/viewthreaddata.h" @@ -63,6 +72,8 @@ namespace pov { +using std::vector; + PhotonEstimationTask::PhotonEstimationTask(ViewData *vd, size_t seed) : RenderTask(vd, seed, "Photon"), cooperate(*this) @@ -135,7 +146,7 @@ void PhotonEstimationTask::Finish() void PhotonEstimationTask::SearchThroughObjectsEstimatePhotons(vector& Objects, LightSource *Light) { ViewThreadData *renderDataPtr = GetViewDataPtr(); - shared_ptr sceneData = GetSceneData(); + std::shared_ptr sceneData = GetSceneData(); /* check this object and all siblings */ for(vector::iterator Sib = Objects.begin(); Sib != Objects.end(); Sib++) @@ -214,3 +225,4 @@ void PhotonEstimationTask::EstimatePhotonsForObjectAndLight(ObjectPtr Object, Li } } +// end of namespace pov diff --git a/source/backend/lighting/photonestimationtask.h b/source/backend/lighting/photonestimationtask.h index a14e0060a..6a9f2d868 100644 --- a/source/backend/lighting/photonestimationtask.h +++ b/source/backend/lighting/photonestimationtask.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 @@ -33,12 +33,25 @@ /// //****************************************************************************** -#ifndef PHOTONESTIMATIONTASK_H -#define PHOTONESTIMATIONTASK_H +#ifndef POVRAY_BACKEND_PHOTONESTIMATIONTASK_H +#define POVRAY_BACKEND_PHOTONESTIMATIONTASK_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 + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/render/trace.h" -#include "backend/frame.h" +// POV-Ray header files (backend module) #include "backend/render/rendertask.h" namespace pov @@ -46,26 +59,26 @@ namespace pov using namespace pov_base; -class PhotonEstimationTask : public RenderTask +class PhotonEstimationTask final : public RenderTask { public: DBL photonCountEstimate; PhotonEstimationTask(ViewData *vd, size_t seed); - ~PhotonEstimationTask(); + virtual ~PhotonEstimationTask() override; - void Run(); - void Stopped(); - void Finish(); + virtual void Run() override; + virtual void Stopped() override; + virtual void Finish() override; - void SearchThroughObjectsEstimatePhotons(vector& Objects, LightSource *Light); + void SearchThroughObjectsEstimatePhotons(std::vector& Objects, LightSource *Light); void EstimatePhotonsForObjectAndLight(ObjectPtr Object, LightSource *Light); private: - class CooperateFunction : public Trace::CooperateFunctor + class CooperateFunction final : public Trace::CooperateFunctor { public: CooperateFunction(Task& t) : task(t) { } - virtual void operator()() { task.Cooperate(); } + virtual void operator()() override { task.Cooperate(); } private: Task& task; }; @@ -74,4 +87,6 @@ class PhotonEstimationTask : public RenderTask }; } -#endif +// end of namespace pov + +#endif // POVRAY_BACKEND_PHOTONESTIMATIONTASK_H diff --git a/source/backend/lighting/photonshootingstrategy.cpp b/source/backend/lighting/photonshootingstrategy.cpp index 58f71f7d7..3c808c241 100644 --- a/source/backend/lighting/photonshootingstrategy.cpp +++ b/source/backend/lighting/photonshootingstrategy.cpp @@ -10,7 +10,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 @@ -35,12 +35,17 @@ /// //****************************************************************************** -#include - -// 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/lighting/photonshootingstrategy.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" #include "core/lighting/lightsource.h" @@ -53,6 +58,10 @@ #include "core/shape/csg.h" #include "core/support/octree.h" +// POV-Ray header files (POVMS module) +// POV-Ray header files (backend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -74,7 +83,7 @@ PhotonShootingUnit* PhotonShootingStrategy::getNextUnit() return unit; } -void PhotonShootingStrategy::createUnitsForCombo(ObjectPtr obj, LightSource* light, shared_ptr sceneData) +void PhotonShootingStrategy::createUnitsForCombo(ObjectPtr obj, LightSource* light, std::shared_ptr sceneData) { PhotonShootingUnit* unit = new PhotonShootingUnit(light, obj); unit->lightAndObject.computeAnglesAndDeltas(sceneData); @@ -83,7 +92,7 @@ void PhotonShootingStrategy::createUnitsForCombo(ObjectPtr obj, LightSource* lig PhotonShootingStrategy::~PhotonShootingStrategy() { - vector::iterator delIter; + std::vector::iterator delIter; for(delIter = units.begin(); delIter != units.end(); delIter++) { delete (*delIter); @@ -91,5 +100,5 @@ PhotonShootingStrategy::~PhotonShootingStrategy() units.clear(); } - } +// end of namespace pov diff --git a/source/backend/lighting/photonshootingstrategy.h b/source/backend/lighting/photonshootingstrategy.h index 552f75cf9..6774b979a 100644 --- a/source/backend/lighting/photonshootingstrategy.h +++ b/source/backend/lighting/photonshootingstrategy.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,41 +33,56 @@ /// //****************************************************************************** -#ifndef PHOTONSHOOTINGSTRATEGY_H -#define PHOTONSHOOTINGSTRATEGY_H +#ifndef POVRAY_BACKEND_PHOTONSHOOTINGSTRATEGY_H +#define POVRAY_BACKEND_PHOTONSHOOTINGSTRATEGY_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" +#include "backend/lighting/photonshootingstrategy_fwd.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// Boost header files #include -#include "backend/frame.h" +// POV-Ray header files (base module) +// (none at the moment) -namespace pov -{ +// POV-Ray header files (core module) +#include "core/core_fwd.h" -using namespace pov_base; +// POV-Ray header files (backend module) +// (none at the moment) -class PhotonShootingUnit; -class SceneData; +namespace pov +{ -class PhotonShootingStrategy +class PhotonShootingStrategy final { public: ObjectPtr obj; LightSource *light; - vector units; + std::vector units; - void createUnitsForCombo(ObjectPtr obj, LightSource* light, shared_ptr sceneData); + void createUnitsForCombo(ObjectPtr obj, LightSource* light, std::shared_ptr sceneData); void start(); PhotonShootingUnit* getNextUnit(); virtual ~PhotonShootingStrategy(); private: - vector::iterator iter; + std::vector::iterator iter; boost::mutex nextUnitMutex; }; } +// end of namespace pov -#endif +#endif // POVRAY_BACKEND_PHOTONSHOOTINGSTRATEGY_H diff --git a/source/backend/lighting/photonshootingstrategy_fwd.h b/source/backend/lighting/photonshootingstrategy_fwd.h new file mode 100644 index 000000000..70f3a5e0e --- /dev/null +++ b/source/backend/lighting/photonshootingstrategy_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file backend/lighting/photonshootingstrategy_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_PHOTONSHOOTINGSTRATEGY_FWD_H +#define POVRAY_BACKEND_PHOTONSHOOTINGSTRATEGY_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class PhotonShootingStrategy; + +} +// end of namespace pov + +#endif // POVRAY_BACKEND_PHOTONSHOOTINGSTRATEGY_FWD_H diff --git a/source/backend/lighting/photonshootingtask.cpp b/source/backend/lighting/photonshootingtask.cpp index 53ee3ce65..ce593ebb0 100644 --- a/source/backend/lighting/photonshootingtask.cpp +++ b/source/backend/lighting/photonshootingtask.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,12 +33,19 @@ /// //****************************************************************************** -#include - -// 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/lighting/photonshootingtask.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" #include "core/lighting/lightsource.h" @@ -48,10 +55,12 @@ #include "core/shape/csg.h" #include "core/support/octree.h" +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" #include "povms/povmsid.h" #include "povms/povmsutil.h" +// POV-Ray header files (backend module) #include "backend/lighting/photonshootingstrategy.h" #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" @@ -357,7 +366,7 @@ void PhotonShootingTask::ShootPhotonsAtObject(LightTargetCombo& combo) //Initialize_Ray_Containers(&ray); ray.ClearInteriors (); - for(vector::iterator object = GetSceneData()->objects.begin(); object != GetSceneData()->objects.end(); object++) + for(std::vector::iterator object = GetSceneData()->objects.begin(); object != GetSceneData()->objects.end(); object++) { if ((*object)->Inside(ray.Origin, renderDataPtr) && ((*object)->interior != nullptr)) ray.AppendInterior((*object)->interior.get()); @@ -447,3 +456,4 @@ DBL PhotonShootingTask::computeAttenuation(const LightSource* Light, const Ray& } } +// end of namespace pov diff --git a/source/backend/lighting/photonshootingtask.h b/source/backend/lighting/photonshootingtask.h index 63d1f3eb1..87476cb90 100644 --- a/source/backend/lighting/photonshootingtask.h +++ b/source/backend/lighting/photonshootingtask.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 @@ -33,26 +33,32 @@ /// //****************************************************************************** -#ifndef PHOTONSHOOTINGTASK_H -#define PHOTONSHOOTINGTASK_H +#ifndef POVRAY_BACKEND_PHOTONSHOOTINGTASK_H +#define POVRAY_BACKEND_PHOTONSHOOTINGTASK_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) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/core_fwd.h" #include "core/lighting/photons.h" #include "core/render/trace.h" -#include "backend/frame.h" +// POV-Ray header files (backend module) +#include "backend/lighting/photonshootingstrategy_fwd.h" #include "backend/render/rendertask.h" namespace pov { -using namespace pov_base; - -class LightSource; -class LightTargetCombo; -class PhotonMap; -class PhotonShootingStrategy; - -class PhotonShootingTask : public RenderTask +class PhotonShootingTask final : public RenderTask { public: PhotonTrace trace; @@ -64,11 +70,11 @@ class PhotonShootingTask : public RenderTask RandomDoubleSequence::Generator randgen; PhotonShootingTask(ViewData *vd, PhotonShootingStrategy* strategy, size_t seed); - ~PhotonShootingTask(); + virtual ~PhotonShootingTask() override; - void Run(); - void Stopped(); - void Finish(); + virtual void Run() override; + virtual void Stopped() override; + virtual void Finish() override; void SendProgress(); @@ -78,11 +84,11 @@ class PhotonShootingTask : public RenderTask PhotonMap* getMediaPhotonMap(); PhotonMap* getSurfacePhotonMap(); private: - class CooperateFunction : public Trace::CooperateFunctor + class CooperateFunction final : public Trace::CooperateFunctor { public: CooperateFunction(Task& t) : task(t) { } - virtual void operator()() { task.Cooperate(); } + virtual void operator()() override { task.Cooperate(); } private: Task& task; }; @@ -93,6 +99,7 @@ class PhotonShootingTask : public RenderTask DBL adcBailout; }; - } -#endif +// end of namespace pov + +#endif // POVRAY_BACKEND_PHOTONSHOOTINGTASK_H diff --git a/source/backend/lighting/photonsortingtask.cpp b/source/backend/lighting/photonsortingtask.cpp index d75b33518..b66c87cc5 100644 --- a/source/backend/lighting/photonsortingtask.cpp +++ b/source/backend/lighting/photonsortingtask.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,12 +33,17 @@ /// //****************************************************************************** -#include - -// 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/lighting/photonsortingtask.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" #include "core/lighting/lightsource.h" @@ -47,10 +52,13 @@ #include "core/shape/csg.h" #include "core/support/octree.h" +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" #include "povms/povmsid.h" #include "povms/povmsutil.h" +// POV-Ray header files (backend module) +#include "backend/control/messagefactory.h" #include "backend/lighting/photonshootingstrategy.h" #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" @@ -71,8 +79,8 @@ namespace pov 3) compute gather options 4) clean up memory (delete the non-merged maps and delete the strategy) */ -PhotonSortingTask::PhotonSortingTask(ViewData *vd, const vector& surfaceMaps, - const vector& mediaMaps, PhotonShootingStrategy* strategy, +PhotonSortingTask::PhotonSortingTask(ViewData *vd, const std::vector& surfaceMaps, + const std::vector& mediaMaps, PhotonShootingStrategy* strategy, size_t seed) : RenderTask(vd, seed, "Photon"), surfaceMaps(surfaceMaps), @@ -117,7 +125,7 @@ void PhotonSortingTask::Run() else { if (!this->load()) - messageFactory.Error(POV_EXCEPTION_STRING("Failed to load photon map from disk"), "Could not load photon map (%s)",GetSceneData()->photonSettings.fileName.c_str()); + mpMessageFactory->Error(POV_EXCEPTION_STRING("Failed to load photon map from disk"), "Could not load photon map (%s)",GetSceneData()->photonSettings.fileName.c_str()); // set photon options automatically if (GetSceneData()->surfacePhotonMap.numPhotons>0) @@ -146,7 +154,7 @@ void PhotonSortingTask::Finish() void PhotonSortingTask::sortPhotonMap() { - vector::iterator mapIter; + std::vector::iterator mapIter; for(mapIter = surfaceMaps.begin(); mapIter != surfaceMaps.end(); mapIter++) { GetSceneData()->surfacePhotonMap.mergeMap(*mapIter); @@ -201,13 +209,13 @@ void PhotonSortingTask::sortPhotonMap() /* status bar for user */ // Send_Progress("Saving Photon Maps", PROGRESS_SAVING_PHOTON_MAPS); if (!this->save()) - messageFactory.Warning(kWarningGeneral,"Could not save photon map."); + mpMessageFactory->Warning(kWarningGeneral,"Could not save photon map."); } } else { if (!GetSceneData()->photonSettings.fileName.empty() && !GetSceneData()->photonSettings.loadFile) - messageFactory.Warning(kWarningGeneral,"Could not save photon map - no photons!"); + mpMessageFactory->Warning(kWarningGeneral,"Could not save photon map - no photons!"); } } @@ -257,7 +265,7 @@ bool PhotonSortingTask::save() } else { - messageFactory.PossibleError("Photon map for surface is empty."); + mpMessageFactory->PossibleError("Photon map for surface is empty."); } #ifdef GLOBAL_PHOTONS @@ -281,7 +289,7 @@ bool PhotonSortingTask::save() } else { - messageFactory.PossibleError("Global photon map is empty."); + mpMessageFactory->PossibleError("Global photon map is empty."); } #endif @@ -305,7 +313,7 @@ bool PhotonSortingTask::save() } else { - messageFactory.PossibleError("Photon map for media is empty."); + mpMessageFactory->PossibleError("Photon map for media is empty."); } fclose(f); @@ -336,7 +344,7 @@ bool PhotonSortingTask::load() if (!GetSceneData()->photonSettings.photonsEnabled) return false; - messageFactory.Warning(kWarningGeneral,"Starting the load of photon file %s\n",GetSceneData()->photonSettings.fileName.c_str()); + mpMessageFactory->Warning(kWarningGeneral,"Starting the load of photon file %s\n",GetSceneData()->photonSettings.fileName.c_str()); f = fopen(GetSceneData()->photonSettings.fileName.c_str(), "rb"); if (!f) @@ -398,5 +406,5 @@ bool PhotonSortingTask::load() return true; } - } +// end of namespace pov diff --git a/source/backend/lighting/photonsortingtask.h b/source/backend/lighting/photonsortingtask.h index de16eb32b..ed547fde3 100644 --- a/source/backend/lighting/photonsortingtask.h +++ b/source/backend/lighting/photonsortingtask.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 @@ -33,38 +33,47 @@ /// //****************************************************************************** -#ifndef PHOTONSORTINGTASK_H -#define PHOTONSORTINGTASK_H +#ifndef POVRAY_BACKEND_PHOTONSORTINGTASK_H +#define POVRAY_BACKEND_PHOTONSORTINGTASK_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 + +// POV-Ray header files (base module) +#include "core/lighting/photons_fwd.h" + +// POV-Ray header files (core module) #include "core/render/trace.h" -#include "backend/frame.h" +// POV-Ray header files (backend module) +#include "backend/lighting/photonshootingstrategy_fwd.h" #include "backend/render/rendertask.h" namespace pov { -using namespace pov_base; - -class PhotonMap; -class PhotonShootingStrategy; - -class PhotonSortingTask : public RenderTask +class PhotonSortingTask final : public RenderTask { public: Timer timer; - vector surfaceMaps; - vector mediaMaps; + std::vector surfaceMaps; + std::vector mediaMaps; PhotonShootingStrategy* strategy; - PhotonSortingTask(ViewData *vd, const vector& surfaceMaps, const vector& mediaMaps, + PhotonSortingTask(ViewData *vd, const std::vector& surfaceMaps, const std::vector& mediaMaps, PhotonShootingStrategy* strategy, size_t seed); - ~PhotonSortingTask(); + virtual ~PhotonSortingTask() override; - void Run(); - void Stopped(); - void Finish(); + virtual void Run() override; + virtual void Stopped() override; + virtual void Finish() override; void SendProgress(); @@ -72,11 +81,11 @@ class PhotonSortingTask : public RenderTask bool save(); bool load(); private: - class CooperateFunction : public Trace::CooperateFunctor + class CooperateFunction final : public Trace::CooperateFunctor { public: CooperateFunction(Task& t) : task(t) { } - virtual void operator()() { task.Cooperate(); } + virtual void operator()() override { task.Cooperate(); } private: Task& task; }; @@ -85,4 +94,6 @@ class PhotonSortingTask : public RenderTask }; } -#endif +// end of namespace pov + +#endif // POVRAY_BACKEND_PHOTONSORTINGTASK_H diff --git a/source/backend/lighting/photonstrategytask.cpp b/source/backend/lighting/photonstrategytask.cpp index 0f64816c4..aab0f715b 100644 --- a/source/backend/lighting/photonstrategytask.cpp +++ b/source/backend/lighting/photonstrategytask.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,12 +33,19 @@ /// //****************************************************************************** -#include - -// 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/lighting/photonstrategytask.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" #include "core/lighting/lightsource.h" @@ -47,10 +54,13 @@ #include "core/shape/csg.h" #include "core/support/octree.h" +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" #include "povms/povmsid.h" #include "povms/povmsutil.h" +// POV-Ray header files (backend module) +#include "backend/control/messagefactory.h" #include "backend/lighting/photonshootingstrategy.h" #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" @@ -62,6 +72,8 @@ namespace pov { +using std::vector; + PhotonStrategyTask::PhotonStrategyTask(ViewData *vd, PhotonShootingStrategy* strategy, size_t seed) : RenderTask(vd, seed, "Photon"), strategy(strategy), @@ -100,7 +112,7 @@ void PhotonStrategyTask::Run() if ((*Light)->Light_Type != FILL_LIGHT_SOURCE) { if ((*Light)->Light_Type == CYLINDER_SOURCE && !(*Light)->Parallel) - messageFactory.Warning(kWarningGeneral,"Cylinder lights should be parallel when used with photons."); + mpMessageFactory->Warning(kWarningGeneral,"Cylinder lights should be parallel when used with photons."); /* do object-specific lighting */ SearchThroughObjectsCreateUnits(GetSceneData()->objects, (*Light)); @@ -118,7 +130,7 @@ void PhotonStrategyTask::Run() Light = Light_Group_Light->Light; if (Light->Light_Type == CYLINDER_SOURCE && !Light->Parallel) - messageFactory.Warning(kWarningGeneral,"Cylinder lights should be parallel when used with photons."); + mpMessageFactory->Warning(kWarningGeneral,"Cylinder lights should be parallel when used with photons."); // do object-specific lighting SearchThroughObjectsCreateUnits(GetSceneData()->objects, Light); @@ -169,7 +181,7 @@ void PhotonStrategyTask::Finish() void PhotonStrategyTask::SearchThroughObjectsCreateUnits(vector& Objects, LightSource *Light) { - shared_ptr sceneData = GetSceneData(); + std::shared_ptr sceneData = GetSceneData(); /* check this object and all siblings */ for(vector::iterator Sib = Objects.begin(); Sib != Objects.end(); Sib++) @@ -194,5 +206,5 @@ void PhotonStrategyTask::SearchThroughObjectsCreateUnits(vector& Obje } } - } +// end of namespace pov diff --git a/source/backend/lighting/photonstrategytask.h b/source/backend/lighting/photonstrategytask.h index 1708d0d25..15cdae641 100644 --- a/source/backend/lighting/photonstrategytask.h +++ b/source/backend/lighting/photonstrategytask.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 @@ -33,22 +33,32 @@ /// //****************************************************************************** -#ifndef PHOTONSTRATEGYTASK_H -#define PHOTONSTRATEGYTASK_H +#ifndef POVRAY_BACKEND_PHOTONSTRATEGYTASK_H +#define POVRAY_BACKEND_PHOTONSTRATEGYTASK_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 + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/render/trace.h" -#include "backend/frame.h" +// POV-Ray header files (backend module) +#include "backend/lighting/photonshootingstrategy_fwd.h" #include "backend/render/rendertask.h" namespace pov { -using namespace pov_base; - -class PhotonShootingStrategy; - -class PhotonStrategyTask : public RenderTask +class PhotonStrategyTask final : public RenderTask { public: Timer timer; @@ -56,21 +66,21 @@ class PhotonStrategyTask : public RenderTask PhotonShootingStrategy* strategy; PhotonStrategyTask(ViewData *vd, PhotonShootingStrategy* strategy, size_t seed); - ~PhotonStrategyTask(); + virtual ~PhotonStrategyTask() override; - void Run(); - void Stopped(); - void Finish(); + virtual void Run() override; + virtual void Stopped() override; + virtual void Finish() override; void SendProgress(); - void SearchThroughObjectsCreateUnits(vector& Objects, LightSource *Light); + void SearchThroughObjectsCreateUnits(std::vector& Objects, LightSource *Light); private: - class CooperateFunction : public Trace::CooperateFunctor + class CooperateFunction final : public Trace::CooperateFunctor { public: CooperateFunction(Task& t) : task(t) { } - virtual void operator()() { task.Cooperate(); } + virtual void operator()() override { task.Cooperate(); } private: Task& task; }; @@ -79,4 +89,6 @@ class PhotonStrategyTask : public RenderTask }; } -#endif +// end of namespace pov + +#endif // POVRAY_BACKEND_PHOTONSTRATEGYTASK_H diff --git a/source/backend/povray.cpp b/source/backend/povray.cpp index b38f00bd7..7b7690db7 100644 --- a/source/backend/povray.cpp +++ b/source/backend/povray.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,27 +33,36 @@ /// //****************************************************************************** -#include -#include +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/povray.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/povray.h" +// C++ standard header files +#include -#include "povms/povmscpp.h" -#include "povms/povmsid.h" -#include "povms/povmsutil.h" +// Boost header files +#include +#include +// POV-Ray header files (base module) #include "base/platformbase.h" #include "base/pov_err.h" +#include "base/stringutilities.h" #include "base/timer.h" #include "base/types.h" +// POV-Ray header files (core module) #include "core/material/noise.h" #include "core/material/pattern.h" +// POV-Ray header files (POVMS module) +#include "povms/povmscpp.h" +#include "povms/povmsid.h" +#include "povms/povmsutil.h" + +// POV-Ray header files (backend module) #include "backend/control/renderbackend.h" #include "backend/support/task.h" @@ -508,7 +517,7 @@ void BuildInitInfo(POVMSObjectPtr msg) { #ifdef TRY_OPTIMIZED_NOISE const OptimizedNoiseInfo* pNoise = GetRecommendedOptimizedNoise(); - std::string noiseGenInfo = "Noise generator: " + std::string(pNoise->name) + " (" + ::string(pNoise->info) + ")"; + std::string noiseGenInfo = "Noise generator: " + std::string(pNoise->name) + " (" + std::string(pNoise->info) + ")"; err = POVMSAttr_New(&attr); if (err == kNoErr) { diff --git a/source/backend/povray.h b/source/backend/povray.h index 984a55086..eb53108da 100644 --- a/source/backend/povray.h +++ b/source/backend/povray.h @@ -14,7 +14,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 @@ -42,12 +42,22 @@ #ifndef POVRAY_BACKEND_POVRAY_H #define POVRAY_BACKEND_POVRAY_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) + +// Boost header files #include #include +// POV-Ray header files (base module) #include "base/version_info.h" -#include "povms/povmscpp.h" +// POV-Ray header files (backend module) +// (none at the moment) /** * This function does essential initialisation that is required before diff --git a/source/backend/precomp.h b/source/backend/precomp.h index 95c341178..f9397f771 100644 --- a/source/backend/precomp.h +++ b/source/backend/precomp.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 @@ -45,8 +45,9 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -#include "base/configbase.h" +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED +// C++ variants of C standard header files #include #include #include @@ -56,6 +57,7 @@ #include #include +// C++ standard header files #include #include #include @@ -68,13 +70,11 @@ #include #include +// Boost header files #include #include #include #include -#include -#include -#include #if POV_MULTITHREADED #include #include diff --git a/source/backend/render/radiositytask.cpp b/source/backend/render/radiositytask.cpp index 6472f6bb3..fc706957e 100644 --- a/source/backend/render/radiositytask.cpp +++ b/source/backend/render/radiositytask.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,16 +33,29 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/render/radiositytask.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/render/radiositytask.h" - +// POV-Ray header files (base module) #include "base/timer.h" #include "base/types.h" +// POV-Ray header files (core module) +// POV-Ray header files (POVMS module) +// (none at the moment) + +// POV-Ray header files (backend module) #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" #include "backend/scene/viewthreaddata.h" @@ -55,6 +68,9 @@ namespace pov using namespace pov_base; +using std::min; +using std::max; + RadiosityTask::RadiosityTask(ViewData *vd, DBL ptsz, DBL ptesz, unsigned int pts, unsigned int ptsc, unsigned int nt, size_t seed) : RenderTask(vd, seed, "Radiosity", vd->GetViewId()), @@ -89,8 +105,8 @@ void RadiosityTask::Run() DBL height = GetViewData()->GetHeight(); POVRect rect; - vector pixelpositions; - vector pixelcolors; + std::vector pixelpositions; + std::vector pixelcolors; unsigned int serial; float progressWeightTotal = (pow(4.0f, (float)pretraceStepCount) - 1.0) / 3.0; // equal to SUM[i=0,N-1](pow(4.0, i)) @@ -261,3 +277,4 @@ void RadiosityTask::Finish() } } +// end of namespace pov diff --git a/source/backend/render/radiositytask.h b/source/backend/render/radiositytask.h index 55873eaa6..299428028 100644 --- a/source/backend/render/radiositytask.h +++ b/source/backend/render/radiositytask.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,41 +36,54 @@ #ifndef POVRAY_BACKEND_RADIOSITYTASK_H #define POVRAY_BACKEND_RADIOSITYTASK_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) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/lighting/photons.h" #include "core/lighting/radiosity.h" #include "core/material/media.h" #include "core/render/tracepixel.h" +// POV-Ray header files (backend module) #include "backend/render/rendertask.h" #include "backend/scene/view.h" namespace pov { -class RadiosityTask : public RenderTask +class RadiosityTask final : public RenderTask { public: RadiosityTask(ViewData *vd, DBL ptsz, DBL ptesz, unsigned int pts, unsigned int ptsc, unsigned int nt, size_t seed); - virtual ~RadiosityTask(); + virtual ~RadiosityTask() override; - virtual void Run(); - virtual void Stopped(); - virtual void Finish(); + virtual void Run() override; + virtual void Stopped() override; + virtual void Finish() override; private: - class CooperateFunction : public Trace::CooperateFunctor + class CooperateFunction final : public Trace::CooperateFunctor { public: CooperateFunction(Task& t) : task(t) { } - virtual void operator()() { task.Cooperate(); } + virtual void operator()() override { task.Cooperate(); } private: Task& task; }; - struct RadiositySubBlockInfo { + struct RadiositySubBlockInfo final + { RadiositySubBlockInfo(unsigned short x, unsigned short y): subBlockPosX(x), subBlockPosY(y) {} unsigned short subBlockPosX, subBlockPosY; }; - class RadiosityBlockInfo : public ViewData::BlockInfo + class RadiosityBlockInfo final : public ViewData::BlockInfo { public: RadiosityBlockInfo(): pass(0), subBlockCountX(1), subBlockCountY(1), completion(0.0) @@ -104,6 +117,6 @@ class RadiosityTask : public RenderTask }; } +// end of namespace pov #endif // POVRAY_BACKEND_RADIOSITYTASK_H - diff --git a/source/backend/render/rendertask.cpp b/source/backend/render/rendertask.cpp index 2d3b3c210..9219624bc 100644 --- a/source/backend/render/rendertask.cpp +++ b/source/backend/render/rendertask.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,18 +33,28 @@ /// //****************************************************************************** -#include -#include +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/render/rendertask.h" -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) -#include "povms/povmsid.h" +// Boost header files +#include +#include +// POV-Ray header files (base module) #include "base/types.h" #include "base/timer.h" -#include "backend/render/rendertask.h" +// POV-Ray header files (core module) +// (none at the moment) + +// POV-Ray header files (POVMS module) +#include "povms/povmsid.h" + +// POV-Ray header files (backend module) #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" #include "backend/scene/viewthreaddata.h" @@ -67,7 +77,7 @@ RenderTask::~RenderTask() { } -shared_ptr& RenderTask::GetSceneData() +std::shared_ptr& RenderTask::GetSceneData() { return viewData->GetSceneData(); } @@ -95,3 +105,4 @@ void RenderTask::SendFatalError(Exception& e) } } +// end of namespace pov diff --git a/source/backend/render/rendertask.h b/source/backend/render/rendertask.h index 8d9371df4..51f3c2ada 100644 --- a/source/backend/render/rendertask.h +++ b/source/backend/render/rendertask.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,25 +36,36 @@ #ifndef POVRAY_BACKEND_RENDERTASK_H #define POVRAY_BACKEND_RENDERTASK_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 + +// POV-Ray header files (base module) +#include "core/core_fwd.h" + +// POV-Ray header files (backend module) +#include "backend/scene/view_fwd.h" +#include "backend/scene/viewthreaddata_fwd.h" #include "backend/support/task.h" namespace pov { -class SceneData; -class ViewData; -class ViewThreadData; - class RenderTask : public SceneTask { public: RenderTask(ViewData *vd, size_t seed, const char* sn, RenderBackend::ViewId vid = 0); - virtual ~RenderTask(); + virtual ~RenderTask() override; protected: - virtual void Run() = 0; - virtual void Stopped() = 0; + virtual void Run() override = 0; + virtual void Stopped() override = 0; - shared_ptr& GetSceneData(); + std::shared_ptr& GetSceneData(); ViewData *GetViewData(); inline ViewThreadData *GetViewDataPtr() { return reinterpret_cast(GetDataPtr()); } @@ -66,5 +77,6 @@ class RenderTask : public SceneTask }; } +// end of namespace pov #endif // POVRAY_BACKEND_RENDERTASK_H diff --git a/source/backend/render/tracetask.cpp b/source/backend/render/tracetask.cpp index 64a1b70b9..063404981 100644 --- a/source/backend/render/tracetask.cpp +++ b/source/backend/render/tracetask.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,47 +33,62 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/render/tracetask.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include -#include +// Boost header files #include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/render/tracetask.h" +// POV-Ray header files (base module) +#include "base/image/colourspace.h" +#ifdef PROFILE_INTERSECTIONS +#include "base/image/image_fwd.h" +#endif +// POV-Ray header files (core module) #include "core/material/normal.h" #include "core/math/chi2.h" #include "core/math/jitter.h" #include "core/math/matrix.h" #include "core/render/trace.h" +// POV-Ray header files (POVMS module) +// (none at the moment) + +// POV-Ray header files (backend module) #include "backend/scene/backendscenedata.h" #include "backend/scene/view.h" #include "backend/scene/viewthreaddata.h" -#ifdef PROFILE_INTERSECTIONS -#include "base/image/image.h" -#endif - // this must be the last file included #include "base/povdebug.h" namespace pov { +using std::min; +using std::max; +using std::vector; + #ifdef PROFILE_INTERSECTIONS bool gDoneBSP; bool gDoneBVH; POV_ULONG gMinVal = std::numeric_limits::max(); POV_ULONG gMaxVal = 0; POV_ULONG gIntersectionTime; - vector > gBSPIntersectionTimes; - vector > gBVHIntersectionTimes; - vector > *gIntersectionTimes; + vector> gBSPIntersectionTimes; + vector> gBVHIntersectionTimes; + vector> *gIntersectionTimes; #endif -class SmartBlock +class SmartBlock final { public: SmartBlock(int ox, int oy, int bw, int bh); @@ -330,9 +345,9 @@ void TraceTask::Finish() if (width == gBVHIntersectionTimes[0].size() && height == gBVHIntersectionTimes.size()) { SNGL scale = 1.0 / (gMaxVal - gMinVal); - Image::WriteOptions opts; + ImageWriteOptions opts; opts.bitsPerChannel = 16; - Image *img = Image::Create(width, height, Image::Gray_Int16, false); + Image *img = Image::Create(width, height, ImageDataType::Gray_Int16, false); for (int y = 0 ; y < height ; y++) for (int x = 0 ; x < width ; x++) img->SetGrayValue(x, y, (gBSPIntersectionTimes[y][x] - gMinVal) * scale); @@ -341,7 +356,7 @@ void TraceTask::Finish() delete imagefile; delete img; - img = Image::Create(width, height, Image::Gray_Int16, false); + img = Image::Create(width, height, ImageDataType::Gray_Int16, false); imagefile = NewOStream("bvhprofile.png", 0, false); for (int y = 0 ; y < height ; y++) for (int x = 0 ; x < width ; x++) @@ -350,7 +365,7 @@ void TraceTask::Finish() delete imagefile; delete img; - img = Image::Create(width, height, Image::Gray_Int16, false); + img = Image::Create(width, height, ImageDataType::Gray_Int16, false); imagefile = NewOStream("summedprofile.png", 0, false); for (int y = 0 ; y < height ; y++) for (int x = 0 ; x < width ; x++) @@ -359,7 +374,7 @@ void TraceTask::Finish() delete imagefile; delete img; - img = Image::Create(width, height, Image::RGBFT_Float, false); + img = Image::Create(width, height, ImageDataType::RGBFT_Float, false); imagefile = NewOStream("rgbprofile.png", 0, false); for (int y = 0 ; y < height ; y++) { @@ -1061,3 +1076,4 @@ void TraceTask::SubdivideOnePixel(DBL x, DBL y, DBL d, size_t bx, size_t by, siz } } +// end of namespace pov diff --git a/source/backend/render/tracetask.h b/source/backend/render/tracetask.h index 230f3542a..462b9a1d9 100644 --- a/source/backend/render/tracetask.h +++ b/source/backend/render/tracetask.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,15 +36,24 @@ #ifndef POVRAY_BACKEND_TRACETASK_H #define POVRAY_BACKEND_TRACETASK_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 -#include "base/image/colourspace.h" +// POV-Ray header files (base module) +#include "base/image/colourspace_fwd.h" +// POV-Ray header files (core module) #include "core/lighting/radiosity.h" #include "core/material/media.h" #include "core/render/tracepixel.h" -#include "backend/frame.h" +// POV-Ray header files (backend module) #include "backend/render/rendertask.h" namespace pov @@ -53,33 +62,33 @@ namespace pov #ifdef PROFILE_INTERSECTIONS // NB not thread-safe (and not intended to be) extern POV_ULONG gIntersectionTime; - extern vector > gBSPIntersectionTimes; - extern vector > gBVHIntersectionTimes; - extern vector > *gIntersectionTimes; + extern std::vector> gBSPIntersectionTimes; + extern std::vector> gBVHIntersectionTimes; + extern std::vector> *gIntersectionTimes; #endif -class TraceTask : public RenderTask +class TraceTask final : public RenderTask { public: TraceTask(ViewData *vd, unsigned int tm, DBL js, DBL aat, DBL aac, unsigned int aad, pov_base::GammaCurvePtr& aag, unsigned int ps, bool psc, bool contributesToImage, bool hr, size_t seed); - virtual ~TraceTask(); + virtual ~TraceTask() override; - virtual void Run(); - virtual void Stopped(); - virtual void Finish(); + virtual void Run() override; + virtual void Stopped() override; + virtual void Finish() override; private: - class CooperateFunction : public Trace::CooperateFunctor + class CooperateFunction final : public Trace::CooperateFunctor { public: CooperateFunction(Task& t) : task(t) { } - virtual void operator()() { task.Cooperate(); } + virtual void operator()() override { task.Cooperate(); } private: Task& task; }; - class SubdivisionBuffer + class SubdivisionBuffer final { public: SubdivisionBuffer(size_t s); @@ -91,8 +100,8 @@ class TraceTask : public RenderTask void Clear(); private: - vector colors; - vector sampled; + std::vector colors; + std::vector sampled; size_t size; }; @@ -128,5 +137,6 @@ class TraceTask : public RenderTask }; } +// end of namespace pov #endif // POVRAY_BACKEND_TRACETASK_H diff --git a/source/backend/scene/backendscenedata.cpp b/source/backend/scene/backendscenedata.cpp index e5e2a0c45..e2829156a 100644 --- a/source/backend/scene/backendscenedata.cpp +++ b/source/backend/scene/backendscenedata.cpp @@ -33,19 +33,35 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/scene/backendscenedata.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/scene/backendscenedata.h" - +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/fileutil.h" +#include "base/path.h" +#include "base/stringutilities.h" + +// POV-Ray header files (core module) +// (none at the moment) +// POV-Ray header files (POVMS module) #include "povms/povmsid.h" +// POV-Ray header files (backend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -58,7 +74,7 @@ BackendSceneData::BackendSceneData() : UCS2String BackendSceneData::FindFile(POVMSContext ctx, const UCS2String& filename, unsigned int stype) { - vector filenames; + std::vector filenames; UCS2String foundfile; bool tryExactFirst; @@ -100,7 +116,7 @@ UCS2String BackendSceneData::FindFile(POVMSContext ctx, const UCS2String& filena #ifdef USE_SCENE_FILE_MAPPING // see if the file is available locally - for(vector::const_iterator i(filenames.begin()); i != filenames.end(); i++) + for(std::vector::const_iterator i(filenames.begin()); i != filenames.end(); i++) { FilenameToFilenameMap::iterator ilocalfile(scene2LocalFiles.find(*i)); @@ -109,7 +125,7 @@ UCS2String BackendSceneData::FindFile(POVMSContext ctx, const UCS2String& filena } // see if the file is available as temporary file - for(vector::const_iterator i(filenames.begin()); i != filenames.end(); i++) + for(std::vector::const_iterator i(filenames.begin()); i != filenames.end(); i++) { FilenameToFilenameMap::iterator itempfile(scene2TempFiles.find(*i)); @@ -309,3 +325,4 @@ OStream *BackendSceneData::CreateFile(POVMSContext ctx, const UCS2String& filena } } +// end of namespace pov diff --git a/source/backend/scene/backendscenedata.h b/source/backend/scene/backendscenedata.h index bd347326b..5c73a99ff 100644 --- a/source/backend/scene/backendscenedata.h +++ b/source/backend/scene/backendscenedata.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,14 +36,29 @@ #ifndef POVRAY_BACKEND_BACKENDSCENEDATA_H #define POVRAY_BACKEND_BACKENDSCENEDATA_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" +#include "backend/scene/backendscenedata_fwd.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/stringtypes.h" + +// POV-Ray header files (core module) #include "core/scene/scenedata.h" +// POV-Ray header files (backend module) #include "backend/control/renderbackend.h" namespace pov { -class BackendSceneData : public SceneData +class BackendSceneData final : public SceneData { // Scene needs access to the private scene data constructor! friend class Scene; @@ -130,13 +145,11 @@ class BackendSceneData : public SceneData */ BackendSceneData(); - /// not available - BackendSceneData(const BackendSceneData&); - - /// not available - BackendSceneData& operator=(const BackendSceneData&); + BackendSceneData(const BackendSceneData&) = delete; + BackendSceneData& operator=(const BackendSceneData&) = delete; }; } +// end of namespace pov #endif // POVRAY_BACKEND_BACKENDSCENEDATA_H diff --git a/source/backend/scene/backendscenedata_fwd.h b/source/backend/scene/backendscenedata_fwd.h new file mode 100644 index 000000000..782d233f0 --- /dev/null +++ b/source/backend/scene/backendscenedata_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file backend/scene/backendscenedata_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_BACKENDSCENEDATA_FWD_H +#define POVRAY_BACKEND_BACKENDSCENEDATA_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class BackendSceneData; + +} +// end of namespace pov + +#endif // POVRAY_BACKEND_BACKENDSCENEDATA_FWD_H diff --git a/source/backend/scene/view.cpp b/source/backend/scene/view.cpp index 00c60f63e..f1b693085 100644 --- a/source/backend/scene/view.cpp +++ b/source/backend/scene/view.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,27 +33,40 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/scene/view.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// Boost header files #include #include #include #include #include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/scene/view.h" - +// POV-Ray header files (base module) #include "base/path.h" +#include "base/povassert.h" #include "base/timer.h" +#include "base/image/colourspace.h" +// POV-Ray header files (core module) #include "core/lighting/photons.h" #include "core/lighting/radiosity.h" #include "core/math/matrix.h" #include "core/support/octree.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/control/renderbackend.h" #include "backend/lighting/photonestimationtask.h" #include "backend/lighting/photonshootingstrategy.h" @@ -73,6 +86,11 @@ namespace pov { +using std::min; +using std::max; +using std::shared_ptr; +using std::vector; + /// Round up to a power of two. inline unsigned int MakePowerOfTwo(unsigned int i) { @@ -1327,7 +1345,7 @@ void View::GetStatistics(POVMS_Object& renderStats) renderStats.SetLong(kPOVAttrib_GatherPerformedCnt, stats[Gather_Performed_Count]); renderStats.SetLong(kPOVAttrib_GatherExpandedCnt, stats[Gather_Expanded_Count]); - struct TimeData + struct TimeData final { POV_LONG cpuTime; POV_LONG realTime; @@ -1547,3 +1565,4 @@ const Camera *RTRData::CompletedFrame() } } +// end of namespace pov diff --git a/source/backend/scene/view.h b/source/backend/scene/view.h index abdf2f855..c5fb4164c 100644 --- a/source/backend/scene/view.h +++ b/source/backend/scene/view.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,12 +36,29 @@ #ifndef POVRAY_BACKEND_VIEW_H #define POVRAY_BACKEND_VIEW_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" +#include "backend/scene/view_fwd.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +// POV-Ray header files (base module) +#include "base/types.h" // TODO - only appears to be pulled in for POVRect - can we avoid this? + +// POV-Ray header files (core module) +#include "core/core_fwd.h" #include "core/bounding/bsptree.h" #include "core/lighting/radiosity.h" #include "core/scene/camera.h" +// POV-Ray header files (backend module) +#include "backend/control/scene_fwd.h" +#include "backend/scene/viewthreaddata_fwd.h" #include "backend/support/taskqueue.h" namespace pov @@ -49,12 +66,7 @@ namespace pov using namespace pov_base; -class Scene; -class SceneData; -class ViewData; -class ViewThreadData; - -class RTRData +class RTRData final { public: RTRData(ViewData& v, int mrt); @@ -65,7 +77,7 @@ class RTRData /// number of frames rendered in real-time raytracing mode unsigned int numRTRframes; /// this holds the pixels rendered in real-time-raytracing mode - vector rtrPixels; + std::vector rtrPixels; /// the number of render threads to wait for int numRenderThreads; /// the number of render threads that have completed the current RTR frame @@ -89,7 +101,7 @@ class RTRData * such there are no public members but only accessor * methods. Please do not add public data members!!! */ -class ViewData +class ViewData final { // View needs access to the private view data constructor as well // as some private data in order to initialise it properly! @@ -105,7 +117,7 @@ class ViewData class BlockInfo { public: - virtual ~BlockInfo() {} // need to have a virtual member so we can use dynamic_cast + virtual ~BlockInfo() {} }; /** @@ -152,7 +164,7 @@ class ViewData * data passed to whichever rendering thread the rectangle will be re-dispatched to. * If this value is `nullptr`, the rectangle will not be re-dispatched. */ - void CompletedRectangle(const POVRect& rect, unsigned int serial, const vector& pixels, + void CompletedRectangle(const POVRect& rect, unsigned int serial, const std::vector& pixels, unsigned int size, bool relevant, bool complete, float completion = 1.0, BlockInfo* blockInfo = nullptr); @@ -173,8 +185,8 @@ class ViewData * data passed to whichever rendering thread the rectangle will be re-dispatched to. * If this value is `nullptr`, the rectangle will not be re-dispatched. */ - void CompletedRectangle(const POVRect& rect, unsigned int serial, const vector& positions, - const vector& colors, unsigned int size, bool relevant, bool complete, + void CompletedRectangle(const POVRect& rect, unsigned int serial, const std::vector& positions, + const std::vector& colors, unsigned int size, bool relevant, bool complete, float completion = 1.0, BlockInfo* blockInfo = nullptr); /** @@ -226,7 +238,7 @@ class ViewData * Get the scene data for this view. * @return Scene data. */ - inline shared_ptr& GetSceneData() { return sceneData; } + inline std::shared_ptr& GetSceneData() { return sceneData; } /** * Get the view id for this view. @@ -247,7 +259,7 @@ class ViewData void SetHighestTraceLevel(unsigned int htl); /** - * Get the render qualitiy features to use when rendering this view. + * Get the render quality features to use when rendering this view. * @return Quality feature flags. */ const QualityFlags& GetQualityFeatureFlags() const; @@ -272,7 +284,8 @@ class ViewData private: - struct BlockPostponedEntry { + struct BlockPostponedEntry final + { unsigned int blockId; unsigned int pass; BlockPostponedEntry(unsigned int id, unsigned int p) : blockId(id), pass(p) {} @@ -317,7 +330,7 @@ class ViewData /// list of blocks postponed for some reason BlockIdSet blockPostponedList; /// list of additional block information - vector blockInfoList; + std::vector blockInfoList; /// area of view to be rendered POVRect renderArea; /// camera of this view @@ -325,7 +338,7 @@ class ViewData /// generated radiosity data RadiosityCache radiosityCache; /// scene data - shared_ptr sceneData; + std::shared_ptr sceneData; /// view id RenderBackend::ViewId viewId; @@ -349,7 +362,7 @@ class ViewData * Create view data. * @param sd Scene data associated with the view data. */ - ViewData(shared_ptr sd); + ViewData(std::shared_ptr sd); /** * Destructor. @@ -361,7 +374,7 @@ class ViewData * View class representing an view with a specific camera * being rendered. */ -class View +class View final { // Scene needs access to the private view constructor! friend class Scene; @@ -440,7 +453,7 @@ class View /// running and pending render tasks for this view TaskQueue renderTasks; /// view thread data (i.e. statistics) - vector viewThreadData; + std::vector viewThreadData; /// view data ViewData viewData; /// stop request flag @@ -450,11 +463,8 @@ class View /// BSP tree mailbox BSPTree::Mailbox mailbox; - /// not available - View(); - - /// not available - View(const View&); + View() = delete; + View(const View&) = delete; /** * Create an view and associate a scene's data with it. @@ -464,10 +474,9 @@ class View * @param vid Id of this view to include with * POVMS messages sent to the frontend. */ - explicit View(shared_ptr sd, unsigned int width, unsigned int height, RenderBackend::ViewId vid); + explicit View(std::shared_ptr sd, unsigned int width, unsigned int height, RenderBackend::ViewId vid); - /// not available - View& operator=(const View&); + View& operator=(const View&) = delete; /** * Dispatch any shutdown messages appropriate at the end of rendering a view (e.g. max_gradient). @@ -488,7 +497,7 @@ class View * @param bsl Block serial numbers to skip. * @param fs First block to start with checking with serial number. */ - void SetNextRectangle(TaskQueue& taskq, shared_ptr bsl, unsigned int fs); + void SetNextRectangle(TaskQueue& taskq, std::shared_ptr bsl, unsigned int fs); /** * Thread controlling the render task queue. @@ -505,5 +514,6 @@ class View }; } +// end of namespace pov #endif // POVRAY_BACKEND_VIEW_H diff --git a/source/backend/scene/view_fwd.h b/source/backend/scene/view_fwd.h new file mode 100644 index 000000000..de4fefdc8 --- /dev/null +++ b/source/backend/scene/view_fwd.h @@ -0,0 +1,52 @@ +//****************************************************************************** +/// +/// @file backend/scene/view_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_VIEW_FWD_H +#define POVRAY_BACKEND_VIEW_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class View; +class ViewData; + +} +// end of namespace pov + +#endif // POVRAY_BACKEND_VIEW_FWD_H diff --git a/source/backend/scene/viewthreaddata.cpp b/source/backend/scene/viewthreaddata.cpp index 82020a62c..3044f6acc 100644 --- a/source/backend/scene/viewthreaddata.cpp +++ b/source/backend/scene/viewthreaddata.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,12 +33,22 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/scene/viewthreaddata.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include -// frame.h must always be the first POV file included (pulls in platform config) -#include "backend/frame.h" -#include "backend/scene/viewthreaddata.h" +// 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/scene/backendscenedata.h" #include "backend/scene/view.h" @@ -49,7 +59,7 @@ namespace pov { ViewThreadData::ViewThreadData(ViewData *vd, size_t seed) : - TraceThreadData(dynamic_pointer_cast(vd->GetSceneData()), seed), + TraceThreadData(std::dynamic_pointer_cast(vd->GetSceneData()), seed), viewData(vd) { } @@ -74,3 +84,4 @@ const POVRect& ViewThreadData::GetRenderArea() } } +// end of namespace pov diff --git a/source/backend/scene/viewthreaddata.h b/source/backend/scene/viewthreaddata.h index 3817f7d62..66e3ab697 100644 --- a/source/backend/scene/viewthreaddata.h +++ b/source/backend/scene/viewthreaddata.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,17 +36,30 @@ #ifndef POVRAY_BACKEND_VIEWTHREADDATA_H #define POVRAY_BACKEND_VIEWTHREADDATA_H +// Module config header file must be the first file included within POV-Ray unit header files +#include "backend/configbackend.h" +#include "backend/scene/viewthreaddata_fwd.h" + +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/tracethreaddata.h" +// POV-Ray header files (backend module) +#include "backend/scene/view_fwd.h" + namespace pov { -class ViewData; - /** * Class holding render thread specific data. */ -class ViewThreadData : public TraceThreadData +class ViewThreadData final : public TraceThreadData { friend class Scene; public: @@ -80,21 +93,19 @@ class ViewThreadData : public TraceThreadData /// view data ViewData *viewData; private: - /// not available - ViewThreadData(); - /// not available - ViewThreadData(const ViewThreadData&); + ViewThreadData() = delete; + ViewThreadData(const ViewThreadData&) = delete; + ViewThreadData& operator=(const ViewThreadData&) = delete; - /// not available - ViewThreadData& operator=(const ViewThreadData&); public: // TODO FIXME - temporary workaround [trf] /** * Destructor. */ - ~ViewThreadData(); + virtual ~ViewThreadData() override; }; } +// end of namespace pov #endif // POVRAY_BACKEND_VIEWTHREADDATA_H diff --git a/source/backend/scene/viewthreaddata_fwd.h b/source/backend/scene/viewthreaddata_fwd.h new file mode 100644 index 000000000..df2b7b37e --- /dev/null +++ b/source/backend/scene/viewthreaddata_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file backend/scene/viewthreaddata_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_VIEWTHREADDATA_FWD_H +#define POVRAY_BACKEND_VIEWTHREADDATA_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class ViewThreadData; + +} +// end of namespace pov + +#endif // POVRAY_BACKEND_VIEWTHREADDATA_FWD_H diff --git a/source/backend/support/task.cpp b/source/backend/support/task.cpp index c5f01a6bf..f6732d71a 100644 --- a/source/backend/support/task.cpp +++ b/source/backend/support/task.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,19 +33,29 @@ /// //****************************************************************************** -#include +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/support/task.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #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/support/task.h" - +// POV-Ray header files (base module) +#include "base/povassert.h" #include "base/timer.h" #include "base/types.h" +// 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/messagefactory.h" #include "backend/scene/backendscenedata.h" @@ -270,9 +280,15 @@ void Task::Cleanup () #endif // POV_USE_DEFAULT_TASK_CLEANUP -SceneTask::SceneTask(ThreadData *td, const boost::function1& f, const char* sn, shared_ptr sd, RenderBackend::ViewId vid) : +SceneTask::SceneTask(ThreadData *td, const boost::function1& f, const char* sn, std::shared_ptr sd, RenderBackend::ViewId vid) : Task(td, f), - messageFactory(sd->warningLevel, sn, sd->backendAddress, sd->frontendAddress, sd->sceneId, vid) + mpMessageFactory(new MessageFactory(sd->warningLevel, sn, sd->backendAddress, sd->frontendAddress, sd->sceneId, vid)) {} +SceneTask::~SceneTask() +{ + delete mpMessageFactory; +} + } +// end of namespace pov diff --git a/source/backend/support/task.h b/source/backend/support/task.h index dfb91da0e..14a2f6904 100644 --- a/source/backend/support/task.h +++ b/source/backend/support/task.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,26 +36,34 @@ #ifndef POVRAY_BACKEND_TASK_H #define POVRAY_BACKEND_TASK_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 #include -#include +// Boost header files #include #include -#include "backend/frame.h" +// POV-Ray header files (base module) +#include "base/base_fwd.h" +#include "base/timer.h" -#include "backend/control/messagefactory.h" +// POV-Ray header files (backend module) +#include "backend/control/messagefactory_fwd.h" #include "backend/control/renderbackend.h" -#include "base/timer.h" +#include "backend/scene/backendscenedata_fwd.h" namespace pov { using namespace pov_base; -class BackendSceneData; - - class Task { public: @@ -119,7 +127,7 @@ class Task protected: - struct StopThreadException { }; + struct StopThreadException final {}; // TODO - consider subclassing from std::exception hierarchy. virtual void Run() = 0; virtual void Stopped() = 0; @@ -161,14 +169,9 @@ class Task inline void FatalErrorHandler(Exception& e) { fatalErrorHandler(e); } - /// not available - Task(); - - /// not available - Task(const Task&); - - /// not available - Task& operator=(const Task&); + Task() = delete; + Task(const Task&) = delete; + Task& operator=(const Task&) = delete; /// Execute the thread. void TaskThread(const boost::function0& completion); @@ -194,12 +197,14 @@ class Task class SceneTask : public Task { public: - SceneTask(ThreadData *td, const boost::function1& f, const char* sn, shared_ptr sd, RenderBackend::ViewId vid = 0); + SceneTask(ThreadData *td, const boost::function1& f, const char* sn, std::shared_ptr sd, RenderBackend::ViewId vid = 0); + virtual ~SceneTask() override; protected: - MessageFactory messageFactory; + MessageFactory* mpMessageFactory; }; } +// end of namespace pov #endif // POVRAY_BACKEND_TASK_H diff --git a/source/backend/support/taskqueue.cpp b/source/backend/support/taskqueue.cpp index 2a8fe6e14..9db706040 100644 --- a/source/backend/support/taskqueue.cpp +++ b/source/backend/support/taskqueue.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 @@ -33,13 +33,22 @@ /// //****************************************************************************** +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) +#include "backend/support/taskqueue.h" + +// C++ variants of C standard header files +// C++ standard header files + +// 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/support/taskqueue.h" +// 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/support/task.h" // this must be the last file included @@ -48,7 +57,8 @@ namespace pov { -using boost::recursive_mutex; +using std::list; +using std::shared_ptr; TaskQueue::TaskQueue() : failed(kNoError) { @@ -61,7 +71,7 @@ TaskQueue::~TaskQueue() void TaskQueue::Stop() { - recursive_mutex::scoped_lock lock(queueMutex); + boost::recursive_mutex::scoped_lock lock(queueMutex); // we pass through this list twice; the first time through only sets the cancel // flag, and the second time through waits for the threads to exit. if we only @@ -83,7 +93,7 @@ void TaskQueue::Stop() void TaskQueue::Pause() { - recursive_mutex::scoped_lock lock(queueMutex); + boost::recursive_mutex::scoped_lock lock(queueMutex); for(list::iterator i(activeTasks.begin()); i != activeTasks.end(); i++) i->GetTask()->Pause(); @@ -142,7 +152,7 @@ bool TaskQueue::Failed() int TaskQueue::FailureCode(int defval) { - recursive_mutex::scoped_lock lock(queueMutex); + boost::recursive_mutex::scoped_lock lock(queueMutex); if(failed == kNoError) return defval; @@ -261,3 +271,4 @@ void TaskQueue::Notify() } } +// end of namespace pov diff --git a/source/backend/support/taskqueue.h b/source/backend/support/taskqueue.h index cb9e2b664..ba482a311 100644 --- a/source/backend/support/taskqueue.h +++ b/source/backend/support/taskqueue.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,19 +36,36 @@ #ifndef POVRAY_BACKEND_TASKQUEUE_H #define POVRAY_BACKEND_TASKQUEUE_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 +#include +#include + +// Boost header files #include #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (backend module) #include "backend/support/task.h" namespace pov { -class TaskQueue +class TaskQueue final { - class TaskEntry + class TaskEntry final { public: enum EntryType @@ -60,19 +77,19 @@ class TaskQueue }; TaskEntry(EntryType et) : entryType(et) { } - TaskEntry(shared_ptr rt) : entryType(kTask), task(rt) { } + TaskEntry(std::shared_ptr rt) : entryType(kTask), task(rt) { } TaskEntry(POVMS_Message& m) : entryType(kMessage), msg(m) { } TaskEntry(const boost::function1& f) : entryType(kFunction), fn(f) { } ~TaskEntry() { } - shared_ptr GetTask() { return task; } + std::shared_ptr GetTask() { return task; } POVMS_Message& GetMessage() { return msg; } boost::function1& GetFunction() { return fn; } EntryType GetEntryType() { return entryType; } private: EntryType entryType; - shared_ptr task; + std::shared_ptr task; POVMS_Message msg; boost::function1 fn; }; @@ -103,20 +120,19 @@ class TaskQueue /// queued task list std::queue queuedTasks; /// active task list - list activeTasks; + std::list activeTasks; /// queue mutex boost::recursive_mutex queueMutex; /// failed code int failed; /// wait for data in queue or related operation to be processed boost::condition processCondition; - /// not available - TaskQueue(const TaskQueue&); - /// not available - TaskQueue& operator=(const TaskQueue&); + TaskQueue(const TaskQueue&) = delete; + TaskQueue& operator=(const TaskQueue&) = delete; }; } +// end of namespace pov #endif // POVRAY_BACKEND_TASKQUEUE_H diff --git a/source/base/animation/animation.cpp b/source/base/animation/animation.cpp index 22af697b0..3ebcd1c5c 100644 --- a/source/base/animation/animation.cpp +++ b/source/base/animation/animation.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,14 +36,21 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/animation/animation.h" -// Boost header files -#include +// C++ variants of C standard header files +// (none at the moment) -// POV-Ray base header files +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/povassert.h" //#include "base/animation/avi.h" #include "base/animation/moov.h" //#include "base/animation/mpeg.h" #include "base/image/bmp.h" +#include "base/image/colourspace.h" +#include "base/image/image.h" #include "base/image/jpeg_pov.h" #include "base/image/png_pov.h" @@ -191,7 +198,7 @@ void Animation::AppendFrame(Image *image) // writing only - NOTE: This method re { if(writeOptions.blurradius > 0.0f) { - boost::scoped_ptr mask(Image::Create(image->GetWidth(), image->GetHeight(), Image::Bit_Map)); + std::unique_ptr mask(Image::Create(image->GetWidth(), image->GetHeight(), ImageDataType::Bit_Map)); float r, g, b, f, t; mask->FillBitValue(false); @@ -245,7 +252,7 @@ void Animation::SetCurrentFrame(unsigned int frame) // reading only currentFrame = frame; } -const vector& Animation::GetWarnings() const +const std::vector& Animation::GetWarnings() const { return warnings; } @@ -259,11 +266,11 @@ Image *Animation::ReadFrame(IStream *file) { POV_OFF_T bytes = 0; Image *image = nullptr; - Image::ReadOptions options; + ImageReadOptions options; options.defaultGamma = PowerLawGammaCurve::GetByDecodingGamma(readOptions.gamma); options.gammacorrect = readOptions.gammacorrect; - options.itype = Image::RGBFT_Float; + options.itype = ImageDataType::RGBFT_Float; switch(fileType) { @@ -328,10 +335,10 @@ Image *Animation::ReadFrame(IStream *file) POV_OFF_T Animation::WriteFrame(OStream *file, const Image *image) { - Image::WriteOptions options; + ImageWriteOptions options; options.bitsPerChannel = writeOptions.bpcc; - options.alphaMode = (writeOptions.alphachannel ? Image::kAlphaMode_Default : Image::kAlphaMode_None); + options.alphaMode = (writeOptions.alphachannel ? ImageAlphaMode::Default : ImageAlphaMode::None); options.compression = writeOptions.compress; // options.gamma = writeOptions.gamma; options.encodingGamma = PowerLawGammaCurve::GetByEncodingGamma(writeOptions.gamma); @@ -432,3 +439,4 @@ void Animation::GetBlurredPixel(const Image& image, unsigned int x, unsigned int } } +// end of namespace pov_base diff --git a/source/base/animation/animation.h b/source/base/animation/animation.h index 3252a0add..5b7fdd9f6 100644 --- a/source/base/animation/animation.h +++ b/source/base/animation/animation.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 @@ -39,14 +39,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include -// POV-Ray base header files -#include "base/fileinputoutput.h" +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" #include "base/pov_err.h" -#include "base/types.h" -#include "base/image/image.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -94,7 +97,7 @@ class Animation YUV410 }; - struct ReadOptions + struct ReadOptions final { float gamma; bool gammacorrect; @@ -102,7 +105,7 @@ class Animation ReadOptions() : gamma(1.0f), gammacorrect(false) { } }; - struct WriteOptions + struct WriteOptions final { ColorEncodingType colorencoding; unsigned char compress; // relative quality from 100 best to 0 worst @@ -134,7 +137,7 @@ class Animation unsigned int GetWidth() const { return width; } unsigned int GetHeight() const { return height; } - const vector& GetWarnings() const; + const std::vector& GetWarnings() const; void ClearWarnings(); protected: FileType fileType; @@ -144,7 +147,7 @@ class Animation unsigned int height; ReadOptions readOptions; WriteOptions writeOptions; - vector warnings; + std::vector warnings; CodecType codec; unsigned int currentFrame; unsigned int totalFrames; @@ -163,12 +166,9 @@ class Animation float blurMatrix[16][16]; // only uses 15 x 15 maximum (16 x 16 for better alignment) int blurMatrixRadius; - /// not available - Animation(); - /// not available - Animation(const Animation&); - /// not available - Animation& operator=(Animation&); + Animation() = delete; + Animation(const Animation&) = delete; + Animation& operator=(Animation&) = delete; }; /// @} @@ -176,5 +176,6 @@ class Animation //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_ANIMATION_H diff --git a/source/base/animation/moov.cpp b/source/base/animation/moov.cpp index ab025dfd1..80d8fee88 100644 --- a/source/base/animation/moov.cpp +++ b/source/base/animation/moov.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,7 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/animation/moov.h" -// POV-Ray base header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/pov_err.h" #include "base/types.h" #include "base/animation/animation.h" @@ -49,7 +56,7 @@ namespace pov_base typedef POV_INT32 Type; // TODO - this is a lousy type name -struct PrivateData +struct PrivateData final { unsigned int width; unsigned int height; @@ -58,7 +65,7 @@ struct PrivateData int timescale; int frameduration; POV_OFF_T mdatsize; - vector imagesizes; + std::vector imagesizes; }; namespace Moov @@ -71,25 +78,25 @@ void WriteInt4(OStream *file, POV_INT32 data); void WriteInt8(OStream *file, POV_INT64 data); void WriteN(OStream *file, size_t cnt, POV_INT8 data); -void *ReadFileHeader(IStream *file, float& lengthinseconds, unsigned int& lengthinframes, Animation::CodecType& codec, unsigned int& w, unsigned int& h, const Animation::ReadOptions& options, vector& warnings) +void *ReadFileHeader(IStream *file, float& lengthinseconds, unsigned int& lengthinframes, Animation::CodecType& codec, unsigned int& w, unsigned int& h, const Animation::ReadOptions& options, std::vector& warnings) { throw POV_EXCEPTION(kCannotHandleDataErr, "Reading QuickTime movie files is not supported (yet)!"); return nullptr; } -void PreReadFrame(IStream *file, unsigned int frame, POV_OFF_T& bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, vector& warnings, void *state) +void PreReadFrame(IStream *file, unsigned int frame, POV_OFF_T& bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, std::vector& warnings, void *state) { } -void PostReadFrame(IStream *file, unsigned int frame, POV_OFF_T bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, vector& warnings, void *state) +void PostReadFrame(IStream *file, unsigned int frame, POV_OFF_T bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, std::vector& warnings, void *state) { } -void FinishReadFile(IStream *file, vector& warnings, void *state) +void FinishReadFile(IStream *file, std::vector& warnings, void *state) { } -void *WriteFileHeader(OStream *file, Animation::CodecType& codec, unsigned int w, unsigned int h, const Animation::WriteOptions& options, vector& warnings) +void *WriteFileHeader(OStream *file, Animation::CodecType& codec, unsigned int w, unsigned int h, const Animation::WriteOptions& options, std::vector& warnings) { PrivateData pd; @@ -135,7 +142,7 @@ void *WriteFileHeader(OStream *file, Animation::CodecType& codec, unsigned int w break; } - pd.timescale = max(int(double(options.framespersecond) * double(m)), 1); + pd.timescale = std::max(int(double(options.framespersecond) * double(m)), 1); // frame duration according to time scale @@ -153,7 +160,7 @@ void *WriteFileHeader(OStream *file, Animation::CodecType& codec, unsigned int w return reinterpret_cast(new PrivateData(pd)); } -void PreWriteFrame(OStream *, const Animation::WriteOptions&, vector&, void *state) +void PreWriteFrame(OStream *, const Animation::WriteOptions&, std::vector&, void *state) { PrivateData *pd = reinterpret_cast(state); @@ -163,7 +170,7 @@ void PreWriteFrame(OStream *, const Animation::WriteOptions&, vector&, v // there really is nothing to do here [trf] } -void PostWriteFrame(OStream *file, POV_OFF_T bytes, const Animation::WriteOptions&, vector&, void *state) +void PostWriteFrame(OStream *file, POV_OFF_T bytes, const Animation::WriteOptions&, std::vector&, void *state) { PrivateData *pd = reinterpret_cast(state); @@ -184,7 +191,7 @@ void PostWriteFrame(OStream *file, POV_OFF_T bytes, const Animation::WriteOption pd->imagesizes.push_back(int(bytes)); } -void FinishWriteFile(OStream *file, const Animation::WriteOptions& options, vector& warnings, void *state) +void FinishWriteFile(OStream *file, const Animation::WriteOptions& options, std::vector& warnings, void *state) { PrivateData *pd = reinterpret_cast(state); @@ -372,7 +379,7 @@ void FinishWriteFile(OStream *file, const Animation::WriteOptions& options, vect WriteInt4(file, 0); // sample size (all samples have different sizes, so this needs to be zero) WriteInt4(file, pd->imagesizes.size()); // number of entries - for(vector::const_iterator i = pd->imagesizes.begin(); i != pd->imagesizes.end(); i++) + for(std::vector::const_iterator i = pd->imagesizes.begin(); i != pd->imagesizes.end(); i++) WriteInt4(file, *i); // sample size entry delete pd; @@ -463,5 +470,7 @@ void WriteN(OStream *file, size_t cnt, POV_INT8 data) } } +// end of namespace Moov } +// end of namespace pov_base diff --git a/source/base/animation/moov.h b/source/base/animation/moov.h index 4b2366039..48c4295f2 100644 --- a/source/base/animation/moov.h +++ b/source/base/animation/moov.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 @@ -39,8 +39,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/types.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" #include "base/animation/animation.h" namespace pov_base @@ -55,22 +62,24 @@ namespace pov_base namespace Moov { -void *ReadFileHeader(IStream *file, float& lengthinseconds, unsigned int& lengthinframes, Animation::CodecType& codec, unsigned int& w, unsigned int& h, const Animation::ReadOptions& options, vector& warnings); -void PreReadFrame(IStream *file, unsigned int frame, POV_OFF_T& bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, vector& warnings, void *state); -void PostReadFrame(IStream *file, unsigned int frame, POV_OFF_T bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, vector& warnings, void *state); -void FinishReadFile(IStream *file, vector& warnings, void *state); +void *ReadFileHeader(IStream *file, float& lengthinseconds, unsigned int& lengthinframes, Animation::CodecType& codec, unsigned int& w, unsigned int& h, const Animation::ReadOptions& options, std::vector& warnings); +void PreReadFrame(IStream *file, unsigned int frame, POV_OFF_T& bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, std::vector& warnings, void *state); +void PostReadFrame(IStream *file, unsigned int frame, POV_OFF_T bytes, Animation::CodecType& codec, const Animation::ReadOptions& options, std::vector& warnings, void *state); +void FinishReadFile(IStream *file, std::vector& warnings, void *state); -void *WriteFileHeader(OStream *file, Animation::CodecType& codec, unsigned int w, unsigned int h, const Animation::WriteOptions& options, vector& warnings); -void PreWriteFrame(OStream *file, const Animation::WriteOptions& options, vector& warnings, void *state); -void PostWriteFrame(OStream *file, POV_OFF_T bytes, const Animation::WriteOptions& options, vector& warnings, void *state); -void FinishWriteFile(OStream *file, const Animation::WriteOptions& options, vector& warnings, void *state); +void *WriteFileHeader(OStream *file, Animation::CodecType& codec, unsigned int w, unsigned int h, const Animation::WriteOptions& options, std::vector& warnings); +void PreWriteFrame(OStream *file, const Animation::WriteOptions& options, std::vector& warnings, void *state); +void PostWriteFrame(OStream *file, POV_OFF_T bytes, const Animation::WriteOptions& options, std::vector& warnings, void *state); +void FinishWriteFile(OStream *file, const Animation::WriteOptions& options, std::vector& warnings, void *state); } +// end of namespace Moov /// @} /// //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_MOOV_H diff --git a/source/base/base_fwd.h b/source/base/base_fwd.h new file mode 100644 index 000000000..c71b98949 --- /dev/null +++ b/source/base/base_fwd.h @@ -0,0 +1,59 @@ +//****************************************************************************** +/// +/// @file base/base_fwd.h +/// +/// Forward declaration of base types referenced by other modules. +/// +/// @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_BASE_FWD_H +#define POVRAY_BASE_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class Exception; +class ThreadData; + +enum class CharsetID : int; +enum LegacyCharset : int; + +/// 5-dimensional vector type shared between parser and splines. +/// @todo Make this obsolete. +typedef double EXPRESS[5]; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_FWD_H diff --git a/source/base/colour.cpp b/source/base/colour.cpp index d29e5ca84..6d56151f8 100644 --- a/source/base/colour.cpp +++ b/source/base/colour.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,6 +36,13 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/colour.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -62,3 +69,4 @@ template class GenericColour; template class GenericColour; } +// end of namespace pov_base diff --git a/source/base/colour.h b/source/base/colour.h index d226c48d4..d39324149 100644 --- a/source/base/colour.h +++ b/source/base/colour.h @@ -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 @@ -40,15 +40,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include -// Standard C++ header files +// C++ standard header files +#include #include -// POV-Ray base header files +// POV-Ray header files (base module) +#include "base/base_fwd.h" #include "base/mathutil.h" -#include "base/types.h" #define NUM_COLOUR_CHANNELS 3 @@ -119,7 +120,7 @@ const PreciseColourChannel kBlueIntensity = 0.114; /// @tparam T Floating-point type to use for the individual colour components. /// template -class GenericRGBColour +class GenericRGBColour final { public: @@ -241,11 +242,11 @@ class GenericRGBColour /// @remark This used to be implemented differently at different places in the code; /// variations were: /// - `max3(r,g,b)` - /// - `max3(fabs(r),fabs(g),fabs(b))` - /// - `fabs(greyscale)` [1] - /// - `max(0.0,greyscale)` - /// @remark [1] A variant of this was `max(0.0,fabs(greyscale))`; note the superfluous - /// `max()`. + /// - `max3(std::fabs(r),std::fabs(g),std::fabs(b))` + /// - `std::fabs(greyscale)` [1] + /// - `std::max(0.0,greyscale)` + /// @remark [1] A variant of this was `std::max(0.0,std::fabs(greyscale))`; note the superfluous + /// `std::max()`. /// @remark The rationale for choosing the current implementation is as follows: /// - In general, the weight should scale proportionally with the colour /// brightness. [2] @@ -265,9 +266,9 @@ class GenericRGBColour /// @remark For backward compatibility, @ref WeightMax(), @ref WeightMaxAbs(), /// @ref WeightGreyscale() and @ref WeightAbsGreyscale() are provided. - return (fabs(mColour[RED]) + - fabs(mColour[GREEN]) + - fabs(mColour[BLUE])) / 3.0; + return (std::fabs(mColour[RED]) + + std::fabs(mColour[GREEN]) + + std::fabs(mColour[BLUE])) / 3.0; } /// Computes a measure for the weight of the colour based on the magnitude of its greyscale @@ -278,7 +279,7 @@ class GenericRGBColour /// inline T WeightAbsGreyscale() const { - return fabs(Greyscale()); + return std::fabs(Greyscale()); } /// Computes a measure for the weight of the colour based on its greyscale value. @@ -298,7 +299,7 @@ class GenericRGBColour /// greatest value. /// /// @note Do _not_ use this function if you absolutely want to know the intensity of - /// the strongest colour channel. For such cases, use @ref max() instead. + /// the strongest colour channel. For such cases, use @ref Max() instead. /// /// @deprecated Calls to this function should probably be replaced by calls to /// @ref WeightMaxAbs() or @ref Weight() for consistency of colour math. @@ -338,9 +339,9 @@ class GenericRGBColour /// inline T MaxAbs() const { - return max3(fabs(mColour[RED]), - fabs(mColour[GREEN]), - fabs(mColour[BLUE])); + return max3(std::fabs(mColour[RED]), + std::fabs(mColour[GREEN]), + std::fabs(mColour[BLUE])); } /// Computes the intensity of the colour channel with the smallest value. @@ -378,9 +379,9 @@ class GenericRGBColour inline bool IsNearZero(T epsilon) const { - return (fabs(mColour[RED]) < epsilon) && - (fabs(mColour[GREEN]) < epsilon) && - (fabs(mColour[BLUE]) < epsilon); + return (std::fabs(mColour[RED]) < epsilon) && + (std::fabs(mColour[GREEN]) < epsilon) && + (std::fabs(mColour[BLUE]) < epsilon); } inline void Clear() @@ -427,16 +428,16 @@ class GenericRGBColour inline GenericRGBColour ClippedUpper(T maxc) const { - return GenericRGBColour(min(mColour[RED], maxc), - min(mColour[GREEN], maxc), - min(mColour[BLUE], maxc)); + return GenericRGBColour(std::min(mColour[RED], maxc), + std::min(mColour[GREEN], maxc), + std::min(mColour[BLUE], maxc)); } inline GenericRGBColour ClippedLower(T minc) const { - return GenericRGBColour(max(mColour[RED], minc), - max(mColour[GREEN], minc), - max(mColour[BLUE], minc)); + return GenericRGBColour(std::max(mColour[RED], minc), + std::max(mColour[GREEN], minc), + std::max(mColour[BLUE], minc)); } inline GenericRGBColour operator+(const GenericRGBColour& b) const @@ -614,9 +615,9 @@ inline GenericRGBColour operator- (double a, const GenericRGBColour& b) { template inline T ColourDistance (const GenericRGBColour& a, const GenericRGBColour& b) { - return fabs(a.red() - b.red()) + - fabs(a.green() - b.green()) + - fabs(a.blue() - b.blue()); + return std::fabs(a.red() - b.red()) + + std::fabs(a.green() - b.green()) + + std::fabs(a.blue() - b.blue()); } /// @relates GenericRGBColour @@ -672,7 +673,7 @@ typedef GenericRGBColour PreciseRGBColour; ///< High pr /// @tparam T Floating-point type to use for the individual colour components. /// template -class GenericRGBFTColour +class GenericRGBFTColour final { public: @@ -681,8 +682,6 @@ class GenericRGBFTColour friend GenericRGBFTColour ToRGBFTColour(const GenericTransColour& col); - typedef DBL EXPRESS[5]; - /// Default constructor. inline GenericRGBFTColour() : mColour(0.0), @@ -966,7 +965,7 @@ inline GenericRGBFTColour operator- (double a, const GenericRGBFTColour& b template inline T ColourDistanceRGBT (const GenericRGBFTColour& a, const GenericRGBFTColour& b) { - return ColourDistance(a.rgb(), b.rgb()) + fabs(a.transm() - b.transm()); + return ColourDistance(a.rgb(), b.rgb()) + std::fabs(a.transm() - b.transm()); } typedef GenericRGBFTColour RGBFTColour; ///< Standard precision RGBFT colour. @@ -995,7 +994,7 @@ enum /// @tparam T Floating-point type to use for the individual colour components. /// template -class GenericRGBTColour +class GenericRGBTColour final { public: @@ -1069,7 +1068,7 @@ class GenericRGBTColour inline bool IsNearZero(T epsilon) const { return mColour.IsNearZero(epsilon) && - (fabs(mTransm) < epsilon); + (std::fabs(mTransm) < epsilon); } inline void Clear() @@ -1221,7 +1220,7 @@ inline GenericRGBTColour operator- (double a, const GenericRGBTColour& b) template inline T ColourDistanceRGBT (const GenericRGBTColour& a, const GenericRGBTColour& b) { - return ColourDistance(a.rgb(), b.rgb()) + fabs(a.transm() - b.transm()); + return ColourDistance(a.rgb(), b.rgb()) + std::fabs(a.transm() - b.transm()); } /// @relates GenericRGBTColour @@ -1245,7 +1244,7 @@ typedef GenericRGBTColour PreciseRGBTColour; ///< High pr /// @tparam T Floating-point type to use for the individual colour channels. /// template -class GenericColour +class GenericColour final { public: @@ -1384,11 +1383,11 @@ class GenericColour /// @remark This used to be implemented differently at different places in the code; /// variations were: /// - `max3(r,g,b)` - /// - `max3(fabs(r),fabs(g),fabs(b))` - /// - `fabs(greyscale)` [1] - /// - `max(0.0,greyscale)` - /// @remark [1] A variant of this was `max(0.0,fabs(greyscale))`; note the superfluous - /// `max()`. + /// - `max3(std::fabs(r),std::fabs(g),std::fabs(b))` + /// - `std::fabs(greyscale)` [1] + /// - `std::max(0.0,greyscale)` + /// @remark [1] A variant of this was `std::max(0.0,std::fabs(greyscale))`; note the superfluous + /// `std::max()`. /// @remark The rationale for choosing the current implementation is as follows: /// - In general, the weight should scale proportionally with the colour /// brightness. [2] @@ -1419,7 +1418,7 @@ class GenericColour /// inline T WeightAbsGreyscale() const { - return fabs(Greyscale()); + return std::fabs(Greyscale()); } /// Computes a measure for the weight of the colour based on its greyscale value. @@ -1439,7 +1438,7 @@ class GenericColour /// greatest value. /// /// @note Do _not_ use this function if you absolutely want to know the intensity of - /// the strongest colour channel. For such cases, use @ref max() instead. + /// the strongest colour channel. For such cases, use @ref Max() instead. /// /// @deprecated Calls to this function should probably be replaced by calls to /// @ref WeightMaxAbs() or @ref Weight() for consistency of colour math. @@ -1465,7 +1464,7 @@ class GenericColour { T result = 0.0; for (int i = 0; i < channels; i ++) - result += fabs(mColour[i]); + result += std::fabs(mColour[i]); return result; } @@ -1478,7 +1477,7 @@ class GenericColour { T result = mColour[0]; for (int i = 1; i < channels; i ++) - result = max(result, mColour[i]); + result = std::max(result, mColour[i]); return result; } @@ -1491,7 +1490,7 @@ class GenericColour { T result = mColour[0]; for (int i = 1; i < channels; i ++) - result = max(result, fabs(mColour[i])); + result = std::max(result, std::fabs(mColour[i])); return result; } @@ -1501,7 +1500,7 @@ class GenericColour { T result = mColour[0]; for (int i = 1; i < channels; i ++) - result = min(result, mColour[i]); + result = std::min(result, mColour[i]); return result; } @@ -1522,7 +1521,7 @@ class GenericColour { bool result = true; for (int i = 0; i < channels; i ++) - result = result && (fabs(mColour[i]) < epsilon); + result = result && (std::fabs(mColour[i]) < epsilon); return result; } @@ -1562,7 +1561,7 @@ class GenericColour { GenericColour result; for (int i = 0; i < channels; i ++) - result.mColour[i] = min(mColour[i], maxc); + result.mColour[i] = std::min(mColour[i], maxc); return result; } @@ -1570,7 +1569,7 @@ class GenericColour { GenericColour result; for (int i = 0; i < channels; i ++) - result.mColour[i] = max(mColour[i], minc); + result.mColour[i] = std::max(mColour[i], minc); return result; } @@ -1810,7 +1809,7 @@ extern template class GenericColour; /// @tparam T Floating-point type to use for the individual colour components. /// template -class GenericTransColour +class GenericTransColour final { public: @@ -1821,8 +1820,6 @@ class GenericTransColour friend GenericTransColour ToTransColour(const GenericRGBFTColour& col); - typedef DBL EXPRESS[5]; - /// Default constructor. inline GenericTransColour() : mColour(0.0), @@ -2101,7 +2098,7 @@ typedef GenericTransColour PreciseTransColour; ///< Hig /// Defaults to unsigned char. /// template -class GenericRGBEColour +class GenericRGBEColour final { public: @@ -2256,5 +2253,6 @@ typedef GenericRGBEColour<250,true> PhotonColour; ///< RGBE format as //############################################################################## } +// end of namespace pov_base -#endif +#endif // POVRAY_BASE_COLOUR_H diff --git a/source/base/configbase.h b/source/base/configbase.h index 625ad3f69..18b9bae02 100644 --- a/source/base/configbase.h +++ b/source/base/configbase.h @@ -10,7 +10,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 @@ -38,12 +38,14 @@ #ifndef POVRAY_BASE_CONFIGBASE_H #define POVRAY_BASE_CONFIGBASE_H +// Pull in other compile-time config header files first #include "syspovconfigbase.h" -#include - -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// Boost header files #include //############################################################################## @@ -59,35 +61,6 @@ /// the corresponding header files and specifying `using NAMESPACE::SYMBOL`. However, alternative /// implementations may also be provided unless noted otherwise. /// -/// The following symbols must have the same semantics as those from C++11's `std::` namespace: -/// -/// - `const_pointer_cast` -/// - `dynamic_pointer_cast` -/// - `list` -/// - `runtime_error` (should be identical to `std::runtime_error`) -/// - `shared_ptr` -/// - `static_pointer_cast` -/// - `string` -/// - `vector` -/// - `weak_ptr` -/// -/// The following symbols must have the same semantics as those from Boost's `boost::` namespace: -/// -/// - `intrusive_ptr` -/// -/// @todo -/// The following POSIX features also need to be present or emulated: -/// - `O_CREAT`, `O_RDWR`, `O_TRUNC` -/// - `S_IRUSR`, `S_IWUSR` -/// - `int open(const char*, int, int)` -/// - `int close(int)` -/// - `ssize_t write(int, const void*, size_t)` -/// - `ssize_t read(int, void*, size_t)` -/// -/// @todo -/// The following somewhat obscure macros also need to be defined: -/// - `IFF_SWITCH_CAST` -/// /// @todo /// The following macros currently default to unexpected values; also, the implementations /// they default to are currently not part of the base module: @@ -355,56 +328,16 @@ #define COLC float #endif -/// @def UCS2 -/// Data type used to represent individual UCS2 characters. -/// -/// This data type is used to represent characters from the UCS2 character set, i.e. the 16-bit -/// Basic Multilingual Plane subset of Unicode. -/// -/// This should be an unsigned character or integer type at least 16 bits wide. -/// -/// @note -/// For clarity, this data type should _not_ be used as the base type for UTF-16 encoded -/// full-fledged Unicode strings. Use @ref UTF16 instead. -/// -/// @todo -/// Currently, the actual type must be identical to that of @ref UTF16. -/// -/// @attention -/// Some legacy portions of the code may improperly use this type where they should use -/// @ref UTF16 instead. -/// -#ifndef UCS2 - #define UCS2 char16_t +// The following character types are no longer defined as macros, +// but instead use aliased or dedicated types. +#ifdef UCS2 + #error "Platform-specific configurations should no longer define UCS2 as a macro." #endif - -/// @def UCS4 -/// Integer data type used to represent UCS4 or full-fledged Unicode characters. -/// -/// This should be an unsigned character or integer type at least 21 (sic!) bits wide. -/// -#ifndef UCS4 - #define UCS4 char32_t +#ifdef UCS4 + #error "Platform-specific configurations should no longer define UCS4 as a macro." #endif - -/// @def UTF16 -/// Integer data type used as the base type to represent UTF-16 encoded Unicode strings. -/// This should be an unsigned integer type at least 16 bits wide. -/// -/// @note -/// For clarity, this data type should _not_ be used to store regular UCS2 characters -/// (16-bit Basic Multilingual Plane subset of Unicode). For that purpose, use @ref UCS2 -/// instead. -/// -/// @todo -/// Currently, the actual type must be identical to that of @ref UCS2. -/// -/// @attention -/// Some legacy portions of the code may improperly use @ref UCS2 where they should use this -/// type instead. -/// -#ifndef UTF16 - #define UTF16 UCS2 +#ifdef UTF16 + #error "Platform-specific configurations should no longer define UTF16 as a macro." #endif /// @def POV_LONG @@ -841,76 +774,45 @@ #define POV_USE_DEFAULT_PATH_PARSER 1 #endif -/// @def POV_DELETE_FILE -/// Delete a given file. +/// @def POV_USE_DEFAULT_DELETEFILE +/// Whether to use a default implementation to delete a file. /// -/// Define as a single command that erases the specified file from the file system. +/// Define as non-zero to use a default implementation for the @ref pov_base::Filesystem::DeleteFile() method, +/// or zero if the platform provides its own implementation. /// /// @note -/// There is no default implementation for this macro. -/// -/// @param[in] name UTF-8 encoded file name in system-specific format. +/// The default implementation is only provided as a last-ditch resort. Wherever possible, +/// implementations should provide their own implementation. /// -#ifndef POV_DELETE_FILE - #ifdef DOXYGEN - // just leave undefined when running doxygen - // The following two lines work around doxygen being unable to document undefined macros. - #define POV_DELETE_FILE(name) (undefined) - #undef POV_DELETE_FILE - #else - #error "No default implementation for POV_DELETE_FILE." - #endif +#ifndef POV_USE_DEFAULT_DELETEFILE + #define POV_USE_DEFAULT_DELETEFILE 1 #endif -/// @def POV_LSEEK(handle,offset,whence) -/// Seek a particular absolute or relative location in a (large) file. +/// @def POV_USE_DEFAULT_LARGEFILE +/// Whether to use a default implementation for large file handling. /// -/// Define this to `lseek64()` (GNU/Linux), `_lseeki64()` (Windows), or an equivalent function -/// supporting large files (i.e. files significantly larger than 2 GiB). +/// Define as non-zero to use a default implementation for the @ref pov_base::Filesystem::LargeFile class, +/// or zero if the platform provides its own implementation. /// /// @note -/// If large file support is unavailable, it is technically safe to substitute equivalent -/// functions taking 32 bit file offsets instead. However, this will limit output file size to -/// approx. 100 Megapixels. -/// -#ifndef POV_LSEEK - #ifdef DOXYGEN - // just leave undefined when running doxygen - // The following two lines work around doxygen being unable to document undefined macros. - #define POV_LSEEK(name) (undefined) - #undef POV_LSEEK - #else - #error "No default implementation for POV_LSEEK." - #endif +/// The current default implementation may or may not actually support large +/// files, and may provide less than optimal performance. +/// +#ifndef POV_USE_DEFAULT_LARGEFILE + #define POV_USE_DEFAULT_LARGEFILE 1 #endif /// @def POV_OFF_T /// Type representing a particular absolute or relative location in a (large) file. /// -/// Define this to the return type of `lseek64()` (GNU/Linux), `_lseeki64()` (Windows), or -/// equivalent function used in the definition of @ref POV_LSEEK(). +/// Define this to a signed integer wide enough to hold the maximum file size +/// supported by the operating system. On most modern systems, this should be +/// at least 64 bits (including the sign bit). /// #ifndef POV_OFF_T - #ifdef DOXYGEN - // just leave undefined when running doxygen - // The following two lines work around doxygen being unable to document undefined macros. - #define POV_OFF_T (undefined) - #undef POV_OFF_T - #else - #error "No default implementation for POV_OFF_T." - #endif + #define POV_OFF_T std::int_least64_t #endif -static_assert( - std::is_same::value, - "POV_OFF_T does not match return type of POV_LSEEK()." -); - -static_assert( - std::numeric_limits::max() >= std::numeric_limits::max(), - "Large files (> 2 GiB) not supported, limiting image size to approx. 100 Megapixels. Proceed at your own risk." -); - /// @} /// //****************************************************************************** @@ -1124,6 +1026,9 @@ static_assert( #define M_TAU TWO_M_PI +#define POVMSAddress void* +#define POVMSInvalidAddress nullptr + /// @} /// //****************************************************************************** diff --git a/source/base/fileinputoutput.cpp b/source/base/fileinputoutput.cpp index 97a6f423e..1f95d55a2 100644 --- a/source/base/fileinputoutput.cpp +++ b/source/base/fileinputoutput.cpp @@ -36,17 +36,21 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/fileinputoutput.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include #include -// Standard C++ header files -#include +// C++ standard header files +#include +#include -// POV-Ray base header files +// POV-Ray header files (base module) +#include "base/path.h" #include "base/platformbase.h" +#include "base/povassert.h" #include "base/pov_err.h" +#include "base/stringutilities.h" // this must be the last file included #include "base/povdebug.h" @@ -54,6 +58,9 @@ namespace pov_base { +using std::min; +using std::max; + IOBase::IOBase() : filename(), fail(true) { } @@ -323,7 +330,7 @@ IStream *NewIStream(const Path& p, unsigned int stype) { if (!PlatformBase::GetInstance().AllowLocalFileAccess(p(), stype, false)) { - string str ("IO Restrictions prohibit read access to '") ; + std::string str ("IO Restrictions prohibit read access to '") ; str += UCS2toSysString(p()); str += "'"; throw POV_EXCEPTION(kCannotOpenFileErr, str); @@ -341,7 +348,7 @@ OStream *NewOStream(const Path& p, unsigned int stype, bool sappend) if (!PlatformBase::GetInstance().AllowLocalFileAccess(p(), stype, true)) { - string str ("IO Restrictions prohibit write access to '") ; + std::string str ("IO Restrictions prohibit write access to '") ; str += UCS2toSysString(p()); str += "'"; throw POV_EXCEPTION(kCannotOpenFileErr, str); @@ -372,7 +379,7 @@ UCS2String GetFileName(const Path& p) bool CheckIfFileExists(const Path& p) { - FILE *tempf = PlatformBase::GetInstance().OpenLocalFile (p().c_str(), "r"); + FILE *tempf = PlatformBase::GetInstance().OpenLocalFile (p(), "r"); if (tempf != nullptr) fclose(tempf); @@ -384,7 +391,7 @@ bool CheckIfFileExists(const Path& p) POV_OFF_T GetFileLength(const Path& p) { - FILE *tempf = PlatformBase::GetInstance().OpenLocalFile (p().c_str(), "rb"); + FILE *tempf = PlatformBase::GetInstance().OpenLocalFile (p(), "rb"); POV_OFF_T result = -1; if (tempf != nullptr) @@ -545,3 +552,4 @@ bool IMemStream::seekg(POV_OFF_T posi, unsigned int whence) } } +// end of namespace pov_base diff --git a/source/base/fileinputoutput.h b/source/base/fileinputoutput.h index ffabfd61f..212c50bb0 100644 --- a/source/base/fileinputoutput.h +++ b/source/base/fileinputoutput.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 @@ -38,15 +38,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/fileinputoutput_fwd.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include -// POV-Ray base header files -#include "base/path.h" -#include "base/stringutilities.h" -#include "base/types.h" +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/path_fwd.h" +#include "base/stringtypes.h" namespace pov_base { @@ -120,7 +123,7 @@ class IStream : public IOBase public: IStream(); IStream(const UCS2String& name); - virtual ~IStream(); + virtual ~IStream() override; virtual bool read(void *buffer, size_t exactCount) = 0; virtual size_t readUpTo(void *buffer, size_t maxCount) = 0; @@ -144,23 +147,23 @@ class IStream : public IOBase /// /// This class provides file read access. /// -class IFileStream : public IStream +class IFileStream final : public IStream { public: IFileStream(const UCS2String& name); - virtual ~IFileStream(); + virtual ~IFileStream() override; - virtual bool eof() const { return(fail ? true : feof(f) != 0); } - virtual bool seekg(POV_OFF_T pos, unsigned int whence = seek_set); - virtual POV_OFF_T tellg() const { return(f == nullptr ? -1 : ftell(f)); } - virtual bool clearstate() { if (f != nullptr) fail = false; return !fail; } + virtual bool eof() const override { return(fail ? true : feof(f) != 0); } + virtual bool seekg(POV_OFF_T pos, unsigned int whence = seek_set) override; + virtual POV_OFF_T tellg() const override { return(f == nullptr ? -1 : ftell(f)); } + virtual bool clearstate() override { if (f != nullptr) fail = false; return !fail; } - virtual bool read(void *buffer, size_t exactCount); - virtual size_t readUpTo(void *buffer, size_t maxCount); - virtual bool getline(char *s, size_t buflen); - virtual int Read_Byte(); + virtual bool read(void *buffer, size_t exactCount) override; + virtual size_t readUpTo(void *buffer, size_t maxCount) override; + virtual bool getline(char *s, size_t buflen) override; + virtual int Read_Byte() override; - virtual bool UnRead_Byte(int c); + virtual bool UnRead_Byte(int c) override; protected: FILE *f; @@ -173,23 +176,23 @@ class IFileStream : public IStream /// /// This class is used to support in-built fonts and cached macros. /// -class IMemStream : public IStream +class IMemStream final : public IStream { public: IMemStream(const unsigned char* data, size_t size, const char* formalName, POV_OFF_T formalStart = 0); IMemStream(const unsigned char* data, size_t size, const UCS2String& formalName, POV_OFF_T formalStart = 0); - virtual ~IMemStream(); + virtual ~IMemStream() override; - virtual int Read_Byte(); - virtual bool UnRead_Byte(int c); - virtual bool getline(char *s, size_t buflen); - virtual POV_OFF_T tellg() const; - virtual bool read(void *buffer, size_t exactCount); - virtual size_t readUpTo(void *buffer, size_t count); - virtual bool seekg(POV_OFF_T pos, unsigned int whence = seek_set); - virtual bool clearstate() { fail = false; return true; } + virtual int Read_Byte() override; + virtual bool UnRead_Byte(int c) override; + virtual bool getline(char *s, size_t buflen) override; + virtual POV_OFF_T tellg() const override; + virtual bool read(void *buffer, size_t exactCount) override; + virtual size_t readUpTo(void *buffer, size_t count) override; + virtual bool seekg(POV_OFF_T pos, unsigned int whence = seek_set) override; + virtual bool clearstate() override { fail = false; return true; } - virtual bool eof() const { return fail; } + virtual bool eof() const override { return fail; } protected: @@ -204,12 +207,12 @@ class OStream : public IOBase { public: OStream(const UCS2String& name, unsigned int Flags = 0); - ~OStream(); + virtual ~OStream() override; - virtual bool seekg(POV_OFF_T pos, unsigned int whence = seek_set); - virtual POV_OFF_T tellg() const { return(f == nullptr ? -1 : ftell(f)); } - inline bool clearstate() { if (f != nullptr) fail = false; return !fail; } - virtual bool eof() const { return(fail ? true : feof(f) != 0); } + virtual bool seekg(POV_OFF_T pos, unsigned int whence = seek_set) override; + virtual POV_OFF_T tellg() const override { return(f == nullptr ? -1 : ftell(f)); } + virtual inline bool clearstate() override { if (f != nullptr) fail = false; return !fail; } + virtual bool eof() const override { return(fail ? true : feof(f) != 0); } bool write(const void *buffer, size_t count); void printf(const char *format, ...); @@ -224,16 +227,17 @@ class OStream : public IOBase IStream *NewIStream(const Path&, unsigned int); OStream *NewOStream(const Path&, unsigned int, bool); -UCS2String GetFileExtension(const Path& p); -UCS2String GetFileName(const Path& p); +UCS2String GetFileExtension(const Path& p); ///< @todo Move this to the @ref Path class. +UCS2String GetFileName(const Path& p); ///< @todo Move this to the @ref Path class. -bool CheckIfFileExists(const Path& p); -POV_OFF_T GetFileLength(const Path& p); +bool CheckIfFileExists(const Path& p); ///< @todo Move this to the @ref PlatformBase class. +POV_OFF_T GetFileLength(const Path& p); ///< @todo Move this to the @ref PlatformBase class. /// @} /// //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_FILEINPUTOUTPUT_H diff --git a/source/base/fileinputoutput_fwd.h b/source/base/fileinputoutput_fwd.h new file mode 100644 index 000000000..2190f3172 --- /dev/null +++ b/source/base/fileinputoutput_fwd.h @@ -0,0 +1,52 @@ +//****************************************************************************** +/// +/// @file base/fileinputoutput_fwd.h +/// +/// Forward declarations related to basic file input and output. +/// +/// @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_BASE_FILEINPUTOUTPUT_FWD_H +#define POVRAY_BASE_FILEINPUTOUTPUT_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class IStream; +class OStream; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_FILEINPUTOUTPUT_FWD_H diff --git a/source/base/filesystem.cpp b/source/base/filesystem.cpp new file mode 100644 index 000000000..c7e072b9e --- /dev/null +++ b/source/base/filesystem.cpp @@ -0,0 +1,208 @@ +//****************************************************************************** +/// +/// @file base/filesystem.cpp +/// +/// Implementation of file system services (default implementation). +/// +/// @note +/// This is a default implementation, provided primarily as a template for +/// creating platform-specific implementations. +/// +/// @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 +#if POV_USE_DEFAULT_DELETEFILE +#include +#endif + +// C++ standard header files +#if POV_USE_DEFAULT_LARGEFILE +#include +#include +#include +#endif +#if POV_USE_DEFAULT_TEMPORARYFILE +#include +#endif + +// POV-Ray header files (base module) +#if POV_USE_DEFAULT_DELETEFILE || POV_USE_DEFAULT_LARGEFILE || POV_USE_DEFAULT_TEMPORARYFILE +#include "base/stringutilities.h" +#endif + +// this must be the last file included +#include "base/povdebug.h" + +namespace pov_base +{ + +namespace Filesystem +{ + +//****************************************************************************** + +#if POV_USE_DEFAULT_DELETEFILE + +bool DeleteFile(const UCS2String& fileName) +{ + // Note: The C++ standard does not specify whether `remove` will or will not + // delete directories. On POSIX systems it will, which is not ideal for our + // purposes. + return (std::remove(UCS2toSysString(fileName).c_str()) == 0); +} + +#endif // POV_USE_DEFAULT_DELETEFILE + +//****************************************************************************** + +#if POV_USE_DEFAULT_LARGEFILE + +using Offset = std::streamoff; + +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 +{ + std::fstream stream; +}; + +LargeFile::LargeFile() : + mpData(new Data) +{ + // Disable stream buffering. + mpData->stream.rdbuf()->pubsetbuf(nullptr, 0); +} + +LargeFile::~LargeFile() +{ + Close(); +} + +bool LargeFile::CreateRW(const UCS2String& fileName) +{ + mpData->stream.open(UCS2toSysString(fileName), + std::ios_base::binary | std::ios_base::in | std::ios_base::out | std::ios_base::trunc); + return mpData->stream.is_open(); +} + +bool LargeFile::Seek(std::int_least64_t offset) +{ + if (!mpData->stream.is_open() || mpData->stream.bad()) + return false; + if ((offset < 0) || (offset > std::numeric_limits::max())) + return false; + return (mpData->stream.rdbuf()->pubseekpos(Offset(offset), + std::ios_base::in | std::ios_base::out) == offset); +} + +std::size_t LargeFile::Read(void* data, std::size_t maxSize) +{ + if (!mpData->stream.is_open() || mpData->stream.bad()) + return false; + return mpData->stream.read(reinterpret_cast(data), maxSize).gcount(); +} + +bool LargeFile::Write(const void* data, std::size_t size) +{ + if (!mpData->stream.is_open() || mpData->stream.bad()) + return false; + return !mpData->stream.write(reinterpret_cast(data), size).bad(); +} + +void LargeFile::Close() +{ + if (mpData->stream.is_open()) + mpData->stream.close(); +} + +#endif // POV_USE_DEFAULT_LARGEFILE + +//****************************************************************************** + +TemporaryFile::TemporaryFile() : + mFileName(SuggestName()) +{} + +TemporaryFile::TemporaryFile(const UCS2String& name) : + mFileName(name) +{} + +TemporaryFile::~TemporaryFile() +{ + Delete(); +} + +const UCS2String& TemporaryFile::GetFileName() const +{ + return mFileName; +} + +void TemporaryFile::Keep() +{ + mFileName.clear(); +} + +void TemporaryFile::Delete() +{ + if (!mFileName.empty()) + { + (void)DeleteFile(mFileName); + mFileName.clear(); + } +} + +#if POV_USE_DEFAULT_TEMPORARYFILE + +UCS2String TemporaryFile::SuggestName() +{ + static std::atomic_int globalIndex = 0; + int index = globalIndex++; + + char buffer[32]; + sprintf(buffer, "/tmp/pov%08x.dat", index); + + return ASCIItoUCS2String(buffer); +} + +#endif // POV_USE_DEFAULT_TEMPORARYFILE + +//****************************************************************************** + +} +// end of namespace Filesystem + +} +// end of namespace pov_base diff --git a/source/base/filesystem.h b/source/base/filesystem.h new file mode 100644 index 000000000..67f53162e --- /dev/null +++ b/source/base/filesystem.h @@ -0,0 +1,217 @@ +//****************************************************************************** +/// +/// @file base/filesystem.h +/// +/// Declaration of file system services (default implementation). +/// +/// @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_BASE_FILESYSTEM_H +#define POVRAY_BASE_FILESYSTEM_H + +// Module config header file must be the first file included within POV-Ray unit header files +#include "base/configbase.h" +#include "base/filesystem_fwd.h" + +// C++ variants of C standard header files +#include // Pulled in for `std::int_least64_t`. +#include // Pulled in for `std::size_t`. + +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/stringtypes.h" + +namespace pov_base +{ + +/// File System Handling. +/// @ingroup PovBase +/// +namespace Filesystem +{ + +#ifdef DeleteFile +#undef DeleteFile // Shame on you, Windows! +#endif + +/// Delete file. +/// +/// This function shall try to delete (or, more specifically, "unlink") the +/// specified file. +/// +/// @note +/// If the file does not exist, the return value is currently undefined. +/// +/// @note +/// If the file is a directory, the function should fail (but callers are +/// advised to not rely on this property). +/// +/// @note +/// The default implementation has some limitations; specifically, it only +/// supports file names comprised of the _narrow execution character set_, +/// and on some platforms may happily delete directories. Platforms are +/// strongly encouraged to provide their own implementation. +/// +/// @param fileName Name of the file to delete. +/// @return `true` if the file was deleted, `false` otherwise. +/// +bool DeleteFile(const UCS2String& fileName); + +/// Large file handling. +/// +/// This class provides basic random access to large (>2 GiB) files. +/// +/// @note +/// Implementations should be optimized for random access of several dozen +/// kByte at a time; typically, this means implementations should refrain +/// from buffering. +/// +/// @note +/// The default implementation of this function may or may not support files +/// larger than 2 GiB, and performance may be less than optimal. Platforms +/// are encouraged to provide their own implementation. +/// +class LargeFile final +{ +public: + + LargeFile(); + ~LargeFile(); + + /// Create file for read/write access. + /// @note + /// If the file already exists, it should be truncated to zero size. + bool CreateRW(const UCS2String& fileName); + + /// Seek in file. + bool Seek(std::int_least64_t offset); + + /// Read from file. + std::size_t Read(void* data, std::size_t maxSize); + + /// Write to file. + bool Write(const void* data, std::size_t size); + + /// Close file. + void Close(); + +private: + + struct Data; + std::unique_ptr mpData; +}; + +/// Temporary file tracker. +/// +/// This class can be used to make sure that a given file is automatically +/// deleted, based on the lifetime of this object. +/// +class TemporaryFile final +{ +public: + + /// Track a file with an auto-generated name. + /// + /// This constructor associates the object with a new unique file name in + /// a location well-suited for temporary files. The name of the file can be + /// queried via @ref GetFileName(). + /// + /// @note + /// The constructor may or may not auto-create an empty file with the + /// generated name. + /// + explicit TemporaryFile(); + + explicit TemporaryFile(const TemporaryFile&) = delete; + + /// Track a caller-specified file. + /// + /// This constructor associates the object with a caller-specified + /// file name. + /// + explicit TemporaryFile(const UCS2String& name); + + /// Delete tracked file. + ~TemporaryFile(); + + /// Get associated file name. + const UCS2String& GetFileName() const; + + /// Keep file. + /// + /// Calling this method will disassociate the file, such that it will _not_ + /// be deleted upon object destruction. + /// @note + /// Once this method has been called, it is no longer possible to query + /// the name of the file originally associated. + /// + void Keep(); + + /// Delete file. + /// + /// Calling this method will delete the file early. + /// @note + /// Once this method has been called, it is no longer possible to query + /// the name of the file originally associated. + /// + void Delete(); + +private: + + /// Suggest name for temporary file. + /// + /// This method suggests a new unique file name in a location well-suited + /// for temporary files. + /// + /// @note + /// The method may or may not auto-create an empty file with the + /// generated name, depending on what is easiest and/or best suited to + /// the algorithm by which names are generated. + /// + /// @note + /// The default implementation is less than optimal, potentially choosing + /// an unsuited location or generating duplicate names under certain + /// conditions. Platforms should provide their own implementation of this + /// method. + /// + static UCS2String SuggestName(); + + UCS2String mFileName; ///< Associated file name, or empty string if not applicable. +}; + +} +// end of namespace Filesystem + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_FILESYSTEM_H diff --git a/source/base/filesystem_fwd.h b/source/base/filesystem_fwd.h new file mode 100644 index 000000000..08ac0a636 --- /dev/null +++ b/source/base/filesystem_fwd.h @@ -0,0 +1,61 @@ +//****************************************************************************** +/// +/// @file base/filesystem_fwd.h +/// +/// Forward declarations related to 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 +/// +//****************************************************************************** + +#ifndef POVRAY_BASE_FILESYSTEM_FWD_H +#define POVRAY_BASE_FILESYSTEM_FWD_H + +// C++ standard header files +#include + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +namespace Filesystem +{ + +class TemporaryFile; +using TemporaryFilePtr = std::shared_ptr; + +} +// end of namespace Filesystem + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_FILESYSTEM_FWD_H diff --git a/source/base/fileutil.cpp b/source/base/fileutil.cpp index cfefabe13..55f7ef660 100644 --- a/source/base/fileutil.cpp +++ b/source/base/fileutil.cpp @@ -38,12 +38,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/fileutil.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include -#include -// POV-Ray base header files +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/path.h" +#include "base/stringutilities.h" // All the builtin fonts must be declared here #include "base/font/crystal.h" @@ -59,13 +63,13 @@ namespace pov_base /* // not used right now -typedef struct +struct POV_File_Restrictions final { bool read_local; bool read_global; bool write_local; bool write_global; -} POV_File_Restrictions; +}; POV_File_Restrictions gPOV_File_Restrictions[POV_File_Count] = { @@ -173,7 +177,7 @@ int InferFileTypeFromExt(const UCS2String& ext) { // TODO FIXME - better compare in the string domain - string str = UCS2toSysString(ext); + std::string str = UCS2toSysString(ext); for (int i = 0; i < POV_File_Count; i++) { @@ -226,7 +230,7 @@ int InferFileTypeFromExt(const UCS2String& ext) * * To add a font, check first its license */ -IMemStream *Internal_Font_File(int font_id) +IStream *Internal_Font_File(int font_id) { switch(font_id) { @@ -240,3 +244,4 @@ IMemStream *Internal_Font_File(int font_id) //****************************************************************************** } +// end of namespace pov_base diff --git a/source/base/fileutil.h b/source/base/fileutil.h index f4ae1a6b8..fa572b7e1 100644 --- a/source/base/fileutil.h +++ b/source/base/fileutil.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 @@ -39,9 +39,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/fileinputoutput.h" -#include "base/stringutilities.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/stringtypes.h" namespace pov_base { @@ -53,9 +57,6 @@ namespace pov_base /// /// @{ -class IMemStream; -class IStream; - // Legal image file attributes. #define NO_FILE 0x00000000 @@ -76,7 +77,7 @@ class IStream; #define POV_FILE_EXTENSIONS_PER_TYPE 4 -struct POV_File_Extensions +struct POV_File_Extensions final { const char *ext[POV_FILE_EXTENSIONS_PER_TYPE]; }; @@ -85,12 +86,13 @@ extern POV_File_Extensions gPOV_File_Extensions[]; extern const int gFile_Type_To_Mask[]; int InferFileTypeFromExt(const pov_base::UCS2String& ext); -IMemStream *Internal_Font_File(int font_id); +IStream *Internal_Font_File(int font_id); /// @} /// //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_FILEUTIL_H diff --git a/source/base/image/bmp.cpp b/source/base/image/bmp.cpp index 4acce9279..c1ecd6dcd 100644 --- a/source/base/image/bmp.cpp +++ b/source/base/image/bmp.cpp @@ -10,7 +10,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 @@ -38,11 +38,18 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/bmp.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -// POV-Ray base header files +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/types.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" // this must be the last file included #include "base/povdebug.h" @@ -454,7 +461,7 @@ static void Read_BMP_8b_RLE(Image *image, IStream& in, unsigned width, unsigned * ******************************************************************************/ -void Write (OStream *file, const Image *image, const Image::WriteOptions& options) +void Write (OStream *file, const Image *image, const ImageWriteOptions& options) { int width = image->GetWidth(); int height = image->GetHeight(); @@ -518,7 +525,7 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option throw POV_EXCEPTION(kFileDataErr, "Error writing to BMP file") ; } -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { unsigned file_width, file_height; unsigned file_depth, file_colors; @@ -592,7 +599,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) if (file_depth < 24) { int color_map_length = file_colors ? file_colors : 1< colormap ; + std::vector colormap ; Image::RGBMapEntry entry; for (int i=0; ieof ()) throw POV_EXCEPTION(kFileDataErr, "Unexpected EOF while reading BMP file"); - image = Image::Create (file_width, file_height, Image::Colour_Map, colormap) ; + image = Image::Create (file_width, file_height, ImageDataType::Colour_Map, colormap) ; image->SetPremultiplied(premul); // specify whether the color map data has premultiplied alpha switch (file_depth) @@ -649,17 +656,10 @@ Image *Read (IStream *file, const Image::ReadOptions& options) } else { - /* includes update from stefan maierhofer for 32bit */ - Image::ImageDataType imagetype = options.itype ; - if (imagetype == Image::Undefined) - { - if (GammaCurve::IsNeutral(gamma)) - // No gamma correction required, raw values can be stored "as is". - imagetype = has_alpha ? Image::RGBA_Int8 : Image::RGB_Int8 ; - else - // Gamma correction required; use an image container that will take care of that. - imagetype = has_alpha ? Image::RGBA_Gamma8 : Image::RGB_Gamma8 ; - } + /* includes update from Stefan Maierhofer for 32bit */ + ImageDataType imagetype = options.itype ; + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType(8, 3, has_alpha, gamma); image = Image::Create (file_width, file_height, imagetype) ; image->SetPremultiplied(premul); // set desired storage mode regarding alpha premultiplication image->TryDeferDecoding(gamma, 255); // try to have gamma adjustment being deferred until image evaluation. @@ -687,6 +687,8 @@ Image *Read (IStream *file, const Image::ReadOptions& options) } -} // end of namespace Bmp +} +// end of namespace Bmp } +// end of namespace pov_base diff --git a/source/base/image/bmp.h b/source/base/image/bmp.h index 9cf66ba17..70f0a897f 100644 --- a/source/base/image/bmp.h +++ b/source/base/image/bmp.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 @@ -39,8 +39,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -54,15 +59,17 @@ namespace pov_base namespace Bmp { -void Write(OStream *file, const Image *image, const Image::WriteOptions& options); -Image *Read(IStream *file, const Image::ReadOptions& options); +void Write(OStream *file, const Image *image, const ImageWriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); } +// end of namespace Bmp /// @} /// //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_BMP_H diff --git a/source/base/image/colourspace.cpp b/source/base/image/colourspace.cpp index 232e28dab..eadbb7d32 100644 --- a/source/base/image/colourspace.cpp +++ b/source/base/image/colourspace.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,11 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/colourspace.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -#include -// POV-Ray base header files +// POV-Ray header files (base module) +#include "base/povassert.h" #include "base/image/encoding.h" // this must be the last file included @@ -49,8 +52,11 @@ namespace pov_base { +using std::min; +using std::max; + // definitions of static GammaCurve member variables to satisfy the linker -list > GammaCurve::cache; +std::list> GammaCurve::cache; #if POV_MULTITHREADED boost::mutex GammaCurve::cacheMutex; #endif @@ -106,7 +112,7 @@ GammaCurvePtr GammaCurve::GetMatching(const GammaCurvePtr& newInstance) // Check if we already have created a matching gamma curve object; if so, return that object instead. // Also, make sure we get the new object stored (as we're using weak pointers, we may have stale entries; // it also won't hurt if we store the new instance, even if we decide to discard it) - for(list >::iterator i(cache.begin()); i != cache.end(); i++) + for(std::list>::iterator i(cache.begin()); i != cache.end(); i++) { oldInstance = (*i).lock(); if (!oldInstance) @@ -301,7 +307,7 @@ SimpleGammaCurvePtr PowerLawGammaCurve::GetByEncodingGamma(float gamma) { if (IsNeutral(gamma)) return NeutralGammaCurve::Get(); - return dynamic_pointer_cast(GetMatching(GammaCurvePtr(new PowerLawGammaCurve(gamma)))); + return std::dynamic_pointer_cast(GetMatching(GammaCurvePtr(new PowerLawGammaCurve(gamma)))); } SimpleGammaCurvePtr PowerLawGammaCurve::GetByDecodingGamma(float gamma) { @@ -448,3 +454,4 @@ SimpleGammaCurvePtr GetGammaCurve(GammaTypeId type, float param) } } +// end of namespace pov_base diff --git a/source/base/image/colourspace.h b/source/base/image/colourspace.h index 043f25043..21a2d16e8 100644 --- a/source/base/image/colourspace.h +++ b/source/base/image/colourspace.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 @@ -38,18 +38,22 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/image/colourspace_fwd.h" -// Standard C++ header files -#include +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include // Boost header files #if POV_MULTITHREADED #include #endif -// POV-Ray base header files +// POV-Ray header files (base module) #include "base/colour.h" -#include "base/types.h" namespace pov_base { @@ -61,15 +65,6 @@ namespace pov_base /// /// @{ -class GammaCurve; -class SimpleGammaCurve; - -/// Class holding a shared reference to a gamma curve. -typedef shared_ptr GammaCurvePtr; - -/// Class holding a shared reference to a simple gamma curve. -typedef shared_ptr SimpleGammaCurvePtr; - /// Abstract class representing an encoding gamma curve (or, more generally, transfer function). /// /// In this generic form, the gamma curve may be arbitrarily complex. @@ -342,7 +337,7 @@ class GammaCurve /// This static member variable caches pointers of gamma curve instances currently in use, forming the basis /// of the `GetMatching()` mechanism to avoid duplicate instances. /// - static list > cache; + static std::list> cache; #if POV_MULTITHREADED /// Mutex to guard access to `cache`. @@ -393,7 +388,7 @@ class SimpleGammaCurve : public GammaCurve /// @param[in] p Pointer to the gamma curve to compare with. /// @return `true` if the gamma curve will produce the same result as this instance, `false` otherwise. /// - virtual bool Matches(const GammaCurvePtr& p) const + virtual bool Matches(const GammaCurvePtr& p) const override { SimpleGammaCurve* simpleP = dynamic_cast(p.get()); if (simpleP) @@ -412,7 +407,7 @@ class UniqueGammaCurve : public SimpleGammaCurve /// /// This function is to be implemented by subclasses to return the type-specific parameter of the gamma curve subclass. /// - virtual float GetParam() const { return 0.0; } + virtual float GetParam() const override { return 0.0; } protected: @@ -423,7 +418,7 @@ class UniqueGammaCurve : public SimpleGammaCurve /// @param[in] p Pointer to the gamma curve to compare with. /// @return `true` if the gamma curve will produce the same result as this instance, `false` otherwise. /// - virtual bool Matches(const GammaCurvePtr& p) const + virtual bool Matches(const GammaCurvePtr& p) const override { UniqueGammaCurve* uniqueP = dynamic_cast(p.get()); if (uniqueP) @@ -434,18 +429,18 @@ class UniqueGammaCurve : public SimpleGammaCurve }; /// Class representing a neutral gamma curve. -class NeutralGammaCurve : public UniqueGammaCurve +class NeutralGammaCurve final : public UniqueGammaCurve { public: static SimpleGammaCurvePtr Get(); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; - virtual int GetTypeId() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; + virtual int GetTypeId() const override; private: static SimpleGammaCurvePtr instance; - virtual bool Matches(const GammaCurvePtr&) const; - virtual bool IsNeutral() const; + virtual bool Matches(const GammaCurvePtr&) const override; + virtual bool IsNeutral() const override; NeutralGammaCurve(); }; @@ -455,14 +450,14 @@ class NeutralGammaCurve : public UniqueGammaCurve /// having a constant gamma of 1/2.2, the two are not identical. This class represents /// the exact function as specified in IEC 61966-2-1. /// -class SRGBGammaCurve : public UniqueGammaCurve +class SRGBGammaCurve final : public UniqueGammaCurve { public: static SimpleGammaCurvePtr Get(); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; - virtual int GetTypeId() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; + virtual int GetTypeId() const override; private: static SimpleGammaCurvePtr instance; SRGBGammaCurve(); @@ -475,14 +470,14 @@ class SRGBGammaCurve : public UniqueGammaCurve /// @note This class does _not_ account for the "black digital count" and "white digital count" being defined /// as 16/255 and 235/255, respectively. /// -class BT709GammaCurve : public UniqueGammaCurve +class BT709GammaCurve final : public UniqueGammaCurve { public: static SimpleGammaCurvePtr Get(); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; - virtual int GetTypeId() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; + virtual int GetTypeId() const override; private: static SimpleGammaCurvePtr instance; BT709GammaCurve(); @@ -492,14 +487,14 @@ class BT709GammaCurve : public UniqueGammaCurve /// /// This transfer function is a wide-gamut extension to that specified in ITU-R BT.709. /// -class BT1361GammaCurve : public UniqueGammaCurve +class BT1361GammaCurve final : public UniqueGammaCurve { public: static SimpleGammaCurvePtr Get(); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; - virtual int GetTypeId() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; + virtual int GetTypeId() const override; private: static SimpleGammaCurvePtr instance; BT1361GammaCurve(); @@ -513,51 +508,51 @@ class BT1361GammaCurve : public UniqueGammaCurve /// @note This class does _not_ account for the "black digital count" and "white digital count" being defined /// as 16/255 and 235/255, respectively. /// -class BT2020GammaCurve : public UniqueGammaCurve +class BT2020GammaCurve final : public UniqueGammaCurve { public: static SimpleGammaCurvePtr Get(); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; - virtual int GetTypeId() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; + virtual int GetTypeId() const override; private: static SimpleGammaCurvePtr instance; BT2020GammaCurve(); }; /// Class representing a classic constant-gamma (power-law) gamma encoding curve. -class PowerLawGammaCurve : public SimpleGammaCurve +class PowerLawGammaCurve final : public SimpleGammaCurve { public: static SimpleGammaCurvePtr GetByEncodingGamma(float gamma); static SimpleGammaCurvePtr GetByDecodingGamma(float gamma); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; - virtual int GetTypeId() const; - virtual float GetParam() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; + virtual int GetTypeId() const override; + virtual float GetParam() const override; protected: float encGamma; PowerLawGammaCurve(float encGamma); - virtual bool Matches(const GammaCurvePtr&) const; + virtual bool Matches(const GammaCurvePtr&) const override; static bool IsNeutral(float gamma); }; /// Class representing a scaled-encoding variant of another gamma curves. -class ScaledGammaCurve : public GammaCurve +class ScaledGammaCurve final : public GammaCurve { public: static GammaCurvePtr GetByEncoding(const GammaCurvePtr&, float encodingFactor); static GammaCurvePtr GetByDecoding(float decodingFactor, const GammaCurvePtr&); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; protected: GammaCurvePtr baseGamma; float encFactor; ScaledGammaCurve(const GammaCurvePtr&, float); - virtual bool Matches(const GammaCurvePtr&) const; + virtual bool Matches(const GammaCurvePtr&) const override; static bool IsNeutral(float factor); }; @@ -565,22 +560,22 @@ class ScaledGammaCurve : public GammaCurve /// /// @note This class is only required for backward compatibility with POV-Ray v3.6. /// -class TranscodingGammaCurve : public GammaCurve +class TranscodingGammaCurve final : public GammaCurve { public: static GammaCurvePtr Get(const GammaCurvePtr& working, const GammaCurvePtr& encoding); - virtual float Encode(float x) const; - virtual float Decode(float x) const; - virtual float ApproximateDecodingGamma() const; + virtual float Encode(float x) const override; + virtual float Decode(float x) const override; + virtual float ApproximateDecodingGamma() const override; protected: GammaCurvePtr workGamma; GammaCurvePtr encGamma; TranscodingGammaCurve(); TranscodingGammaCurve(const GammaCurvePtr&, const GammaCurvePtr&); - virtual bool Matches(const GammaCurvePtr&) const; + virtual bool Matches(const GammaCurvePtr&) const override; }; -enum GammaTypeId +enum GammaTypeId : int { kPOVList_GammaType_Unknown, kPOVList_GammaType_Neutral, @@ -603,5 +598,6 @@ SimpleGammaCurvePtr GetGammaCurve(GammaTypeId typeId, float param); //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_COLOURSPACE_H diff --git a/source/base/image/colourspace_fwd.h b/source/base/image/colourspace_fwd.h new file mode 100644 index 000000000..55ee33371 --- /dev/null +++ b/source/base/image/colourspace_fwd.h @@ -0,0 +1,60 @@ +//****************************************************************************** +/// +/// @file base/image/colourspace_fwd.h +/// +/// Forward declarations related to colour space conversions. +/// +/// @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_BASE_COLOURSPACE_FWD_H +#define POVRAY_BASE_COLOURSPACE_FWD_H + +// C++ standard header files +#include + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class GammaCurve; +typedef std::shared_ptr GammaCurvePtr; ///< Class holding a shared reference to a gamma curve. + +class SimpleGammaCurve; +typedef std::shared_ptr SimpleGammaCurvePtr; ///< Class holding a shared reference to a simple gamma curve. + +enum GammaTypeId : int; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_DITHER_FWD_H diff --git a/source/base/image/dither.cpp b/source/base/image/dither.cpp index d1fc259cb..85f1d6242 100644 --- a/source/base/image/dither.cpp +++ b/source/base/image/dither.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,10 +36,12 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/dither.h" -// Standard C++ header files -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) // POV-Ray header files (base module) +#include "base/povassert.h" #include "base/data/bluenoise64a.h" // this must be the last file included @@ -58,7 +60,7 @@ void NoDither::GetOffset(unsigned int x, unsigned int y, ColourOffset& offLin, C //******************************************************************************* -class OrderedDither::Pattern +class OrderedDither::Pattern final { public: template Pattern(unsigned int size, const T* raw, unsigned int rank); @@ -256,7 +258,7 @@ void FloydSteinbergDither::SetError(unsigned int x, unsigned int y, const Colour //******************************************************************************* -class DiffusionDither::Filter +class DiffusionDither::Filter final { public: Filter(std::initializer_list> raw, int drop = 0); @@ -426,4 +428,5 @@ ColourChannel GetDitherOffset(unsigned int x, unsigned int y) return BlueNoise64a(x, y); } -} // end of namespace pov_base +} +// end of namespace pov_base diff --git a/source/base/image/dither.h b/source/base/image/dither.h index 6939277c6..16e3f024e 100644 --- a/source/base/image/dither.h +++ b/source/base/image/dither.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 @@ -33,15 +33,22 @@ /// //****************************************************************************** -#ifndef POVRAY_BASE_IMAGE_DITHER_H -#define POVRAY_BASE_IMAGE_DITHER_H +#ifndef POVRAY_BASE_DITHER_H +#define POVRAY_BASE_DITHER_H // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/image/dither_fwd.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/types.h" #include "base/colour.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -53,8 +60,6 @@ namespace pov_base /// /// @{ -class Image; - //***************************************************************************** /// /// @name Dithering @@ -126,7 +131,7 @@ class DitherStrategy virtual void SetError(unsigned int x, unsigned int y, const ColourOffset& err) {} }; -struct DitherStrategy::ColourOffset +struct DitherStrategy::ColourOffset final { union { ColourChannel red, gray; }; ColourChannel green, blue, alpha; @@ -142,7 +147,7 @@ struct DitherStrategy::ColourOffset inline ColourOffset& operator+=(const ColourOffset& b) { red += b.red; green += b.green; blue += b.blue; alpha += b.alpha; return *this; } }; -typedef shared_ptr DitherStrategySPtr; +typedef std::shared_ptr DitherStrategySPtr; /// Factory function to get a dithering algorithm and state. DitherStrategySPtr GetDitherStrategy(DitherMethodId method, unsigned int imageWidth); @@ -171,7 +176,7 @@ ColourChannel GetDitherOffset(unsigned int x, unsigned int y); /// This stateless dithering strategy serves as a placeholder when dithering /// is not desired. /// -class NoDither : public DitherStrategy +class NoDither final : public DitherStrategy { public: virtual void GetOffset(unsigned int x, unsigned int y, ColourOffset& offLin, ColourOffset& offQnt) override; @@ -184,7 +189,7 @@ class NoDither : public DitherStrategy /// This stateless dithering strategy implements a generalized ordered /// dithering filter. The specifics of the filter are defined by a matrix. /// -class OrderedDither : public DitherStrategy +class OrderedDither final : public DitherStrategy { public: class Pattern; @@ -232,7 +237,7 @@ extern const OrderedDither::Pattern BlueNoise64a; /// DiffusionDither::Filter( /// {{ 1 }}); /// -class DiffusionDither1D : public DitherStrategy +class DiffusionDither1D final : public DitherStrategy { public: virtual void GetOffset(unsigned int x, unsigned int y, ColourOffset& offLin, ColourOffset& offQnt) override; @@ -258,11 +263,11 @@ class DiffusionDither1D : public DitherStrategy /// {{ 2 }, /// { 1, 1, 0 }}); /// -class SierraLiteDither : public DitherStrategy +class SierraLiteDither final : public DitherStrategy { public: SierraLiteDither(unsigned int width); - virtual ~SierraLiteDither(); + virtual ~SierraLiteDither() override; virtual void GetOffset(unsigned int x, unsigned int y, ColourOffset& offLin, ColourOffset& offQnt) override; virtual void SetError(unsigned int x, unsigned int y, const ColourOffset& err) override; protected: @@ -288,11 +293,11 @@ class SierraLiteDither : public DitherStrategy /// {{ 7 }, /// { 3, 5, 1 }}); /// -class FloydSteinbergDither : public DitherStrategy +class FloydSteinbergDither final : public DitherStrategy { public: FloydSteinbergDither(unsigned int width); - virtual ~FloydSteinbergDither(); + virtual ~FloydSteinbergDither() override; virtual void GetOffset(unsigned int x, unsigned int y, ColourOffset& offLin, ColourOffset& offQnt) override; virtual void SetError(unsigned int x, unsigned int y, const ColourOffset& err) override; protected: @@ -310,12 +315,12 @@ class FloydSteinbergDither : public DitherStrategy /// /// @note This implementation uses an additional multi-line pixel buffer to avoid manipulating the original image. /// -class DiffusionDither : public DitherStrategy +class DiffusionDither final : public DitherStrategy { public: class Filter; DiffusionDither(const Filter& matrix, unsigned int width); - virtual ~DiffusionDither(); + virtual ~DiffusionDither() override; virtual void GetOffset(unsigned int x, unsigned int y, ColourOffset& offLin, ColourOffset& offQnt) override; virtual void SetError(unsigned int x, unsigned int y, const ColourOffset& err) override; protected: @@ -381,6 +386,7 @@ extern const DiffusionDither::Filter StuckiMatrix; /// //############################################################################## -} // end of namespace pov_base +} +// end of namespace pov_base #endif // POVRAY_BASE_IMAGE_DITHER_H diff --git a/source/base/image/dither_fwd.h b/source/base/image/dither_fwd.h new file mode 100644 index 000000000..5e568b37a --- /dev/null +++ b/source/base/image/dither_fwd.h @@ -0,0 +1,55 @@ +//****************************************************************************** +/// +/// @file base/image/dither_fwd.h +/// +/// Forward declarations related to image dithering. +/// +/// @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_BASE_DITHER_FWD_H +#define POVRAY_BASE_DITHER_FWD_H + +// C++ standard header files +#include + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class DitherStrategy; +using DitherStrategySPtr = std::shared_ptr; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_DITHER_FWD_H diff --git a/source/base/image/encoding.cpp b/source/base/image/encoding.cpp index f751b67a5..896f214d6 100644 --- a/source/base/image/encoding.cpp +++ b/source/base/image/encoding.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 @@ -37,7 +37,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/encoding.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/image/colourspace.h" #include "base/image/dither.h" #include "base/image/image.h" @@ -47,6 +54,40 @@ namespace pov_base { +using std::min; +using std::max; + +//***************************************************************************** + +float IntDecode(const GammaCurvePtr& g, unsigned int x, unsigned int max) +{ + return GammaCurve::Decode(g, IntDecode(x, max)); +} + +unsigned int IntEncode(const GammaCurvePtr& g, float x, unsigned int max, float qOff, float& err) +{ + if (GammaCurve::IsNeutral(g)) + return IntEncode(x, max, qOff, err); + + float xEff = clip(x, 0.0f, 1.0f) + err; + unsigned int v = IntEncodeDown(GammaCurve::Encode(g, xEff), max); + float decoded = IntDecode(g, v, max); + if (v >= max) + { + err = xEff - decoded; + return v; + } + float decodedUp = IntDecode(g, v + 1, max); + float threshold = (0.5 - qOff) * decoded + (0.5 + qOff) * decodedUp; + if (xEff > threshold) + { + decoded = decodedUp; + ++v; + } + err = xEff - decoded; + return v; +} + /*******************************************************************************/ #define ALPHA_EPSILON 1.0e-6 ///< Smallest alpha value we dare to safely use with premultiplied alpha. @@ -430,3 +471,4 @@ void GetEncodedRGBValue(const Image* img, unsigned int x, unsigned int y, const } } +// end of namespace pov_base diff --git a/source/base/image/encoding.h b/source/base/image/encoding.h index f4e444efd..4b23fd9d3 100644 --- a/source/base/image/encoding.h +++ b/source/base/image/encoding.h @@ -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 @@ -40,17 +40,22 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files +// C++ variants of C standard header files +#include + +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/colour.h" #include "base/mathutil.h" -#include "base/types.h" -#include "base/image/colourspace.h" +#include "base/image/colourspace_fwd.h" +#include "base/image/dither_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { -class DitherStrategy; -class Image; - //############################################################################## /// /// @defgroup PovBaseImageEncoding Basic Colour Encoding and Decoding @@ -89,10 +94,7 @@ inline float IntDecode(unsigned int x, unsigned int max) /// @param[in] x Value to decode. /// @param max Encoded value representing 1.0. /// -inline float IntDecode(const GammaCurvePtr& g, unsigned int x, unsigned int max) -{ - return GammaCurve::Decode(g, IntDecode(x, max)); -} +float IntDecode(const GammaCurvePtr& g, unsigned int x, unsigned int max); /// @} /// @@ -119,7 +121,9 @@ inline float IntDecode(const GammaCurvePtr& g, unsigned int x, unsigned int max) /// inline unsigned int IntEncodeDown(float x, unsigned int max, float qOff = 0.0f) { - return (unsigned int)clip(floor(x * float(max) + qOff), 0.0f, float(max)); + // NB: Deliberately using `std::floor(float)` instead of `std::floorf(float)` + // to work around GCC Bug 89279. + return (unsigned int)clip(std::floor(x * float(max) + qOff), 0.0f, float(max)); } /// Linear encoding function rounding to nearest. @@ -179,29 +183,7 @@ inline unsigned int IntEncode(float x, unsigned int max, float qOff, float& err) /// @param[in] qOff Offset to add before quantization. /// @param[in,out] err Quantization error (including effects due to adding qOff). /// -inline unsigned int IntEncode(const GammaCurvePtr& g, float x, unsigned int max, float qOff, float& err) -{ - if (GammaCurve::IsNeutral(g)) - return IntEncode(x, max, qOff, err); - - float xEff = clip(x, 0.0f, 1.0f) + err; - unsigned int v = IntEncodeDown(GammaCurve::Encode(g, xEff), max); - float decoded = IntDecode(g, v, max); - if (v >= max) - { - err = xEff - decoded; - return v; - } - float decodedUp = IntDecode(g, v + 1, max); - float threshold = (0.5 - qOff) * decoded + (0.5 + qOff) * decodedUp; - if (xEff > threshold) - { - decoded = decodedUp; - ++v; - } - err = xEff - decoded; - return v; -} +unsigned int IntEncode(const GammaCurvePtr& g, float x, unsigned int max, float qOff, float& err); /// Generic encoding function. /// @@ -321,5 +303,6 @@ void GetEncodedRGBValue(const Image* img, unsigned int x, unsigned int y, const //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_IMAGE_ENCODING_H diff --git a/source/base/image/gif.cpp b/source/base/image/gif.cpp index dab308dba..cc0a3df32 100644 --- a/source/base/image/gif.cpp +++ b/source/base/image/gif.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,9 +50,18 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/gif.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" + // this must be the last file included #include "base/povdebug.h" @@ -63,15 +72,15 @@ namespace Gif { // TODO: make sure we don't leak an image object if we throw an exception. -Image *Read (IStream *file, const Image::ReadOptions& options, bool IsPOTFile) +Image *Read (IStream *file, const ImageReadOptions& options, bool IsPOTFile) { - int data ; - int width; - int height; - Image *image = nullptr; - unsigned char buffer[256]; - vector colormap ; - int alphaIdx = -1; // assume no transparency color + int data; + int width; + int height; + Image* image = nullptr; + unsigned char buffer[256]; + std::vector colormap; + int alphaIdx = -1; // assume no transparency color // GIF files used to have no clearly defined gamma by default, but a W3C recommendation exists for them to use sRGB. // Anyway, use whatever the user has chosen as default. @@ -173,7 +182,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options, bool IsPOTFile) width = (int) buffer[4] | ((int) buffer[5] << 8); height = (int) buffer[6] | ((int) buffer[7] << 8); - image = Image::Create (width, height, Image::Colour_Map, colormap) ; + image = Image::Create (width, height, ImageDataType::Colour_Map, colormap) ; // [CLi] GIF only uses full opacity or full transparency, so premultiplied vs. non-premultiplied alpha is not an issue /* Get bytes */ @@ -201,7 +210,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options, bool IsPOTFile) if ((width & 0x01) != 0) throw POV_EXCEPTION(kFileDataErr, "Invalid width for POT file"); int newWidth = width / 2 ; - Image *newImage = Image::Create (newWidth, height, Image::Gray_Int16) ; + Image *newImage = Image::Create (newWidth, height, ImageDataType::Gray_Int16) ; for (int y = 0 ; y < height ; y++) for (int x = 0 ; x < newWidth ; x++) newImage->SetGrayValue (x, y, (unsigned int) image->GetIndexedValue (x, y) << 8 | image->GetIndexedValue (x + newWidth, y)) ; @@ -211,7 +220,9 @@ Image *Read (IStream *file, const Image::ReadOptions& options, bool IsPOTFile) return (newImage) ; } -} // end of namespace Gif +} +// end of namespace Gif } +// end of namespace pov_base diff --git a/source/base/image/gif.h b/source/base/image/gif.h index cb33f1c46..717dc10d0 100644 --- a/source/base/image/gif.h +++ b/source/base/image/gif.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 @@ -40,8 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -55,15 +60,17 @@ namespace pov_base namespace Gif { -Image *Read(IStream *file, const Image::ReadOptions& options, bool IsPOTFile); +Image *Read(IStream *file, const ImageReadOptions& options, bool IsPOTFile); void Decode(IStream *file, Image *image); } +// end of namespace Gif /// @} /// //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_GIF_H diff --git a/source/base/image/gifdecod.cpp b/source/base/image/gifdecod.cpp index 86414da4c..c71d7957e 100644 --- a/source/base/image/gifdecod.cpp +++ b/source/base/image/gifdecod.cpp @@ -10,7 +10,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 @@ -61,8 +61,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/gif.h" -// Boost header files -#include +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/pov_err.h" +#include "base/image/image.h" // this must be the last file included #include "base/povdebug.h" @@ -111,7 +119,7 @@ namespace Gif 0x07FF, 0x0FFF }; - typedef struct + struct Param_Block final { short curr_size; /* The current code size */ short clear_code; /* Value for a clear code */ @@ -124,7 +132,7 @@ namespace Gif UTINY b1; /* Current byte */ UTINY byte_buff[257]; /* Current block */ UTINY *pbytes; /* Pointer to next byte in block */ - } Param_Block ; + }; /* get_next_code() * - gets the next code from the GIF file. Returns the code, or else @@ -255,10 +263,10 @@ namespace Gif params.slot = params.newcodes = params.ending + 1; params.navail_bytes = params.nbits_left = 0; - boost::scoped_array dstack (new UTINY [MAX_CODES + 1]); - boost::scoped_array suffix (new UTINY [MAX_CODES + 1]); - boost::scoped_array prefix (new UWORD [MAX_CODES + 1]); - boost::scoped_array buf (new UTINY [width]); + std::unique_ptr dstack (new UTINY [MAX_CODES + 1]); + std::unique_ptr suffix (new UTINY [MAX_CODES + 1]); + std::unique_ptr prefix (new UWORD [MAX_CODES + 1]); + std::unique_ptr buf (new UTINY [width]); /* Initialize in case they forgot to put in a clear code. * (This shouldn't happen, but we'll try and decode it anyway...) @@ -404,5 +412,7 @@ namespace Gif } } +// end of namespace Gif } +// end of namespace pov_base diff --git a/source/base/image/hdr.cpp b/source/base/image/hdr.cpp index cc56c0047..ba29ee6a8 100644 --- a/source/base/image/hdr.cpp +++ b/source/base/image/hdr.cpp @@ -13,7 +13,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 @@ -41,14 +41,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/hdr.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -#include // POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/types.h" +#include "base/image/colourspace.h" #include "base/image/dither.h" +#include "base/image/encoding.h" +#include "base/image/image.h" #include "base/image/metadata.h" // this must be the last file included @@ -72,12 +77,6 @@ namespace HDR * Local typedefs ******************************************************************************/ -struct Messages -{ - vector warnings; - string error; -}; - typedef unsigned char RGBE[4]; // red, green, blue, exponent void GetRGBE(RGBE rgbe, const Image *image, int col, int row, const GammaCurvePtr& gamma, DitherStrategy& dither); @@ -157,7 +156,7 @@ void ReadOldLine(unsigned char *scanline, int width, IStream *file) } } -Image *Read(IStream *file, const Image::ReadOptions& options) +Image *Read(IStream *file, const ImageReadOptions& options) { char line[2048]; char *s; @@ -170,7 +169,7 @@ Image *Read(IStream *file, const Image::ReadOptions& options) unsigned int width; unsigned int height; Image *image = nullptr; - Image::ImageDataType imagetype = options.itype; + ImageDataType imagetype = options.itype; // Radiance HDR files store linear color values by default, so never convert unless the user overrides // (e.g. to handle a non-compliant file). @@ -202,8 +201,8 @@ Image *Read(IStream *file, const Image::ReadOptions& options) if(sscanf(line, "%2[+-XY] %u %2[+-XY] %u\n", s1, &height, s2, &width) != 4) throw POV_EXCEPTION(kFileDataErr, "Bad HDR file header"); - if(imagetype == Image::Undefined) - imagetype = Image::RGBFT_Float; + if(imagetype == ImageDataType::Undefined) + imagetype = ImageDataType::RGBFT_Float; // TODO - A dedicated RGB_Float container would be more space efficient. image = Image::Create(width, height, imagetype); // NB: HDR files don't use alpha, so premultiplied vs. non-premultiplied is not an issue @@ -287,7 +286,7 @@ Image *Read(IStream *file, const Image::ReadOptions& options) return image; } -void Write(OStream *file, const Image *image, const Image::WriteOptions& options) +void Write(OStream *file, const Image *image, const ImageWriteOptions& options) { int width = image->GetWidth(); int height = image->GetHeight(); @@ -409,7 +408,8 @@ void Write(OStream *file, const Image *image, const Image::WriteOptions& options } } -} // end of namespace HDR - -} // end of namespace pov_base +} +// end of namespace HDR +} +// end of namespace pov_base diff --git a/source/base/image/hdr.h b/source/base/image/hdr.h index c291a2aa9..b1b6f7bae 100644 --- a/source/base/image/hdr.h +++ b/source/base/image/hdr.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 @@ -40,8 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -55,15 +60,17 @@ namespace HDR /// /// @{ -void Write(OStream *file, const Image *image, const Image::WriteOptions& options); -Image *Read(IStream *file, const Image::ReadOptions& options); +void Write(OStream *file, const Image *image, const ImageWriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace HDR } +// end of namespace pov_base #endif // POVRAY_BASE_HDR_H diff --git a/source/base/image/iff.cpp b/source/base/image/iff.cpp index 48e739411..0c2e0bf50 100644 --- a/source/base/image/iff.cpp +++ b/source/base/image/iff.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 @@ -37,11 +37,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/iff.h" -// Standard C++ header files +// C++ variants of C standard header files +#include + +// C++ standard header files +#include #include -// Boost header files -#include +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/image/image.h" // this must be the last file included #include "base/povdebug.h" @@ -70,11 +75,13 @@ namespace Iff * Type definitions ******************************************************************************/ -typedef struct Chunk_Header_Struct +struct Chunk_Header_Struct final { - int name; - int size; -} CHUNK_HEADER ; + std::int_fast32_t name; + std::int_fast32_t size; +}; + +using CHUNK_HEADER = Chunk_Header_Struct; ///< @deprecated /***************************************************************************** * Static functions @@ -96,15 +103,15 @@ static int read_word(IStream *file) return (result); } -static long read_long(IStream *file) +static std::int_fast32_t read_long(IStream *file) { - long result = 0; + std::int_fast32_t result = 0; for (int i = 0; i < 4; i++) result = (result << 8) + read_byte(file); return (result); } -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { int nPlanes = 0; int compression = 0; @@ -123,16 +130,16 @@ Image *Read (IStream *file, const Image::ReadOptions& options) unsigned int r; unsigned int g; unsigned int b; - unsigned long creg; + std::uint_fast32_t creg; Image::RGBMapEntry entry; - vector colormap; + std::vector colormap; while (true) { Chunk_Header.name = read_long(file); Chunk_Header.size = read_long(file); - switch (IFF_SWITCH_CAST Chunk_Header.name) + switch (Chunk_Header.name) { case FORM: if (read_long(file) != ILBM) @@ -179,7 +186,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) // TODO FIXME - gamma! } - for (int i = colourmap_size * 3; (long)i < Chunk_Header.size; i++) + for (std::int_fast32_t i = colourmap_size * 3; i < Chunk_Header.size; i++) read_byte(file); break; @@ -187,9 +194,9 @@ Image *Read (IStream *file, const Image::ReadOptions& options) case BODY: if (width > 0 && height > 0) { - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = ((viewmodes & HAM) != 0 || nPlanes == 24) ? Image::RGB_Int8 : Image::Colour_Map; + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = ((viewmodes & HAM) != 0 || nPlanes == 24) ? ImageDataType::RGB_Int8 : ImageDataType::Colour_Map; if ((viewmodes & HAM) != 0 || nPlanes == 24) image = Image::Create (width, height, imagetype); else @@ -197,7 +204,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) // NB: IFF-ILBM files don't use alpha, so premultiplied vs. non-premultiplied is not an issue int rowlen = ((width + 15) / 16) * 2 ; - boost::scoped_array row_bytes (new unsigned char [nPlanes * rowlen]); + std::unique_ptr row_bytes (new unsigned char [nPlanes * rowlen]); for (int row = 0; row < height; row++) { @@ -312,7 +319,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) break; default: - for (int i = 0; (long)i < Chunk_Header.size; i++) + for (std::int_fast32_t i = 0; i < Chunk_Header.size; i++) if (file->Read_Byte() == EOF) throw POV_EXCEPTION(kFileDataErr, "Unexpected EOF while reading IFF-ILBM file"); break; @@ -321,7 +328,8 @@ Image *Read (IStream *file, const Image::ReadOptions& options) return (image); } -} // end of namespace Iff - } +// end of namespace Iff +} +// end of namespace pov_base diff --git a/source/base/image/iff.h b/source/base/image/iff.h index b958e2241..554131e3b 100644 --- a/source/base/image/iff.h +++ b/source/base/image/iff.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 @@ -40,8 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -55,14 +60,16 @@ namespace Iff /// /// @{ -Image *Read(IStream *file, const Image::ReadOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace Iff } +// end of namespace pov_base #endif // POVRAY_BASE_IFF_H diff --git a/source/base/image/image.cpp b/source/base/image/image.cpp index 3418aff79..42d331f9f 100644 --- a/source/base/image/image.cpp +++ b/source/base/image/image.cpp @@ -36,20 +36,28 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/image.h" -// Standard C++ header files -#include -#include +// C++ variants of C standard header files +#include -// Standard POSIX header files +// C++ standard header files +// (none at the moment) + +// POSIX standard header files +// TODO FIXME - Any POSIX-specific stuff should be considered platform-specific. #include #include #include // POV-Ray header files (base module) +#include "base/filesystem.h" #include "base/platformbase.h" +#include "base/povassert.h" #include "base/safemath.h" +#include "base/stringutilities.h" #include "base/image/bmp.h" +#include "base/image/colourspace.h" #include "base/image/dither.h" +#include "base/image/encoding.h" #include "base/image/gif.h" #include "base/image/hdr.h" #include "base/image/iff.h" @@ -78,82 +86,93 @@ namespace pov_base { using std::allocator; +using std::min; +using std::max; +using std::vector; -Image::WriteOptions::WriteOptions() : +ImageWriteOptions::ImageWriteOptions() : ditherStrategy(GetNoOpDitherStrategy()), offset_x(0), offset_y(0), - alphaMode(kAlphaMode_None), + alphaMode(ImageAlphaMode::None), bitsPerChannel(8), compression(-1), grayscale(false) {} -template > -class BitMapImage : public Image +GammaCurvePtr ImageWriteOptions::GetTranscodingGammaCurve(GammaCurvePtr defaultEncodingGamma) const +{ + if (encodingGamma) + return TranscodingGammaCurve::Get(workingGamma, encodingGamma); + else + return TranscodingGammaCurve::Get(workingGamma, defaultEncodingGamma); +} + +template> +class BitMapImage final : public Image { public: BitMapImage(unsigned int w, unsigned int h) : - Image(w, h, Bit_Map) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + Image(w, h, ImageDataType::Bit_Map) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } BitMapImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, Bit_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + Image(w, h, ImageDataType::Bit_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } BitMapImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, Bit_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + Image(w, h, ImageDataType::Bit_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } BitMapImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, Bit_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } - ~BitMapImage() { } + Image(w, h, ImageDataType::Bit_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + virtual ~BitMapImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return true; } - bool IsColour() const + virtual bool IsColour() const override { return false; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return false; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return 1; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return pixels[x + y * size_t(width)]; } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); if(pixels[x + y * size_t(width)] == true) @@ -161,143 +180,143 @@ class BitMapImage : public Image else return 0.0f; } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { gray = GetGrayValue(x, y); alpha = ALPHA_OPAQUE; } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { red = green = blue = GetGrayValue(x, y); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { red = green = blue = GetGrayValue(x, y); alpha = ALPHA_OPAQUE; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { red = green = blue = GetGrayValue(x, y); transm = FT_OPAQUE; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { red = green = blue = GetGrayValue(x, y); filter = transm = FT_OPAQUE; } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = bit; } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = (gray != 0.0f); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = (gray != 0); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = (gray != 0.0f); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = (gray != 0); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = IS_NONZERO_RGB(red, green, blue); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = IS_NONZERO_RGB_INT(red, green, blue); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. SetRGBValue(x, y, red, green, blue); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. SetRGBValue(x, y, red, green, blue); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { fill(pixels.begin(), pixels.end(), bit); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillBitValue(gray != 0.0f); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillBitValue(gray != 0); } - void FillGrayAValue(float gray, float) + virtual void FillGrayAValue(float gray, float) override { FillBitValue(gray != 0.0f); } - void FillGrayAValue(unsigned int gray, unsigned int) + virtual void FillGrayAValue(unsigned int gray, unsigned int) override { FillBitValue(gray != 0); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillBitValue(IS_NONZERO_RGB(red, green, blue)); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillBitValue(IS_NONZERO_RGB_INT(red, green, blue)); } - void FillRGBAValue(float red, float green, float blue, float) + virtual void FillRGBAValue(float red, float green, float blue, float) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. FillRGBValue(red, green, blue); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. FillRGBValue(red, green, blue); } - void FillRGBTValue(float red, float green, float blue, float) + virtual void FillRGBTValue(float red, float green, float blue, float) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. FillRGBValue(red, green, blue); } - void FillRGBFTValue(float red, float green, float blue, float, float) + virtual void FillRGBFTValue(float red, float green, float blue, float, float) override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. FillRGBValue(red, green, blue); @@ -308,19 +327,19 @@ class BitMapImage : public Image typedef BitMapImage<> MemoryBitMapImage; -template > -class ColourMapImage : public Image +template> +class ColourMapImage final : public Image { public: ColourMapImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, Colour_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + Image(w, h, ImageDataType::Colour_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } ColourMapImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, Colour_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + Image(w, h, ImageDataType::Colour_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } ColourMapImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, Colour_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } - ~ColourMapImage() { } + Image(w, h, ImageDataType::Colour_Map, m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } + virtual ~ColourMapImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { if((colormaptype != RGBAColourMap) && (colormaptype != RGBFTColourMap)) return true; @@ -359,48 +378,48 @@ class ColourMapImage : public Image return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return false; } - bool IsColour() const + virtual bool IsColour() const override { return true; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return true; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return (colormaptype == RGBAColourMap); } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return (colormaptype == RGBFTColourMap); } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return 255; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { float red, green, blue, filter, transm, alpha; switch(colormaptype) @@ -420,7 +439,7 @@ class ColourMapImage : public Image return false; } } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue, filter, transm, alpha; switch(colormaptype) @@ -438,7 +457,7 @@ class ColourMapImage : public Image return 0.0f; } } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { float red, green, blue, filter, transm; alpha = ALPHA_OPAQUE; // (unless noted otherwise) @@ -462,7 +481,7 @@ class ColourMapImage : public Image return; } } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { CHECK_BOUNDS(x, y); MapEntry e(colormap[pixels[x + y * size_t(width)]]); @@ -470,7 +489,7 @@ class ColourMapImage : public Image green = e.green; blue = e.blue; } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { CHECK_BOUNDS(x, y); MapEntry e(colormap[pixels[x + y * size_t(width)]]); @@ -490,7 +509,7 @@ class ColourMapImage : public Image return; } } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { CHECK_BOUNDS(x, y); MapEntry e(colormap[pixels[x + y * size_t(width)]]); @@ -510,7 +529,7 @@ class ColourMapImage : public Image return; } } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { CHECK_BOUNDS(x, y); MapEntry e(colormap[pixels[x + y * size_t(width)]]); @@ -532,126 +551,126 @@ class ColourMapImage : public Image return; } } - unsigned char GetIndexedValue(unsigned int x, unsigned int y) + virtual unsigned char GetIndexedValue(unsigned int x, unsigned int y) override { CHECK_BOUNDS(x, y); return pixels[x + y * size_t(width)]; } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = Bit2Map(bit); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = Gray2Map(gray); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = Gray2Map(float(gray) / 255.0); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = GrayA2Map(gray, alpha); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = GrayA2Map(float(gray) / 255.0, float(alpha) / 255.0); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = RGB2Map(red, green, blue); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = RGB2Map(float(red) / 255.0, float(green) / 255.0, float(blue) / 255.0); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = RGBA2Map(red, green, blue, alpha); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = RGBA2Map(float(red) / 255.0, float(green) / 255.0, float(blue) / 255.0, float(alpha) / 255.0); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = RGBT2Map(red, green, blue, transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = RGBA2Map(col.red(), col.green(), col.blue(), col.alpha()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { CHECK_BOUNDS(x, y); // [CLi 2009-09] this was dividing by 255 - which I presume to have been a bug. pixels[x + y * size_t(width)] = RGBFT2Map(red, green, blue, filter, transm); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { CHECK_BOUNDS(x, y); // [CLi 2009-09] this was dividing by 255 - which I presume to have been a bug. pixels[x + y * size_t(width)] = RGBFT2Map(col.red(), col.green(), col.blue(), col.filter(), col.transm()); } - void SetIndexedValue(unsigned int x, unsigned int y, unsigned char index) + virtual void SetIndexedValue(unsigned int x, unsigned int y, unsigned char index) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = index; } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { fill(pixels.begin(), pixels.end(), Bit2Map(bit)); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { fill(pixels.begin(), pixels.end(), Gray2Map(gray)); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { fill(pixels.begin(), pixels.end(), Gray2Map(float(gray) / 255.0)); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { fill(pixels.begin(), pixels.end(), GrayA2Map(gray, alpha)); } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { fill(pixels.begin(), pixels.end(), GrayA2Map(float(gray) / 255.0, float(alpha) / 255.0)); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { fill(pixels.begin(), pixels.end(), RGB2Map(red, green, blue)); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { fill(pixels.begin(), pixels.end(), RGB2Map(float(red) / 255.0, float(green) / 255.0, float(blue) / 255.0)); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { fill(pixels.begin(), pixels.end(), RGBA2Map(red, green, blue, alpha)); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { fill(pixels.begin(), pixels.end(), RGBA2Map(float(red) / 255.0, float(green) / 255.0, float(blue) / 255.0, float(alpha) / 255.0)); } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { fill(pixels.begin(), pixels.end(), RGBT2Map(red, green, blue, transm)); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { // [CLi 2009-09] this was dividing by 255 - which I presume to have been a bug. fill(pixels.begin(), pixels.end(), RGBFT2Map(red, green, blue, filter, transm)); @@ -811,8 +830,8 @@ class ColourMapImage : public Image typedef ColourMapImage<> MemoryColourMapImage; -template > -class GrayImage : public Image +template> +class GrayImage final : public Image { public: GrayImage(unsigned int w, unsigned int h) : @@ -823,198 +842,198 @@ class GrayImage : public Image Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } GrayImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } - ~GrayImage() { } + virtual ~GrayImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return true; } - bool IsColour() const + virtual bool IsColour() const override { return false; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return false; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return (pixels[x + y * size_t(width)] != 0); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return float(pixels[x + y * size_t(width)]) / float(TMAX); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { CHECK_BOUNDS(x, y); gray = float(pixels[x + y * size_t(width)]) / float(TMAX); alpha = ALPHA_OPAQUE; } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { red = green = blue = GetGrayValue(x, y); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { red = green = blue = GetGrayValue(x, y); alpha = ALPHA_OPAQUE; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { red = green = blue = GetGrayValue(x, y); transm = FT_OPAQUE; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { red = green = blue = GetGrayValue(x, y); filter = transm = FT_OPAQUE; } - unsigned char GetIndexedValue(unsigned int x, unsigned int y) + virtual unsigned char GetIndexedValue(unsigned int x, unsigned int y) override { CHECK_BOUNDS(x, y); return (unsigned char)(int(pixels[x + y * size_t(width)]) / ((TMAX + 1) >> 8)); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, TMAX); else SetGrayValue(x, y, (unsigned int)0); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = T(gray * float(TMAX)); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = T(gray); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = T(gray * float(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = T(gray); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetGrayValue(x, y, RGB2Gray(red, green, blue)); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetGrayValue(x, y, RGB2Gray(float(red) / float(TMAX), float(green) / float(TMAX), float(blue) / float(TMAX))); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillGrayValue((unsigned int)(gray * float(TMAX))); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { fill(pixels.begin(), pixels.end(), T(gray)); } - void FillGrayAValue(float gray, float) + virtual void FillGrayAValue(float gray, float) override { FillGrayValue(gray); } - void FillGrayAValue(unsigned int gray, unsigned int) + virtual void FillGrayAValue(unsigned int gray, unsigned int) override { FillGrayValue(gray); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillGrayValue(RGB2Gray(red, green, blue)); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillGrayValue(RGB2Gray(float(red) / float(TMAX), float(green) / float(TMAX), float(blue) / float(TMAX))); } - void FillRGBAValue(float red, float green, float blue, float) + virtual void FillRGBAValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { FillRGBValue(red, green, blue); } - void FillRGBTValue(float red, float green, float blue, float) + virtual void FillRGBTValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBFTValue(float red, float green, float blue, float, float) + virtual void FillRGBFTValue(float red, float green, float blue, float, float) override { FillRGBValue(red, green, blue); } @@ -1022,12 +1041,12 @@ class GrayImage : public Image vector pixels; }; -typedef GrayImage MemoryGray8Image; +typedef GrayImage MemoryGray8Image; -typedef GrayImage MemoryGray16Image; +typedef GrayImage MemoryGray16Image; -template > -class GrayAImage : public Image +template> +class GrayAImage final : public Image { public: GrayAImage(unsigned int w, unsigned int h) : @@ -1038,9 +1057,9 @@ class GrayAImage : public Image Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h, 2u)); FillBitValue(false); } GrayAImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h, 2u)); FillBitValue(false); } - ~GrayAImage() { } + virtual ~GrayAImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { for(typename vector::const_iterator i(pixels.begin()); i != pixels.end(); i += 2) { @@ -1050,81 +1069,81 @@ class GrayAImage : public Image return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return true; } - bool IsColour() const + virtual bool IsColour() const override { return false; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return true; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. CHECK_BOUNDS(x, y); return (pixels[(x + y * size_t(width)) * 2] != 0); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return float(pixels[(x + y * size_t(width)) * 2]) / float(TMAX); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { CHECK_BOUNDS(x, y); gray = float(pixels[(x + y * size_t(width)) * 2]) / float(TMAX); alpha = float(pixels[(x + y * size_t(width)) * 2 + 1]) / float(TMAX); } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { red = green = blue = GetGrayValue(x, y); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { GetGrayAValue(x, y, red, alpha); green = blue = red; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { float alpha; GetGrayAValue(x, y, red, alpha); green = blue = red; transm = 1.0 - alpha; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { float alpha; GetGrayAValue(x, y, red, alpha); @@ -1132,83 +1151,83 @@ class GrayAImage : public Image RGBFTColour::AtoFT(alpha, filter, transm); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayAValue(x, y, TMAX, ALPHA_OPAQUE_INT(TMAX)); else SetGrayAValue(x, y, (unsigned int)0, ALPHA_OPAQUE_INT(TMAX)); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetGrayAValue(x, y, gray, ALPHA_OPAQUE); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { SetGrayAValue(x, y, gray, ALPHA_OPAQUE_INT(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 2] = T(gray * float(TMAX)); pixels[(x + y * size_t(width)) * 2 + 1] = T(alpha * float(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 2] = gray; pixels[(x + y * size_t(width)) * 2 + 1] = alpha; } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetGrayValue(x, y, RGB2Gray(red, green, blue)); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetGrayValue(x, y, RGB2Gray(float(red) / float(TMAX), float(green) / float(TMAX), float(blue) / float(TMAX))); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { SetGrayAValue(x, y, RGB2Gray(red, green, blue), alpha); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { // TODO FIXME - this unnecessarily converts alpha from int to float, requiring it to be converted back to int SetGrayAValue(x, y, RGB2Gray(float(red) / float(TMAX), float(green) / float(TMAX), float(blue) / float(TMAX)), float(alpha) / float(TMAX)); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetGrayAValue(x, y, RGB2Gray(red, green, blue), 1.0 - transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetGrayAValue(x, y, RGB2Gray(col.red(), col.green(), col.blue()), col.alpha()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { SetGrayAValue(x, y, RGB2Gray(red, green, blue), RGBFTColour::FTtoA(filter, transm)); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { SetGrayAValue(x, y, RGB2Gray(col.red(), col.green(), col.blue()), col.FTtoA()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillGrayValue((unsigned int)(gray * float(TMAX))); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillGrayAValue(gray, ALPHA_OPAQUE_INT(TMAX)); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { // [CLi 2009-09] this was dividing by float(TMAX) - which I presume to have been a bug. T g(gray * float(TMAX)), a(alpha * float(TMAX)); @@ -1219,7 +1238,7 @@ class GrayAImage : public Image *i = a; } } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { for(typename vector::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -1228,28 +1247,28 @@ class GrayAImage : public Image *i = T(alpha); } } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillGrayValue(RGB2Gray(red, green, blue)); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillGrayValue(RGB2Gray(float(red) / float(TMAX), float(green) / float(TMAX), float(blue) / float(TMAX))); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { FillGrayAValue(RGB2Gray(red, green, blue), alpha); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { // TODO FIXME - this unnecessarily converts alpha from int to float, requiring it to be converted back to int FillGrayAValue(RGB2Gray(float(red) / float(TMAX), float(green) / float(TMAX), float(blue) / float(TMAX)), float(alpha) / float(TMAX)); } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { FillGrayAValue(RGB2Gray(red, green, blue), 1.0 - transm); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { FillGrayAValue(RGB2Gray(red, green, blue), RGBFTColour::FTtoA(filter, transm)); } @@ -1257,12 +1276,12 @@ class GrayAImage : public Image vector pixels; }; -typedef GrayAImage MemoryGrayA8Image; +typedef GrayAImage MemoryGrayA8Image; -typedef GrayAImage MemoryGrayA16Image; +typedef GrayAImage MemoryGrayA16Image; -template > -class RGBImage : public Image +template> +class RGBImage final : public Image { public: RGBImage(unsigned int w, unsigned int h) : @@ -1273,188 +1292,188 @@ class RGBImage : public Image Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h, 3u)); FillBitValue(false); } RGBImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h, 3u)); FillBitValue(false); } - ~RGBImage() { } + virtual ~RGBImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return false; } - bool IsColour() const + virtual bool IsColour() const override { return true; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return false; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { float red, green, blue; GetRGBValue(x, y, red, green, blue); return IS_NONZERO_RGB(red, green, blue); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue; GetRGBValue(x, y, red, green, blue); return RGB2Gray(red, green, blue); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { gray = GetGrayValue(x, y); alpha = ALPHA_OPAQUE; } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { CHECK_BOUNDS(x, y); red = float(pixels[(x + y * size_t(width)) * 3]) / float(TMAX); green = float(pixels[(x + y * size_t(width)) * 3 + 1]) / float(TMAX); blue = float(pixels[(x + y * size_t(width)) * 3 + 2]) / float(TMAX); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { GetRGBValue(x, y, red, green, blue); alpha = ALPHA_OPAQUE; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { GetRGBValue(x, y, red, green, blue); transm = FT_OPAQUE; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { GetRGBValue(x, y, red, green, blue); filter = transm = FT_OPAQUE; } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, TMAX); else SetGrayValue(x, y, (unsigned int)0); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetRGBValue(x, y, gray, gray, gray); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width) * 3] = pixels[x + y * size_t(width) * 3 + 1] = pixels[x + y * size_t(width) * 3 + 2] = gray; } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width) * 3] = pixels[x + y * size_t(width) * 3 + 1] = pixels[x + y * size_t(width) * 3 + 2] = T(gray * float(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width) * 3] = pixels[x + y * size_t(width) * 3 + 1] = pixels[x + y * size_t(width) * 3 + 2] = gray; } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 3] = T(red * float(TMAX)); pixels[(x + y * size_t(width)) * 3 + 1] = T(green * float(TMAX)); pixels[(x + y * size_t(width)) * 3 + 2] = T(blue * float(TMAX)); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 3] = T(red); pixels[(x + y * size_t(width)) * 3 + 1] = T(green); pixels[(x + y * size_t(width)) * 3 + 2] = T(blue); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillGrayValue((unsigned int)(gray * float(TMAX))); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { fill(pixels.begin(), pixels.end(), gray); } - void FillGrayAValue(float gray, float) + virtual void FillGrayAValue(float gray, float) override { FillRGBValue(gray, gray, gray); } - void FillGrayAValue(unsigned int gray, unsigned int) + virtual void FillGrayAValue(unsigned int gray, unsigned int) override { FillRGBValue(gray, gray, gray); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { // [CLi 2009-09] this was dividing by float(TMAX) - which I presume to have been a bug. T r(red * float(TMAX)), g(green * float(TMAX)), b(blue * float(TMAX)); @@ -1467,7 +1486,7 @@ class RGBImage : public Image *i = b; } } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { for(typename vector::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -1478,19 +1497,19 @@ class RGBImage : public Image *i = T(blue); } } - void FillRGBAValue(float red, float green, float blue, float) + virtual void FillRGBAValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { FillRGBValue(red, green, blue); } - void FillRGBTValue(float red, float green, float blue, float) + virtual void FillRGBTValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBFTValue(float red, float green, float blue, float, float) + virtual void FillRGBFTValue(float red, float green, float blue, float, float) override { FillRGBValue(red, green, blue); } @@ -1498,12 +1517,12 @@ class RGBImage : public Image vector pixels; }; -typedef RGBImage MemoryRGB8Image; +typedef RGBImage MemoryRGB8Image; -typedef RGBImage MemoryRGB16Image; +typedef RGBImage MemoryRGB16Image; -template > -class RGBAImage : public Image +template> +class RGBAImage final : public Image { public: RGBAImage(unsigned int w, unsigned int h) : @@ -1514,9 +1533,9 @@ class RGBAImage : public Image Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h, 4u)); FillBitValue(false); } RGBAImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m) { pixels.resize(SafeUnsignedProduct(w, h, 4u)); FillBitValue(false); } - ~RGBAImage() { } + virtual ~RGBAImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { for(typename vector::const_iterator i(pixels.begin()); i != pixels.end(); i += 4) { @@ -1526,72 +1545,72 @@ class RGBAImage : public Image return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return false; } - bool IsColour() const + virtual bool IsColour() const override { return true; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return true; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. float red, green, blue, alpha; GetRGBAValue(x, y, red, green, blue, alpha); return IS_NONZERO_RGB(red, green, blue); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue, alpha; GetRGBAValue(x, y, red, green, blue, alpha); return RGB2Gray(red, green, blue); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { float red, green, blue; GetRGBAValue(x, y, red, green, blue, alpha); gray = RGB2Gray(red, green, blue); } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { float alpha; GetRGBAValue(x, y, red, green, blue, alpha); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { CHECK_BOUNDS(x, y); red = float(pixels[(x + y * size_t(width)) * 4]) / float(TMAX); @@ -1599,51 +1618,51 @@ class RGBAImage : public Image blue = float(pixels[(x + y * size_t(width)) * 4 + 2]) / float(TMAX); alpha = float(pixels[(x + y * size_t(width)) * 4 + 3]) / float(TMAX); } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { float alpha; GetRGBAValue(x, y, red, green, blue, alpha); transm = 1.0 - alpha; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { float alpha; GetRGBAValue(x, y, red, green, blue, alpha); RGBFTColour::AtoFT(alpha, filter, transm); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, TMAX); else SetGrayValue(x, y, (unsigned int)0); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetRGBAValue(x, y, gray, gray, gray, ALPHA_OPAQUE); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { SetRGBAValue(x, y, gray, gray, gray, ALPHA_OPAQUE_INT(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { SetRGBAValue(x, y, gray, gray, gray, alpha); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { SetRGBAValue(x, y, gray, gray, gray, alpha); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetRGBAValue(x, y, red, green, blue, ALPHA_OPAQUE); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetRGBAValue(x, y, red, green, blue, ALPHA_OPAQUE_INT(TMAX)); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(red * float(TMAX)); @@ -1651,7 +1670,7 @@ class RGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 2] = T(blue * float(TMAX)); pixels[(x + y * size_t(width)) * 4 + 3] = T(alpha * float(TMAX)); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(red); @@ -1659,11 +1678,11 @@ class RGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 2] = T(blue); pixels[(x + y * size_t(width)) * 4 + 3] = T(alpha); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBAValue(x, y, red, green, blue, 1.0 - transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(col.red() * float(TMAX)); @@ -1671,11 +1690,11 @@ class RGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 2] = T(col.blue() * float(TMAX)); pixels[(x + y * size_t(width)) * 4 + 3] = T(col.alpha() * float(TMAX)); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { SetRGBAValue(x, y, red, green, blue, RGBFTColour::FTtoA(filter, transm)); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(col.red() * float(TMAX)); @@ -1684,38 +1703,38 @@ class RGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 3] = T(col.FTtoA() * float(TMAX)); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillRGBAValue(gray, gray, gray, ALPHA_OPAQUE); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillRGBAValue(gray, gray, gray, ALPHA_OPAQUE_INT(TMAX)); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { FillRGBAValue(gray, gray, gray, alpha); } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { FillRGBAValue(gray, gray, gray, alpha); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillRGBAValue(red, green, blue, ALPHA_OPAQUE); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillRGBAValue(red, green, blue, ALPHA_OPAQUE_INT(TMAX)); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { // [CLi 2009-09] this was dividing by float(TMAX) - which I presume to have been a bug. T r(red * float(TMAX)), g(green * float(TMAX)), b(blue * float(TMAX)), a(alpha * float(TMAX)); @@ -1730,7 +1749,7 @@ class RGBAImage : public Image *i = a; } } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { for(typename vector::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -1743,11 +1762,11 @@ class RGBAImage : public Image *i = T(alpha); } } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { FillRGBAValue(red, green, blue, 1.0 - transm); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { FillRGBAValue(red, green, blue, RGBFTColour::FTtoA(filter, transm)); } @@ -1755,25 +1774,25 @@ class RGBAImage : public Image vector pixels; }; -typedef RGBAImage MemoryRGBA8Image; +typedef RGBAImage MemoryRGBA8Image; -typedef RGBAImage MemoryRGBA16Image; +typedef RGBAImage MemoryRGBA16Image; -template > > -class RGBFTImage : public Image +template>> +class RGBFTImage final : public Image { public: RGBFTImage(unsigned int w, unsigned int h) : - Image(w, h, RGBFT_Float) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } + Image(w, h, ImageDataType::RGBFT_Float) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } RGBFTImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, RGBFT_Float, m) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } + Image(w, h, ImageDataType::RGBFT_Float, m) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } RGBFTImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, RGBFT_Float, m) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } + Image(w, h, ImageDataType::RGBFT_Float, m) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } RGBFTImage(unsigned int w, unsigned int h, const vector& m) : - Image(w, h, RGBFT_Float, m) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } - ~RGBFTImage() { } + Image(w, h, ImageDataType::RGBFT_Float, m) { pixels.resize(SafeUnsignedProduct(w, h, 5u)); FillBitValue(false); } + virtual ~RGBFTImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { for(typename PixelContainer::const_iterator i(pixels.begin()); i != pixels.end(); i += 5) { @@ -1782,85 +1801,85 @@ class RGBFTImage : public Image } return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return false; } - bool IsColour() const + virtual bool IsColour() const override { return true; } - bool IsFloat() const + virtual bool IsFloat() const override { return true; } - bool IsInt() const + virtual bool IsInt() const override { return false; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return false; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return false; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return true; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return 255; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. float red, green, blue, filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); return IS_NONZERO_RGB(red, green, blue); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue, filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); return RGB2Gray(red, green, blue); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { float red, green, blue, filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); gray = RGB2Gray(red, green, blue); alpha = RGBFTColour::FTtoA(filter, transm); } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { float filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { float filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); alpha = RGBFTColour::FTtoA(filter, transm); } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { float filter; GetRGBFTValue(x, y, red, green, blue, filter, transm); transm = 1.0 - RGBFTColour::FTtoA(filter, transm); } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { CHECK_BOUNDS(x, y); red = pixels[(x + y * size_t(width)) * 5]; @@ -1870,63 +1889,63 @@ class RGBFTImage : public Image transm = pixels[(x + y * size_t(width)) * 5 + 4]; } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, 1.0f); else SetGrayValue(x, y, 0.0f); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetRGBFTValue(x, y, gray, gray, gray, FT_OPAQUE, FT_OPAQUE); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { SetGrayValue(x, y, float(gray) / 255.0f); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); SetRGBFTValue(x, y, gray, gray, gray, filter, transm); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { float c = float(gray) / 255.0f; float filter, transm; RGBFTColour::AtoFT(float(alpha) / 255.0f, filter, transm); SetRGBFTValue(x, y, c, c, c, filter, transm); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetRGBFTValue(x, y, red, green, blue, FT_OPAQUE, FT_OPAQUE); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetRGBFTValue(x, y, float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, FT_OPAQUE, FT_OPAQUE); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); SetRGBFTValue(x, y, red, green, blue, filter, transm); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { float filter, transm; RGBFTColour::AtoFT(float(alpha) / 255.0f, filter, transm); SetRGBFTValue(x, y, float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, filter, transm); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBFTValue(x, y, red, green, blue, FT_OPAQUE, transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetRGBFTValue(x, y, col.red(), col.green(), col.blue(), FT_OPAQUE, col.transm()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 5] = red; @@ -1935,7 +1954,7 @@ class RGBFTImage : public Image pixels[(x + y * size_t(width)) * 5 + 3] = filter; pixels[(x + y * size_t(width)) * 5 + 4] = transm; } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 5] = col.red(); @@ -1945,56 +1964,56 @@ class RGBFTImage : public Image pixels[(x + y * size_t(width)) * 5 + 4] = col.transm(); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(1.0f); else FillGrayValue(0.0f); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillRGBFTValue(gray, gray, gray, FT_OPAQUE, FT_OPAQUE); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillGrayValue(float(gray) / 255.0f); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); FillRGBFTValue(gray, gray, gray, filter, transm); } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { FillGrayAValue(float(gray) / 255.0f, float(alpha) / 255.0f); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillRGBFTValue(red, green, blue, FT_OPAQUE, FT_OPAQUE); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillRGBFTValue(float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, FT_OPAQUE, FT_OPAQUE); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); FillRGBFTValue(red, green, blue, filter, transm); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { float filter, transm; RGBFTColour::AtoFT(float(alpha) / 255.0f, filter, transm); FillRGBFTValue(float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, filter, transm); } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { FillRGBFTValue(red, green, blue, FT_OPAQUE, transm); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { for(typename PixelContainer::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -2015,8 +2034,8 @@ class RGBFTImage : public Image typedef RGBFTImage<> MemoryRGBFTImage; -template > -class NonlinearGrayImage : public Image +template> +class NonlinearGrayImage final : public Image { public: NonlinearGrayImage(unsigned int w, unsigned int h) : @@ -2027,49 +2046,49 @@ class NonlinearGrayImage : public Image Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } NonlinearGrayImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h)); FillBitValue(false); } - ~NonlinearGrayImage() { } + virtual ~NonlinearGrayImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return true; } - bool IsColour() const + virtual bool IsColour() const override { return false; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return true; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return false; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) + virtual bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) override { if (max != TMAX) return false; if (!GammaCurve::IsNeutral(gamma)) return !g; @@ -2078,151 +2097,151 @@ class NonlinearGrayImage : public Image return true; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return (pixels[x + y * size_t(width)] != 0); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return gammaLUT[pixels[x + y * size_t(width)]]; } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { CHECK_BOUNDS(x, y); gray = gammaLUT[pixels[x + y * size_t(width)]]; alpha = ALPHA_OPAQUE; } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { red = green = blue = GetGrayValue(x, y); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { red = green = blue = GetGrayValue(x, y); alpha = ALPHA_OPAQUE; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { red = green = blue = GetGrayValue(x, y); transm = FT_OPAQUE; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { red = green = blue = GetGrayValue(x, y); filter = transm = FT_OPAQUE; } - unsigned char GetIndexedValue(unsigned int x, unsigned int y) + virtual unsigned char GetIndexedValue(unsigned int x, unsigned int y) override { CHECK_BOUNDS(x, y); return (unsigned char)(int(pixels[x + y * size_t(width)]) / ((TMAX + 1) >> 8)); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, TMAX); else SetGrayValue(x, y, (unsigned int)0); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = IntEncode(gamma, gray, TMAX); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = T(gray); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = IntEncode(gamma, gray, TMAX); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width)] = T(gray); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetGrayValue(x, y, RGB2Gray(red, green, blue)); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetGrayValue(x, y, RGB2Gray(gammaLUT[red], gammaLUT[green], gammaLUT[blue])); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillGrayValue(IntEncode(gamma, gray, TMAX)); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { fill(pixels.begin(), pixels.end(), T(gray)); } - void FillGrayAValue(float gray, float) + virtual void FillGrayAValue(float gray, float) override { FillGrayValue(gray); } - void FillGrayAValue(unsigned int gray, unsigned int) + virtual void FillGrayAValue(unsigned int gray, unsigned int) override { FillGrayValue(gray); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillGrayValue(RGB2Gray(red, green, blue)); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillGrayValue(RGB2Gray(gammaLUT[red], gammaLUT[green], gammaLUT[blue])); } - void FillRGBAValue(float red, float green, float blue, float) + virtual void FillRGBAValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { FillRGBValue(red, green, blue); } - void FillRGBTValue(float red, float green, float blue, float) + virtual void FillRGBTValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBFTValue(float red, float green, float blue, float, float) + virtual void FillRGBFTValue(float red, float green, float blue, float, float) override { FillRGBValue(red, green, blue); } @@ -2232,12 +2251,12 @@ class NonlinearGrayImage : public Image const float* gammaLUT; }; -typedef NonlinearGrayImage MemoryNonlinearGray8Image; +typedef NonlinearGrayImage MemoryNonlinearGray8Image; -typedef NonlinearGrayImage MemoryNonlinearGray16Image; +typedef NonlinearGrayImage MemoryNonlinearGray16Image; -template > -class NonlinearGrayAImage : public Image +template> +class NonlinearGrayAImage final : public Image { public: NonlinearGrayAImage(unsigned int w, unsigned int h) : @@ -2248,9 +2267,9 @@ class NonlinearGrayAImage : public Image Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h, 2u)); FillBitValue(false); } NonlinearGrayAImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h, 2u)); FillBitValue(false); } - ~NonlinearGrayAImage() { } + virtual ~NonlinearGrayAImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { for(typename vector::const_iterator i(pixels.begin()); i != pixels.end(); i += 2) { @@ -2260,43 +2279,43 @@ class NonlinearGrayAImage : public Image return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return true; } - bool IsColour() const + virtual bool IsColour() const override { return false; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return true; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return true; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) + virtual bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) override { if (max != TMAX) return false; if (!GammaCurve::IsNeutral(gamma)) return !g; @@ -2305,40 +2324,40 @@ class NonlinearGrayAImage : public Image return true; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. CHECK_BOUNDS(x, y); return (pixels[(x + y * size_t(width)) * 2] != 0); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { CHECK_BOUNDS(x, y); return gammaLUT[pixels[(x + y * size_t(width)) * 2]]; } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { CHECK_BOUNDS(x, y); gray = gammaLUT[pixels[(x + y * size_t(width)) * 2]]; alpha = pixels[(x + y * size_t(width)) * 2 + 1] / float(TMAX); } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { red = green = blue = GetGrayValue(x, y); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { GetGrayAValue(x, y, red, alpha); green = blue = red; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { float alpha; GetGrayAValue(x, y, red, alpha); green = blue = red; transm = 1.0 - alpha; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { float alpha; GetGrayAValue(x, y, red, alpha); @@ -2346,85 +2365,85 @@ class NonlinearGrayAImage : public Image RGBFTColour::AtoFT(alpha, filter, transm); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayAValue(x, y, TMAX, ALPHA_OPAQUE_INT(TMAX)); else SetGrayAValue(x, y, (unsigned int)0, ALPHA_OPAQUE_INT(TMAX)); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetGrayAValue(x, y, gray, ALPHA_OPAQUE); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { SetGrayAValue(x, y, gray, ALPHA_OPAQUE_INT(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 2] = IntEncode(gamma, gray, TMAX); pixels[(x + y * size_t(width)) * 2 + 1] = T(alpha * float(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 2] = gray; pixels[(x + y * size_t(width)) * 2 + 1] = alpha; } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetGrayValue(x, y, RGB2Gray(red, green, blue)); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { // not really pretty here, but we're doing color math, so we need to decode and re-encode SetGrayValue(x, y, RGB2Gray(gammaLUT[red], gammaLUT[green], gammaLUT[blue])); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { SetGrayAValue(x, y, RGB2Gray(red, green, blue), alpha); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { // not really pretty here, but we're doing color math, so we need to decode and re-encode // TODO FIXME - this unnecessarily converts alpha from int to float, requiring it to be converted back to int SetGrayAValue(x, y, RGB2Gray(gammaLUT[red], gammaLUT[green], gammaLUT[blue]), float(alpha) / float(TMAX)); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetGrayAValue(x, y, RGB2Gray(red, green, blue), 1.0 - transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetGrayAValue(x, y, RGB2Gray(col.red(), col.green(), col.blue()), col.alpha()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { SetGrayAValue(x, y, RGB2Gray(red, green, blue), RGBFTColour::FTtoA(filter, transm)); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { SetGrayAValue(x, y, RGB2Gray(col.red(), col.green(), col.blue()), col.FTtoA()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillGrayValue(IntEncode(gamma, gray, TMAX)); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillGrayAValue(gray, ALPHA_OPAQUE_INT(TMAX)); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { // [CLi 2009-09] this was dividing by float(TMAX) - which I presume to have been a bug. T g(IntEncode(gamma, gray, TMAX)), a(IntEncode(alpha, TMAX)); @@ -2435,7 +2454,7 @@ class NonlinearGrayAImage : public Image *i = a; } } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { for(typename vector::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -2444,30 +2463,30 @@ class NonlinearGrayAImage : public Image *i = T(alpha); } } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillGrayValue(RGB2Gray(red, green, blue)); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { // not really pretty here, but we're doing color math, so we need to decode and re-encode FillGrayValue(RGB2Gray(gammaLUT[red], gammaLUT[green], gammaLUT[blue])); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { FillGrayAValue(RGB2Gray(red, green, blue), alpha); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { // not really pretty here, but we're doing color math, so we need to decode and re-encode // TODO FIXME - this unnecessarily converts alpha from int to float, requiring it to be converted back to int FillGrayAValue(RGB2Gray(gammaLUT[red], gammaLUT[green], gammaLUT[blue]), float(alpha) / float(TMAX)); } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { FillGrayAValue(RGB2Gray(red, green, blue), 1.0 - transm); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { FillGrayAValue(RGB2Gray(red, green, blue), RGBFTColour::FTtoA(filter, transm)); } @@ -2477,12 +2496,12 @@ class NonlinearGrayAImage : public Image const float* gammaLUT; }; -typedef NonlinearGrayAImage MemoryNonlinearGrayA8Image; +typedef NonlinearGrayAImage MemoryNonlinearGrayA8Image; -typedef NonlinearGrayAImage MemoryNonlinearGrayA16Image; +typedef NonlinearGrayAImage MemoryNonlinearGrayA16Image; -template > -class NonlinearRGBImage : public Image +template> +class NonlinearRGBImage final : public Image { public: NonlinearRGBImage(unsigned int w, unsigned int h) : @@ -2493,49 +2512,49 @@ class NonlinearRGBImage : public Image Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h, 3u)); FillBitValue(false); } NonlinearRGBImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h, 3u)); FillBitValue(false); } - ~NonlinearRGBImage() { } + virtual ~NonlinearRGBImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return false; } - bool IsColour() const + virtual bool IsColour() const override { return true; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return true; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return false; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) + virtual bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) override { if (max != TMAX) return false; if (!GammaCurve::IsNeutral(gamma)) return !g; @@ -2544,141 +2563,141 @@ class NonlinearRGBImage : public Image return true; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { float red, green, blue; GetRGBValue(x, y, red, green, blue); return IS_NONZERO_RGB(red, green, blue); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue; GetRGBValue(x, y, red, green, blue); return RGB2Gray(red, green, blue); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { gray = GetGrayValue(x, y); alpha = ALPHA_OPAQUE; } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { CHECK_BOUNDS(x, y); red = gammaLUT[pixels[(x + y * size_t(width)) * 3]]; green = gammaLUT[pixels[(x + y * size_t(width)) * 3 + 1]]; blue = gammaLUT[pixels[(x + y * size_t(width)) * 3 + 2]]; } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { GetRGBValue(x, y, red, green, blue); alpha = ALPHA_OPAQUE; } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { GetRGBValue(x, y, red, green, blue); transm = FT_OPAQUE; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { GetRGBValue(x, y, red, green, blue); filter = transm = FT_OPAQUE; } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, TMAX); else SetGrayValue(x, y, (unsigned int)0); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetRGBValue(x, y, gray, gray, gray); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width) * 3] = pixels[x + y * size_t(width) * 3 + 1] = pixels[x + y * size_t(width) * 3 + 2] = gray; } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width) * 3] = pixels[x + y * size_t(width) * 3 + 1] = pixels[x + y * size_t(width) * 3 + 2] = IntEncode(gamma, gray, TMAX); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int) override { CHECK_BOUNDS(x, y); pixels[x + y * size_t(width) * 3] = pixels[x + y * size_t(width) * 3 + 1] = pixels[x + y * size_t(width) * 3 + 2] = gray; } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 3] = IntEncode(gamma, red, TMAX); pixels[(x + y * size_t(width)) * 3 + 1] = IntEncode(gamma, green, TMAX); pixels[(x + y * size_t(width)) * 3 + 2] = IntEncode(gamma, blue, TMAX); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 3] = T(red); pixels[(x + y * size_t(width)) * 3 + 1] = T(green); pixels[(x + y * size_t(width)) * 3 + 2] = T(blue); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float, float) override { SetRGBValue(x, y, red, green, blue); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { SetRGBValue(x, y, col.red(), col.green(), col.blue()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillGrayValue((unsigned int)(IntEncode(gamma, gray, TMAX))); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { fill(pixels.begin(), pixels.end(), gray); } - void FillGrayAValue(float gray, float) + virtual void FillGrayAValue(float gray, float) override { FillRGBValue(gray, gray, gray); } - void FillGrayAValue(unsigned int gray, unsigned int) + virtual void FillGrayAValue(unsigned int gray, unsigned int) override { FillRGBValue(gray, gray, gray); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { // [CLi 2009-09] this was dividing by float(TMAX) - which I presume to have been a bug. T r(IntEncode(gamma, red, TMAX)), g(IntEncode(gamma, green, TMAX)), b(IntEncode(gamma, blue, TMAX)); @@ -2691,7 +2710,7 @@ class NonlinearRGBImage : public Image *i = b; } } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { for(typename vector::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -2702,19 +2721,19 @@ class NonlinearRGBImage : public Image *i = T(blue); } } - void FillRGBAValue(float red, float green, float blue, float) + virtual void FillRGBAValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int) override { FillRGBValue(red, green, blue); } - void FillRGBTValue(float red, float green, float blue, float) + virtual void FillRGBTValue(float red, float green, float blue, float) override { FillRGBValue(red, green, blue); } - void FillRGBFTValue(float red, float green, float blue, float, float) + virtual void FillRGBFTValue(float red, float green, float blue, float, float) override { FillRGBValue(red, green, blue); } @@ -2724,12 +2743,12 @@ class NonlinearRGBImage : public Image const float* gammaLUT; }; -typedef NonlinearRGBImage MemoryNonlinearRGB8Image; +typedef NonlinearRGBImage MemoryNonlinearRGB8Image; -typedef NonlinearRGBImage MemoryNonlinearRGB16Image; +typedef NonlinearRGBImage MemoryNonlinearRGB16Image; -template > -class NonlinearRGBAImage : public Image +template> +class NonlinearRGBAImage final : public Image { public: NonlinearRGBAImage(unsigned int w, unsigned int h) : @@ -2740,9 +2759,9 @@ class NonlinearRGBAImage : public Image Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h, 4u)); FillBitValue(false); } NonlinearRGBAImage(unsigned int w, unsigned int h, const vector& m) : Image(w, h, ImageDataType(IDT), m), gamma(NeutralGammaCurve::Get()) { gammaLUT = gamma->GetLookupTable(TMAX); pixels.resize(SafeUnsignedProduct(w, h, 4u)); FillBitValue(false); } - ~NonlinearRGBAImage() { } + virtual ~NonlinearRGBAImage() override { } - bool IsOpaque() const + virtual bool IsOpaque() const override { for(typename vector::const_iterator i(pixels.begin()); i != pixels.end(); i += 4) { @@ -2752,43 +2771,43 @@ class NonlinearRGBAImage : public Image return true; } - bool IsGrayscale() const + virtual bool IsGrayscale() const override { return false; } - bool IsColour() const + virtual bool IsColour() const override { return true; } - bool IsFloat() const + virtual bool IsFloat() const override { return false; } - bool IsInt() const + virtual bool IsInt() const override { return true; } - bool IsIndexed() const + virtual bool IsIndexed() const override { return false; } - bool IsGammaEncoded() const + virtual bool IsGammaEncoded() const override { return true; } - bool HasAlphaChannel() const + virtual bool HasAlphaChannel() const override { return true; } - bool HasFilterTransmit() const + virtual bool HasFilterTransmit() const override { return false; } - unsigned int GetMaxIntValue() const + virtual unsigned int GetMaxIntValue() const override { return TMAX; } - bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) + virtual bool TryDeferDecoding(GammaCurvePtr& g, unsigned int max) override { if (max != TMAX) return false; if (!GammaCurve::IsNeutral(gamma)) return !g; @@ -2797,31 +2816,31 @@ class NonlinearRGBAImage : public Image return true; } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. float red, green, blue, alpha; GetRGBAValue(x, y, red, green, blue, alpha); return IS_NONZERO_RGB(red, green, blue); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue, alpha; GetRGBAValue(x, y, red, green, blue, alpha); return RGB2Gray(red, green, blue); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { float red, green, blue; GetRGBAValue(x, y, red, green, blue, alpha); gray = RGB2Gray(red, green, blue); } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { float alpha; GetRGBAValue(x, y, red, green, blue, alpha); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { CHECK_BOUNDS(x, y); red = gammaLUT[pixels[(x + y * size_t(width)) * 4]]; @@ -2829,51 +2848,51 @@ class NonlinearRGBAImage : public Image blue = gammaLUT[pixels[(x + y * size_t(width)) * 4 + 2]]; alpha = float(pixels[(x + y * size_t(width)) * 4 + 3]) / float(TMAX); } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { float alpha; GetRGBAValue(x, y, red, green, blue, alpha); transm = 1.0 - alpha; } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { float alpha; GetRGBAValue(x, y, red, green, blue, alpha); RGBFTColour::AtoFT(alpha, filter, transm); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, TMAX); else SetGrayValue(x, y, (unsigned int)0); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetRGBAValue(x, y, gray, gray, gray, ALPHA_OPAQUE); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { SetRGBAValue(x, y, gray, gray, gray, ALPHA_OPAQUE_INT(TMAX)); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { SetRGBAValue(x, y, gray, gray, gray, alpha); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { SetRGBAValue(x, y, gray, gray, gray, alpha); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetRGBAValue(x, y, red, green, blue, ALPHA_OPAQUE); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetRGBAValue(x, y, red, green, blue, ALPHA_OPAQUE_INT(TMAX)); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(IntEncode(gamma, red, TMAX)); @@ -2881,7 +2900,7 @@ class NonlinearRGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 2] = T(IntEncode(gamma, blue, TMAX)); pixels[(x + y * size_t(width)) * 4 + 3] = T(IntEncode( alpha, TMAX)); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(red); @@ -2889,11 +2908,11 @@ class NonlinearRGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 2] = T(blue); pixels[(x + y * size_t(width)) * 4 + 3] = T(alpha); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBAValue(x, y, red, green, blue, 1.0 - transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(col.red()); @@ -2901,11 +2920,11 @@ class NonlinearRGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 2] = T(col.blue()); pixels[(x + y * size_t(width)) * 4 + 3] = T(col.alpha()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { SetRGBAValue(x, y, red, green, blue, RGBFTColour::FTtoA(filter, transm)); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { CHECK_BOUNDS(x, y); pixels[(x + y * size_t(width)) * 4] = T(col.red()); @@ -2914,38 +2933,38 @@ class NonlinearRGBAImage : public Image pixels[(x + y * size_t(width)) * 4 + 3] = T(col.FTtoA()); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(TMAX); else FillGrayValue((unsigned int)0); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillRGBAValue(gray, gray, gray, ALPHA_OPAQUE); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillRGBAValue(gray, gray, gray, ALPHA_OPAQUE_INT(TMAX)); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { FillRGBAValue(gray, gray, gray, alpha); } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { FillRGBAValue(gray, gray, gray, alpha); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillRGBAValue(red, green, blue, ALPHA_OPAQUE); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillRGBAValue(red, green, blue, ALPHA_OPAQUE_INT(TMAX)); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { // [CLi 2009-09] this was dividing by float(TMAX) - which I presume to have been a bug. T r(IntEncode(gamma, red, TMAX)), g(IntEncode(gamma, green, TMAX)), b(IntEncode(gamma, blue, TMAX)), a(IntEncode(alpha, TMAX)); @@ -2960,7 +2979,7 @@ class NonlinearRGBAImage : public Image *i = a; } } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { for(typename vector::iterator i(pixels.begin()); i != pixels.end(); i++) { @@ -2973,11 +2992,11 @@ class NonlinearRGBAImage : public Image *i = T(alpha); } } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { FillRGBAValue(red, green, blue, 1.0 - transm); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { FillRGBAValue(red, green, blue, RGBFTColour::FTtoA(filter, transm)); } @@ -2987,9 +3006,9 @@ class NonlinearRGBAImage : public Image const float* gammaLUT; }; -typedef NonlinearRGBAImage MemoryNonlinearRGBA8Image; +typedef NonlinearRGBAImage MemoryNonlinearRGBA8Image; -typedef NonlinearRGBAImage MemoryNonlinearRGBA16Image; +typedef NonlinearRGBAImage MemoryNonlinearRGBA16Image; // sample basic file-based pixel container. not very efficient. // it is expected that for performance reasons, platforms will provide their own specific @@ -3014,7 +3033,7 @@ class FileBackedPixelContainer FILTER = 3, TRANSM = 4 }; - class pixel_type + class pixel_type final { public: pixel_type() @@ -3064,43 +3083,40 @@ class FileBackedPixelContainer }; FileBackedPixelContainer(size_type width, size_type height, size_type bs): - m_File(-1), m_Width(width), m_Height(height), m_xPos(0), m_yPos(0), m_Dirty(false), m_Path(PlatformBase::GetInstance().CreateTemporaryFile()) + m_Width(width), m_Height(height), m_xPos(0), m_yPos(0), m_Dirty(false), m_Path(PlatformBase::GetInstance().CreateTemporaryFile()) { - if ((m_File = open(UCS2toSysString(m_Path).c_str(), O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) == -1) + if (!m_File.CreateRW(m_Path)) throw POV_EXCEPTION(kCannotOpenFileErr, "Cannot open backing file for intermediate image storage."); m_Blocksize = bs; m_Buffer.resize(m_Blocksize); // write extra data to create the big file and help 3rd party reader - POV_OFF_T pos; + std::int_least64_t pos; // NB: The following use of SafeUnsignedProduct also safeguards later computations of // pixel positions within the file, as long as x and y coordinates are sane - pos = SafeUnsignedProduct(m_Width, m_Height); + pos = SafeUnsignedProduct(m_Width, m_Height); if ( pos% m_Blocksize) { /* issue: the block would overlap the end of file */ pos /= m_Blocksize; pos++; - pos = SafeUnsignedProduct(pos, m_Blocksize); + pos = SafeUnsignedProduct(pos, m_Blocksize); } /* else fine case: the boundary of block match the boundary of pixels in file */ - pos = SafeUnsignedProduct(pos, sizeof(pixel_type)); + pos = SafeUnsignedProduct(pos, sizeof(pixel_type)); size_type meta[3]; meta[0] = sizeof(pixel_type); meta[1] = m_Width; meta[2] = m_Height; - if (POV_LSEEK(m_File, pos, SEEK_SET) != pos) + if (!m_File.Seek(pos)) throw POV_EXCEPTION(kFileDataErr, "Intermediate image storage backing file write/seek failed at creation."); - if (write(m_File, &meta[0], (int) sizeof(size_type)*3) != (sizeof(size_type)*3)) + if (!m_File.Write(meta, sizeof(size_type)*3)) throw POV_EXCEPTION(kFileDataErr, "Intermediate image storage backing file write failed at creation."); // m_Committed.resize(width * height / m_Blocksize); } virtual ~FileBackedPixelContainer() { - if (m_File != -1) - { - Flush(); - close(m_File); - } + Flush(); + m_File.Close(); if (m_Path.empty() == false) { // if shutdown has been delayed, by the time we reach here, the platform base @@ -3205,10 +3221,10 @@ class FileBackedPixelContainer } protected: - int m_File; + Filesystem::LargeFile m_File; bool m_Dirty; size_type m_Blocksize; - POV_OFF_T m_CurrentBlock; + std::int_least64_t m_CurrentBlock; size_type m_Width; size_type m_Height; size_type m_xPos; @@ -3243,7 +3259,7 @@ class FileBackedPixelContainer void ReadPixel(size_type x, size_type y, pixel_type& pixel) { - POV_OFF_T pos, block = (y * (POV_OFF_T)(m_Width) + x) / m_Blocksize; + std::int_least64_t pos, block = (y * (std::int_least64_t)(m_Width) + x) / m_Blocksize; if (block != m_CurrentBlock) { WriteCurrentBlock(); @@ -3258,33 +3274,33 @@ class FileBackedPixelContainer #endif pos = block * sizeof(pixel_type) * m_Blocksize; int chunk = sizeof(pixel_type) * m_Blocksize; - if (POV_LSEEK(m_File, pos, SEEK_SET) != pos) + if (!m_File.Seek(pos)) throw POV_EXCEPTION(kFileDataErr, "Intermediate image storage backing file read/seek failed."); - int bytes = read(m_File, &m_Buffer[0], chunk); + int bytes = m_File.Read(m_Buffer.data(), chunk); if (bytes != (sizeof(pixel_type) * m_Blocksize)) throw POV_EXCEPTION(kFileDataErr, "Intermediate image storage backing file read failed."); m_CurrentBlock = block; } POV_IMAGE_ASSERT (m_Blocksize != 0); - memcpy(&pixel, m_Buffer[(y * (POV_OFF_T)(m_Width) + x) % m_Blocksize], sizeof(pixel)); + memcpy(&pixel, m_Buffer[(y * (std::int_least64_t)(m_Width) + x) % m_Blocksize], sizeof(pixel)); } #if 0 bool BlockCommitted(size_type x, size_type y) { - POV_OFF_T block = (y * POV_OFF_T(m_Width) + x) / m_Blocksize; + std::int_least64_t block = (y * std::int_least64_t(m_Width) + x) / m_Blocksize; return(m_Committed[block]); } #endif void WriteCurrentBlock() { - POV_OFF_T pos; + std::int_least64_t pos; if (m_Dirty) { pos = m_CurrentBlock * sizeof(pixel_type) * m_Blocksize; - if (POV_LSEEK(m_File, pos, SEEK_SET) != pos) + if (!m_File.Seek(pos)) throw POV_EXCEPTION(kFileDataErr, "Intermediate image storage backing file write/seek failed."); - if (write(m_File, &m_Buffer[0], (int) sizeof(pixel_type) * m_Blocksize) != (sizeof(pixel_type) * m_Blocksize)) + if (!m_File.Write(m_Buffer.data(), sizeof(pixel_type) * m_Blocksize)) throw POV_EXCEPTION(kFileDataErr, "Intermediate image storage backing file write failed."); // m_Committed[m_CurrentBlock] = true; m_Dirty = false; @@ -3296,101 +3312,101 @@ class FileBackedPixelContainer pixel_type dummy; ReadPixel(x, y, dummy); - memcpy(m_Buffer[(y * (POV_OFF_T)(m_Width) + x) % m_Blocksize], &pixel, sizeof(pixel)); + memcpy(m_Buffer[(y * (std::int_least64_t)(m_Width) + x) % m_Blocksize], &pixel, sizeof(pixel)); m_Dirty = true; } private: - // not available - FileBackedPixelContainer(void) {} + + FileBackedPixelContainer() = delete; }; -class FileRGBFTImage : public Image +class FileRGBFTImage final : public Image { public: typedef FileBackedPixelContainer::pixel_type pixel_type; - FileRGBFTImage(unsigned int w, unsigned int h, unsigned int bs): Image(w, h, RGBFT_Float), pixels(width, height, bs) { } - ~FileRGBFTImage() { } - - bool IsGrayscale() const { return false; } - bool IsColour() const { return true; } - bool IsFloat() const { return true; } - bool IsInt() const { return false; } - bool IsIndexed() const { return false; } - bool IsGammaEncoded() const { return false; } - bool HasAlphaChannel() const { return false; } - bool HasFilterTransmit() const { return true; } - unsigned int GetMaxIntValue() const { return 255; } + FileRGBFTImage(unsigned int w, unsigned int h, unsigned int bs): Image(w, h, ImageDataType::RGBFT_Float), pixels(width, height, bs) { } + virtual ~FileRGBFTImage() override { } + + virtual bool IsGrayscale() const override { return false; } + virtual bool IsColour() const override { return true; } + virtual bool IsFloat() const override { return true; } + virtual bool IsInt() const override { return false; } + virtual bool IsIndexed() const override { return false; } + virtual bool IsGammaEncoded() const override { return false; } + virtual bool HasAlphaChannel() const override { return false; } + virtual bool HasFilterTransmit() const override { return true; } + virtual unsigned int GetMaxIntValue() const override { return 255; } void SetEncodingGamma(GammaCurvePtr gamma) { ; } - bool TryDeferDecoding(GammaCurvePtr&, unsigned int) { return false; } - bool IsOpaque() const { throw POV_EXCEPTION(kUncategorizedError, "Internal error: IsOpaque() not supported in FileRGBFTImage"); } - bool GetBitValue(unsigned int x, unsigned int y) const + virtual bool TryDeferDecoding(GammaCurvePtr&, unsigned int) override { return false; } + virtual bool IsOpaque() const override { throw POV_EXCEPTION(kUncategorizedError, "Internal error: IsOpaque() not supported in FileRGBFTImage"); } + virtual bool GetBitValue(unsigned int x, unsigned int y) const override { // TODO FIXME - [CLi] This ignores opacity information; other bit-based code doesn't. float red, green, blue, filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); return IS_NONZERO_RGB(red, green, blue); } - float GetGrayValue(unsigned int x, unsigned int y) const + virtual float GetGrayValue(unsigned int x, unsigned int y) const override { float red, green, blue, filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); return RGB2Gray(red, green, blue); } - void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const + virtual void GetGrayAValue(unsigned int x, unsigned int y, float& gray, float& alpha) const override { float red, green, blue, filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); gray = RGB2Gray(red, green, blue); alpha = RGBFTColour::FTtoA(filter, transm); } - void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const + virtual void GetRGBValue(unsigned int x, unsigned int y, float& red, float& green, float& blue) const override { float filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); } - void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const + virtual void GetRGBAValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& alpha) const override { float filter, transm; GetRGBFTValue(x, y, red, green, blue, filter, transm); alpha = RGBFTColour::FTtoA(filter, transm); } - void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const + virtual void GetRGBTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& transm) const override { float filter; GetRGBFTValue(x, y, red, green, blue, filter, transm); transm = 1.0 - RGBFTColour::FTtoA(filter, transm); } - void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const + virtual void GetRGBFTValue(unsigned int x, unsigned int y, float& red, float& green, float& blue, float& filter, float& transm) const override { CHECK_BOUNDS(x, y); pixels.GetPixel(x, y, red, green, blue, filter, transm); } - void SetBitValue(unsigned int x, unsigned int y, bool bit) + virtual void SetBitValue(unsigned int x, unsigned int y, bool bit) override { if(bit == true) SetGrayValue(x, y, 1.0f); else SetGrayValue(x, y, 0.0f); } - void SetGrayValue(unsigned int x, unsigned int y, float gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, float gray) override { SetRGBFTValue(x, y, gray, gray, gray, FT_OPAQUE, FT_OPAQUE); } - void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) + virtual void SetGrayValue(unsigned int x, unsigned int y, unsigned int gray) override { SetGrayValue(x, y, float(gray) / 255.0f); } - void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, float gray, float alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); SetRGBFTValue(x, y, gray, gray, gray, filter, transm); } - void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) + virtual void SetGrayAValue(unsigned int x, unsigned int y, unsigned int gray, unsigned int alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float c = float(gray) / 255.0f; @@ -3398,101 +3414,101 @@ class FileRGBFTImage : public Image RGBFTColour::AtoFT(float(alpha) / 255.0f, filter, transm); SetRGBFTValue(x, y, c, c, c, filter, transm); } - void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, float red, float green, float blue) override { SetRGBFTValue(x, y, red, green, blue, FT_OPAQUE, FT_OPAQUE); } - void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) + virtual void SetRGBValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue) override { SetRGBFTValue(x, y, float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, FT_OPAQUE, FT_OPAQUE); } - void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, float red, float green, float blue, float alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); SetRGBFTValue(x, y, red, green, blue, filter, transm); } - void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void SetRGBAValue(unsigned int x, unsigned int y, unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float filter, transm; RGBFTColour::AtoFT(float(alpha) / 255.0f, filter, transm); SetRGBFTValue(x, y, float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, filter, transm); } - void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) + virtual void SetRGBTValue(unsigned int x, unsigned int y, float red, float green, float blue, float transm) override { SetRGBFTValue(x, y, red, green, blue, FT_OPAQUE, transm); } - void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) + virtual void SetRGBTValue(unsigned int x, unsigned int y, const RGBTColour& col) override { SetRGBFTValue(x, y, col.red(), col.green(), col.blue(), FT_OPAQUE, col.transm()); } - void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, float red, float green, float blue, float filter, float transm) override { CHECK_BOUNDS(x, y); pixels.SetPixel(x, y, red, green, blue, filter, transm); } - void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) + virtual void SetRGBFTValue(unsigned int x, unsigned int y, const RGBFTColour& col) override { CHECK_BOUNDS(x, y); pixels.SetPixel(x, y, col); } - void FillBitValue(bool bit) + virtual void FillBitValue(bool bit) override { if(bit == true) FillGrayValue(1.0f); else FillGrayValue(0.0f); } - void FillGrayValue(float gray) + virtual void FillGrayValue(float gray) override { FillRGBFTValue(gray, gray, gray, FT_OPAQUE, FT_OPAQUE); } - void FillGrayValue(unsigned int gray) + virtual void FillGrayValue(unsigned int gray) override { FillGrayValue(float(gray) / 255.0f); } - void FillGrayAValue(float gray, float alpha) + virtual void FillGrayAValue(float gray, float alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); FillRGBFTValue(gray, gray, gray, filter, transm); } - void FillGrayAValue(unsigned int gray, unsigned int alpha) + virtual void FillGrayAValue(unsigned int gray, unsigned int alpha) override { // TODO - should alpha be converted to filter and transm? [trf] FillGrayAValue(float(gray) / 255.0f, float(alpha) / 255.0f); } - void FillRGBValue(float red, float green, float blue) + virtual void FillRGBValue(float red, float green, float blue) override { FillRGBFTValue(red, green, blue, FT_OPAQUE, FT_OPAQUE); } - void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) + virtual void FillRGBValue(unsigned int red, unsigned int green, unsigned int blue) override { FillRGBFTValue(float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, FT_OPAQUE, FT_OPAQUE); } - void FillRGBAValue(float red, float green, float blue, float alpha) + virtual void FillRGBAValue(float red, float green, float blue, float alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float filter, transm; RGBFTColour::AtoFT(alpha, filter, transm); FillRGBFTValue(red, green, blue, filter, transm); } - void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) + virtual void FillRGBAValue(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) override { // TODO - should alpha be converted to filter and transm? [trf] float filter, transm; RGBFTColour::AtoFT(float(alpha) / 255.0f, filter, transm); FillRGBFTValue(float(red) / 255.0f, float(green) / 255.0f, float(blue) / 255.0f, filter, transm); } - void FillRGBTValue(float red, float green, float blue, float transm) + virtual void FillRGBTValue(float red, float green, float blue, float transm) override { FillRGBFTValue(red, green, blue, FT_OPAQUE, transm); } - void FillRGBFTValue(float red, float green, float blue, float filter, float transm) + virtual void FillRGBFTValue(float red, float green, float blue, float filter, float transm) override { pixels.Fill(red, green, blue, filter, transm); } @@ -3566,68 +3582,40 @@ void RGBFTMap2RGBAMap(const vector& m, vectorred, i->green, i->blue, RGBFTColour::FTtoA(i->filter, i->transm))); } -Image::ImageDataType Image::GetImageDataType (ImageChannelDataType channelType, ImageChannelLayout layout) +ImageDataType Image::GetImageDataType (int minBitsPerChannel, int colourChannels, int alphaChannels, bool linear) { - switch (layout) + struct { ImageDataType type; int bpc; int cc; int ac; bool lin; } kaImageDataModels[] = { + // Note: Entries differing only in bpc must be ordered low-bpc first! + { ImageDataType::Gray_Gamma8, 8, 1, 0, false }, + { ImageDataType::Gray_Gamma16, 16, 1, 0, false }, + { ImageDataType::Gray_Int8, 8, 1, 0, true }, + { ImageDataType::Gray_Int16, 16, 1, 0, true }, + { ImageDataType::GrayA_Gamma8, 8, 1, 1, false }, + { ImageDataType::GrayA_Gamma16, 16, 1, 1, false }, + { ImageDataType::GrayA_Int8, 8, 1, 1, true }, + { ImageDataType::GrayA_Int16, 16, 1, 1, true }, + { ImageDataType::RGB_Gamma8, 8, 3, 0, false }, + { ImageDataType::RGB_Gamma16, 16, 3, 0, false }, + { ImageDataType::RGB_Int8, 8, 3, 0, true }, + { ImageDataType::RGB_Int16, 16, 3, 0, true }, + { ImageDataType::RGBA_Gamma8, 8, 3, 1, false }, + { ImageDataType::RGBA_Gamma16, 16, 3, 1, false }, + { ImageDataType::RGBA_Int8, 8, 3, 1, true }, + { ImageDataType::RGBA_Int16, 16, 3, 1, true }, + }; + for (auto& model : kaImageDataModels) { - case kImageChannelLayout_Gray: - switch (channelType) - { - case kImageChannelDataType_Int8: return Image::Gray_Int8; - case kImageChannelDataType_Int16: return Image::Gray_Int16; - case kImageChannelDataType_Gamma8: return Image::Gray_Gamma8; - case kImageChannelDataType_Gamma16: return Image::Gray_Gamma16; - default: - POV_IMAGE_ASSERT(false); - break; - } - break; - - case kImageChannelLayout_GrayA: - switch (channelType) - { - case kImageChannelDataType_Int8: return Image::GrayA_Int8; - case kImageChannelDataType_Int16: return Image::GrayA_Int16; - case kImageChannelDataType_Gamma8: return Image::GrayA_Gamma8; - case kImageChannelDataType_Gamma16: return Image::GrayA_Gamma16; - default: - POV_IMAGE_ASSERT(false); - break; - } - break; - - case kImageChannelLayout_RGB: - switch (channelType) - { - case kImageChannelDataType_Int8: return Image::RGB_Int8; - case kImageChannelDataType_Int16: return Image::RGB_Int16; - case kImageChannelDataType_Gamma8: return Image::RGB_Gamma8; - case kImageChannelDataType_Gamma16: return Image::RGB_Gamma16; - default: - POV_IMAGE_ASSERT(false); - break; - } - break; - - case kImageChannelLayout_RGBA: - switch (channelType) - { - case kImageChannelDataType_Int8: return Image::RGBA_Int8; - case kImageChannelDataType_Int16: return Image::RGBA_Int16; - case kImageChannelDataType_Gamma8: return Image::RGBA_Gamma8; - case kImageChannelDataType_Gamma16: return Image::RGBA_Gamma16; - default: - POV_IMAGE_ASSERT(false); - break; - } - break; - - default: - POV_IMAGE_ASSERT(false); - break; + if ((model.bpc >= minBitsPerChannel) && (model.cc == colourChannels) && + (model.ac == alphaChannels) && (model.lin == linear)) + return model.type; } + POV_IMAGE_ASSERT(false); + return ImageDataType::Undefined; +} - return Image::Undefined; +ImageDataType Image::GetImageDataType(int bitsPerChannel, int colourChannels, bool alpha, GammaCurvePtr gamma) +{ + return GetImageDataType(bitsPerChannel, colourChannels, (alpha ? 1 : 0), GammaCurve::IsNeutral(gamma)); } Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, unsigned int maxRAMmbHint, unsigned int pixelsPerBlockHint) @@ -3636,44 +3624,44 @@ Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, unsigned i { switch(t) { - case Bit_Map: + case ImageDataType::Bit_Map: return new MemoryBitMapImage(w, h); - case Gray_Int8: + case ImageDataType::Gray_Int8: return new MemoryGray8Image(w, h); - case Gray_Int16: + case ImageDataType::Gray_Int16: return new MemoryGray16Image(w, h); - case GrayA_Int8: + case ImageDataType::GrayA_Int8: return new MemoryGrayA8Image(w, h); - case GrayA_Int16: + case ImageDataType::GrayA_Int16: return new MemoryGrayA16Image(w, h); - case RGB_Int8: + case ImageDataType::RGB_Int8: return new MemoryRGB8Image(w, h); - case RGB_Int16: + case ImageDataType::RGB_Int16: return new MemoryRGB16Image(w, h); - case RGBA_Int8: + case ImageDataType::RGBA_Int8: return new MemoryRGBA8Image (w, h); - case RGBA_Int16: + case ImageDataType::RGBA_Int16: return new MemoryRGBA16Image(w, h); - case RGBFT_Float: + case ImageDataType::RGBFT_Float: if (maxRAMmbHint > 0) if (SafeUnsignedProduct(w, h, sizeof(FileRGBFTImage::pixel_type)) / 1048576 > maxRAMmbHint) return new FileRGBFTImage(w, h, pixelsPerBlockHint); return new MemoryRGBFTImage(w, h); - case RGB_Gamma8: + case ImageDataType::RGB_Gamma8: return new MemoryNonlinearRGB8Image(w, h); - case RGB_Gamma16: + case ImageDataType::RGB_Gamma16: return new MemoryNonlinearRGB16Image(w, h); - case RGBA_Gamma8: + case ImageDataType::RGBA_Gamma8: return new MemoryNonlinearRGBA8Image (w, h); - case RGBA_Gamma16: + case ImageDataType::RGBA_Gamma16: return new MemoryNonlinearRGBA16Image(w, h); - case Gray_Gamma8: + case ImageDataType::Gray_Gamma8: return new MemoryNonlinearGray8Image(w, h); - case Gray_Gamma16: + case ImageDataType::Gray_Gamma16: return new MemoryNonlinearGray16Image(w, h); - case GrayA_Gamma8: + case ImageDataType::GrayA_Gamma8: return new MemoryNonlinearGrayA8Image(w, h); - case GrayA_Gamma16: + case ImageDataType::GrayA_Gamma16: return new MemoryNonlinearGrayA16Image(w, h); default: throw POV_EXCEPTION_STRING("Undefined image format in Image::Create"); @@ -3691,45 +3679,45 @@ Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, bool allow { switch(t) { - case Bit_Map: + case ImageDataType::Bit_Map: return new MemoryBitMapImage(w, h); - case Gray_Int8: + case ImageDataType::Gray_Int8: return new MemoryGray8Image(w, h); - case Gray_Int16: + case ImageDataType::Gray_Int16: return new MemoryGray16Image(w, h); - case GrayA_Int8: + case ImageDataType::GrayA_Int8: return new MemoryGrayA8Image(w, h); - case GrayA_Int16: + case ImageDataType::GrayA_Int16: return new MemoryGrayA16Image(w, h); - case RGB_Int8: + case ImageDataType::RGB_Int8: return new MemoryRGB8Image(w, h); - case RGB_Int16: + case ImageDataType::RGB_Int16: return new MemoryRGB16Image(w, h); - case RGBA_Int8: + case ImageDataType::RGBA_Int8: return new MemoryRGBA8Image (w, h); - case RGBA_Int16: + case ImageDataType::RGBA_Int16: return new MemoryRGBA16Image(w, h); - case RGBFT_Float: + case ImageDataType::RGBFT_Float: #ifdef FILE_MAPPED_IMAGE_ALLOCATOR if (allowFileBacking) - return new RGBFTImage >(w, h); + return new RGBFTImage>(w, h); #endif return new MemoryRGBFTImage(w, h); - case RGB_Gamma8: + case ImageDataType::RGB_Gamma8: return new MemoryNonlinearRGB8Image(w, h); - case RGB_Gamma16: + case ImageDataType::RGB_Gamma16: return new MemoryNonlinearRGB16Image(w, h); - case RGBA_Gamma8: + case ImageDataType::RGBA_Gamma8: return new MemoryNonlinearRGBA8Image (w, h); - case RGBA_Gamma16: + case ImageDataType::RGBA_Gamma16: return new MemoryNonlinearRGBA16Image(w, h); - case Gray_Gamma8: + case ImageDataType::Gray_Gamma8: return new MemoryNonlinearGray8Image(w, h); - case Gray_Gamma16: + case ImageDataType::Gray_Gamma16: return new MemoryNonlinearGray16Image(w, h); - case GrayA_Gamma8: + case ImageDataType::GrayA_Gamma8: return new MemoryNonlinearGrayA8Image(w, h); - case GrayA_Gamma16: + case ImageDataType::GrayA_Gamma16: return new MemoryNonlinearGrayA16Image(w, h); default: throw POV_EXCEPTION_STRING("Undefined image format in Image::Create"); @@ -3747,47 +3735,47 @@ Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, const vect { switch(t) { - case Bit_Map: + case ImageDataType::Bit_Map: return new MemoryBitMapImage(w, h, m); - case Colour_Map: + case ImageDataType::Colour_Map: return new MemoryColourMapImage(w, h, m); - case Gray_Int8: + case ImageDataType::Gray_Int8: return new MemoryGray8Image(w, h, m); - case Gray_Int16: + case ImageDataType::Gray_Int16: return new MemoryGray16Image(w, h, m); - case GrayA_Int8: + case ImageDataType::GrayA_Int8: return new MemoryGrayA8Image(w, h, m); - case GrayA_Int16: + case ImageDataType::GrayA_Int16: return new MemoryGrayA16Image(w, h, m); - case RGB_Int8: + case ImageDataType::RGB_Int8: return new MemoryRGB8Image(w, h, m); - case RGB_Int16: + case ImageDataType::RGB_Int16: return new MemoryRGB16Image(w, h, m); - case RGBA_Int8: + case ImageDataType::RGBA_Int8: return new MemoryRGBA8Image (w, h, m); - case RGBA_Int16: + case ImageDataType::RGBA_Int16: return new MemoryRGBA16Image(w, h, m); - case RGBFT_Float: + case ImageDataType::RGBFT_Float: #ifdef FILE_MAPPED_IMAGE_ALLOCATOR if (allowFileBacking) - return new RGBFTImage >(w, h, m); + return new RGBFTImage>(w, h, m); #endif return new MemoryRGBFTImage(w, h, m); - case RGB_Gamma8: + case ImageDataType::RGB_Gamma8: return new MemoryNonlinearRGB8Image(w, h, m); - case RGB_Gamma16: + case ImageDataType::RGB_Gamma16: return new MemoryNonlinearRGB16Image(w, h, m); - case RGBA_Gamma8: + case ImageDataType::RGBA_Gamma8: return new MemoryNonlinearRGBA8Image (w, h, m); - case RGBA_Gamma16: + case ImageDataType::RGBA_Gamma16: return new MemoryNonlinearRGBA16Image(w, h, m); - case Gray_Gamma8: + case ImageDataType::Gray_Gamma8: return new MemoryNonlinearGray8Image(w, h, m); - case Gray_Gamma16: + case ImageDataType::Gray_Gamma16: return new MemoryNonlinearGray16Image(w, h, m); - case GrayA_Gamma8: + case ImageDataType::GrayA_Gamma8: return new MemoryNonlinearGrayA8Image(w, h, m); - case GrayA_Gamma16: + case ImageDataType::GrayA_Gamma16: return new MemoryNonlinearGrayA16Image(w, h, m); default: throw POV_EXCEPTION_STRING("Image::Create Exception TODO"); // TODO FIXME WIP @@ -3805,47 +3793,47 @@ Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, const vect { switch(t) { - case Bit_Map: + case ImageDataType::Bit_Map: return new MemoryBitMapImage(w, h, m); - case Colour_Map: + case ImageDataType::Colour_Map: return new MemoryColourMapImage(w, h, m); - case Gray_Int8: + case ImageDataType::Gray_Int8: return new MemoryGray8Image(w, h, m); - case Gray_Int16: + case ImageDataType::Gray_Int16: return new MemoryGray16Image(w, h, m); - case GrayA_Int8: + case ImageDataType::GrayA_Int8: return new MemoryGrayA8Image(w, h, m); - case GrayA_Int16: + case ImageDataType::GrayA_Int16: return new MemoryGrayA16Image(w, h, m); - case RGB_Int8: + case ImageDataType::RGB_Int8: return new MemoryRGB8Image(w, h, m); - case RGB_Int16: + case ImageDataType::RGB_Int16: return new MemoryRGB16Image(w, h, m); - case RGBA_Int8: + case ImageDataType::RGBA_Int8: return new MemoryRGBA8Image (w, h, m); - case RGBA_Int16: + case ImageDataType::RGBA_Int16: return new MemoryRGBA16Image(w, h, m); - case RGBFT_Float: -#ifdef FILE_MAPPED_RGBFT_IMAGE_ALLOCATOR + case ImageDataType::RGBFT_Float: +#ifdef FILE_MAPPED_IMAGE_ALLOCATOR if (allowFileBacking) - return new RGBFTImage >(w, h, m); + return new RGBFTImage>(w, h, m); #endif return new MemoryRGBFTImage(w, h, m); - case RGB_Gamma8: + case ImageDataType::RGB_Gamma8: return new MemoryNonlinearRGB8Image(w, h, m); - case RGB_Gamma16: + case ImageDataType::RGB_Gamma16: return new MemoryNonlinearRGB16Image(w, h, m); - case RGBA_Gamma8: + case ImageDataType::RGBA_Gamma8: return new MemoryNonlinearRGBA8Image (w, h, m); - case RGBA_Gamma16: + case ImageDataType::RGBA_Gamma16: return new MemoryNonlinearRGBA16Image(w, h, m); - case Gray_Gamma8: + case ImageDataType::Gray_Gamma8: return new MemoryNonlinearGray8Image(w, h, m); - case Gray_Gamma16: + case ImageDataType::Gray_Gamma16: return new MemoryNonlinearGray16Image(w, h, m); - case GrayA_Gamma8: + case ImageDataType::GrayA_Gamma8: return new MemoryNonlinearGrayA8Image(w, h, m); - case GrayA_Gamma16: + case ImageDataType::GrayA_Gamma16: return new MemoryNonlinearGrayA16Image(w, h, m); default: throw POV_EXCEPTION_STRING("Image::Create Exception TODO"); // TODO FIXME WIP @@ -3863,47 +3851,47 @@ Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, const vect { switch(t) { - case Bit_Map: + case ImageDataType::Bit_Map: return new MemoryBitMapImage(w, h, m); - case Colour_Map: + case ImageDataType::Colour_Map: return new MemoryColourMapImage(w, h, m); - case Gray_Int8: + case ImageDataType::Gray_Int8: return new MemoryGray8Image(w, h, m); - case Gray_Int16: + case ImageDataType::Gray_Int16: return new MemoryGray16Image(w, h, m); - case GrayA_Int8: + case ImageDataType::GrayA_Int8: return new MemoryGrayA8Image(w, h, m); - case GrayA_Int16: + case ImageDataType::GrayA_Int16: return new MemoryGrayA16Image(w, h, m); - case RGB_Int8: + case ImageDataType::RGB_Int8: return new MemoryRGB8Image(w, h, m); - case RGB_Int16: + case ImageDataType::RGB_Int16: return new MemoryRGB16Image(w, h, m); - case RGBA_Int8: + case ImageDataType::RGBA_Int8: return new MemoryRGBA8Image (w, h, m); - case RGBA_Int16: + case ImageDataType::RGBA_Int16: return new MemoryRGBA16Image(w, h, m); - case RGBFT_Float: + case ImageDataType::RGBFT_Float: #ifdef FILE_MAPPED_IMAGE_ALLOCATOR if (allowFileBacking) - return new RGBFTImage >(w, h, m); + return new RGBFTImage>(w, h, m); #endif return new MemoryRGBFTImage(w, h, m); - case RGB_Gamma8: + case ImageDataType::RGB_Gamma8: return new MemoryNonlinearRGB8Image(w, h, m); - case RGB_Gamma16: + case ImageDataType::RGB_Gamma16: return new MemoryNonlinearRGB16Image(w, h, m); - case RGBA_Gamma8: + case ImageDataType::RGBA_Gamma8: return new MemoryNonlinearRGBA8Image (w, h, m); - case RGBA_Gamma16: + case ImageDataType::RGBA_Gamma16: return new MemoryNonlinearRGBA16Image(w, h, m); - case Gray_Gamma8: + case ImageDataType::Gray_Gamma8: return new MemoryNonlinearGray8Image(w, h, m); - case Gray_Gamma16: + case ImageDataType::Gray_Gamma16: return new MemoryNonlinearGray16Image(w, h, m); - case GrayA_Gamma8: + case ImageDataType::GrayA_Gamma8: return new MemoryNonlinearGrayA8Image(w, h, m); - case GrayA_Gamma16: + case ImageDataType::GrayA_Gamma16: return new MemoryNonlinearGrayA16Image(w, h, m); default: throw POV_EXCEPTION_STRING("Image::Create Exception TODO"); // TODO FIXME WIP @@ -3915,7 +3903,7 @@ Image *Image::Create(unsigned int w, unsigned int h, ImageDataType t, const vect } } -Image *Image::Read(ImageFileType type, IStream *file, const ReadOptions& options) +Image *Image::Read(ImageFileType type, IStream *file, const ImageReadOptions& options) { #ifdef POV_SYS_IMAGE_TYPE if (type == SYS) @@ -4010,7 +3998,7 @@ following built-in formats: GIF, TGA, IFF, PGM, PPM, BMP."); } } -void Image::Write(ImageFileType type, OStream *file, const Image *image, const WriteOptions& options) +void Image::Write(ImageFileType type, OStream *file, const Image *image, const ImageWriteOptions& options) { if (image->GetWidth() == 0 || image->GetHeight() == 0) throw POV_EXCEPTION(kParamErr, "Invalid image size for output"); @@ -4425,3 +4413,4 @@ void Image::SetColourMap(const vector& m) } } +// end of namespace pov_base diff --git a/source/base/image/image.h b/source/base/image/image.h index 68b3d7cae..cee4f1be1 100644 --- a/source/base/image/image.h +++ b/source/base/image/image.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 @@ -38,19 +38,26 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/image/image_fwd.h" -// POV-Ray base header files -#include "base/fileinputoutput.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include +#include + +// POV-Ray header files (base module) +#include "base/colour.h" +#include "base/fileinputoutput_fwd.h" #include "base/pov_err.h" -#include "base/image/colourspace.h" -#include "base/image/encoding.h" +#include "base/image/colourspace_fwd.h" +#include "base/image/dither_fwd.h" namespace pov_base { -class DitherStrategy; -using DitherStrategySPtr = shared_ptr; - //############################################################################## /// /// @defgroup PovBaseImage Image Handling @@ -58,6 +65,147 @@ using DitherStrategySPtr = shared_ptr; /// /// @{ +enum class ImageDataType : int +{ + Undefined, ///< Special value indicating that image decoder is free to pick most fitting type. + Bit_Map, ///< Palette-based image with 2 palette entries. + Colour_Map, ///< Palette-based image with up to 256 palette entries. + Gray_Int8, ///< Single-channel (grayscale) image using 8-bit linear encoding. + Gray_Int16, ///< Single-channel (grayscale) image using 16-bit linear encoding. + GrayA_Int8, ///< Dual-channel (grayscale and alpha) image using 8-bit linear encoding. + GrayA_Int16, ///< Dual-channel (grayscale and alpha) image using 16-bit linear encoding. + RGB_Int8, ///< 3-channel (colour) image using 8-bit linear encoding. + RGB_Int16, ///< 3-channel (colour) image using 16-bit linear encoding. + RGBA_Int8, ///< 4-channel (colour and alpha) image using 8-bit linear encoding. + RGBA_Int16, ///< 4-channel (colour and alpha) image using 16-bit linear encoding. + RGBFT_Float, ///< 5-channel (colour, filter and transmit) image using single-precision floating-point encoding. + RGB_Gamma8, ///< 3-channel (colour) image using 8-bit gamma encoding. + RGB_Gamma16, ///< 3-channel (colour) image using 16-bit gamma encoding. + RGBA_Gamma8, ///< 4-channel (colour and alpha) image using 8-bit gamma colour encoding and 8-bit linear alpha encoding. + RGBA_Gamma16, ///< 4-channel (colour and alpha) image using 16-bit gamma colour encoding and 16-bit linear alpha encoding. + Gray_Gamma8, ///< Single-channel (grayscale) image using 8-bit gamma encoding. + Gray_Gamma16, ///< Single-channel (grayscale) image using 16-bit gamma encoding. + GrayA_Gamma8, ///< Dual-channel (grayscale and alpha) image using 8-bit gamma greyscale encoding and 8-bit linear alpha encoding. + GrayA_Gamma16, ///< Dual-channel (grayscale and alpha) image using 16-bit gamma greyscale encoding and 16-bit linear alpha encoding. +}; + +/// The mode to use for alpha handling. +enum class ImageAlphaMode : int +{ + None, ///< Disable alpha channel. @note Not a valid setting for input files. + Default, ///< Use auto-detection or file format specific default. + Premultiplied, ///< Enforce premultiplied mode, aka associated alpha. + Straight, ///< Enforce straight mode, aka unassociated alpha. +}; + +struct ImageReadOptions final +{ + ImageDataType itype; + SimpleGammaCurvePtr defaultGamma; // the gamma curve to use by default for converting to linear colour space + SimpleGammaCurvePtr workingGamma; // the working colour space gamma + bool gammaOverride; // whether to apply defaultGamma even if the file indicates a different gamma + bool gammacorrect; // whether to do any gamma correction at all; if false, raw encoded values are used + bool premultipliedOverride; // whether to override file-format default for alpha premultiplication + bool premultiplied; // whether to expect premultiplied ("associated") alpha or not ("straight alpha") + mutable std::vector warnings; + + ImageReadOptions() : + itype(ImageDataType::Undefined), + gammaOverride(false), gammacorrect(false), premultipliedOverride(false), premultiplied(false) + {} +}; + +struct ImageWriteOptions final +{ + //------------------------------------------------------------------------------ + /// @name Gamma Handling + /// @{ + + /// Gamma to encode for. + /// Set this to `nullptr` to use the file format specific default. + /// @note + /// This setting is ignored with file formats that mandate linear encoding or a + /// specific encoding gamma. + SimpleGammaCurvePtr encodingGamma; + + /// Working colour space gamma to encode from. + /// Set to `nullptr` or a neutral gamma curve to indicate linear working colour space. + SimpleGammaCurvePtr workingGamma; + + /// @} + //------------------------------------------------------------------------------ + + /// Dithering algorithm. + /// Leave this at the default to disable dithering. + /// @note + /// This setting is ignored with file formats that are not prone to colour banding + /// artifacts (such as OpenEXR) or do not benefit from dithering (such as JPEG). + DitherStrategySPtr ditherStrategy; + + unsigned int offset_x; ///< Currently not actively set. + unsigned int offset_y; ///< Currently not actively set. + + /// How to handle image transparency. + /// Set this to @ref ImageAlphaMode::None to disable creation of an alpha channel, + /// @ref ImageAlphaMode::Default to write an alpha channel using a file format specific + /// default mode, @ref ImageAlphaMode::Premultiplied to write an alpha channel using + /// premultiplied mode (aka associated alpha), or @ref ImageAlphaMode::Straight to write an + /// alpha channel using straight mode (aka unassociated alpha). + /// @note + /// This setting is ignored with file formats that do not support transparency, or + /// for which transparency support has not been implemented in POV-Ray. + ImageAlphaMode alphaMode; + + /// Bits per colour channel. + /// Set this to `0` to use the file format specific default. + /// @note + /// This setting is ignored with file formats that mandate a particular bit depth, + /// for which POV-Ray only supports a particular bit depth, or for which bit depth + /// is not applicable (such as JPEG). + /// @note + /// The actual bit depth may differ if the file format or POV-Ray's implementation + /// thereof does not support the requested bit depth. In that case, the next higher + /// supported bit depth is used if possible, or the highest supported bit depth + /// otherwise. + unsigned char bitsPerChannel; + + /// Whether to use compression. + /// Set this to a negative value to use the file format specific default setting, `0` + /// to disable, or any higher value to enable. Depending on the file format, such a + /// setting may be interpreted as a format specific compression parameter. + /// @note + /// Whether a positive value indicates a mode, compression level or quality level + /// is specific to the file format. + /// @note + /// This setting is ignored with file formats that never use compression, always + /// use compression, or for which POV-Ray's implementation leaves no choice. + signed short compression; + + /// Whether to write a greyscale image. + /// @note + /// This setting is ignored with file formats that do not support a dedicated + /// greyscale mode, or for which support of such a mode has not been implemented + /// in POV-Ray. + bool grayscale : 1; + + ImageWriteOptions(); + + inline bool AlphaIsEnabled() const + { + return (alphaMode != ImageAlphaMode::None); + } + + inline bool AlphaIsPremultiplied(bool defaultToPremultiplied) const + { + if (defaultToPremultiplied) + return (alphaMode != ImageAlphaMode::Straight); + else + return (alphaMode == ImageAlphaMode::Premultiplied); + } + + GammaCurvePtr GetTranscodingGammaCurve(GammaCurvePtr defaultEncodingGamma) const; +}; + /** * Generic image data container. * @@ -75,7 +223,7 @@ using DitherStrategySPtr = shared_ptr; class Image { public: - struct RGBMapEntry + struct RGBMapEntry final { float red; float green; @@ -85,7 +233,7 @@ class Image RGBMapEntry(float r, float g, float b) : red(r), green(g), blue(b) { } }; - struct RGBAMapEntry + struct RGBAMapEntry final { float red; float green; @@ -96,7 +244,7 @@ class Image RGBAMapEntry(float r, float g, float b, float a) : red(r), green(g), blue(b), alpha(a) { } }; - struct RGBFTMapEntry + struct RGBFTMapEntry final { float red; float green; @@ -116,66 +264,6 @@ class Image RGBFTColourMap }; - enum ImageChannelDataType - { - kImageChannelDataType_Int8, - kImageChannelDataType_Int16, - kImageChannelDataType_Gamma8, - kImageChannelDataType_Gamma16, - }; - - enum ImageChannelLayout - { - kImageChannelLayout_Gray, - kImageChannelLayout_GrayA, - kImageChannelLayout_RGB, - kImageChannelLayout_RGBA, - }; - - enum ImageDataType - { - /// Value used to indicate that image decoder is free to pick the most fitting type. - Undefined, - /// Palette-based image with 2 palette entries. - Bit_Map, - /// Palette-based image with up to 256 palette entries. - Colour_Map, - /// Single-channel (grayscale) image using 8-bit linear encoding. - Gray_Int8, - /// Single-channel (grayscale) image using 16-bit linear encoding. - Gray_Int16, - /// Dual-channel (grayscale and alpha) image using 8-bit linear encoding. - GrayA_Int8, - /// Dual-channel (grayscale and alpha) image using 16-bit linear encoding. - GrayA_Int16, - /// 3-channel (colour) image using 8-bit linear encoding. - RGB_Int8, - /// 3-channel (colour) image using 16-bit linear encoding. - RGB_Int16, - /// 4-channel (colour and alpha) image using 8-bit linear encoding. - RGBA_Int8, - /// 4-channel (colour and alpha) image using 16-bit linear encoding. - RGBA_Int16, - /// 5-channel (colour, filter and transmit) image using single-precision floating-point encoding. - RGBFT_Float, - /// 3-channel (colour) image using 8-bit gamma encoding. - RGB_Gamma8, - /// 3-channel (colour) image using 16-bit gamma encoding. - RGB_Gamma16, - /// 4-channel (colour and alpha) image using 8-bit gamma colour encoding and 8-bit linear alpha encoding. - RGBA_Gamma8, - /// 4-channel (colour and alpha) image using 16-bit gamma colour encoding and 16-bit linear alpha encoding. - RGBA_Gamma16, - /// Single-channel (grayscale) image using 8-bit gamma encoding. - Gray_Gamma8, - /// Single-channel (grayscale) image using 16-bit gamma encoding. - Gray_Gamma16, - /// Dual-channel (grayscale and alpha) image using 8-bit gamma greyscale encoding and 8-bit linear alpha encoding. - GrayA_Gamma8, - /// Dual-channel (grayscale and alpha) image using 16-bit gamma greyscale encoding and 16-bit linear alpha encoding. - GrayA_Gamma16 - }; - /// Image file type identifier. enum ImageFileType { @@ -194,140 +282,49 @@ class Image HDR }; - /// The mode to use for alpha handling. - enum AlphaMode - { - kAlphaMode_None, ///< Disable alpha channel. @note Not a valid setting for input files. - kAlphaMode_Default, ///< Use auto-detection or file format specific default. - kAlphaMode_Premultiplied, ///< Enforce premultiplied mode, aka associated alpha. - kAlphaMode_Straight, ///< Enforce straight mode, aka unassociated alpha. - }; - - struct ReadOptions - { - ImageDataType itype; - SimpleGammaCurvePtr defaultGamma; // the gamma curve to use by default for converting to linear colour space - SimpleGammaCurvePtr workingGamma; // the working colour space gamma - bool gammaOverride; // whether to apply defaultGamma even if the file indicates a different gamma - bool gammacorrect; // whether to do any gamma correction at all; if false, raw encoded values are used - bool premultipliedOverride; // whether to override file-format default for alpha premultiplication - bool premultiplied; // whether to expect premultiplied ("associated") alpha or not ("straight alpha") - mutable vector warnings; - - ReadOptions() : itype(Undefined), gammaOverride(false), gammacorrect(false), premultipliedOverride(false), premultiplied(false) { } - }; - - struct WriteOptions - { - //------------------------------------------------------------------------------ - /// @name Gamma Handling - /// @{ - - /// Gamma to encode for. - /// Set this to `nullptr` to use the file format specific default. - /// @note - /// This setting is ignored with file formats that mandate linear encoding or a - /// specific encoding gamma. - SimpleGammaCurvePtr encodingGamma; - - /// Working colour space gamma to encode from. - /// Set to `nullptr` or a neutral gamma curve to indicate linear working colour space. - SimpleGammaCurvePtr workingGamma; - - /// @} - //------------------------------------------------------------------------------ - - /// Dithering algorithm. - /// Leave this at the default to disable dithering. - /// @note - /// This setting is ignored with file formats that are not prone to colour banding - /// artifacts (such as OpenEXR) or do not benefit from dithering (such as JPEG). - DitherStrategySPtr ditherStrategy; - - unsigned int offset_x; ///< Currently not actively set. - unsigned int offset_y; ///< Currently not actively set. - - /// How to handle image transparency. - /// Set this to @ref kAlphaMode_None to disable creation of an alpha channel, - /// @ref kAlphaMode_Default to write an alpha channel using a file format specific - /// default mode, @ref kAlphaMode_Premultiplied to write an alpha channel using - /// premultiplied mode (aka associated alpha), or @ref kAlphaMode_Straight to write an - /// alpha channel using straight mode (aka unassociated alpha). - /// @note - /// This setting is ignored with file formats that do not support transparency, or - /// for which transparency support has not been implemented in POV-Ray. - AlphaMode alphaMode; - - /// Bits per colour channel. - /// Set this to `0` to use the file format specific default. - /// @note - /// This setting is ignored with file formats that mandate a particular bit depth, - /// for which POV-Ray only supports a particular bit depth, or for which bit depth - /// is not applicable (such as JPEG). - /// @note - /// The actual bit depth may differ if the file format or POV-Ray's implementation - /// thereof does not support the requested bit depth. In that case, the next higher - /// supported bit depth is used if possible, or the highest supported bit depth - /// otherwise. - unsigned char bitsPerChannel; - - /// Whether to use compression. - /// Set this to a negative value to use the file format specific default setting, `0` - /// to disable, or any higher value to enable. Depending on the file format, such a - /// setting may be interpreted as a format specific compression parameter. - /// @note - /// Whether a positive value indicates a mode, compression level or quality level - /// is specific to the file format. - /// @note - /// This setting is ignored with file formats that never use compression, always - /// use compression, or for which POV-Ray's implementation leaves no choice. - signed short compression; - - /// Whether to write a greyscale image. - /// @note - /// This setting is ignored with file formats that do not support a dedicated - /// greyscale mode, or for which support of such a mode has not been implemented - /// in POV-Ray. - bool grayscale : 1; - - WriteOptions(); - - inline bool AlphaIsEnabled() const - { - return (alphaMode != Image::kAlphaMode_None); - } - - inline bool AlphaIsPremultiplied(bool defaultToPremultiplied) const - { - if (defaultToPremultiplied) - return (alphaMode != Image::kAlphaMode_Straight); - else - return (alphaMode == Image::kAlphaMode_Premultiplied); - } - - GammaCurvePtr GetTranscodingGammaCurve(GammaCurvePtr defaultEncodingGamma) const - { - if (encodingGamma) - return TranscodingGammaCurve::Get(workingGamma, encodingGamma); - else - return TranscodingGammaCurve::Get(workingGamma, defaultEncodingGamma); - } - }; - virtual ~Image() { } - static ImageDataType GetImageDataType (ImageChannelDataType channelType, ImageChannelLayout layout); + /// Suggest an image data container satisfying certain constraints. + /// + /// This method returns an @ref ImageDataType representing a non-paletted, integer-based + /// image data container matching the specified constraints. + /// + /// @note + /// The number of bits per colour channel is taken as a minimum requirement. All other + /// constraints are currently implemented as exact-match requirements. + /// @note + /// RGB alpha is not supported yet. + /// + /// @param minBitsPerChannel Minimum number of bits per colour or alpha channel. + /// @param colourChannels Number of colour channels (1 = greyscale, 3 = RGB). + /// @param alphaChannels Number of alpha channels (0 = no alpha, 1 = common alpha, 3 = RGB alpha). + /// @param linear Whether the caller will write linear (as opposed to gamma encoded) data. + static ImageDataType GetImageDataType(int minBitsPerChannel, int colourChannels, int alphaChannels, bool linear); + + /// Suggest an image data container satisfying certain constraints. + /// + /// This method is a convenience function equivalent to calling: + /// + /// GetImageDataType(minBitsPerChannel, colourChannels, alpha? 1:0, IsNeutral(gamma)); + /// + /// See @ref GetImageDataType(int,int,int,bool) for more details. + /// + /// @param minBitsPerChannel Minimum number of bits per colour or alpha channel. + /// @param colourChannels Number of colour channels (1 = greyscale, 3 = RGB). + /// @param alpha Whether to provide a (common) alpha channel. + /// @param gamma Encoding gamma of the data to be written. + static ImageDataType GetImageDataType(int minBitsPerChannel, int colourChannels, bool alpha, GammaCurvePtr gamma); static Image *Create(unsigned int w, unsigned int h, ImageDataType t, unsigned int maxRAMmbHint, unsigned int pixelsPerBlockHint); static Image *Create(unsigned int w, unsigned int h, ImageDataType t, bool allowFileBacking = false); - static Image *Create(unsigned int w, unsigned int h, ImageDataType t, const vector& m, bool allowFileBacking = false); - static Image *Create(unsigned int w, unsigned int h, ImageDataType t, const vector& m, bool allowFileBacking = false); - static Image *Create(unsigned int w, unsigned int h, ImageDataType t, const vector& m, bool allowFileBacking = false); + static Image *Create(unsigned int w, unsigned int h, ImageDataType t, const std::vector& m, bool allowFileBacking = false); + static Image *Create(unsigned int w, unsigned int h, ImageDataType t, const std::vector& m, bool allowFileBacking = false); + static Image *Create(unsigned int w, unsigned int h, ImageDataType t, const std::vector& m, bool allowFileBacking = false); // ftype = use this image type, if "Undefined" use best match - static Image *Read(ImageFileType ftype, IStream *file, const ReadOptions& options = ReadOptions()); + static Image *Read(ImageFileType ftype, IStream *file, const ImageReadOptions& options = ImageReadOptions()); - static void Write(ImageFileType ftype, OStream *file, const Image *image, const WriteOptions& options = WriteOptions()); + static void Write(ImageFileType ftype, OStream *file, const Image *image, const ImageWriteOptions& options = ImageWriteOptions()); unsigned int GetWidth() const { return width; } unsigned int GetHeight() const { return height; } @@ -432,13 +429,13 @@ class Image unsigned int GetColourMapSize() const; - void GetColourMap(vector& m) const; - void GetColourMap(vector& m) const; - void GetColourMap(vector& m) const; + void GetColourMap(std::vector& m) const; + void GetColourMap(std::vector& m) const; + void GetColourMap(std::vector& m) const; - void SetColourMap(const vector& m); - void SetColourMap(const vector& m); - void SetColourMap(const vector& m); + void SetColourMap(const std::vector& m); + void SetColourMap(const std::vector& m); + void SetColourMap(const std::vector& m); /* void CopyTo(unsigned int x, unsigned int y, const Image& srcimage) { @@ -449,7 +446,7 @@ class Image // TODO }*/ protected: - struct MapEntry + struct MapEntry final { float red; float green; @@ -464,7 +461,7 @@ class Image MapEntry(const RGBFTMapEntry& e) : red(e.red), green(e.green), blue(e.blue), filter(e.filter), transm(e.transm) { } }; - vector colormap; + std::vector colormap; ColourMapType colormaptype; unsigned int width; unsigned int height; @@ -474,26 +471,24 @@ class Image Image(unsigned int w, unsigned int h, ImageDataType t) : width(w), height(h), type(t), colormaptype(NoColourMap), premultiplied(false) { } - Image(unsigned int w, unsigned int h, ImageDataType t, const vector& m) : - width(w), height(h), type(t), colormaptype(RGBColourMap), premultiplied(false) { colormap.resize(max(m.size(), sizeof(unsigned char) * 256)); colormap.assign(m.begin(), m.end()); } + Image(unsigned int w, unsigned int h, ImageDataType t, const std::vector& m) : + width(w), height(h), type(t), colormaptype(RGBColourMap), premultiplied(false) { colormap.resize(std::max(m.size(), sizeof(unsigned char) * 256)); colormap.assign(m.begin(), m.end()); } - Image(unsigned int w, unsigned int h, ImageDataType t, const vector& m) : - width(w), height(h), type(t), colormaptype(RGBAColourMap), premultiplied(false) { colormap.resize(max(m.size(), sizeof(unsigned char) * 256)); colormap.assign(m.begin(), m.end()); } + Image(unsigned int w, unsigned int h, ImageDataType t, const std::vector& m) : + width(w), height(h), type(t), colormaptype(RGBAColourMap), premultiplied(false) { colormap.resize(std::max(m.size(), sizeof(unsigned char) * 256)); colormap.assign(m.begin(), m.end()); } - Image(unsigned int w, unsigned int h, ImageDataType t, const vector& m) : - width(w), height(h), type(t), colormaptype(RGBFTColourMap), premultiplied(false) { colormap.resize(max(m.size(), sizeof(unsigned char) * 256)); colormap.assign(m.begin(), m.end()); } + Image(unsigned int w, unsigned int h, ImageDataType t, const std::vector& m) : + width(w), height(h), type(t), colormaptype(RGBFTColourMap), premultiplied(false) { colormap.resize(std::max(m.size(), sizeof(unsigned char) * 256)); colormap.assign(m.begin(), m.end()); } float RGB2Gray(float red, float green, float blue) const { return RGBColour(red, green, blue).Greyscale(); } private: - /// not available - Image(); - /// not available - Image(const Image&); - /// not available - Image& operator=(Image&); + + Image() = delete; + Image(const Image&) = delete; + Image& operator=(Image&) = delete; }; /// @} @@ -501,5 +496,6 @@ class Image //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_IMAGE_H diff --git a/source/base/image/image_fwd.h b/source/base/image/image_fwd.h new file mode 100644 index 000000000..5e3980d45 --- /dev/null +++ b/source/base/image/image_fwd.h @@ -0,0 +1,53 @@ +//****************************************************************************** +/// +/// @file base/image/image_fwd.h +/// +/// Forward declarations related to image containers. +/// +/// @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_BASE_IMAGE_FWD_H +#define POVRAY_BASE_IMAGE_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class Image; +struct ImageReadOptions; +struct ImageWriteOptions; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_IMAGE_FWD_H diff --git a/source/base/image/jpeg.cpp b/source/base/image/jpeg.cpp index aa5041f13..22f343372 100644 --- a/source/base/image/jpeg.cpp +++ b/source/base/image/jpeg.cpp @@ -14,7 +14,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 @@ -44,15 +44,13 @@ #ifndef LIBJPEG_MISSING -// C++ variants of standard C header files +// C++ variants of C standard header files #include -// Standard C++ header files +// C++ standard header files +#include #include -// Boost header files -#include - // Other 3rd party header files extern "C" { @@ -60,7 +58,11 @@ extern "C" } // POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/image/colourspace.h" #include "base/image/dither.h" +#include "base/image/encoding.h" +#include "base/image/image.h" #include "base/image/metadata.h" // this must be the last file included @@ -83,7 +85,7 @@ const int POV_JPEG_BUFFER_SIZE = 1024; ******************************************************************************/ // write buffer for JPEG images -class POV_JPEG_Write_Buffer +class POV_JPEG_Write_Buffer final { public: POV_JPEG_Write_Buffer(); @@ -96,7 +98,7 @@ class POV_JPEG_Write_Buffer JSAMPROW row_pointer[1]; int row_stride; struct jpeg_compress_struct cinfo; - string msg; + std::string msg; OStream *file; } ; @@ -111,7 +113,7 @@ POV_JPEG_Write_Buffer::POV_JPEG_Write_Buffer() row_stride = 0; } -class POV_JPEG_Read_Buffer +class POV_JPEG_Read_Buffer final { public: POV_JPEG_Read_Buffer(); @@ -124,7 +126,7 @@ class POV_JPEG_Read_Buffer JSAMPROW row_pointer[1]; int row_stride; struct jpeg_decompress_struct cinfo; - string msg; + std::string msg; IStream *file; }; @@ -276,7 +278,7 @@ extern "C" } // TODO: handle possible memory leakage if an exception is thrown during a read -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { int width; int height; @@ -345,16 +347,9 @@ Image *Read (IStream *file, const Image::ReadOptions& options) height = readbuf.cinfo.output_height; width = readbuf.cinfo.output_width; - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - { - if (GammaCurve::IsNeutral(gamma)) - // No gamma correction required, raw values can be stored "as is". - imagetype = readbuf.cinfo.output_components == 1 ? Image::Gray_Int8 : Image::RGB_Int8; - else - // Gamma correction required; use an image container that will take care of that. - imagetype = readbuf.cinfo.output_components == 1 ? Image::Gray_Gamma8 : Image::RGB_Gamma8; - } + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType(8, (readbuf.cinfo.output_components == 1 ? 1 : 3), false, gamma); image = Image::Create (width, height, imagetype) ; // NB: JPEG files don't use alpha, so premultiplied vs. non-premultiplied is not an issue image->TryDeferDecoding(gamma, MAXJSAMPLE); // try to have gamma adjustment being deferred until image evaluation. @@ -363,7 +358,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) readbuf.row_stride = readbuf.cinfo.output_width * readbuf.cinfo.output_components; // Make a one-row-high sample array - boost::scoped_array scopedarray (new JSAMPLE [readbuf.row_stride]); + std::unique_ptr scopedarray (new JSAMPLE [readbuf.row_stride]); readbuf.row_pointer[0] = (JSAMPROW) &scopedarray[0] ; // read image row by row @@ -401,7 +396,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) } // TODO: handle possible memory leakage if an exception is thrown during a write -void Write (OStream *file, const Image *image, const Image::WriteOptions& options) +void Write (OStream *file, const Image *image, const ImageWriteOptions& options) { int width = image->GetWidth() ; int height = image->GetHeight() ; @@ -457,7 +452,7 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option writebuf.row_stride = writebuf.cinfo.image_width * writebuf.cinfo.input_components; // Make a one-row-high sample array - boost::scoped_array scopedarray (new JSAMPLE [writebuf.row_stride]); + std::unique_ptr scopedarray (new JSAMPLE [writebuf.row_stride]); writebuf.row_pointer[0] = (JSAMPROW) &scopedarray[0] ; // if quality is not specified, we wind the output quality waaaay up (usually needed for raytracing) @@ -487,7 +482,7 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option // prepare metadata Metadata meta; /* Line feed is "local" */ - string comment=string("Render Date: ") + meta.getDateTime() + "\n"; + std::string comment = std::string("Render Date: ") + meta.getDateTime() + "\n"; comment += "Software: " + meta.getSoftware() + "\n"; if (!meta.getComment1().empty()) comment += meta.getComment1() + "\n"; @@ -530,8 +525,10 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option jpeg_destroy_compress(&writebuf.cinfo); } -} // end of namespace Jpeg +} +// end of namespace Jpeg -} // end of namespace pov_base +} +// end of namespace pov_base #endif // LIBJPEG_MISSING diff --git a/source/base/image/jpeg_pov.h b/source/base/image/jpeg_pov.h index 345b659d8..b297c9aef 100644 --- a/source/base/image/jpeg_pov.h +++ b/source/base/image/jpeg_pov.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 @@ -40,8 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -55,15 +60,17 @@ namespace Jpeg /// /// @{ -Image *Read(IStream *file, const Image::ReadOptions& options); -void Write (OStream *file, const Image *image, const Image::WriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); +void Write (OStream *file, const Image *image, const ImageWriteOptions& options); /// @} /// //############################################################################## } +// end of namespace Jpeg } +// end of namespace pov_base #endif // POVRAY_BASE_JPEG_H diff --git a/source/base/image/metadata.cpp b/source/base/image/metadata.cpp index e00cde4df..dbef9a309 100644 --- a/source/base/image/metadata.cpp +++ b/source/base/image/metadata.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,9 +36,13 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/metadata.h" +// C++ variants of C standard header files #include -// POV-Ray base header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/version_info.h" // this must be the last file included @@ -55,60 +59,60 @@ Metadata::Metadata() Metadata::~Metadata() {} -string Metadata::getSoftware() const +std::string Metadata::getSoftware() const { return "POV-Ray v" POV_RAY_SOURCE_VERSION; } -string Metadata::getComment1() const +std::string Metadata::getComment1() const { #ifdef METADATA_PLATFORM_STRING // METADATA_PLATFORM_STRING should be in a form similar to 'i686-pc-linux-gnu', 'i386-pc-win', etc. - return string("Platform: ") + METADATA_PLATFORM_STRING; + return std::string("Platform: ") + METADATA_PLATFORM_STRING; #else - return string(); + return std::string(); #endif } -string Metadata::getComment2() const +std::string Metadata::getComment2() const { #ifdef METADATA_COMPILER_STRING // METADATA_COMPILER_STRING should be in a form similar to 'g++ 4.4.3', 'msvc 10.0', etc. - return string("Compiler: ") + METADATA_COMPILER_STRING; + return std::string("Compiler: ") + METADATA_COMPILER_STRING; #else - return string(); + return std::string(); #endif } -string Metadata::getComment3() const +std::string Metadata::getComment3() const { #ifdef METADATA_COMMENT_3 // NB it is legal for METADATA_COMMENT_3 to be a function returning string // Note that it may be called more than once - return string(METADATA_COMMENT_3); + return std::string(METADATA_COMMENT_3); #else - return string(); + return std::string(); #endif } -string Metadata::getComment4() const +std::string Metadata::getComment4() const { #ifdef METADATA_COMMENT_4 // NB it is legal for METADATA_COMMENT_4 to be a function returning string // Note that it may be called more than once - return string(METADATA_COMMENT_4); + return std::string(METADATA_COMMENT_4); #else - return string(); + return std::string(); #endif } -string Metadata::getDateTime() const +std::string Metadata::getDateTime() const { // Not using boost's `to_iso_extended_string` because that would mean we couldn't reliably // get away with using the boost date_time library in header-only mode. char s[21]; // 10 (date) + 1 (blank) + 8 (time) + 1 (timezone "Z") + 1 (trailing NUL) std::snprintf(s, sizeof(s), "%04d-%02d-%02d %02d:%02d:%02dZ", getYear(), getMonth(), getDay(), getHour(), getMin(), getSec()); - return string(s); + return std::string(s); } int Metadata::getYear() const @@ -142,3 +146,4 @@ int Metadata::getSec() const } } +// end of namespace pov_base diff --git a/source/base/image/metadata.h b/source/base/image/metadata.h index 63a7bd02c..6520c8fed 100644 --- a/source/base/image/metadata.h +++ b/source/base/image/metadata.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 @@ -39,13 +39,19 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include // Boost header files #include #include +// POV-Ray header files (base module) +// (none at the moment) + namespace pov_base { @@ -56,7 +62,7 @@ namespace pov_base /// @{ /// Generates metadata to write into output images. -class Metadata +class Metadata final { public: Metadata(); @@ -67,7 +73,7 @@ class Metadata * @note This method should return at most 40 ascii bytes, otherwise it may become truncated by some file formats. * non-printable characters, line feeds and tabs are not allowed. */ - string getSoftware() const; + std::string getSoftware() const; /* Up to 4 comments, each at most 80 ascii bytes, no line feed, no tab * if it's longer, it can either fit anyway or get truncated, it's the @@ -79,31 +85,31 @@ class Metadata * @note This method should return at most 80 ascii bytes, otherwise it may become truncated by some file formats. * non-printable characters, line feeds and tabs are not allowed. */ - string getComment1() const; + std::string getComment1() const; /** * Get comment string #2. * @note This method should return at most 80 ascii bytes, otherwise it may become truncated by some file formats. * non-printable characters, line feeds and tabs are not allowed. */ - string getComment2() const; + std::string getComment2() const; /** * Get comment string #3. * @note This method should return at most 80 ascii bytes, otherwise it may become truncated by some file formats. * non-printable characters, line feeds and tabs are not allowed. */ - string getComment3() const; + std::string getComment3() const; /** * Get comment string #4. * @note This method should return at most 80 ascii bytes, otherwise it may become truncated by some file formats. * non-printable characters, line feeds and tabs are not allowed. */ - string getComment4() const; + std::string getComment4() const; /// Get date string in ISO 8601 format. - string getDateTime() const; + std::string getDateTime() const; /// Get year (including full century) int getYear() const; @@ -128,4 +134,6 @@ class Metadata //############################################################################## } -#endif +// end of namespace pov_base + +#endif // POVRAY_BASE_METADATA_H diff --git a/source/base/image/openexr.cpp b/source/base/image/openexr.cpp index bdc8bd951..653e6f0d8 100644 --- a/source/base/image/openexr.cpp +++ b/source/base/image/openexr.cpp @@ -38,12 +38,12 @@ #ifndef OPENEXR_MISSING -// Standard C++ header files -#include +// C++ variants of C standard header files +// (none at the moment) -// Boost header files -#include -#include +// C++ standard header files +#include +#include // Other 3rd party header files #include @@ -51,9 +51,13 @@ #include #include -// POV-Ray base header files +// POV-Ray header files (base module) #include "base/fileinputoutput.h" +#include "base/stringutilities.h" #include "base/types.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" #include "base/image/metadata.h" // this must be the last file included @@ -75,28 +79,23 @@ using namespace Imath; /***************************************************************************** * Local typedefs ******************************************************************************/ -struct Messages -{ - vector warnings; - string error; -}; /////////////////////////////////////////// // class POV_EXR_OStream /////////////////////////////////////////// -class POV_EXR_OStream : public Imf::OStream +class POV_EXR_OStream final : public Imf::OStream { public: POV_EXR_OStream(pov_base::OStream& pov_stream) : Imf::OStream(UCS2toSysString(pov_stream.Name()).c_str()), os(pov_stream) { } - virtual ~POV_EXR_OStream() { } + virtual ~POV_EXR_OStream() override { } - void write(const char *c, int n) + virtual void write(const char *c, int n) override { if(os.write(c, n) == false) throw POV_EXCEPTION(kFileDataErr, "Error while writing EXR output"); } - Int64 tellp() + virtual Int64 tellp() override { unsigned long pos = os.tellg(); if((int) pos == -1) @@ -104,7 +103,7 @@ class POV_EXR_OStream : public Imf::OStream return(pos); } - void seekp(Int64 pos) + virtual void seekp(Int64 pos) override { if(os.seekg((unsigned long)pos) == false) throw POV_EXCEPTION(kFileDataErr, "Error when writing EXR output"); @@ -116,7 +115,7 @@ class POV_EXR_OStream : public Imf::OStream /////////////////////////////////////////// // class POV_EXR_IStream /////////////////////////////////////////// -class POV_EXR_IStream : public Imf::IStream +class POV_EXR_IStream final : public Imf::IStream { public: POV_EXR_IStream(pov_base::IStream& pov_stream) : Imf::IStream(UCS2toSysString(pov_stream.Name()).c_str()), is(pov_stream) @@ -126,18 +125,18 @@ class POV_EXR_IStream : public Imf::IStream is.seekg(0, IOBase::seek_set); } - virtual ~POV_EXR_IStream() { } + virtual ~POV_EXR_IStream() override { } - void clear(void) { is.clearstate(); } + virtual void clear(void) override { is.clearstate(); } - bool read(char *c, int n) + virtual bool read(char *c, int n) override { if(is.read(c, n) == false) throw POV_EXCEPTION(kFileDataErr, "Error while reading EXR file"); return (is.tellg() < fsize); } - Int64 tellg() + virtual Int64 tellg() override { unsigned long pos = is.tellg(); if((int)pos == -1) @@ -145,7 +144,7 @@ class POV_EXR_IStream : public Imf::IStream return pos; } - void seekg(Int64 pos) + virtual void seekg(Int64 pos) override { if(is.seekg((unsigned long)pos) == false) throw POV_EXCEPTION(kFileDataErr, "Error while reading EXR file"); @@ -159,7 +158,7 @@ class POV_EXR_IStream : public Imf::IStream * Implementation ******************************************************************************/ -Image *Read(IStream *file, const Image::ReadOptions& options) +Image *Read(IStream *file, const ImageReadOptions& options) { unsigned int width; unsigned int height; @@ -189,7 +188,7 @@ Image *Read(IStream *file, const Image::ReadOptions& options) RgbaInputFile rif(is); Array2D pixels; Box2i dw = rif.dataWindow(); - Image::ImageDataType imagetype = options.itype; + ImageDataType imagetype = options.itype; width = dw.max.x - dw.min.x + 1; height = dw.max.y - dw.min.y + 1; @@ -197,8 +196,8 @@ Image *Read(IStream *file, const Image::ReadOptions& options) rif.setFrameBuffer(&pixels[0][0] - dw.min.x - dw.min.y * width, 1, width); rif.readPixels(dw.min.y, dw.max.y); - if(imagetype == Image::Undefined) - imagetype = Image::RGBFT_Float; + if(imagetype == ImageDataType::Undefined) + imagetype = ImageDataType::RGBFT_Float; image = Image::Create(width, height, imagetype); image->SetPremultiplied(premul); // set desired storage mode regarding alpha premultiplication @@ -220,14 +219,14 @@ Image *Read(IStream *file, const Image::ReadOptions& options) return image; } -void Write(OStream *file, const Image *image, const Image::WriteOptions& options) +void Write(OStream *file, const Image *image, const ImageWriteOptions& options) { int width = image->GetWidth(); int height = image->GetHeight(); bool use_alpha = image->HasTransparency() && options.AlphaIsEnabled(); float pixelAspect = 1.0; Header hdr(width, height, pixelAspect, Imath::V2f(0, 0), 1.0, INCREASING_Y, ZIP_COMPRESSION); - boost::scoped_array pixels(new Rgba[width * height]); + std::unique_ptr pixels(new Rgba[width * height]); Rgba *p = pixels.get(); // OpenEXR format mandates that colours are encoded linearly. @@ -263,7 +262,7 @@ void Write(OStream *file, const Image *image, const Image::WriteOptions& options channels = WRITE_RGB; // write RGB Metadata meta; - string comments; + std::string comments; if (!meta.getComment1().empty()) comments += meta.getComment1() + "\n"; if (!meta.getComment2().empty()) @@ -276,8 +275,8 @@ void Write(OStream *file, const Image *image, const Image::WriteOptions& options if (!comments.empty()) hdr.insert("comments",StringAttribute(comments)); - string software= meta.getSoftware(); - string datetime= meta.getDateTime(); + std::string software= meta.getSoftware(); + std::string datetime= meta.getDateTime(); hdr.insert("software",StringAttribute(software)); hdr.insert("creation",StringAttribute(datetime)); @@ -291,8 +290,10 @@ void Write(OStream *file, const Image *image, const Image::WriteOptions& options } } -} // end of namespace OpenEXR +} +// end of namespace OpenEXR -} // end of namespace pov_base +} +// end of namespace pov_base #endif // OPENEXR_MISSING diff --git a/source/base/image/openexr.h b/source/base/image/openexr.h index 04540c1c5..8e19ba5b4 100644 --- a/source/base/image/openexr.h +++ b/source/base/image/openexr.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 @@ -40,8 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -55,15 +60,17 @@ namespace OpenEXR /// /// @{ -void Write(OStream *file, const Image *image, const Image::WriteOptions& options); -Image *Read(IStream *file, const Image::ReadOptions& options); +void Write(OStream *file, const Image *image, const ImageWriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace OpenEXR } +// end of namespace pov_base #endif // POVRAY_BASE_OPENEXR_H diff --git a/source/base/image/png.cpp b/source/base/image/png.cpp index 1151bbbae..83c0d3804 100644 --- a/source/base/image/png.cpp +++ b/source/base/image/png.cpp @@ -13,7 +13,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 @@ -43,16 +43,23 @@ #ifndef LIBPNG_MISSING -// C++ standard headers +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include #include +#include -// other 3rd party library headers +// other 3rd party library header files #include -// POV-Ray base header files +// POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/types.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" #include "base/image/metadata.h" // this must be the last file included @@ -82,10 +89,10 @@ const int MAXTEXT = 1024; // Maximum length of a tEXt message /***************************************************************************** * Local typedefs ******************************************************************************/ -struct Messages +struct Messages final { - vector warnings; - string error; + std::vector warnings; + std::string error; }; /***************************************************************************** @@ -134,7 +141,7 @@ extern "C" Messages *m = reinterpret_cast(png_get_error_ptr(png_ptr)); if (m) - m->warnings.push_back (string(msg)) ; + m->warnings.push_back (std::string(msg)) ; } @@ -164,7 +171,7 @@ extern "C" Messages *m = reinterpret_cast(png_get_error_ptr(png_ptr)); if (m) - m->error = string(msg) ; + m->error = std::string(msg) ; throw POV_EXCEPTION(kFileDataErr, msg); } @@ -312,7 +319,7 @@ extern "C" ******************************************************************************/ // TODO: use scoped clean-up class in case of exception -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { int stride; int j; @@ -386,7 +393,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) if (color_type == PNG_COLOR_TYPE_PALETTE) { // color palette image - vector colormap ; + std::vector colormap; Image::RGBAMapEntry entry; png_colorp palette; int cmap_len; @@ -408,9 +415,9 @@ Image *Read (IStream *file, const Image::ReadOptions& options) colormap.push_back (entry); } - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = Image::Colour_Map; + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = ImageDataType::Colour_Map; image = Image::Create (width, height, imagetype, colormap) ; image->SetPremultiplied(premul); // specify whether the color map data has premultiplied alpha gamma.reset(); // gamma has been taken care of by transforming the color table. @@ -422,7 +429,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) { // grayscale image // (To keep the actual data reading code simple, we're pretending this to be a color palette image.) - vector colormap ; + std::vector colormap; Image::RGBAMapEntry entry; int cmap_len = 1 << bit_depth; bool has_alpha = png_get_valid(r_png_ptr, r_info_ptr, PNG_INFO_tRNS); @@ -440,9 +447,9 @@ Image *Read (IStream *file, const Image::ReadOptions& options) colormap.push_back (entry); } - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = has_alpha ? Image::GrayA_Int8 : Image::Gray_Int8; + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = has_alpha ? ImageDataType::GrayA_Int8 : ImageDataType::Gray_Int8; image = Image::Create (width, height, imagetype, colormap) ; image->SetPremultiplied(premul); // specify whether the color map data has premultiplied alpha gamma.reset(); // gamma has been taken care of by transforming the color table. @@ -512,25 +519,10 @@ Image *Read (IStream *file, const Image::ReadOptions& options) // grayscale image // (note that although 8-bit greyscale images should have been handled earlier already, 8-bit greyscale + 8-bit alpha images haven't.) - Image::ImageDataType imagetype = options.itype; + ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - { - if (GammaCurve::IsNeutral(gamma)) - { - if (has_alpha) - imagetype = bit_depth > 8 ? Image::GrayA_Int16 : Image::GrayA_Int8; - else - imagetype = bit_depth > 8 ? Image::Gray_Int16 : Image::Gray_Int8; - } - else - { - if (has_alpha) - imagetype = bit_depth > 8 ? Image::GrayA_Gamma16 : Image::GrayA_Gamma8; - else - imagetype = bit_depth > 8 ? Image::Gray_Gamma16 : Image::Gray_Gamma8; - } - } + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType(bit_depth, 1, has_alpha, gamma); image = Image::Create (width, height, imagetype); image->SetPremultiplied(premul); // set desired storage mode regarding alpha premultiplication @@ -581,25 +573,10 @@ Image *Read (IStream *file, const Image::ReadOptions& options) else { // color image ((color_type & PNG_COLOR_MASK_COLOR) != 0) - Image::ImageDataType imagetype = options.itype; + ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - { - if (GammaCurve::IsNeutral(gamma)) - { - if (has_alpha) - imagetype = bit_depth > 8 ? Image::RGBA_Int16 : Image::RGBA_Int8; - else - imagetype = bit_depth > 8 ? Image::RGB_Int16 : Image::RGB_Int8; - } - else - { - if (has_alpha) - imagetype = bit_depth > 8 ? Image::RGBA_Gamma16 : Image::RGBA_Gamma8; - else - imagetype = bit_depth > 8 ? Image::RGB_Gamma16 : Image::RGB_Gamma8; - } - } + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType(bit_depth, 3, has_alpha, gamma); image = Image::Create (width, height, imagetype); image->SetPremultiplied(premul); // set desired storage mode regarding alpha premultiplication @@ -672,7 +649,7 @@ void SetChannelValue(png_bytep& p, unsigned int v, unsigned int bpcc) *(p++) = (v & 0xFF); } -void Write (OStream *file, const Image *image, const Image::WriteOptions& options) +void Write (OStream *file, const Image *image, const ImageWriteOptions& options) { int png_stride; int width = image->GetWidth() ; @@ -775,7 +752,7 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option #if defined(PNG_WRITE_TEXT_SUPPORTED) /* Line feed is "local" */ - string comment=string("Render Date: ") + meta.getDateTime() + "\n"; + std::string comment = std::string("Render Date: ") + meta.getDateTime() + "\n"; if (!meta.getComment1().empty()) comment += meta.getComment1() + "\n"; if (!meta.getComment2().empty()) @@ -784,7 +761,7 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option comment += meta.getComment3() + "\n"; if (!meta.getComment4().empty()) comment += meta.getComment4() + "\n"; - string soft (meta.getSoftware()); + std::string soft (meta.getSoftware()); png_text p_text[2] = { { PNG_TEXT_COMPRESSION_NONE, const_cast("Software"), const_cast(soft.c_str()), soft.length() }, { PNG_TEXT_COMPRESSION_NONE, const_cast("Comment"), const_cast(comment.c_str()), comment.length() }, @@ -855,8 +832,10 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option png_destroy_write_struct(&png_ptr, &info_ptr); } -} // end of namespace Png +} +// end of namespace Png -} // end of namespace pov_base +} +// end of namespace pov_base #endif // LIBPNG_MISSING diff --git a/source/base/image/png_pov.h b/source/base/image/png_pov.h index 6def3c23f..d21fbafc6 100644 --- a/source/base/image/png_pov.h +++ b/source/base/image/png_pov.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 @@ -39,8 +39,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -54,15 +59,17 @@ namespace Png /// /// @{ -void Write(OStream *file, const Image *image, const Image::WriteOptions& options); -Image *Read(IStream *file, const Image::ReadOptions& options); +void Write(OStream *file, const Image *image, const ImageWriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace Png } +// end of namespace pov_base #endif // POVRAY_BASE_PNG_H diff --git a/source/base/image/ppm.cpp b/source/base/image/ppm.cpp index 6a16efa98..664971752 100644 --- a/source/base/image/ppm.cpp +++ b/source/base/image/ppm.cpp @@ -20,7 +20,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 @@ -48,14 +48,18 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/ppm.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include -// Standard C++ header files -#include +// C++ standard header files +// (none at the moment) -// POV-Ray base header files +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/types.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" #include "base/image/metadata.h" // this must be the last file included @@ -76,7 +80,7 @@ enum NetpbmDataFormat /*****************************************************************************/ -void Write (OStream *file, const Image *image, const Image::WriteOptions& options) +void Write (OStream *file, const Image *image, const ImageWriteOptions& options) { int file_type = POV_File_Image_PPM; int width = image->GetWidth() ; @@ -287,7 +291,7 @@ inline static POV_UINT16 ReadNetpbmRasterValue (IStream *file, NetpbmDataFormat /*****************************************************************************/ // TODO: make sure we destroy the image if we throw an exception -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { POV_UINT32 width; POV_UINT32 height; @@ -358,14 +362,9 @@ Image *Read (IStream *file, const Image::ReadOptions& options) // We'll be using an image container that provides for automatic decoding if possible - unless there's no such decoding to do. gamma = ScaledGammaCurve::GetByDecoding(float(maxImageVal)/float(maxval), gamma); // Note that we'll apply the scaling even if we don't officially gamma-correct - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = Image::GetImageDataType( GammaCurve::IsNeutral(gamma) ? (is16BitData ? Image::kImageChannelDataType_Int16 - : Image::kImageChannelDataType_Int8) - : (is16BitData ? Image::kImageChannelDataType_Gamma16 - : Image::kImageChannelDataType_Gamma8), - isMonochrome ? Image::kImageChannelLayout_Gray - : Image::kImageChannelLayout_RGB ); + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType((is16BitData ? 16 : 8), (isMonochrome ? 1 : 3), false, gamma); image = Image::Create (width, height, imagetype) ; // NB: PGM files don't use alpha, so premultiplied vs. non-premultiplied is not an issue image->TryDeferDecoding(gamma, maxImageVal); // try to have gamma adjustment being deferred until image evaluation. @@ -394,7 +393,8 @@ Image *Read (IStream *file, const Image::ReadOptions& options) return image; } -} // end of namespace Netpbm - -} // end of namespace pov_base +} +// end of namespace Netpbm +} +// end of namespace pov_base diff --git a/source/base/image/ppm.h b/source/base/image/ppm.h index e6f01e02c..8e04a7607 100644 --- a/source/base/image/ppm.h +++ b/source/base/image/ppm.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 @@ -40,8 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -55,15 +60,17 @@ namespace Netpbm /// /// @{ -void Write(OStream *file, const Image *image, const Image::WriteOptions& options); -Image *Read(IStream *file, const Image::ReadOptions& options); +void Write(OStream *file, const Image *image, const ImageWriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace Netpbm } +// end of namespace pov_base #endif // POVRAY_BASE_PPM_H diff --git a/source/base/image/targa.cpp b/source/base/image/targa.cpp index ed9e39d2b..85b489e6f 100644 --- a/source/base/image/targa.cpp +++ b/source/base/image/targa.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 @@ -56,11 +56,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/image/targa.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include -// POV-Ray base header files +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/types.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" #include "base/image/metadata.h" // this must be the last file included @@ -72,13 +80,16 @@ namespace pov_base namespace Targa { -typedef struct pix +using std::vector; + +struct pix final { unsigned int b; unsigned int g; unsigned int r; unsigned int a; -} Pixel; +}; +using Pixel = pix; typedef char Targa_footer[26]; #define FOO_EXT_OFF 0 @@ -120,7 +131,7 @@ static void PutPix (vector& line, const pix *pixel, bool opaque) line.push_back (pixel->a); } -void Write (OStream *file, const Image *image, const Image::WriteOptions& options) +void Write (OStream *file, const Image *image, const ImageWriteOptions& options) { pix current; pix next; @@ -295,10 +306,10 @@ void Write (OStream *file, const Image *image, const Image::WriteOptions& option // let's prepare the Extension area, then write Extension then footer ext[EXT_SIZE_OFF+1] = (unsigned char) ((495 >> 8) & 0xff); ext[EXT_SIZE_OFF] = (unsigned char) (495 & 0xff); - string soft = meta.getSoftware().substr(0,EXT_SOFT_DIM-1); + std::string soft = meta.getSoftware().substr(0,EXT_SOFT_DIM-1); sprintf(&ext[EXT_SOFT_OFF],"%s",soft.c_str()); - string com = meta.getComment1().substr(0,EXT_COMMENT_DIM-1); + std::string com = meta.getComment1().substr(0,EXT_COMMENT_DIM-1); if (!com.empty()) sprintf(&ext[EXT_COMMENT_OFF],"%s",com.c_str()); com = meta.getComment2().substr(0,EXT_COMMENT_DIM-1); @@ -470,7 +481,7 @@ static void ConvertColor (Image::RGBAMapEntry *pixel, unsigned pixelsize, const * ******************************************************************************/ -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { int temp; int h; @@ -560,25 +571,18 @@ Image *Read (IStream *file, const Image::ReadOptions& options) ConvertColor (&entry, cmsiz, bytes, gamma); colormap.push_back(entry); } - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = Image::Colour_Map ; + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = ImageDataType::Colour_Map ; image = Image::Create (width, height, imagetype, colormap) ; image->SetPremultiplied(premul); // specify whether the color map data has premultiplied alpha gamma.reset(); // gamma has been taken care of by transforming the color table. } else { - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - { - if (GammaCurve::IsNeutral(gamma)) - // No gamma correction required, raw values can be stored "as is". - imagetype = opaque ? Image::RGB_Int8 : Image::RGBA_Int8 ; - else - // Gamma correction required; use an image container that will take care of that. - imagetype = opaque ? Image::RGB_Gamma8 : Image::RGBA_Gamma8 ; - } + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType(8, 3, !opaque, gamma); image = Image::Create (width, height, imagetype) ; image->SetPremultiplied(premul); // set desired storage mode regarding alpha premultiplication image->TryDeferDecoding(gamma, 255); // try to have gamma adjustment being deferred until image evaluation. @@ -706,7 +710,8 @@ Image *Read (IStream *file, const Image::ReadOptions& options) return (image); } -} // end of namespace Targa - } +// end of namespace Targa +} +// end of namespace pov_base diff --git a/source/base/image/targa.h b/source/base/image/targa.h index 3b499f393..8d6c33871 100644 --- a/source/base/image/targa.h +++ b/source/base/image/targa.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 @@ -39,8 +39,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -54,15 +59,17 @@ namespace Targa /// /// @{ -void Write(OStream *file, const Image *image, const Image::WriteOptions& options); -Image *Read(IStream *file, const Image::ReadOptions& options); +void Write(OStream *file, const Image *image, const ImageWriteOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace Targa } +// end of namespace pov_base #endif // POVRAY_BASE_TARGA_H diff --git a/source/base/image/tiff.cpp b/source/base/image/tiff.cpp index 00ba245d6..5f6b26e61 100644 --- a/source/base/image/tiff.cpp +++ b/source/base/image/tiff.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 @@ -38,7 +38,11 @@ #ifndef LIBTIFF_MISSING -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include // Boost header files @@ -56,6 +60,13 @@ extern "C" #include } +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/povassert.h" +#include "base/image/colourspace.h" +#include "base/image/encoding.h" +#include "base/image/image.h" + // this must be the last file included other than tiffio.h #include "base/povdebug.h" @@ -157,7 +168,7 @@ static void Tiff_Unmap(thandle_t, tdata_t, toff_t) * ******************************************************************************/ -Image *Read (IStream *file, const Image::ReadOptions& options) +Image *Read (IStream *file, const ImageReadOptions& options) { int nrow; int result = 0; @@ -259,7 +270,7 @@ Image *Read (IStream *file, const Image::ReadOptions& options) TIFFGetField(tif, TIFFTAG_COLORMAP, &red, &green, &blue); - vector colormap ; + std::vector colormap; Image::RGBMapEntry entry; // I may be mistaken, but it appears that alpha/opacity information doesn't @@ -288,13 +299,13 @@ Image *Read (IStream *file, const Image::ReadOptions& options) } } - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = Image::Colour_Map; + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = ImageDataType::Colour_Map; image = Image::Create (width, height, imagetype, colormap) ; image->SetPremultiplied(premul); // specify whether the color map data has premultiplied alpha - boost::scoped_array buf (new unsigned char [TIFFStripSize(tif)]); + std::unique_ptr buf (new unsigned char [TIFFStripSize(tif)]); //read the tiff lines and save them in the image //with RGB mode, we have to change the order of the 3 samples RGB <=> BGR @@ -310,11 +321,11 @@ Image *Read (IStream *file, const Image::ReadOptions& options) else { // Allocate the row buffers for the image - boost::scoped_array buf (new uint32 [width * height]) ; + std::unique_ptr buf (new uint32 [width * height]) ; - Image::ImageDataType imagetype = options.itype; - if (imagetype == Image::Undefined) - imagetype = ( GammaCurve::IsNeutral(gamma) ? Image::RGBA_Int8 : Image::RGBA_Gamma8 ); + ImageDataType imagetype = options.itype; + if (imagetype == ImageDataType::Undefined) + imagetype = Image::GetImageDataType(8, 3, true, gamma); image = Image::Create (width, height, imagetype) ; image->SetPremultiplied(premul); // set desired storage mode regarding alpha premultiplication image->TryDeferDecoding(gamma, 255); // try to have gamma adjustment being deferred until image evaluation. @@ -340,8 +351,10 @@ Image *Read (IStream *file, const Image::ReadOptions& options) return (image) ; } -} // end of namespace Tiff +} +// end of namespace Tiff } +// end of namespace pov_base #endif // LIBTIFF_MISSING diff --git a/source/base/image/tiff_pov.h b/source/base/image/tiff_pov.h index 51558d962..deba2d0b5 100644 --- a/source/base/image/tiff_pov.h +++ b/source/base/image/tiff_pov.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 @@ -39,8 +39,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// POV-Ray base header files -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/image/image_fwd.h" namespace pov_base { @@ -54,14 +59,16 @@ namespace Tiff /// /// @{ -Image *Read(IStream *file, const Image::ReadOptions& options); +Image *Read(IStream *file, const ImageReadOptions& options); /// @} /// //############################################################################## } +// end of namespace Tiff } +// end of namespace pov_base #endif // POVRAY_BASE_TIFF_H diff --git a/source/base/mathutil.cpp b/source/base/mathutil.cpp index 6c4f6cc79..b865da346 100644 --- a/source/base/mathutil.cpp +++ b/source/base/mathutil.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 @@ -36,12 +36,12 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/mathutil.h" -// C++ variants of standard C header files -#include -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) -// Standard C++ header files -#include +// POV-Ray header files (base module) +// (none at the moment) // this must be the last file included #include "base/povdebug.h" @@ -49,25 +49,7 @@ namespace pov_base { -#ifdef NEED_INVHYP -DBL asinh(DBL x) -{ - return (x < 0 ? -1 : (x > 0 ? 1 : 0)) * log(fabs(x) + sqrt(1 + x * x)); -} - -DBL acosh(DBL x) -{ - if(x < 1.0) - return 0; - return log(x + sqrt(x * x - 1)); -} - -DBL atanh(DBL x) -{ - if(fabs(x) >= 1) - return 0; - return 0.5 * log((1 + x) / (1 - x)); -} -#endif +// nothing in here at the moment } +// end of namespace pov_base diff --git a/source/base/mathutil.h b/source/base/mathutil.h index 55f9a957d..7d1488aaa 100644 --- a/source/base/mathutil.h +++ b/source/base/mathutil.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 @@ -39,9 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -#include +// C++ variants of C standard header files +// (none at the moment) -#include "base/types.h" +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/povassert.h" namespace pov_base { @@ -53,17 +58,11 @@ namespace pov_base /// /// @{ -#ifdef NEED_INVHYP -DBL asinh(DBL x); -DBL acosh(DBL x); -DBL atanh(DBL x); -#endif - // Get minimum/maximum of three values. template -inline T max3(T x, T y, T z) { return max(x, max(y, z)); } +inline T max3(T x, T y, T z) { return std::max(x, std::max(y, z)); } template -inline T min3(T x, T y, T z) { return min(x, min(y, z)); } +inline T min3(T x, T y, T z) { return std::min(x, std::min(y, z)); } template inline T clip(T val, T minv, T maxv); @@ -195,5 +194,6 @@ inline bool IsFinite(double value) //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_MATHUTIL_H diff --git a/source/base/messenger.cpp b/source/base/messenger.cpp index 4ce567256..da16d0979 100644 --- a/source/base/messenger.cpp +++ b/source/base/messenger.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,11 +36,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/messenger.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include #include +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" // this must be the last file included @@ -421,3 +425,4 @@ void GenericMessenger::CleanupString(char *str) } } +// end of namespace pov_base diff --git a/source/base/messenger.h b/source/base/messenger.h index bbffe445b..d1c07c9af 100644 --- a/source/base/messenger.h +++ b/source/base/messenger.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,9 +36,19 @@ #ifndef POVRAY_BASE_MESSENGER_H #define POVRAY_BASE_MESSENGER_H +// Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/messenger_fwd.h" -#include "base/types.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" +#include "base/stringtypes.h" namespace pov_base { @@ -49,8 +59,6 @@ namespace pov_base /// /// @{ -class Exception; - /// @relates GenericMessenger enum MessageClass { @@ -140,5 +148,6 @@ class GenericMessenger //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_MESSENGER_H diff --git a/source/base/messenger_fwd.h b/source/base/messenger_fwd.h new file mode 100644 index 000000000..e5d997d10 --- /dev/null +++ b/source/base/messenger_fwd.h @@ -0,0 +1,52 @@ +//****************************************************************************** +/// +/// @file base/messenger_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_BASE_MESSENGER_FWD_H +#define POVRAY_BASE_MESSENGER_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class MessageContext; +class GenericMessenger; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_MESSENGER_FWD_H diff --git a/source/base/path.cpp b/source/base/path.cpp index bcef1a8c4..08b55bda5 100644 --- a/source/base/path.cpp +++ b/source/base/path.cpp @@ -36,8 +36,13 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/path.h" -// POV-Ray base header files +// 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" +#include "base/stringutilities.h" // this must be the last file included #include "base/povdebug.h" @@ -45,6 +50,9 @@ namespace pov_base { +using std::string; +using std::vector; + Path::Path() { } @@ -327,3 +335,4 @@ UCS2String Path::URLToUCS2String(const string& p) const } } +// end of namespace pov_base diff --git a/source/base/path.h b/source/base/path.h index 9cd756a3a..a52c06ed2 100644 --- a/source/base/path.h +++ b/source/base/path.h @@ -38,14 +38,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/path_fwd.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include #include -// POV-Ray base header files -#include "base/stringutilities.h" -#include "base/types.h" +// POV-Ray header files (base module) +#include "base/stringtypes.h" namespace pov_base { @@ -57,7 +60,7 @@ namespace pov_base /// /// @{ -class Path +class Path final { public: @@ -91,16 +94,16 @@ class Path UCS2String GetVolume() const; UCS2String GetFolder() const; - vector GetAllFolders() const; + std::vector GetAllFolders() const; UCS2String GetFile() const; void SetVolume(const char *p); - void SetVolume(const string& p); + void SetVolume(const std::string& p); void SetVolume(const UCS2 *p); void SetVolume(const UCS2String& p); void AppendFolder(const char *p); - void AppendFolder(const string& p); + void AppendFolder(const std::string& p); void AppendFolder(const UCS2 *p); void AppendFolder(const UCS2String& p); @@ -108,7 +111,7 @@ class Path void RemoveAllFolders(); void SetFile(const char *p); - void SetFile(const string& p); + void SetFile(const std::string& p); void SetFile(const UCS2 *p); void SetFile(const UCS2String& p); @@ -119,7 +122,7 @@ class Path private: UCS2String volume; - vector folders; + std::vector folders; UCS2String file; /// Analyze a path string. @@ -129,7 +132,7 @@ class Path /// if the string does not match the platform-specific conventions. /// /// @note - /// This method calls @ref ParsePathString(UCS2String&,vector,UCS2String&,const UCS2String&) + /// This method calls @ref ParsePathString(UCS2String&,std::vector,UCS2String&,const UCS2String&) /// to do the actual work. /// void ParsePathString(const UCS2String& p); @@ -162,10 +165,10 @@ class Path /// @return Whether the string constitutes a valid path and/or file name according to the /// platform-specific conventions. /// - static bool ParsePathString (UCS2String& v, vector& d, UCS2String& f, const UCS2String& p); + static bool ParsePathString (UCS2String& v, std::vector& d, UCS2String& f, const UCS2String& p); UCS2String URLToUCS2String(const char *p) const; - UCS2String URLToUCS2String(const string& p) const; + UCS2String URLToUCS2String(const std::string& p) const; }; /// @} @@ -173,5 +176,6 @@ class Path //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_PATH_H diff --git a/source/base/path_fwd.h b/source/base/path_fwd.h new file mode 100644 index 000000000..aec3bb35a --- /dev/null +++ b/source/base/path_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file base/path_fwd.h +/// +/// Forward declarations related to file paths. +/// +/// @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_BASE_PATH_FWD_H +#define POVRAY_BASE_PATH_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class Path; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_PATH_FWD_H diff --git a/source/base/platformbase.cpp b/source/base/platformbase.cpp index f46953384..97560d44f 100644 --- a/source/base/platformbase.cpp +++ b/source/base/platformbase.cpp @@ -36,8 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/platformbase.h" -// POV-Ray base header files -#include "base/types.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/filesystem.h" +#include "base/povassert.h" +#include "base/stringutilities.h" // this must be the last file included #include "base/povdebug.h" @@ -47,6 +53,23 @@ namespace pov_base //****************************************************************************** +PlatformBase::PlatformBase() +{ + POV_ASSERT(self == nullptr); + self = this; +}; + +PlatformBase::~PlatformBase() +{ + self = nullptr; +}; + +PlatformBase& PlatformBase::GetInstance() +{ + POV_ASSERT(self != nullptr); + return *self; +}; + /// Platform specific function interface self reference pointer PlatformBase *PlatformBase::self = nullptr; @@ -82,7 +105,7 @@ UCS2String DefaultPlatformBase::CreateTemporaryFile() void DefaultPlatformBase::DeleteTemporaryFile(const UCS2String& filename) { - remove(UCS2toSysString(filename).c_str()); + (void)pov_base::Filesystem::DeleteFile(filename); } bool DefaultPlatformBase::ReadFileFromURL(OStream *, const UCS2String&, const UCS2String&) @@ -95,11 +118,6 @@ FILE* DefaultPlatformBase::OpenLocalFile(const UCS2String& name, const char *mod return fopen(UCS2toSysString(name).c_str(), mode); } -void DefaultPlatformBase::DeleteLocalFile(const UCS2String& name) -{ - POV_DELETE_FILE(UCS2toSysString(name).c_str()); -} - bool DefaultPlatformBase::AllowLocalFileAccess(const UCS2String& name, const unsigned int fileType, bool write) { return true; @@ -108,3 +126,4 @@ bool DefaultPlatformBase::AllowLocalFileAccess(const UCS2String& name, const uns //****************************************************************************** } +// end of namespace pov_base diff --git a/source/base/platformbase.h b/source/base/platformbase.h index 626c2451e..01aabe1cd 100644 --- a/source/base/platformbase.h +++ b/source/base/platformbase.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 @@ -39,13 +39,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// Standard C++ header files -#include +// C++ variants of C standard header files +#include -// POV-Ray base header files -#include "base/fileinputoutput.h" -#include "base/stringutilities.h" -#include "base/types.h" +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/stringtypes.h" namespace pov_base { @@ -58,8 +60,6 @@ namespace pov_base /// /// @{ -#define POV_PLATFORM_BASE PlatformBase::GetPlatformBaseReference() - /// Abstract class defining an interface to platform-specific services. /// /// @note @@ -69,8 +69,8 @@ class PlatformBase { public: - PlatformBase() { POV_ASSERT(!self); self = this; }; - virtual ~PlatformBase() { self = nullptr; }; + PlatformBase(); + virtual ~PlatformBase(); virtual UCS2String GetTemporaryPath() = 0; virtual UCS2String CreateTemporaryFile() = 0; @@ -85,12 +85,6 @@ class PlatformBase /// virtual FILE* OpenLocalFile (const UCS2String& name, const char *mode) = 0; - /// Delete a file. - /// - /// This method removes a file from the local file system. - /// - virtual void DeleteLocalFile (const UCS2String& name) = 0; - /// Check whether a file is allowed to be accessed. /// /// This method shall determine whether a file on the local file system may be accessed for reading, or created @@ -108,7 +102,7 @@ class PlatformBase /// virtual bool AllowLocalFileAccess (const UCS2String& name, const unsigned int fileType, bool write) = 0; - static PlatformBase& GetInstance() { return *self; }; + static PlatformBase& GetInstance(); private: @@ -117,29 +111,25 @@ class PlatformBase /// Default implementation of @ref PlatformBase. /// -class DefaultPlatformBase : public PlatformBase +class DefaultPlatformBase final : public PlatformBase { public: DefaultPlatformBase(); - ~DefaultPlatformBase(); - - virtual UCS2String GetTemporaryPath(); - virtual UCS2String CreateTemporaryFile(); - virtual void DeleteTemporaryFile(const UCS2String& filename); + virtual ~DefaultPlatformBase() override; - virtual bool ReadFileFromURL(OStream *file, const UCS2String& url, const UCS2String& referrer = UCS2String()); + virtual UCS2String GetTemporaryPath() override; + virtual UCS2String CreateTemporaryFile() override; + virtual void DeleteTemporaryFile(const UCS2String& filename) override; - /// @note - /// This implementation only supports ASCII filenames. - virtual FILE* OpenLocalFile(const UCS2String& name, const char *mode); + virtual bool ReadFileFromURL(OStream *file, const UCS2String& url, const UCS2String& referrer = UCS2String()) override; /// @note /// This implementation only supports ASCII filenames. - virtual void DeleteLocalFile(const UCS2String& name); + virtual FILE* OpenLocalFile(const UCS2String& name, const char *mode) override; /// @note /// This implementation grants unrestricted access to any file. - virtual bool AllowLocalFileAccess(const UCS2String& name, const unsigned int fileType, bool write); + virtual bool AllowLocalFileAccess(const UCS2String& name, const unsigned int fileType, bool write) override; }; /// @} @@ -147,5 +137,6 @@ class DefaultPlatformBase : public PlatformBase //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_PLATFORMBASE_H diff --git a/source/base/pov_err.cpp b/source/base/pov_err.cpp index 827b00bf1..0dd27b01f 100644 --- a/source/base/pov_err.cpp +++ b/source/base/pov_err.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,10 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/pov_err.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -183,3 +189,4 @@ std::string Exception::lookup_code(int err, const char *file, unsigned int line) } } +// end of namespace pov_base diff --git a/source/base/pov_err.h b/source/base/pov_err.h index ccfbb0a03..06dd1f5a7 100644 --- a/source/base/pov_err.h +++ b/source/base/pov_err.h @@ -39,10 +39,16 @@ // 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 +// (none at the moment) + // C++ standard header files #include #include +// POV-Ray header files (base module) +// (none at the moment) + namespace pov_base { @@ -132,9 +138,10 @@ class Exception : public std::runtime_error * Create a new exception without location information. * @param str Error message string. */ - Exception(const char *str) throw() : - std::runtime_error(str), xfunction(nullptr), xfile(nullptr), xline(0), xcode(0), - xcodevalid(false), xfrontendnotified(false) + Exception(const char *str) noexcept : + std::runtime_error(str), + xfunction(nullptr), xfile(nullptr), xline(0), + xcode(0), xcodevalid(false), xfrontendnotified(false) {} /** @@ -144,7 +151,11 @@ class Exception : public std::runtime_error * @param li `__LINE__` * @param err Error number. */ - Exception(const char *fn, const char *fi, unsigned int li, int err) throw() : std::runtime_error(Exception::lookup_code(err, fi, li)), xfunction(fn), xfile(fi), xline(li), xcode(err), xcodevalid(true), xfrontendnotified(false) { } + Exception(const char *fn, const char *fi, unsigned int li, int err) noexcept : + std::runtime_error(Exception::lookup_code(err, fi, li)), + xfunction(fn), xfile(fi), xline(li), + xcode(err), xcodevalid(true), xfrontendnotified(false) + {} /** * Create a new exception with code, location information, and an explicit message. @@ -153,7 +164,11 @@ class Exception : public std::runtime_error * @param li `__LINE__` * @param str Error message string. */ - Exception(const char *fn, const char *fi, unsigned int li, const char *str) throw() : std::runtime_error(str), xfunction(fn), xfile(fi), xline(li), xcode(0), xcodevalid(false), xfrontendnotified(false) { } + Exception(const char *fn, const char *fi, unsigned int li, const char *str) noexcept : + std::runtime_error(str), + xfunction(fn), xfile(fi), xline(li), + xcode(0), xcodevalid(false), xfrontendnotified(false) + {} /** * Create a new exception with code, location information, and an explicit message. @@ -162,7 +177,11 @@ class Exception : public std::runtime_error * @param li `__LINE__` * @param str Error message string. */ - Exception(const char *fn, const char *fi, unsigned int li, const string& str) throw() : std::runtime_error(str), xfunction(fn), xfile(fi), xline(li), xcode(0), xcodevalid(false), xfrontendnotified(false) { } + Exception(const char *fn, const char *fi, unsigned int li, const std::string& str) noexcept : + std::runtime_error(str), + xfunction(fn), xfile(fi), xline(li), + xcode(0), xcodevalid(false), xfrontendnotified(false) + {} /** * Create a new exception with code, location information, and an explicit message. @@ -172,7 +191,11 @@ class Exception : public std::runtime_error * @param err Error number. * @param str Error message string. */ - Exception(const char *fn, const char *fi, unsigned int li, int err, const char *str) throw() : std::runtime_error(str), xfunction(fn), xfile(fi), xline(li), xcode(err), xcodevalid(true), xfrontendnotified(false) { } + Exception(const char *fn, const char *fi, unsigned int li, int err, const char *str) noexcept : + std::runtime_error(str), + xfunction(fn), xfile(fi), xline(li), + xcode(err), xcodevalid(true), xfrontendnotified(false) + {} /** * Create a new exception with code, location information, and an explicit message. @@ -182,12 +205,16 @@ class Exception : public std::runtime_error * @param err Error number. * @param str Error message string. */ - Exception(const char *fn, const char *fi, unsigned int li, int err, const string& str) throw() : std::runtime_error(str), xfunction(fn), xfile(fi), xline(li), xcode(err), xcodevalid(true), xfrontendnotified(false) { } + Exception(const char *fn, const char *fi, unsigned int li, int err, const std::string& str) noexcept : + std::runtime_error(str), + xfunction(fn), xfile(fi), xline(li), + xcode(err), xcodevalid(true), xfrontendnotified(false) + {} /** * Destructor. */ - virtual ~Exception() throw() { } + virtual ~Exception() noexcept override { } /** * Determine the function name where the exception occurred. @@ -233,10 +260,10 @@ class Exception : public std::runtime_error /** * Set the front-end notification flag - * @param yes true to indicate notification has been passed on + * @param notified true to indicate notification has been passed on * @return previous value of notification flag */ - bool frontendnotified(bool yes) { bool oldval = xfrontendnotified; xfrontendnotified = yes; return oldval; } + bool frontendnotified(bool notified) { bool oldval = xfrontendnotified; xfrontendnotified = notified; return oldval; } /** * Return the error description for the given code. @@ -265,5 +292,6 @@ class Exception : public std::runtime_error //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_POV_ERR_H diff --git a/source/base/pov_mem.cpp b/source/base/pov_mem.cpp index 4c2fee510..838eea34e 100644 --- a/source/base/pov_mem.cpp +++ b/source/base/pov_mem.cpp @@ -16,7 +16,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 @@ -44,9 +44,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/pov_mem.h" +// C++ variants of C standard header files #include #include +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/pov_err.h" // this must be the last file included @@ -55,6 +60,8 @@ namespace pov_base { +using std::size_t; + /************************************************************************ * AUTHOR * @@ -178,7 +185,7 @@ number of calls to malloc/free and some other statistics. #define MEM_HEADER_ALIGNMENT sizeof(double) #endif - struct mem_node + struct mem_node final { #ifdef MEM_TAG int tag; @@ -770,3 +777,4 @@ void *pov_memmove (void *dest, const void *src, size_t length) } } +// end of namespace pov_base diff --git a/source/base/pov_mem.h b/source/base/pov_mem.h index 261e8c973..6b3fa5267 100644 --- a/source/base/pov_mem.h +++ b/source/base/pov_mem.h @@ -13,7 +13,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 @@ -41,8 +41,18 @@ #ifndef POVRAY_BASE_POV_MEM_H #define POVRAY_BASE_POV_MEM_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 +#include + +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + namespace pov_base { @@ -54,16 +64,17 @@ namespace pov_base void mem_init (void); void mem_release_all (void); -void *pov_malloc (size_t size, const char *file, int line, const char *msg); -void *pov_realloc (void *ptr, size_t size, const char *file, int line, const char *msg); +void *pov_malloc (std::size_t size, const char *file, int line, const char *msg); +void *pov_realloc (void *ptr, std::size_t size, const char *file, int line, const char *msg); void pov_free (void *ptr, const char *file, int line); char *pov_strdup (const char *s); -void *pov_memmove (void *dest, const void *src, size_t length); +void *pov_memmove (void *dest, const void *src, std::size_t length); /// @} /// //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_POV_MEM_H diff --git a/source/base/povassert.h b/source/base/povassert.h new file mode 100644 index 000000000..e763888a1 --- /dev/null +++ b/source/base/povassert.h @@ -0,0 +1,119 @@ +//****************************************************************************** +/// +/// @file base/povassert.h +/// +/// Declarations related to run-time sanity checks. +/// +/// @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_BASE_POVASSERT_H +#define POVRAY_BASE_POVASSERT_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 +#include + +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/pov_err.h" + +namespace pov_base +{ + +//############################################################################## +/// +/// @addtogroup PovBase +/// +/// @{ + +/// A macro wrapping a sequence of statements into a single one. +/// +/// This macro is intended to be used in the definition of other macros that should behave +/// syntactically like a single statement, while evaluating to something that would not normally +/// behave that way. +/// +/// Example: +/// +/// #declare FOO(x) SINGLE_STATEMENT( char buf[128]; foo(buf,x); ) +/// ... +/// if (some_cond) +/// FOO(a); +/// else +/// ... +/// +#define SINGLE_STATEMENT( block ) do { block } while (false) + +/// A macro that does nothing. +/// +/// This macro is intended to be used in the definition of other macros that should behave +/// syntactically like a single statement, while evaluating to a no-operation. +/// +/// Example: +/// +/// #declare MY_ASSERT(x) NO_OP +/// ... +/// if (some_cond) +/// MY_ASSERT(some_test); +/// else +/// ... +/// +#define NO_OP SINGLE_STATEMENT(;) + +/// A macro that tests an expression and, if it evaluates false, throws an exception to allow the +/// application to fail gracefully. +/// +#define POV_ASSERT_SOFT(expr) SINGLE_STATEMENT( if(!(expr)) throw POV_EXCEPTION_CODE(kUncategorizedError); ) + +/// A macro that tests an expression and, if it evaluates false, causes a hard crash to generate a +/// core dump or break to a debugger. +/// +#define POV_ASSERT_HARD(expr) assert(expr) + +/// A macro that does nothing, but is mapped to standard `assert()` during static code analysis. +/// +#ifdef STATIC_CODE_ANALYSIS + #define POV_ASSERT_DISABLE(expr) assert(expr) +#else + #define POV_ASSERT_DISABLE(expr) NO_OP +#endif + + +/// @} +/// +//############################################################################## + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_POVASSERT_H diff --git a/source/base/precomp.h b/source/base/precomp.h index 0ece245bc..9c8636a86 100644 --- a/source/base/precomp.h +++ b/source/base/precomp.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 @@ -45,10 +45,10 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -// Module config header file must be the first file included within POV-Ray unit header files -#include "base/configbase.h" +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED -// C++ variants of standard C header files +// C++ variants of C standard header files +#include #include #include #include @@ -57,7 +57,7 @@ #include #include -// Standard C++ header files +// C++ standard header files #include #include #include @@ -75,12 +75,8 @@ #include #include #include -#include -#include -#include #if POV_MULTITHREADED #include #include #endif #include - diff --git a/source/base/safemath.h b/source/base/safemath.h index 897749ae6..ca71ff596 100644 --- a/source/base/safemath.h +++ b/source/base/safemath.h @@ -24,7 +24,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 @@ -55,11 +55,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" -// Standard C++ header files +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -// POV-Ray base header files +// POV-Ray header files (base module) #include "base/pov_err.h" +#include "base/povassert.h" namespace pov_base { @@ -174,5 +178,6 @@ static inline T SafeSignedProduct(T p1, T p2, T p3 = 1, T p4 = 1) //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_SAFEMATH_H diff --git a/source/base/stringtypes.h b/source/base/stringtypes.h new file mode 100644 index 000000000..e628aece4 --- /dev/null +++ b/source/base/stringtypes.h @@ -0,0 +1,163 @@ +//****************************************************************************** +/// +/// @file base/stringtypes.h +/// +/// Declarations related to string types. +/// +/// @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_BASE_STRINGTYPES_H +#define POVRAY_BASE_STRINGTYPES_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 +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +namespace pov_base +{ + +//############################################################################## +/// +/// @addtogroup PovBase +/// +/// @{ + +//****************************************************************************** + +//****************************************************************************** +/// +/// @name Character Types +/// Character types with encoding semantics. +/// +/// The following types are used throughout POV-Ray instead of the fundamental +/// character types (`char`, `char16_t` and `char32_t`, respectively), +/// to more clearly identify the character encoding associated with them. +/// While they are normally aliased to the fundamental types, static code +/// analysis tools may still treat them as distinct types to ferret out +/// character encoding incompatibilities between different portions of the code. +/// +/// @note +/// There are currently no aliases provided for `wchar_t`. +/// +/// @{ + +/// UTF-16 code unit. +/// This type should be used instead of `char16_t` wherever UTF-16 +/// encoding is guaranteed or required. +/// @note +/// Code handling data of this type must expect and properly handle +/// surrogate pairs. Code that can only handle the BMP subset of UTF-16 +/// should use @ref UCS2Char instead. +/// @note +/// Code that is agnostic about the details of string encoding (including +/// the actual code unit size and whether it is dealing with code points or +/// actual characters) should use @ref POVChar instead. +using UTF16 = char16_t; + +/// Genuine UCS-2 character. +/// This type should be used wherever UCS-2 encoding (aka "BMP-only UTF-16") +/// is required. +/// @deprecated +/// Code that is agnostic about the details of string encoding (including +/// the actual code unit size) should use @ref POVChar instead. Code that +/// requires 16-bit code units but can handle surrogate pairs should use +/// @ref UTF16Unit instead. +using UCS2 = char16_t; + +/// Arbitrary UCS character. +/// This type should be used wherever code needs to operate on proper characters +/// (as opposed to code units), but is not bound to a particular character set +/// (or is bound to using UCS). +using UCS4 = char32_t; + +//****************************************************************************** +/// +/// @name String Types +/// Character string types with encoding semantics. +/// +/// The following types are used throughout POV-Ray instead of the standard C++ +/// string types (`std::string`, `std::u8string`, `std::u16tring` etc.), +/// to more clearly identify the character encoding associated with them. +/// While they are effectively aliased to the standard types, static code +/// analysis tools may still treat them as distinct types to ferret out +/// character encoding incompatibilities between different portions of the code. +/// +/// See @ref base/stringutilities.h for functions to convert between these +/// string types. +/// +/// @note +/// There are currently no aliases provided for `std::wstring`. +/// +/// @{ + +/// Type holding an @glossary{UTF8}-encoded string of characters. +/// +/// @todo +/// Aliasing this as `std::string` may not be ideal, as it creates ambiguity +/// with the use of that same type for ASCII strings. On the other hand, +/// if we use `std::basic_string`, it isn't compatible with +/// the C++11 `u8"..."` UTF-8 string literal notation, which is of type +/// `const char[]`. +/// +using UTF8String = std::string; + +/// Type holding an @glossary{UCS2}-encoded string of characters. +/// +/// @todo +/// UCS-2 is a poor choice for internal string representation, as it cannot +/// encode the full UCS/Unicode character set; we should use either UTF-8 +/// (the best space saver for the strings to be expected), or UTF-32 +/// (allowing easiest processing). We shouldn't use UTF-16, as it needs +/// about just as much special processing as UTF-8 (but people tend to +/// forget that, confusing UTF-16 with UCS-2), and for the expected typical +/// ASCII-heavy use it is less memory-efficient than UTF-8. +/// +using UCS2String = std::basic_string; + +/// @} +/// +//****************************************************************************** + +/// @} +/// +//############################################################################## + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_STRINGTYPES_H diff --git a/source/base/stringutilities.cpp b/source/base/stringutilities.cpp index 5881a3872..003ac0931 100644 --- a/source/base/stringutilities.cpp +++ b/source/base/stringutilities.cpp @@ -36,7 +36,7 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "stringutilities.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include #include @@ -49,6 +49,9 @@ // Boost header files // (none at the moment) +// POV-Ray header files (base module) +#include "base/types.h" + // this must be the last file included #include "base/povdebug.h" @@ -232,8 +235,8 @@ int pov_stricmp(const char *s1, const char *s2) c1 = *s1++; c2 = *s2++; - c1 = (char)toupper(c1); - c2 = (char)toupper(c2); + c1 = (char)std::toupper(c1); + c2 = (char)std::toupper(c2); if(c1 < c2) return -1; @@ -303,6 +306,21 @@ std::size_t UCS2_strlen(const UCS2* str) return (end - str); } +//------------------------------------------------------------------------------ + +int UCS2_strcmp(const UCS2 *s1, const UCS2 *s2) +{ + UCS2 t1, t2; + + while ((t1 = *s1++) == (t2 = *s2++)) + { + if (t1 == '\0') + return 0; + } + + return (t1 - t2); +} + //****************************************************************************** namespace UCS @@ -644,4 +662,5 @@ const Charset* Charset::Get(CharsetID charset) } } -} // end of namespace pov_base +} +// end of namespace pov_base diff --git a/source/base/stringutilities.h b/source/base/stringutilities.h index bbc22a776..d0b20f8c1 100644 --- a/source/base/stringutilities.h +++ b/source/base/stringutilities.h @@ -43,11 +43,15 @@ #include // C++ standard header files +#include + // Boost header files // (none at the moment) // POV-Ray header files (base module) -#include "base/types.h" +#include "base/base_fwd.h" +#include "base/povassert.h" +#include "base/stringtypes.h" namespace pov_base { @@ -71,6 +75,7 @@ int pov_stricmp(const char *, const char *); const char *pov_tsprintf(const char *, ...); std::size_t UCS2_strlen(const UCS2* str); +int UCS2_strcmp(const UCS2* s1, const UCS2* s2); //****************************************************************************** @@ -268,6 +273,7 @@ struct Charset /// //############################################################################## -} // end of namespace pov_base +} +// end of namespace pov_base #endif // POVRAY_BASE_STRINGUTILITIES_H diff --git a/source/base/textstream.cpp b/source/base/textstream.cpp index 0383b7db1..aac2dec6d 100644 --- a/source/base/textstream.cpp +++ b/source/base/textstream.cpp @@ -36,13 +36,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "textstream.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include #include -// Standard C++ header files +// C++ standard header files #include +#include + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/path.h" +#include "base/stringutilities.h" // this must be the last file included #include "base/povdebug.h" @@ -50,6 +56,9 @@ namespace pov_base { +using std::min; +using std::max; + ITextStream::ITextStream() : lineno(1) { @@ -499,3 +508,4 @@ void OTextStream::flush() } } +// end of namespace pov_base diff --git a/source/base/textstream.h b/source/base/textstream.h index 005c3aed1..ac376effd 100644 --- a/source/base/textstream.h +++ b/source/base/textstream.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 @@ -33,27 +33,23 @@ /// //****************************************************************************** -#ifndef TEXTSTREAM_H -#define TEXTSTREAM_H +#ifndef POVRAY_BASE_TEXTSTREAM_H +#define POVRAY_BASE_TEXTSTREAM_H // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/textstream_fwd.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include -// must nuke these since everyone's favourite monopoly's cstdio still defines -// them for some reason (why not just use inlines like everyone else?) -#undef getc -#undef putc -#undef getchar -#undef putchar +// C++ standard header files +// (none at the moment) -// POV-Ray base header files -#include "base/fileinputoutput.h" +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" #include "base/pov_err.h" -#include "base/stringutilities.h" -#include "base/types.h" +#include "base/stringtypes.h" namespace pov_base { @@ -70,7 +66,7 @@ const int ITEXTSTREAM_BUFFER_SIZE = DEFAULT_ITEXTSTREAM_BUFFER_SIZE; class ITextStream { public: - struct FilePos + struct FilePos final { POV_OFF_T offset; POV_LONG lineno; @@ -97,7 +93,7 @@ class ITextStream POV_LONG lineno; }; -class IBufferedTextStream : public ITextStream +class IBufferedTextStream final : public ITextStream { public: IBufferedTextStream(const UCS2 *, unsigned int); @@ -107,19 +103,19 @@ class IBufferedTextStream : public ITextStream /// @param[in] initialLine First line number as known to the user. IBufferedTextStream(const UCS2 *formalName, IStream *byteStream, POV_LONG initialLine = 1); - virtual ~IBufferedTextStream(); + virtual ~IBufferedTextStream() override; - virtual int getchar(); - virtual void ungetchar(int); + virtual int getchar() override; + virtual void ungetchar(int) override; - virtual bool eof() const; - virtual bool seekg(FilePos); - virtual FilePos tellg() const; + virtual bool eof() const override; + virtual bool seekg(FilePos) override; + virtual FilePos tellg() const override; - virtual bool ReadRaw(unsigned char* buf, size_t size); + virtual bool ReadRaw(unsigned char* buf, size_t size) override; /// Formal name of the file, e.g. to be displayed in error messages. - virtual const UCS2 *name() const { return filename.c_str(); }; + virtual const UCS2 *name() const override { return filename.c_str(); }; private: IStream *stream; unsigned char buffer[ITEXTSTREAM_BUFFER_SIZE]; @@ -133,7 +129,7 @@ class IBufferedTextStream : public ITextStream void RefillBuffer(); }; -class IMemTextStream : public ITextStream +class IMemTextStream final : public ITextStream { public: /// @param[in] formalName Name by which the file is known to the user. @@ -142,19 +138,19 @@ class IMemTextStream : public ITextStream /// @param[in] formalStart File position of buffer start as known to the user. IMemTextStream(const UCS2 *formalName, const unsigned char* data, size_t size, const FilePos& formalStart); - virtual ~IMemTextStream(); + virtual ~IMemTextStream() override; - virtual int getchar(); - virtual void ungetchar(int); + virtual int getchar() override; + virtual void ungetchar(int) override; - virtual bool eof() const; - virtual bool seekg(FilePos); - virtual FilePos tellg() const; + virtual bool eof() const override; + virtual bool seekg(FilePos) override; + virtual FilePos tellg() const override; - virtual bool ReadRaw(unsigned char* buf, size_t size); + virtual bool ReadRaw(unsigned char* buf, size_t size) override; /// Formal name of the file, e.g. to be displayed in error messages. - virtual const UCS2 *name() const { return filename.c_str(); }; + virtual const UCS2 *name() const override { return filename.c_str(); }; private: const unsigned char* buffer; size_t bufferoffset; @@ -193,5 +189,6 @@ class OTextStream //############################################################################## } +// end of namespace pov_base -#endif +#endif // POVRAY_BASE_TEXTSTREAM_H diff --git a/source/base/textstream_fwd.h b/source/base/textstream_fwd.h new file mode 100644 index 000000000..cd2f74cbc --- /dev/null +++ b/source/base/textstream_fwd.h @@ -0,0 +1,52 @@ +//****************************************************************************** +/// +/// @file base/textstream_fwd.h +/// +/// Forward declarations related to buffered text file output. +/// +/// @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_BASE_TEXTSTREAM_FWD_H +#define POVRAY_BASE_TEXTSTREAM_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class ITextStream; +class OTextStream; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_TEXTSTREAM_FWD_H diff --git a/source/base/textstreambuffer.cpp b/source/base/textstreambuffer.cpp index b87b5aa6d..19b211c26 100644 --- a/source/base/textstreambuffer.cpp +++ b/source/base/textstreambuffer.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,15 +36,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/textstreambuffer.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include #include #include -// Standard C++ header files +// C++ standard header files #include -// POV-Ray base header files +// POV-Ray header files (base module) #include "base/pov_err.h" #include "base/stringutilities.h" #include "base/types.h" @@ -55,6 +55,9 @@ namespace pov_base { +using std::min; +using std::max; + TextStreamBuffer::TextStreamBuffer(size_t buffersize, unsigned int wrapwidth) { boffset = 0; @@ -332,3 +335,4 @@ void TextStreamBuffer::directflush(const char *str, unsigned int chars) } } +// end of namespace pov_base diff --git a/source/base/textstreambuffer.h b/source/base/textstreambuffer.h index cae6ec84d..86f56fd75 100644 --- a/source/base/textstreambuffer.h +++ b/source/base/textstreambuffer.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 @@ -33,23 +33,22 @@ /// //****************************************************************************** -#ifndef TEXTSTREAMBUFFER_H -#define TEXTSTREAMBUFFER_H +#ifndef POVRAY_BASE_TEXTSTREAMBUFFER_H +#define POVRAY_BASE_TEXTSTREAMBUFFER_H // Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/textstreambuffer_fwd.h" -// C++ variants of standard C header files +// C++ variants of C standard header files #include -#include #include -// must nuke these since everyone's favourite monopoly's cstdio still defines -// them for some reason (why not just use inlines like everyone else?) -#undef getc -#undef putc -#undef getchar -#undef putchar +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) namespace pov_base { @@ -93,5 +92,6 @@ class TextStreamBuffer //############################################################################## } +// end of namespace pov_base -#endif +#endif // POVRAY_BASE_TEXTSTREAMBUFFER_H diff --git a/source/base/textstreambuffer_fwd.h b/source/base/textstreambuffer_fwd.h new file mode 100644 index 000000000..9a223fff9 --- /dev/null +++ b/source/base/textstreambuffer_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file base/textstreambuffer_fwd.h +/// +/// Forward declarations related to buffered text file output. +/// +/// @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_BASE_TEXTSTREAMBUFFER_FWD_H +#define POVRAY_BASE_TEXTSTREAMBUFFER_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_base +{ + +class TextStreamBuffer; + +} +// end of namespace pov_base + +#endif // POVRAY_BASE_TEXTSTREAMBUFFER_FWD_H diff --git a/source/base/timer.cpp b/source/base/timer.cpp index 24aeabbbe..2ffe0270b 100644 --- a/source/base/timer.cpp +++ b/source/base/timer.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 @@ -36,12 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "base/timer.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + // Boost header files #if POV_MULTITHREADED #include #endif -// POV-Ray base header files +// POV-Ray header files (base module) #include "base/types.h" // this must be the last file included @@ -92,3 +96,4 @@ void Timer::Reset() #endif // POV_USE_DEFAULT_TIMER } +// end of namespace pov_base diff --git a/source/base/timer.h b/source/base/timer.h index c02f1744a..6c0204349 100644 --- a/source/base/timer.h +++ b/source/base/timer.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 @@ -39,6 +39,11 @@ // 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) + +// Boost header files #if POV_USE_DEFAULT_TIMER #include #endif @@ -47,6 +52,9 @@ #include "syspovtimer.h" #endif +// POV-Ray header files (base module) +// (none at the moment) + namespace pov_base { @@ -105,7 +113,7 @@ void Delay(unsigned int msec); /// Windows), and/or may be limited to timespans 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: @@ -193,5 +201,6 @@ class Timer //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_TIMER_H diff --git a/source/base/types.h b/source/base/types.h index a382068d5..43e7b22ca 100644 --- a/source/base/types.h +++ b/source/base/types.h @@ -36,13 +36,18 @@ #ifndef POVRAY_BASE_TYPES_H #define POVRAY_BASE_TYPES_H +// Module config header file must be the first file included within POV-Ray unit header files #include "base/configbase.h" +#include "base/base_fwd.h" -#include +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -#include -#include +// POV-Ray header files (base module) +#include "base/pov_err.h" #include "base/pov_mem.h" namespace pov_base @@ -54,23 +59,6 @@ namespace pov_base /// /// @{ -/// A macro wrapping a sequence of statements into a single one. -/// -/// This macro is intended to be used in the definition of other macros that should behave -/// syntactically like a single statement, while evaluating to something that would not normally -/// behave that way. -/// -/// Example: -/// -/// #declare FOO(x) SINGLE_STATEMENT( char buf[128]; foo(buf,x); ) -/// ... -/// if (some_cond) -/// FOO(a); -/// else -/// ... -/// -#define SINGLE_STATEMENT( block ) do { block } while (false) - //****************************************************************************** /// /// @name Theoretical Integer Limits @@ -209,44 +197,6 @@ namespace pov_base /// //****************************************************************************** -/// A macro that does nothing. -/// -/// This macro is intended to be used in the definition of other macros that should behave -/// syntactically like a single statement, while evaluating to a no-operation. -/// -/// Example: -/// -/// #declare MY_ASSERT(x) NO_OP -/// ... -/// if (some_cond) -/// MY_ASSERT(some_test); -/// else -/// ... -/// -#define NO_OP SINGLE_STATEMENT(;) - -/// A macro that tests an expression and, if it evaluates false, throws an exception to allow the -/// application to fail gracefully. -/// -#define POV_ASSERT_SOFT(expr) SINGLE_STATEMENT( if(!(expr)) throw POV_EXCEPTION_CODE(kUncategorizedError); ) - -/// A macro that tests an expression and, if it evaluates false, causes a hard crash to generate a -/// core dump or break to a debugger. -/// -#define POV_ASSERT_HARD(expr) assert(expr) - -/// A macro that does nothing, but is mapped to standard `assert()` during static code analysis. -/// -#ifdef STATIC_CODE_ANALYSIS - #define POV_ASSERT_DISABLE(expr) assert(expr) -#else - #define POV_ASSERT_DISABLE(expr) NO_OP -#endif - -// from ; we don't want to always type the namespace for these. -using std::min; -using std::max; - // from ; we don't want to always type the namespace for these. using std::abs; using std::acos; @@ -272,11 +222,7 @@ using std::sqrt; using std::tan; using std::tanh; -/// 5-dimensional vector type shared between parser and splines. -/// @todo Make this obsolete. -typedef DBL EXPRESS[5]; - -struct POVRect +struct POVRect final { unsigned int top; unsigned int left; @@ -293,7 +239,7 @@ struct POVRect }; /// Legacy (v3.5) `charset` setting. -enum LegacyCharset +enum LegacyCharset : int { kUnspecified, ///< Global settings `charset` not specified. kASCII, ///< Global settings `charset ascii` specified. @@ -317,7 +263,7 @@ enum LegacyCharset /// code page numbers. If you add more character sets, please stick to this scheme wherever /// applicable, or use negative values. /// -enum class CharsetID +enum class CharsetID : int { kUndefined = 0, ///< Special value representing undefined character set. @@ -332,30 +278,6 @@ enum class CharsetID ///< remapping U+0000-U+00FF to U+F000-U+F0FF. }; -/// Type holding an @glossary{UTF8}-encoded string of characters. -/// -/// @todo -/// Aliasing this as `std::string` may not be ideal, as it creates ambiguity -/// with the use of that same type for ASCII strings. On the other hand, -/// if we use `std::basic_string`, it isn't compatible with -/// the C++11 `u8"..."` UTF-8 string literal notation, which is of type -/// `const char[]`. -/// -using UTF8String = std::string; - -/// Type holding an @glossary{UCS2}-encoded string of characters. -/// -/// @todo -/// UCS-2 is a poor choice for internal string representation, as it cannot -/// encode the full UCS/Unicode character set; we should use either UTF-8 -/// (the best space saver for the strings to be expected), or UTF-32 -/// (allowing easiest processing). We shouldn't use UTF-16, as it needs -/// about just as much special processing as UTF-8 (but people tend to -/// forget that, confusing UTF-16 with UCS-2), and for the expected typical -/// ASCII-heavy use it is less memory-efficient than UTF-8. -/// -using UCS2String = std::basic_string; - enum GammaMode { /** @@ -410,5 +332,6 @@ class ThreadData //############################################################################## } +// end of namespace pov_base #endif // POVRAY_BASE_TYPES_H diff --git a/source/core/bounding/bounding.cpp b/source/core/bounding/bounding.cpp index b20602849..f9c5eb90c 100644 --- a/source/core/bounding/bounding.cpp +++ b/source/core/bounding/bounding.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 @@ -36,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/bounding/bounding.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 (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -45,3 +53,4 @@ namespace pov // nothing in here yet } +// end of namespace pov diff --git a/source/core/bounding/bounding.h b/source/core/bounding/bounding.h index db8187360..e5ee39c6c 100644 --- a/source/core/bounding/bounding.h +++ b/source/core/bounding/bounding.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.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 (core module) +// (none at the moment) + namespace pov { @@ -56,5 +64,6 @@ namespace pov //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BOUNDING_H diff --git a/source/core/bounding/boundingbox.cpp b/source/core/bounding/boundingbox.cpp index bbd94ce78..d02901029 100644 --- a/source/core/bounding/boundingbox.cpp +++ b/source/core/bounding/boundingbox.cpp @@ -12,7 +12,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 @@ -40,8 +40,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/bounding/boundingbox.h" +// C++ variants of C standard header files +#include + +// 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) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/object.h" @@ -53,6 +61,8 @@ namespace pov { +using std::vector; + const int BUNCHING_FACTOR = 4; // Initial number of entries in a priority queue. const int INITIAL_PRIORITY_QUEUE_SIZE = 256; @@ -842,13 +852,13 @@ bool sort_and_split(BBOX_TREE **Root, BBOX_TREE **&Finite, size_t *numOfFiniteOb switch(Axis) { case X: - QSORT(reinterpret_cast(&Finite[first]), size, sizeof(BBOX_TREE *), compboxes); + std::qsort(Finite + first, size, sizeof(BBOX_TREE*), compboxes); break; case Y: - QSORT(reinterpret_cast(&Finite[first]), size, sizeof(BBOX_TREE *), compboxes); + std::qsort(Finite + first, size, sizeof(BBOX_TREE*), compboxes); break; case Z: - QSORT(reinterpret_cast(&Finite[first]), size, sizeof(BBOX_TREE *), compboxes); + std::qsort(Finite + first, size, sizeof(BBOX_TREE*), compboxes); break; } @@ -915,3 +925,4 @@ bool sort_and_split(BBOX_TREE **Root, BBOX_TREE **&Finite, size_t *numOfFiniteOb } } +// end of namespace pov diff --git a/source/core/bounding/boundingbox.h b/source/core/bounding/boundingbox.h index 434a15171..928a13e71 100644 --- a/source/core/bounding/boundingbox.h +++ b/source/core/bounding/boundingbox.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 @@ -38,9 +38,21 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/bounding/boundingbox_fwd.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/math/matrix.h" +#include "core/render/ray_fwd.h" namespace pov { @@ -52,11 +64,8 @@ namespace pov /// /// @{ -class Intersection; -class Ray; struct RayObjectCondition; class RenderStatistics; -class TraceThreadData; /***************************************************************************** * Global preprocessor defines @@ -82,7 +91,7 @@ typedef GenericVector3d BBoxVector3d; /// bounding data in min/max format rather than lowerLeft/size, and making sure /// high-precision values are rounded towards positive/negative infinity as appropriate. /// -struct BoundingBox +struct BoundingBox final { BBoxVector3d lowerLeft; BBoxVector3d size; @@ -154,19 +163,15 @@ inline bool Inside_BBox(const Vector3d& point, const BoundingBox& bbox) /// Structure holding bounding box data in min/max format. /// -struct MinMaxBoundingBox +struct MinMaxBoundingBox final { BBoxVector3d pmin; BBoxVector3d pmax; }; -typedef struct BBox_Tree_Struct BBOX_TREE; -typedef BBOX_TREE* BBoxTreePtr; -typedef const BBOX_TREE* ConstBBoxTreePtr; - -struct BBox_Tree_Struct +struct BBox_Tree_Struct final { - BBOX_TREE **Node; // If node: children; if leaf: element + BBox_Tree_Struct **Node; // If node: children; if leaf: element BoundingBox BBox; // Bounding box of this node short Entries; // Number of sub-nodes in this node bool Infinite; // Flag if node is infinite @@ -174,7 +179,7 @@ struct BBox_Tree_Struct typedef bool VECTORB[3]; -class Rayinfo +class Rayinfo final { public: BBoxVector3d origin; ///< Ray's origin. @@ -241,7 +246,7 @@ enum BBoxDirection /// `std::priority_queue` becase we make use of Clear(), an operation /// which `std::priority_queue` does not support. /// -class BBoxPriorityQueue +class BBoxPriorityQueue final { public: @@ -255,13 +260,13 @@ class BBoxPriorityQueue protected: - struct Qelem + struct Qelem final { DBL depth; ConstBBoxTreePtr node; }; - vector mQueue; + std::vector mQueue; }; @@ -270,7 +275,7 @@ class BBoxPriorityQueue ******************************************************************************/ void Build_BBox_Tree(BBOX_TREE **Root, size_t numOfFiniteObjects, BBOX_TREE **&Finite, size_t numOfInfiniteObjects, BBOX_TREE **Infinite, size_t& maxfinitecount); -void Build_Bounding_Slabs(BBOX_TREE **Root, vector& objects, unsigned int& numberOfFiniteObjects, unsigned int& numberOfInfiniteObjects, unsigned int& numberOfLightSources); +void Build_Bounding_Slabs(BBOX_TREE **Root, std::vector& objects, unsigned int& numberOfFiniteObjects, unsigned int& numberOfInfiniteObjects, unsigned int& numberOfLightSources); void Recompute_BBox(BoundingBox *bbox, const TRANSFORM *trans); bool Intersect_BBox_Tree(BBoxPriorityQueue& pqueue, const BBOX_TREE *Root, const Ray& ray, Intersection *Best_Intersection, TraceThreadData *Thread); @@ -294,5 +299,6 @@ inline void BOUNDS_VOLUME(DBL& a, const BoundingBox& b) //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BOUNDINGBOX_H diff --git a/source/core/bounding/boundingbox_fwd.h b/source/core/bounding/boundingbox_fwd.h new file mode 100644 index 000000000..6c8185335 --- /dev/null +++ b/source/core/bounding/boundingbox_fwd.h @@ -0,0 +1,55 @@ +//****************************************************************************** +/// +/// @file core/bounding/boundingbox_fwd.h +/// +/// Forward declarations related to bounding boxes. +/// +/// @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_CORE_BOUNDINGBOX_FWD_H +#define POVRAY_CORE_BOUNDINGBOX_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +struct BBox_Tree_Struct; + +using BBOX_TREE = BBox_Tree_Struct; ///< @deprecated +using BBoxTreePtr = BBox_Tree_Struct*; +using ConstBBoxTreePtr = const BBox_Tree_Struct*; + +} +// end of namespace pov + +#endif // POVRAY_CORE_BOUNDINGBOX_FWD_H diff --git a/source/core/bounding/boundingcylinder.cpp b/source/core/bounding/boundingcylinder.cpp index d9b738ee5..e420375d1 100644 --- a/source/core/bounding/boundingcylinder.cpp +++ b/source/core/bounding/boundingcylinder.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 @@ -33,9 +33,17 @@ /// //****************************************************************************** -// Module config header file must be the first file included within POV-Ray unit header files +// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/bounding/boundingcylinder.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" // this must be the last file included @@ -44,6 +52,8 @@ namespace pov { +using std::vector; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -711,3 +721,4 @@ void Destroy_BCyl(BCYL *BCyl) } } +// end of namespace pov diff --git a/source/core/bounding/boundingcylinder.h b/source/core/bounding/boundingcylinder.h index 1f35527fb..6cf91eb69 100644 --- a/source/core/bounding/boundingcylinder.h +++ b/source/core/bounding/boundingcylinder.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 @@ -38,7 +38,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/bounding/boundingcylinder_fwd.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/vector.h" namespace pov @@ -64,24 +75,22 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct BCyl_Struct BCYL; -typedef struct BCyl_Entry_Struct BCYL_ENTRY; -typedef struct BCyl_Intersection_Struct BCYL_INT; - -struct BCyl_Intersection_Struct +struct BCyl_Intersection_Struct final { int n; /* Number of cylinder hit */ DBL d[2]; /* Intersection distance(s) */ DBL w[2]; /* Intersection parameter(s) */ }; +using BCYL_INT = BCyl_Intersection_Struct; ///< @deprecated -struct BCyl_Entry_Struct +struct BCyl_Entry_Struct final { short r1, r2; /* Index of min/max segment radius */ short h1, h2; /* Index of min/max segmnet height */ }; +using BCYL_ENTRY = BCyl_Entry_Struct; ///< @deprecated -struct BCyl_Struct +struct BCyl_Struct final { int number; /* Number of bounding cylinders. */ short nradius; /* Number of different bound-radii. */ @@ -99,12 +108,13 @@ struct BCyl_Struct BCYL *Create_BCyl (int, const DBL *, const DBL *, const DBL *, const DBL *); void Destroy_BCyl (BCYL *); -int Intersect_BCyl (const BCYL *BCyl, vector& Intervals, vector& rint, vector& hint, const Vector3d& P, const Vector3d& D); +int Intersect_BCyl (const BCYL *BCyl, std::vector& Intervals, std::vector& rint, std::vector& hint, const Vector3d& P, const Vector3d& D); /// @} /// //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BOUNDINGCYLINDER_H diff --git a/source/core/bounding/boundingcylinder_fwd.h b/source/core/bounding/boundingcylinder_fwd.h new file mode 100644 index 000000000..15be9cf05 --- /dev/null +++ b/source/core/bounding/boundingcylinder_fwd.h @@ -0,0 +1,53 @@ +//****************************************************************************** +/// +/// @file core/bounding/boundingcylinder_fwd.h +/// +/// Forward declarations related to bounding cylinders (used by lathe and sor). +/// +/// @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_CORE_BOUNDINGCYLINDER_FWD_H +#define POVRAY_CORE_BOUNDINGCYLINDER_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +struct BCyl_Struct; + +using BCYL = BCyl_Struct; ///< @deprecated + +} +// end of namespace pov + +#endif // POVRAY_CORE_BOUNDINGCYLINDER_FWD_H diff --git a/source/core/bounding/boundingsphere.cpp b/source/core/bounding/boundingsphere.cpp index 67b824f5b..2554afaef 100644 --- a/source/core/bounding/boundingsphere.cpp +++ b/source/core/bounding/boundingsphere.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,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/bounding/boundingsphere.h" +// C++ variants of C standard header files +#include + +// C++ standard header files #include +// POV-Ray header files (base module) +#include "base/pov_mem.h" + +// POV-Ray header files (core module) #include "core/coretypes.h" // this must be the last file included @@ -46,6 +54,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -428,13 +439,13 @@ static int sort_and_split(BSPHERE_TREE **Root, BSPHERE_TREE ***Elements, int *nE switch(Axis) { case X: - QSORT(reinterpret_cast(*Elements + first), size, sizeof(BSPHERE_TREE *), comp_elements); + std::qsort(*Elements + first, size, sizeof(BSPHERE_TREE*), comp_elements); break; case Y: - QSORT(reinterpret_cast(*Elements + first), size, sizeof(BSPHERE_TREE *), comp_elements); + std::qsort(*Elements + first, size, sizeof(BSPHERE_TREE*), comp_elements); break; case Z: - QSORT(reinterpret_cast(*Elements + first), size, sizeof(BSPHERE_TREE *), comp_elements); + std::qsort(*Elements + first, size, sizeof(BSPHERE_TREE*), comp_elements); break; } @@ -647,3 +658,4 @@ void Destroy_Bounding_Sphere_Hierarchy(BSPHERE_TREE *Node) } } +// end of namespace pov diff --git a/source/core/bounding/boundingsphere.h b/source/core/bounding/boundingsphere.h index a0b7c792d..936c1d5d8 100644 --- a/source/core/bounding/boundingsphere.h +++ b/source/core/bounding/boundingsphere.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/vector.h" namespace pov @@ -55,15 +63,14 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct BSphere_Tree_Struct BSPHERE_TREE; - -struct BSphere_Tree_Struct +struct BSphere_Tree_Struct final { short Entries; /* Number of components (node if 0) */ Vector3d C; /* Center of bounding sphere */ DBL r2; /* Radius^2 of bounding sphere */ - BSPHERE_TREE **Node; /* if node: children; if leaf: element */ + BSphere_Tree_Struct **Node; /* if node: children; if leaf: element */ }; +using BSPHERE_TREE = BSphere_Tree_Struct; ///< @deprecated /***************************************************************************** @@ -78,5 +85,6 @@ void Destroy_Bounding_Sphere_Hierarchy (BSPHERE_TREE *Node); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BOUNDINGSPHERE_H diff --git a/source/core/bounding/bsptree.cpp b/source/core/bounding/bsptree.cpp index 241788229..b9aa0b847 100644 --- a/source/core/bounding/bsptree.cpp +++ b/source/core/bounding/bsptree.cpp @@ -36,11 +36,23 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/bounding/bsptree.h" -#include +// C++ variants of C standard header files +#if BSP_WRITEBOUNDS || BSP_READNODES || BSP_WRITETREE +#include +#endif + +// C++ standard header files +#include #include +#if BSP_WRITEBOUNDS || BSP_READNODES || BSP_WRITETREE +#include +#endif +// POV-Ray header files (base module) +#include "base/stringutilities.h" #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/render/ray.h" #include "core/shape/box.h" @@ -50,6 +62,10 @@ namespace pov { +using std::min; +using std::max; +using std::vector; + #ifndef BSP_READNODES #define BSP_READNODES 0 #endif @@ -71,6 +87,17 @@ namespace pov const unsigned int NODE_PROGRESS_INTERVAL = 1000; +//****************************************************************************** + +void BSPTree::Mailbox::clear() +{ + count = 0; + // using memset here as std::fill may not be fast with every standard libaray [trf] + std::memset(objects.data(), 0, objects.size() * sizeof(unsigned int)); +} + +//****************************************************************************** + // we allow the values to be set by users to promote experimentation with tree // building. at a later date we may remove this facility since using compile-time // constants is more efficient. @@ -281,11 +308,11 @@ void BSPTree::build(const Progress& progress, const Objects& objects, splits[Z].resize(objects.size() * 2); #if BSP_WRITEBOUNDS || BSP_READNODES || BSP_WRITETREE - string tempstr = UCS2toSysString(inputFile); + std::string tempstr = UCS2toSysString(inputFile); if (tempstr.empty() == true) tempstr = "default"; - string::size_type pos = tempstr.find_last_of('.'); - if (pos != string::npos) + std::string::size_type pos = tempstr.find_last_of('.'); + if (pos != std::string::npos) tempstr.erase(pos); #endif @@ -896,6 +923,7 @@ void BSPTree::ReadRecursive(const Progress& progress, FILE *infile, unsigned int } } +//****************************************************************************** BSPIntersectFunctor::BSPIntersectFunctor(Intersection& bi, const Ray& r, vector& objs, TraceThreadData *t) : found(false), @@ -933,6 +961,7 @@ bool BSPIntersectFunctor::operator()() const return found; } +//****************************************************************************** BSPIntersectCondFunctor::BSPIntersectCondFunctor(Intersection& bi, const Ray& r, vector& objs, TraceThreadData *t, const RayObjectCondition& prec, const RayObjectCondition& postc) : @@ -977,6 +1006,7 @@ bool BSPIntersectCondFunctor::operator()() const return found; } +//****************************************************************************** BSPInsideCondFunctor::BSPInsideCondFunctor(Vector3d o, vector& objs, TraceThreadData *t, const PointObjectCondition& prec, const PointObjectCondition& postc) : @@ -1004,4 +1034,7 @@ bool BSPInsideCondFunctor::operator()() const return found; } +//****************************************************************************** + } +// end of namespace pov diff --git a/source/core/bounding/bsptree.h b/source/core/bounding/bsptree.h index 3523a31d5..8efe5c703 100644 --- a/source/core/bounding/bsptree.h +++ b/source/core/bounding/bsptree.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 @@ -39,10 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -#include -#include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" namespace pov @@ -55,16 +61,16 @@ namespace pov /// /// @{ -class BSPTree +class BSPTree final { public: - class Mailbox + class Mailbox final { friend class BSPTree; public: inline Mailbox(unsigned int range) : objects((range >> 5) + 1), count(0) { } - inline void clear() { count = 0; memset(&objects[0], 0, objects.size() * sizeof(unsigned int)); } // using memset here as std::fill may not be fast with every standard libaray [trf] + void clear(); inline unsigned int size() const { return count; } inline bool insert(unsigned int i) @@ -79,12 +85,11 @@ class BSPTree } private: /// bit marking object (by index) in mailbox - vector objects; + std::vector objects; /// number of objects in mailbox unsigned int count; - /// unavailable - Mailbox(); + Mailbox() = delete; }; class Objects @@ -142,7 +147,7 @@ class BSPTree private: - struct Node + struct Node final { enum NodeType { @@ -181,7 +186,7 @@ class BSPTree }; }; - struct Split + struct Split final { enum Side { @@ -201,13 +206,13 @@ class BSPTree inline bool operator<(const Split& r) const { return (plane < r.plane); } - struct CompareIndex + struct CompareIndex final { inline bool operator()(const Split& left, const Split& right) const { return (left.index < right.index); } }; }; - struct TraceStack + struct TraceStack final { unsigned int inode; float rentry; @@ -215,11 +220,11 @@ class BSPTree }; /// array of all nodes - vector nodes; + std::vector nodes; /// array of all object pointer lists - vector lists; + std::vector lists; /// splits, only used while building tree - vector splits[3]; + std::vector splits[3]; /// lower left corner of bounding box Vector3d bmin; /// upper right corner of bounding box @@ -253,7 +258,7 @@ class BSPTree /// tree depth counter POV_LONG treeDepthCounter; /// object index list (only used while building tree) - vector indices; + std::vector indices; void BuildRecursive(const Progress& progress, const Objects& objects, unsigned int inode, unsigned int indexbegin, unsigned int indexend, MinMaxBoundingBox& cell, unsigned int maxlevel); void SetObjectNode(unsigned int inode, unsigned int indexbegin, unsigned int indexend); @@ -264,18 +269,18 @@ class BSPTree }; -class BSPIntersectFunctor : public BSPTree::Intersect +class BSPIntersectFunctor final : public BSPTree::Intersect { public: - BSPIntersectFunctor(Intersection& bi, const Ray& r, vector& objs, TraceThreadData *t); - virtual bool operator()(unsigned int index, double& maxdist); - virtual bool operator()() const; + BSPIntersectFunctor(Intersection& bi, const Ray& r, std::vector& objs, TraceThreadData *t); + virtual bool operator()(unsigned int index, double& maxdist) override; + virtual bool operator()() const override; private: bool found; - vector& objects; + std::vector& objects; Intersection& bestisect; const Ray& ray; BBoxVector3d origin; @@ -284,19 +289,19 @@ class BSPIntersectFunctor : public BSPTree::Intersect TraceThreadData *traceThreadData; }; -class BSPIntersectCondFunctor : public BSPTree::Intersect +class BSPIntersectCondFunctor final : public BSPTree::Intersect { public: - BSPIntersectCondFunctor(Intersection& bi, const Ray& r, vector& objs, TraceThreadData *t, + BSPIntersectCondFunctor(Intersection& bi, const Ray& r, std::vector& objs, TraceThreadData *t, const RayObjectCondition& prec, const RayObjectCondition& postc); - virtual bool operator()(unsigned int index, double& maxdist); - virtual bool operator()() const; + virtual bool operator()(unsigned int index, double& maxdist) override; + virtual bool operator()() const override; private: bool found; - vector& objects; + std::vector& objects; Intersection& bestisect; const Ray& ray; BBoxVector3d origin; @@ -307,19 +312,19 @@ class BSPIntersectCondFunctor : public BSPTree::Intersect const RayObjectCondition& postcondition; }; -class BSPInsideCondFunctor : public BSPTree::Inside +class BSPInsideCondFunctor final : public BSPTree::Inside { public: - BSPInsideCondFunctor(Vector3d o, vector& objs, TraceThreadData *t, + BSPInsideCondFunctor(Vector3d o, std::vector& objs, TraceThreadData *t, const PointObjectCondition& prec, const PointObjectCondition& postc); - virtual bool operator()(unsigned int index); - virtual bool operator()() const; + virtual bool operator()(unsigned int index) override; + virtual bool operator()() const override; private: bool found; - vector& objects; + std::vector& objects; Vector3d origin; const PointObjectCondition& precondition; const PointObjectCondition& postcondition; @@ -331,5 +336,6 @@ class BSPInsideCondFunctor : public BSPTree::Inside //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BSPTREE_H diff --git a/source/core/colour/spectral.cpp b/source/core/colour/spectral.cpp index f4aa709a0..3c9083419 100644 --- a/source/core/colour/spectral.cpp +++ b/source/core/colour/spectral.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 @@ -36,9 +36,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/colour/spectral.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/colour.h" #include "base/mathutil.h" +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -376,7 +386,7 @@ static RGBColour SpectralHueIntegral[SPECTRAL_HUE_TABLE_SIZE] = { MathColour SpectralBand::GetHueIntegral(double wavelength) { double tableOffset = clip((wavelength-SPECTRAL_HUE_TABLE_BASE)/SPECTRAL_HUE_TABLE_STEP, 0.0, SPECTRAL_HUE_TABLE_SIZE-1.0); - int tableIndex = min((int)tableOffset, SPECTRAL_HUE_TABLE_SIZE-2); + int tableIndex = std::min((int)tableOffset, SPECTRAL_HUE_TABLE_SIZE-2); tableOffset -= tableIndex; return ToMathColour((1.0-tableOffset) * SpectralHueIntegral[tableIndex] + tableOffset * SpectralHueIntegral[tableIndex+1]); } @@ -384,3 +394,4 @@ MathColour SpectralBand::GetHueIntegral(double wavelength) #endif } +// end of namespace pov diff --git a/source/core/colour/spectral.h b/source/core/colour/spectral.h index d9eca453f..f7de1e0a0 100644 --- a/source/core/colour/spectral.h +++ b/source/core/colour/spectral.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 @@ -39,8 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/colour.h" +// POV-Ray header files (core module) +// (none at the moment) + namespace pov { @@ -59,7 +67,7 @@ using namespace pov_base; #define SPECTRAL_CENTER ((SPECTRAL_VIOLET + SPECTRAL_RED)/2) // TODO - maybe should define this as yellow /// Class representing a spectral band. -class SpectralBand +class SpectralBand final { public: /// Default Constructor. @@ -120,6 +128,7 @@ class SpectralBand }; } +// end of namespace pov namespace pov_base { @@ -158,5 +167,6 @@ RGBColour FromRGB(const MathColour& col); //############################################################################## } +// end of namespace pov_base #endif // POVRAY_CORE_SPECTRAL_H diff --git a/source/core/configcore.h b/source/core/configcore.h index bee21bdde..284b0f3bb 100644 --- a/source/core/configcore.h +++ b/source/core/configcore.h @@ -10,7 +10,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 @@ -42,9 +42,6 @@ #include "base/configbase.h" #include "syspovconfigcore.h" -// C++ variants of C standard header files -#include - //############################################################################## /// /// @defgroup PovCoreConfig Core Compile-Time Configuration @@ -204,10 +201,6 @@ /// //****************************************************************************** -#ifndef QSORT - #define QSORT(a,b,c,d) std::qsort((a),(b),(c),(d)) -#endif - /// @def TRY_OPTIMIZED_NOISE /// Whether the platform provides dynamic optimized noise. /// @@ -227,6 +220,53 @@ #endif #endif +/// @def C99_COMPATIBLE_RADIOSITY +/// @deprecated +/// This is effectively a legacy alias for @ref POV_PORTABLE_RADIOSITY, +/// which takes precedence if defined. +/// +#ifndef C99_COMPATIBLE_RADIOSITY + #define C99_COMPATIBLE_RADIOSITY 0 +#endif + +/// @def POV_PORTABLE_RADIOSITY +/// Whether to implement radiosity octree in a portable manner. +/// +/// This setting selects one of several implementations of certain operations +/// in the octree code: +/// +/// - @ref Pow2Floor(): Rounds a positive value down towards the next lower +/// power of 2. +/// - @ref BiasedIntLog2(): Computes the (biased) integer base-2 logarithm +/// of a positive value. +/// - @ref BiasedIntPow2(): Computes 2 to a (biased) integer ppwer. +/// +/// The available implementations are based on the following primitives: +/// +/// | Value | `Pow2Floor` | `BiasedIntLog2` | `BiasedIntPow2` | Bias | Prerequisites | +/// | ----: | :---------------------------- | :-------- | :-------------------- | ----: | :------------------------------------ | +/// | 0 | `float` bit bashing ||| +127 | `float` must be IEEE 754 "binary32" | +/// | 1 | `logbf`, `pow` | `logbf` | `int` bit shifting | 0 | `float` must be radix-2 | +/// | 2 | `ilogbf`, `int` bit shifting | `ilogbf` | ^ | ^ | ^ | +/// | 3 | `logb`, `pow` | `logb` | ^ | ^ | `double` must be radix-2 | +/// | 4 | `ilogb`, `int` bit shifting | `ilogb` | ^ | ^ | ^ | +/// | 5 | `double` bit bashing ||| +1023 | `double` must be IEEE 754 "binary64" | +/// | 6 | `frexpf`, `ldexpf` | `frexpf` | `ldexpf` | 0 | none | +/// | 7 | `ilogbf`, `ldexpf` | `ilogbf` | `ldexpf` | ^ | `float` must be radix-2 | +/// | 8 | `frexp`, `ldexp` | `frexp` | `ldexp` | ^ | none | +/// | 9 | `ilogb`, `ldexp` | `ilogb` | `ldexp` | ^ | `double` must be radix-2 | +/// +/// @note +/// Settings 1-4 are deprecated, due to their restricted numeric range. +/// +/// @note +/// This setting defaults to @ref C99_COMPATIBLE_RADIOSITY, which in turn +/// defaults to 0. +/// +#ifndef POV_PORTABLE_RADIOSITY + #define POV_PORTABLE_RADIOSITY C99_COMPATIBLE_RADIOSITY +#endif + //****************************************************************************** /// /// @name Debug Settings. diff --git a/source/core/core_fwd.h b/source/core/core_fwd.h new file mode 100644 index 000000000..28fe8da7f --- /dev/null +++ b/source/core/core_fwd.h @@ -0,0 +1,65 @@ +//****************************************************************************** +/// +/// @file core/core_fwd.h +/// +/// Forward declarations of core module referenced by other modules. +/// +/// @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_CORE_FWD_H +#define POVRAY_CORE_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class Interior; + +class Intersection; + +class LightSource; + +class ObjectBase; +using ObjectPtr = ObjectBase*; +using ConstObjectPtr = const ObjectBase*; + +class PhotonShootingUnit; + +class SceneData; + +class TraceThreadData; + +} +// end of namespace pov + +#endif // POVRAY_CORE_FWD_H diff --git a/source/core/coretypes.h b/source/core/coretypes.h index fb09e243f..f075ee7b0 100644 --- a/source/core/coretypes.h +++ b/source/core/coretypes.h @@ -36,16 +36,31 @@ #ifndef POVRAY_CORE_CORETYPES_H #define POVRAY_CORE_CORETYPES_H +// Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/core_fwd.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +#include +#include + +// Boost header files +#include +// POV-Ray header files (base module) #include "base/colour.h" #include "base/messenger.h" -#include "base/types.h" -#include "base/textstream.h" +#include "base/povassert.h" +#include "base/stringtypes.h" +// POV-Ray header files (core module) #include "core/math/vector.h" +#include "core/render/ray_fwd.h" namespace pov { @@ -58,10 +73,6 @@ namespace pov using namespace pov_base; -// from ; we don't want to always type the namespace for these. -using std::min; -using std::max; - // from ; we don't want to always type the namespace for these. using std::abs; using std::acos; @@ -94,11 +105,8 @@ inline T Sqr(T a) return a * a; } -class ObjectBase; -typedef ObjectBase * ObjectPtr; -typedef const ObjectBase * ConstObjectPtr; - -typedef struct Transform_Struct TRANSFORM; +struct Transform_Struct; +using TRANSFORM = Transform_Struct; ///< @deprecated /// @} /// @@ -108,11 +116,17 @@ typedef struct Transform_Struct TRANSFORM; /// /// @{ -typedef struct Pattern_Struct TPATTERN; -typedef struct Texture_Struct TEXTURE; -typedef struct Pigment_Struct PIGMENT; -typedef struct Tnormal_Struct TNORMAL; -typedef struct Finish_Struct FINISH; +struct Pattern_Struct; +struct Texture_Struct; +struct Pigment_Struct; +struct Tnormal_Struct; +struct Finish_Struct; + +using TPATTERN = Pattern_Struct; ///< @deprecated +using TEXTURE = Texture_Struct; ///< @deprecated +using PIGMENT = Pigment_Struct; ///< @deprecated +using TNORMAL = Tnormal_Struct; ///< @deprecated +using FINISH = Finish_Struct; ///< @deprecated typedef TEXTURE* TexturePtr; @@ -124,7 +138,7 @@ typedef TEXTURE* TexturePtr; /// /// @{ -class Media +class Media final { public: int Type; @@ -154,7 +168,7 @@ class Media DBL AA_Threshold; int AA_Level; - vector Density; + std::vector Density; Media(); Media(const Media&); @@ -176,7 +190,7 @@ class Media /// @{ class SubsurfaceInterior; -class Interior +class Interior final { public: int hollow, Disp_NElems; @@ -184,8 +198,8 @@ class Interior SNGL Caustics, Old_Refract; SNGL Fade_Distance, Fade_Power; MathColour Fade_Colour; - vector media; - shared_ptr subsurface; + std::vector media; + std::shared_ptr subsurface; Interior(); Interior(const Interior&); @@ -195,11 +209,12 @@ class Interior void PostProcess(); private: - Interior& operator=(const Interior&); + + Interior& operator=(const Interior&) = delete; }; -typedef shared_ptr InteriorPtr; -typedef shared_ptr ConstInteriorPtr; +typedef std::shared_ptr InteriorPtr; +typedef std::shared_ptr ConstInteriorPtr; /// @} /// @@ -211,8 +226,8 @@ typedef shared_ptr ConstInteriorPtr; struct BasicPattern; -typedef shared_ptr PatternPtr; -typedef shared_ptr ConstPatternPtr; +typedef std::shared_ptr PatternPtr; +typedef std::shared_ptr ConstPatternPtr; struct Pattern_Struct @@ -230,47 +245,44 @@ struct Pattern_Struct /// /// @{ -typedef struct Material_Struct MATERIAL; - -struct Material_Struct +struct Material_Struct final { TEXTURE *Texture; TEXTURE *Interior_Texture; InteriorPtr interior; }; - -class LightSource; +using MATERIAL = Material_Struct; ///< @deprecated template -class RefPool +class RefPool final { public: RefPool() { } - ~RefPool() { for(typename vector::iterator i(pool.begin()); i != pool.end(); i++) delete *i; pool.clear(); } + ~RefPool() { for(typename std::vector::iterator i(pool.begin()); i != pool.end(); i++) delete *i; pool.clear(); } T *alloc() { if(pool.empty()) return new T(); T *ptr(pool.back()); pool.pop_back(); return ptr; } void release(T *ptr) { pool.push_back(ptr); } private: - vector pool; + std::vector pool; - RefPool(const RefPool&); - RefPool& operator=(RefPool&); + RefPool(const RefPool&) = delete; + RefPool& operator=(RefPool&) = delete; }; template -struct RefClearDefault +struct RefClearDefault final { void operator()(T&) { } }; template -struct RefClearContainer +struct RefClearContainer final { void operator()(T& p) { p.clear(); } }; -template > -class Ref +template> +class Ref final { public: Ref(RefPool& p) : pool(p), ptr(p.alloc()) { } @@ -285,12 +297,12 @@ class Ref RefPool& pool; T *ptr; - Ref(); - Ref(const Ref&); - Ref& operator=(Ref&); + Ref() = delete; + Ref(const Ref&) = delete; + Ref& operator=(Ref&) = delete; }; -class ObjectDebugHelper +class ObjectDebugHelper final { public: int Index; @@ -320,7 +332,7 @@ typedef unsigned short HF_VAL; /// /// This class holds various information on a ray-object intersection. /// -class Intersection +class Intersection final { public: @@ -443,7 +455,7 @@ class Intersection ~Intersection() { } }; -typedef std::stack > IStackData; +typedef std::stack> IStackData; typedef RefPool IStackPool; typedef Ref IStack; @@ -470,26 +482,26 @@ struct BasicRay struct TraceTicket; -class Ray; - struct RayObjectCondition { + virtual ~RayObjectCondition() {} virtual bool operator()(const Ray& ray, ConstObjectPtr object, DBL data) const = 0; }; -struct TrueRayObjectCondition : public RayObjectCondition +struct TrueRayObjectCondition final : public RayObjectCondition { - virtual bool operator()(const Ray&, ConstObjectPtr, DBL) const { return true; } + virtual bool operator()(const Ray&, ConstObjectPtr, DBL) const override { return true; } }; struct PointObjectCondition { + virtual ~PointObjectCondition() {} virtual bool operator()(const Vector3d& point, ConstObjectPtr object) const = 0; }; -struct TruePointObjectCondition : public PointObjectCondition +struct TruePointObjectCondition final : public PointObjectCondition { - virtual bool operator()(const Vector3d&, ConstObjectPtr) const { return true; } + virtual bool operator()(const Vector3d&, ConstObjectPtr) const override { return true; } }; /// @} @@ -500,7 +512,7 @@ struct TruePointObjectCondition : public PointObjectCondition /// /// @{ -struct FrameSettings +struct FrameSettings final { DBL Clock_Value; // May change between frames of an animation int FrameNumber; // May change between frames of an animation @@ -541,9 +553,9 @@ class FractalRules virtual bool Bound (const BasicRay&, const Fractal *, DBL *, DBL *) const = 0; }; -typedef shared_ptr FractalRulesPtr; +typedef std::shared_ptr FractalRulesPtr; -struct QualityFlags +struct QualityFlags final { bool ambientOnly : 1; bool quickColour : 1; @@ -581,8 +593,6 @@ struct QualityFlags /// /// @{ -class TraceThreadData; - class GenericFunctionContext { public: @@ -607,8 +617,8 @@ class GenericFunctionContextFactory inline void intrusive_ptr_add_ref(GenericFunctionContextFactory* f) { ++f->mRefCounter; } inline void intrusive_ptr_release(GenericFunctionContextFactory* f) { if (!(--f->mRefCounter)) delete f; } -typedef intrusive_ptr GenericFunctionContextFactoryIPtr; -typedef GenericFunctionContextFactory* GenericFunctionContextFactoryTPtr; +typedef boost::intrusive_ptr GenericFunctionContextFactoryIPtr; +typedef GenericFunctionContextFactory* GenericFunctionContextFactoryTPtr; struct SourcePosition { @@ -658,7 +668,7 @@ typedef GenericCustomFunction GenericScalarFunction; typedef GenericScalarFunction* GenericScalarFunctionPtr; template -class GenericCustomFunctionInstance +class GenericCustomFunctionInstance final { public: inline GenericCustomFunctionInstance(GenericCustomFunction* pFn, TraceThreadData* pThreadData) : @@ -730,7 +740,8 @@ class GenericCustomFunctionInstance bool mReInit; private: - GenericCustomFunctionInstance(); + + GenericCustomFunctionInstance() = delete; }; typedef GenericCustomFunctionInstance GenericScalarFunctionInstance; @@ -741,5 +752,6 @@ typedef GenericScalarFunctionInstance* GenericScalarFunctionInstancePtr; //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_CORETYPES_H diff --git a/source/core/lighting/lightgroup.cpp b/source/core/lighting/lightgroup.cpp index db1a42ec3..ae4b228c5 100644 --- a/source/core/lighting/lightgroup.cpp +++ b/source/core/lighting/lightgroup.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,6 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/lighting/lightgroup.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/lighting/lightsource.h" #include "core/scene/object.h" #include "core/shape/csg.h" @@ -46,6 +56,8 @@ namespace pov { +using std::vector; + void Promote_Local_Lights_Recursive(CompoundObject *Object, vector& Lights); @@ -252,3 +264,4 @@ bool Check_Photon_Light_Group(ConstObjectPtr Object) } } +// end of namespace pov diff --git a/source/core/lighting/lightgroup.h b/source/core/lighting/lightgroup.h index dc251ff0e..0b0f9b46c 100644 --- a/source/core/lighting/lightgroup.h +++ b/source/core/lighting/lightgroup.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 @@ -39,7 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" +#include "core/shape/csg_fwd.h" namespace pov { @@ -51,8 +60,6 @@ namespace pov /// /// @{ -class CSG; - void Promote_Local_Lights(CSG *Object); bool Check_Photon_Light_Group(ConstObjectPtr Object); @@ -61,5 +68,6 @@ bool Check_Photon_Light_Group(ConstObjectPtr Object); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_LIGHTGROUP_H diff --git a/source/core/lighting/lightsource.cpp b/source/core/lighting/lightsource.cpp index 8e34015e2..c4b86c8aa 100644 --- a/source/core/lighting/lightsource.cpp +++ b/source/core/lighting/lightsource.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,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/lighting/lightsource.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/object.h" @@ -657,3 +665,4 @@ void LightSource::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThre } } +// end of namespace pov diff --git a/source/core/lighting/lightsource.h b/source/core/lighting/lightsource.h index efe9b747d..dd4ef7289 100644 --- a/source/core/lighting/lightsource.h +++ b/source/core/lighting/lightsource.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 @@ -39,6 +39,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/core_fwd.h" +#include "core/render/ray_fwd.h" + namespace pov { @@ -49,9 +60,6 @@ namespace pov /// /// @{ -class LightSource; -class Ray; - //****************************************************************************** /// /// @name Object Types @@ -87,5 +95,6 @@ DBL cubic_spline(DBL low,DBL high,DBL pos); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_LIGHTSOURCE_H diff --git a/source/core/lighting/photons.cpp b/source/core/lighting/photons.cpp index 08ed3c83b..b54dfe633 100644 --- a/source/core/lighting/photons.cpp +++ b/source/core/lighting/photons.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 @@ -43,6 +43,9 @@ #include #include +// POV-Ray header files (base module) +#include "base/povassert.h" + // POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" @@ -70,6 +73,10 @@ namespace pov { +using std::min; +using std::max; +using std::vector; + /* ------------------------------------------------------ */ /* global variables */ /* ------------------------------------------------------ */ @@ -92,7 +99,7 @@ constexpr int PHOTON_BLOCK_MASK = PHOTON_BLOCK_SIZE - 1; static_assert(PHOTON_BLOCK_POWER < std::numeric_limits::digits, "PHOTON_BLOCK_POWER too large"); -class PhotonMap::PhotonBlock +class PhotonMap::PhotonBlock final { public: inline Photon& operator[](size_t i) @@ -110,7 +117,7 @@ class PhotonMap::PhotonBlock //****************************************************************************** -PhotonTrace::PhotonTrace(shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, Trace::CooperateFunctor& cf) : +PhotonTrace::PhotonTrace(std::shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, Trace::CooperateFunctor& cf) : Trace(sd, td, qf, cf, mediaPhotons, noRadiosity), mediaPhotons(sd, td, this, new PhotonGatherer(&sd->mediaPhotonMap, sd->photonSettings)) { @@ -932,7 +939,7 @@ void PhotonTrace::addSurfacePhoton(const Vector3d& Point, const Vector3d& Origin } -PhotonMediaFunction::PhotonMediaFunction(shared_ptr sd, TraceThreadData *td, Trace *t, PhotonGatherer *pg) : +PhotonMediaFunction::PhotonMediaFunction(std::shared_ptr sd, TraceThreadData *td, Trace *t, PhotonGatherer *pg) : MediaFunction(td, t, pg), sceneData(sd) { @@ -2624,7 +2631,7 @@ int LightTargetCombo::computeMergedFlags() } -void LightTargetCombo::computeAnglesAndDeltas(shared_ptr sceneData) +void LightTargetCombo::computeAnglesAndDeltas(std::shared_ptr sceneData) { shootingDirection.compute(); @@ -2683,5 +2690,5 @@ void LightTargetCombo::computeAnglesAndDeltas(shared_ptr sceneData) } } -} // end of namespace - +} +// end of namespace pov diff --git a/source/core/lighting/photons.h b/source/core/lighting/photons.h index 8937e6712..e58fcb1a8 100644 --- a/source/core/lighting/photons.h +++ b/source/core/lighting/photons.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 @@ -38,9 +38,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/lighting/photons_fwd.h" + +// C++ variants of C standard header files +// (none at the moment) // C++ standard header files +#include #include +#include + +// POV-Ray header files (base module) +// (none at the moment) // POV-Ray header files (core module) #include "core/material/media.h" @@ -61,7 +70,7 @@ using namespace pov_base; #define MEDIA_INTERACTION 1 /* ------------------------------------------------------ */ -class ScenePhotonSettings +class ScenePhotonSettings final { public: ScenePhotonSettings() @@ -156,7 +165,7 @@ class ScenePhotonSettings typedef float PhotonScalar; typedef GenericVector3d PhotonVector3d; -struct Photon +struct Photon final { void init(unsigned char _info) { @@ -173,7 +182,7 @@ struct Photon /* photon map */ /* ------------------------------------------------------ */ -class PhotonMap +class PhotonMap final { private: @@ -257,7 +266,7 @@ typedef Photon* PhotonPtr; /* ------------------------------------------------------ */ /* photon gatherer */ /* ------------------------------------------------------ */ -class GatheredPhotons +class GatheredPhotons final { public: // priority queue arrays @@ -271,7 +280,7 @@ class GatheredPhotons ~GatheredPhotons(); }; -class PhotonGatherer +class PhotonGatherer final { public: ScenePhotonSettings& photonSettings; @@ -301,30 +310,30 @@ class PhotonGatherer void FullPQInsert(Photon *photon, DBL d); }; -class PhotonMediaFunction : public MediaFunction +class PhotonMediaFunction final : public MediaFunction { public: - PhotonMediaFunction(shared_ptr sd, TraceThreadData *td, Trace *t, PhotonGatherer *pg); + PhotonMediaFunction(std::shared_ptr sd, TraceThreadData *td, Trace *t, PhotonGatherer *pg); void ComputeMediaAndDepositPhotons(MediaVector& medias, const Ray& ray, const Intersection& isect, MathColour& colour); protected: void DepositMediaPhotons(MathColour& colour, MediaVector& medias, LightSourceEntryVector& lights, MediaIntervalVector& mediaintervals, const Ray& ray, int minsamples, bool ignore_photons, bool use_scattering, bool all_constant_and_light_ray); private: - shared_ptr sceneData; + std::shared_ptr sceneData; void addMediaPhoton(const Vector3d& Point, const Vector3d& Origin, const MathColour& LightCol, DBL depthDiff); }; -class PhotonTrace : public Trace +class PhotonTrace final : public Trace { public: - PhotonTrace(shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, Trace::CooperateFunctor& cf); - ~PhotonTrace(); + PhotonTrace(std::shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, Trace::CooperateFunctor& cf); + virtual ~PhotonTrace() override; - virtual DBL TraceRay(Ray& ray, MathColour& colour, ColourChannel&, COLC weight, bool continuedRay, DBL maxDepth = 0.0); + virtual DBL TraceRay(Ray& ray, MathColour& colour, ColourChannel&, COLC weight, bool continuedRay, DBL maxDepth = 0.0) override; protected: - virtual void ComputeLightedTexture(MathColour& LightCol, ColourChannel&, const TEXTURE *Texture, vector& warps, const Vector3d& ipoint, const Vector3d& rawnormal, Ray& ray, COLC weight, Intersection& isect); + virtual void ComputeLightedTexture(MathColour& LightCol, ColourChannel&, const TEXTURE *Texture, std::vector& warps, const Vector3d& ipoint, const Vector3d& rawnormal, Ray& ray, COLC weight, Intersection& isect) override; bool ComputeRefractionForPhotons(const FINISH* finish, Interior *interior, const Vector3d& ipoint, Ray& ray, const Vector3d& normal, const Vector3d& rawnormal, MathColour& colour, COLC weight); bool TraceRefractionRayForPhotons(const FINISH* finish, const Vector3d& ipoint, Ray& ray, Ray& nray, DBL ior, DBL n, const Vector3d& normal, const Vector3d& rawnormal, const Vector3d& localnormal, MathColour& colour, COLC weight); private: @@ -334,14 +343,11 @@ class PhotonTrace : public Trace void addSurfacePhoton(const Vector3d& Point, const Vector3d& Origin, const MathColour& LightCol); }; -// forward declaration -class LightTargetCombo; - /* ------------------------------------------------------ */ /* photon map builder */ /* ------------------------------------------------------ */ -class ShootingDirection +class ShootingDirection final { public: ShootingDirection(LightSource* light, ObjectPtr target):light(light),target(target) {} @@ -357,7 +363,7 @@ class ShootingDirection }; -class LightTargetCombo +class LightTargetCombo final { public: LightTargetCombo(LightSource *light, ObjectPtr target):light(light),target(target),shootingDirection(light,target) {} @@ -371,11 +377,11 @@ class LightTargetCombo ShootingDirection shootingDirection; int computeMergedFlags(); - void computeAnglesAndDeltas(shared_ptr sceneData); + void computeAnglesAndDeltas(std::shared_ptr sceneData); }; -class PhotonShootingUnit +class PhotonShootingUnit final { public: PhotonShootingUnit(LightSource* light, ObjectPtr target):lightAndObject(light,target) {} @@ -385,7 +391,7 @@ class PhotonShootingUnit -class SinCosOptimizations +class SinCosOptimizations final { public: // speed optimization data - sin/cos stored in two arrays @@ -411,5 +417,6 @@ void ChooseRay(BasicRay &NewRay, const Vector3d& Normal, const Vector3d& Raw_Nor //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_PHOTONS_H diff --git a/source/core/lighting/photons_fwd.h b/source/core/lighting/photons_fwd.h new file mode 100644 index 000000000..3b874b44a --- /dev/null +++ b/source/core/lighting/photons_fwd.h @@ -0,0 +1,53 @@ +//****************************************************************************** +/// +/// @file core/lighting/photons_fwd.h +/// +/// Forward declarations related to Photon Mapping. +/// +/// @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_CORE_PHOTONS_FWD_H +#define POVRAY_CORE_PHOTONS_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class LightTargetCombo; +class PhotonMap; +class PhotonTrace; + +} +// end of namespace pov + +#endif // POVRAY_CORE_PHOTONS_FWD_H diff --git a/source/core/lighting/radiosity.cpp b/source/core/lighting/radiosity.cpp index df9956184..f90aa086f 100644 --- a/source/core/lighting/radiosity.cpp +++ b/source/core/lighting/radiosity.cpp @@ -11,7 +11,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 @@ -63,11 +63,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/lighting/radiosity.h" +// C++ variants of C standard header files #include + +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/fileinputoutput.h" +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/lighting/photons.h" #include "core/render/ray.h" #include "core/scene/scenedata.h" @@ -82,6 +88,9 @@ namespace pov using namespace pov_base; +using std::min; +using std::max; + // #define RAD_GRADIENT 1 // [CLi] gradient seems to provide no gain at best, and may actually cause artifacts // #define SAW_METHOD 1 // #define SAW_METHOD_ROOT 2 @@ -106,7 +115,7 @@ const int PRETRACE_STEP_LOADED = std::numeric_limits::max(); // d #define BRILLIANCE_EPSILON 1e-5 // structure used to gather weighted average during tree traversal -struct WT_AVG +struct WT_AVG final { MathColour Weights_Times_Illuminances; // Aggregates during traversal DBL Weights; // Aggregates during traversal @@ -152,7 +161,7 @@ inline QualityFlags GetRadiosityQualityFlags(const SceneRadiositySettings& rs, c static const unsigned int BLOCK_POOL_UNIT_SIZE = 32; -struct RadiosityCache::BlockPool::PoolUnit +struct RadiosityCache::BlockPool::PoolUnit final { PoolUnit *next; ot_block_struct blocks[BLOCK_POOL_UNIT_SIZE]; @@ -284,7 +293,7 @@ RadiosityRecursionSettings* SceneRadiositySettings::GetRecursionSettings(bool fi return recSettings; } -RadiosityFunction::RadiosityFunction(shared_ptr sd, TraceThreadData *td, const SceneRadiositySettings& rs, +RadiosityFunction::RadiosityFunction(std::shared_ptr sd, TraceThreadData *td, const SceneRadiositySettings& rs, RadiosityCache& rc, Trace::CooperateFunctor& cf, bool ft, const Vector3d& camera) : threadData(td), trace(sd, td, GetRadiosityQualityFlags(rs, QualityFlags(9)), cf, media, *this), // TODO FIXME - the only reason we can safely hard-code level-9 quality here is because radiosity happens to be disabled at lower settings @@ -1239,19 +1248,6 @@ ot_node_struct *RadiosityCache::GetNode(RenderStatistics* stats, const ot_id_str // If there is no root yet, create one. This is a first-time-through if (octree.root == nullptr) { - // CLi moved C99_COMPATIBLE_RADIOSITY check from ot_newroot() to ot_ins() `nullptr` root handling section - // (no need to do this again and again for every new node inserted) -#if(C99_COMPATIBLE_RADIOSITY == 0) - if((sizeof(int) != 4) || (sizeof(float) != 4)) - { - throw POV_EXCEPTION_STRING("Radiosity is not available in this unofficial version because\n" - "the person who made this unofficial version available did not\n" - "properly check for compatibility on your platform.\n" - "Look for C99_COMPATIBLE_RADIOSITY in the source code to find\n" - "out how to correct this."); - } -#endif - // now is the time to lock the tree for modification #if POV_MULTITHREADED treeLock.lock(); @@ -1771,4 +1767,5 @@ bool RadiosityCache::AverageNearBlock(ot_block_struct *block, void *void_info) return true; } -} // end of namespace +} +// end of namespace pov diff --git a/source/core/lighting/radiosity.h b/source/core/lighting/radiosity.h index 3136c6808..8689fcef0 100644 --- a/source/core/lighting/radiosity.h +++ b/source/core/lighting/radiosity.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 @@ -39,24 +39,30 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +// Boost header files #if POV_MULTITHREADED #include #endif +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +#include "base/path_fwd.h" + +// POV-Ray header files (core module) #include "core/lighting/photons.h" // TODO FIXME - make PhotonGatherer class visible only as a pointer #include "core/material/media.h" // TODO FIXME - make MediaFunction class visible only as a pointer #include "core/math/randcosweighted.h" #include "core/render/trace.h" // TODO FIXME - make Trace class visible only as a pointer -#include "core/support/octree.h" // TODO FIXME - this should only be included in radiosity.cpp +#include "core/support/octree_fwd.h" #include "core/support/statistics.h" -namespace pov_base -{ -class Path; -} - namespace pov { @@ -67,8 +73,6 @@ namespace pov /// /// @{ -class ViewData; - struct ot_block_struct; struct ot_node_struct; struct ot_id_struct; @@ -85,7 +89,7 @@ static const unsigned int RADIOSITY_MAX_SAMPLE_DIRECTIONS = kRandCosWeightedC // - it gives the highest possible number of "secondary strides", those being -274, 115, -44, -17, -7 and 3 // settings as effective for a particular bounce depth during a particular trace step -struct RadiosityRecursionSettings +struct RadiosityRecursionSettings final { // true "tweakables" unsigned int raysPerSample; // number of sample rays to shoot per sample @@ -104,7 +108,7 @@ struct RadiosityRecursionSettings // settings as specified in the scene file; // naming conventions are as per the respective scene file parameter -class SceneRadiositySettings +class SceneRadiositySettings final { public: @@ -168,12 +172,12 @@ class SceneRadiositySettings RadiosityRecursionSettings* GetRecursionSettings (bool final) const; }; -class RadiosityCache +class RadiosityCache final { public: - class BlockPool + class BlockPool final { friend class RadiosityCache; public: @@ -223,7 +227,7 @@ class RadiosityCache private: - struct Octree + struct Octree final { ot_node_struct *root; #if POV_MULTITHREADED @@ -234,7 +238,7 @@ class RadiosityCache Octree() : root(nullptr) {} }; - vector blockPools; // block pools ready to be re-used + std::vector blockPools; // block pools ready to be re-used #if POV_MULTITHREADED boost::mutex blockPoolsMutex; // lock this when accessing blockPools #endif @@ -254,16 +258,15 @@ class RadiosityCache static bool AverageNearBlock(ot_block_struct *block, void *void_info); }; -class RadiosityFunction : public Trace::RadiosityFunctor +class RadiosityFunction final : public Trace::RadiosityFunctor { public: - static const unsigned int TILE_MAX = OT_TILE_MAX; - static const unsigned int PRETRACE_INVALID = OT_PASS_INVALID; - static const unsigned int PRETRACE_FIRST = OT_PASS_FIRST; - static const unsigned int PRETRACE_MAX = OT_PASS_MAX; - static const unsigned int FINAL_TRACE = OT_PASS_FINAL; - static const unsigned int DEPTH_MAX = (OT_DEPTH_MAX < 20 ? OT_DEPTH_MAX : 20); + static const unsigned int PRETRACE_INVALID = kOctreePassInvalid; + static const unsigned int PRETRACE_FIRST = kOctreePassFirst; + static const unsigned int PRETRACE_MAX = kOctreePassMax; + static const unsigned int FINAL_TRACE = kOctreePassFinal; + static const unsigned int DEPTH_MAX = (kOctreeDepthMax < 20 ? kOctreeDepthMax : 20); static const unsigned int MAX_NEAREST_COUNT = 20; // initializes radiosity module from: @@ -274,9 +277,9 @@ class RadiosityFunction : public Trace::RadiosityFunctor // cf - the cooperate functor (whatever that is - some thing that handles inter-thread communication?) // ft - whether this is the final trace (i.e. not a radiosity pretrace step) // camera - position of the camera - RadiosityFunction(shared_ptr sd, TraceThreadData *td, + RadiosityFunction(std::shared_ptr sd, TraceThreadData *td, const SceneRadiositySettings& rs, RadiosityCache& rc, Trace::CooperateFunctor& cf, bool ft, const Vector3d& camera); - virtual ~RadiosityFunction(); + virtual ~RadiosityFunction() override; // looks up the ambient value for a certain point // ipoint - point on the surface @@ -285,10 +288,10 @@ class RadiosityFunction : public Trace::RadiosityFunctor // brilliance - brilliance // ambient_colour - (output) the ambient color at this point // weight - the base "weight" of the traced ray (used to compare against ADC bailout) - virtual void ComputeAmbient(const Vector3d& ipoint, const Vector3d& raw_normal, const Vector3d& layer_normal, DBL brilliance, MathColour& ambient_colour, DBL weight, TraceTicket& ticket); + virtual void ComputeAmbient(const Vector3d& ipoint, const Vector3d& raw_normal, const Vector3d& layer_normal, DBL brilliance, MathColour& ambient_colour, DBL weight, TraceTicket& ticket) override; // checks whether the specified recursion depth is still within the configured limits - virtual bool CheckRadiosityTraceLevel(const TraceTicket& ticket); + virtual bool CheckRadiosityTraceLevel(const TraceTicket& ticket) override; // retrieves top level statistics information to drive pretrace re-iteration virtual void GetTopLevelStats(long& queryCount, float& reuse); @@ -298,7 +301,7 @@ class RadiosityFunction : public Trace::RadiosityFunctor private: - class SampleDirectionGenerator + class SampleDirectionGenerator final { public: /// constructor @@ -329,7 +332,7 @@ class RadiosityFunction : public Trace::RadiosityFunctor }; // structure to store precomputed effective parameters for each recursion depth - struct RecursionParameters + struct RecursionParameters final { SampleDirectionGenerator directionGenerator; // sample generator for this recursion depth IntStatsIndex statsId; // statistics id for per-pass per-recursion statistics @@ -367,6 +370,7 @@ class RadiosityFunction : public Trace::RadiosityFunctor /// //############################################################################## -} // end of namespace +} +// end of namespace pov #endif // POVRAY_CORE_RADIOSITY_H diff --git a/source/core/lighting/subsurface.cpp b/source/core/lighting/subsurface.cpp index d3bd5078f..06ec56bfc 100644 --- a/source/core/lighting/subsurface.cpp +++ b/source/core/lighting/subsurface.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 @@ -36,8 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/lighting/subsurface.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/mathutil.h" +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -111,4 +119,5 @@ PreciseMathColour SubsurfaceInterior::GetReducedAlbedo(const MathColour& diffuse return result; } -} // end of namespace +} +// end of namespace pov diff --git a/source/core/lighting/subsurface.h b/source/core/lighting/subsurface.h index 559804411..95daa9a65 100644 --- a/source/core/lighting/subsurface.h +++ b/source/core/lighting/subsurface.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 @@ -39,9 +39,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// Boost header files #include #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" namespace pov @@ -58,7 +67,8 @@ using boost::flyweights::flyweight; using boost::flyweights::key_value; /// Class storing SSLT data precomputed based on index of refraction. -class SubsurfaceInterior { +class SubsurfaceInterior final +{ public: @@ -70,13 +80,14 @@ class SubsurfaceInterior { static const int ReducedAlbedoSamples = 100; // precomputed reduced albedo for selected values of diffuse reflectance - struct PrecomputedReducedAlbedo { + struct PrecomputedReducedAlbedo final + { float reducedAlbedo[ReducedAlbedoSamples+1]; PrecomputedReducedAlbedo(float ior); PreciseColourChannel operator()(PreciseColourChannel diffuseReflectance) const; }; - flyweight > precomputedReducedAlbedo; + flyweight> precomputedReducedAlbedo; }; /// Approximation to the Fresnel diffuse reflectance. @@ -100,6 +111,7 @@ inline double FresnelDiffuseReflectance(double eta) /// //############################################################################## -} // end of namespace +} +// end of namespace pov #endif // POVRAY_CORE_SUBSURFACE_H diff --git a/source/core/material/blendmap.cpp b/source/core/material/blendmap.cpp index 62b265908..20a8bb4a4 100644 --- a/source/core/material/blendmap.cpp +++ b/source/core/material/blendmap.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,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/blendmap.h" -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) +#include "base/povassert.h" + +// POV-Ray header files (core module) #include "core/material/normal.h" #include "core/material/pigment.h" #include "core/material/texture.h" @@ -159,9 +165,9 @@ TextureBlendMapPtr Create_Blend_Map (BlendMapTypeId type) ******************************************************************************/ template -shared_ptr Copy_Blend_Map (const shared_ptr& Old) +std::shared_ptr Copy_Blend_Map (const std::shared_ptr& Old) { - return shared_ptr(Old); + return std::shared_ptr(Old); } template ColourBlendMapPtr Copy_Blend_Map (const ColourBlendMapPtr& Old); @@ -221,3 +227,4 @@ template void BlendMap::Set(const Vector& data); template void BlendMap::Set(const Vector& data); } +// end of namespace pov diff --git a/source/core/material/blendmap.h b/source/core/material/blendmap.h index b4304fbb9..9b59a2b07 100644 --- a/source/core/material/blendmap.h +++ b/source/core/material/blendmap.h @@ -4,13 +4,11 @@ /// /// Declarations related to blend maps. /// -/// @note `frame.h` contains other colour stuff. -/// /// @copyright /// @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 @@ -41,6 +39,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) + namespace pov { @@ -64,7 +73,7 @@ enum BlendMapTypeId }; template -struct BlendMapEntry +struct BlendMapEntry final { SNGL value; DATA_T Vals; @@ -80,7 +89,7 @@ class BlendMap typedef BlendMapEntry Entry; typedef Entry* EntryPtr; typedef const Entry* EntryConstPtr; - typedef vector Vector; + typedef std::vector Vector; BlendMap(BlendMapTypeId type); virtual ~BlendMap() {} @@ -99,15 +108,16 @@ class BlendMap ******************************************************************************/ template -shared_ptr Create_Blend_Map (BlendMapTypeId type); +std::shared_ptr Create_Blend_Map (BlendMapTypeId type); template -shared_ptr Copy_Blend_Map (const shared_ptr& Old); +std::shared_ptr Copy_Blend_Map (const std::shared_ptr& Old); /// @} /// //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BLENDMAP_H diff --git a/source/core/material/interior.cpp b/source/core/material/interior.cpp index 7c74e0006..783d3c4e8 100644 --- a/source/core/material/interior.cpp +++ b/source/core/material/interior.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,6 +36,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/interior.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/lighting/subsurface.h" #include "core/material/texture.h" @@ -60,7 +71,7 @@ Interior::Interior() hollow = false; - subsurface = shared_ptr(); + subsurface = std::shared_ptr(); } Interior::Interior(const Interior& source) @@ -74,7 +85,7 @@ Interior::Interior(const Interior& source) media = source.media; hollow = source.hollow; IOR = source.IOR; - subsurface = shared_ptr(source.subsurface); + subsurface = std::shared_ptr(source.subsurface); Caustics = source.Caustics; } @@ -84,13 +95,13 @@ Interior::~Interior() void Interior::Transform(const TRANSFORM *trans) { - for(vector::iterator i(media.begin());i != media.end(); i++) + for(std::vector::iterator i(media.begin());i != media.end(); i++) i->Transform(trans); } void Interior::PostProcess() { - for(vector::iterator i(media.begin());i != media.end(); i++) + for(std::vector::iterator i(media.begin());i != media.end(); i++) i->PostProcess(); } @@ -205,3 +216,4 @@ void Destroy_Material(MATERIAL *Material) } } +// end of namespace pov diff --git a/source/core/material/interior.h b/source/core/material/interior.h index 73634016e..88d7fcc44 100644 --- a/source/core/material/interior.h +++ b/source/core/material/interior.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" namespace pov @@ -77,5 +85,6 @@ void Destroy_Material(MATERIAL *); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_INTERIOR_H diff --git a/source/core/material/media.cpp b/source/core/material/media.cpp index 6137841c8..c8572f7ad 100644 --- a/source/core/material/media.cpp +++ b/source/core/material/media.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,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/media.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/lighting/lightsource.h" #include "core/lighting/photons.h" #include "core/material/pattern.h" @@ -52,6 +60,10 @@ namespace pov { +using std::min; +using std::max; +using std::vector; + Media::Media() { Type = ISOTROPIC_SCATTERING; @@ -1205,3 +1217,4 @@ void MediaFunction::ComputeMediaScatteringAttenuation(MediaVector& medias, MathC } } +// end of namespace pov diff --git a/source/core/material/media.h b/source/core/material/media.h index 5e867c569..f33be6901 100644 --- a/source/core/material/media.h +++ b/source/core/material/media.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 @@ -39,6 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/render/trace.h" namespace pov @@ -62,16 +72,16 @@ enum SCATTERING_TYPES = 5 }; -void Transform_Density(vector& Density, const TRANSFORM *Trans); +void Transform_Density(std::vector& Density, const TRANSFORM *Trans); class MediaFunction : public Trace::MediaFunctor { public: MediaFunction(TraceThreadData *td, Trace *t, PhotonGatherer *pg); - virtual void ComputeMedia(vector& mediasource, const Ray& ray, Intersection& isect, MathColour& colour, ColourChannel& transm); - virtual void ComputeMedia(const RayInteriorVector& mediasource, const Ray& ray, Intersection& isect, MathColour& colour, ColourChannel& transm); - virtual void ComputeMedia(MediaVector& medias, const Ray& ray, Intersection& isect, MathColour& colour, ColourChannel& transm); + virtual void ComputeMedia(std::vector& mediasource, const Ray& ray, Intersection& isect, MathColour& colour, ColourChannel& transm) override; + virtual void ComputeMedia(const RayInteriorVector& mediasource, const Ray& ray, Intersection& isect, MathColour& colour, ColourChannel& transm) override; + virtual void ComputeMedia(MediaVector& medias, const Ray& ray, Intersection& isect, MathColour& colour, ColourChannel& transm) override; protected: /// pseudo-random number sequence RandomDoubleSequence randomNumbers; @@ -109,5 +119,6 @@ class MediaFunction : public Trace::MediaFunctor //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_MEDIA_H diff --git a/source/core/material/noise.cpp b/source/core/material/noise.cpp index 86e920e0d..3b67f01bc 100644 --- a/source/core/material/noise.cpp +++ b/source/core/material/noise.cpp @@ -17,7 +17,7 @@ /// ---------------------------------------------------------------------------- /// /// 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 @@ -45,12 +45,27 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/noise.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/povassert.h" + +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Static functions ******************************************************************************/ @@ -171,7 +186,7 @@ void Initialize_Noise() sintab[i] = sin((DBL)i / SINTABSIZE * TWO_M_PI); } -void Initialize_Waves(vector& waveFrequencies, vector& waveSources, unsigned int numberOfWaves) +void Initialize_Waves(std::vector& waveFrequencies, std::vector& waveSources, unsigned int numberOfWaves) { Vector3d point; @@ -709,3 +724,4 @@ const OptimizedNoiseInfo* GetOptimizedNoise(std::string name) #endif // TRY_OPTIMIZED_NOISE } +// end of namespace pov diff --git a/source/core/material/noise.h b/source/core/material/noise.h index 984559332..4a3f94e80 100644 --- a/source/core/material/noise.h +++ b/source/core/material/noise.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 @@ -39,6 +39,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/warp.h" #include "core/math/vector.h" @@ -97,7 +108,7 @@ extern ALIGN16 DBL RTable[]; ******************************************************************************/ void Initialize_Noise (void); -void Initialize_Waves(vector& waveFrequencies, vector& waveSources, unsigned int numberOfWaves); +void Initialize_Waves(std::vector& waveFrequencies, std::vector& waveSources, unsigned int numberOfWaves); void Free_Noise_Tables (void); DBL SolidNoise(const Vector3d& P); @@ -111,7 +122,7 @@ typedef DBL(*NoiseFunction) (const Vector3d& EPoint, int noise_generator); typedef void(*DNoiseFunction) (Vector3d& result, const Vector3d& EPoint); /// Optimized noise dispatch information. -struct OptimizedNoiseInfo +struct OptimizedNoiseInfo final { /// String unambiguously identifying the optimized implementation. /// @@ -173,7 +184,7 @@ extern OptimizedNoiseInfo gaOptimizedNoiseInfo[]; const OptimizedNoiseInfo* GetRecommendedOptimizedNoise(); /// Get a specific noise generator implementation. -const OptimizedNoiseInfo* GetOptimizedNoise(std::string name); +const OptimizedNoiseInfo* GetOptimizedNoise(const std::string& name); extern NoiseFunction Noise; extern DNoiseFunction DNoise; @@ -195,5 +206,6 @@ void DTurbulence (Vector3d& result, const Vector3d& EPoint, const GenericTurbule //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_NOISE_H diff --git a/source/core/material/normal.cpp b/source/core/material/normal.cpp index a43afe35c..d39bad426 100644 --- a/source/core/material/normal.cpp +++ b/source/core/material/normal.cpp @@ -17,7 +17,7 @@ /// ---------------------------------------------------------------------------- /// /// 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 @@ -45,8 +45,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/normal.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" +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/material/blendmap.h" #include "core/material/noise.h" #include "core/material/pigment.h" @@ -778,7 +785,7 @@ void Perturb_Normal(Vector3d& Layer_Normal, const TNORMAL *Tnormal, const Vector Vector3d TPoint,P1; DBL value1,Amount; int i; - shared_ptr Blend_Map; + std::shared_ptr Blend_Map; if (Tnormal == nullptr) { @@ -787,7 +794,7 @@ void Perturb_Normal(Vector3d& Layer_Normal, const TNORMAL *Tnormal, const Vector /* If normal_map present, use it and return */ - Blend_Map = dynamic_pointer_cast(Tnormal->Blend_Map); + Blend_Map = std::dynamic_pointer_cast(Tnormal->Blend_Map); if (Blend_Map != nullptr) { if (Tnormal->Type == UV_MAP_PATTERN) @@ -871,7 +878,7 @@ void Perturb_Normal(Vector3d& Layer_Normal, const TNORMAL *Tnormal, const Vector } else { - shared_ptr slopeMap = dynamic_pointer_cast(Tnormal->Blend_Map); + std::shared_ptr slopeMap = std::dynamic_pointer_cast(Tnormal->Blend_Map); Warp_Normal(Layer_Normal,Layer_Normal, Tnormal, Test_Flag(Tnormal,DONT_SCALE_BUMPS_FLAG)); @@ -1048,5 +1055,5 @@ void NormalBlendMap::ComputeAverage (const Vector3d& EPoint, Vector3d& normal, I normal = V1 / Total; } - } +// end of namespace pov diff --git a/source/core/material/normal.h b/source/core/material/normal.h index 016a9aa8b..bd46d81a6 100644 --- a/source/core/material/normal.h +++ b/source/core/material/normal.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 @@ -39,9 +39,20 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/material/blendmap.h" #include "core/math/vector.h" +#include "core/render/ray_fwd.h" namespace pov { @@ -53,10 +64,6 @@ namespace pov /// /// @{ -class Intersection; -class Ray; -class TraceThreadData; - /// Common interface for normal-like blend maps. /// /// This purely abstract class provides the common interface for both normal and slope blend maps. @@ -73,42 +80,42 @@ class GenericNormalBlendMap virtual void ComputeAverage (const Vector3d& EPoint, Vector3d& normal, Intersection *Inter, const Ray *ray, TraceThreadData *Thread) = 0; }; -class SlopeBlendMap : public BlendMap, public GenericNormalBlendMap +class SlopeBlendMap final : public BlendMap, public GenericNormalBlendMap { public: SlopeBlendMap(); - virtual ~SlopeBlendMap(); + virtual ~SlopeBlendMap() override; - virtual void Post(bool dontScaleBumps); - virtual void ComputeAverage (const Vector3d& EPoint, Vector3d& normal, Intersection *Inter, const Ray *ray, TraceThreadData *Thread); + virtual void Post(bool dontScaleBumps) override; + virtual void ComputeAverage (const Vector3d& EPoint, Vector3d& normal, Intersection *Inter, const Ray *ray, TraceThreadData *Thread) override; }; -class NormalBlendMap : public BlendMap, public GenericNormalBlendMap +class NormalBlendMap final : public BlendMap, public GenericNormalBlendMap { public: NormalBlendMap(); - virtual ~NormalBlendMap(); + virtual ~NormalBlendMap() override; - virtual void Post(bool dontScaleBumps); - virtual void ComputeAverage (const Vector3d& EPoint, Vector3d& normal, Intersection *Inter, const Ray *ray, TraceThreadData *Thread); + virtual void Post(bool dontScaleBumps) override; + virtual void ComputeAverage (const Vector3d& EPoint, Vector3d& normal, Intersection *Inter, const Ray *ray, TraceThreadData *Thread) override; }; -typedef shared_ptr GenericNormalBlendMapPtr; -typedef shared_ptr GenericNormalBlendMapConstPtr; +typedef std::shared_ptr GenericNormalBlendMapPtr; +typedef std::shared_ptr GenericNormalBlendMapConstPtr; -typedef Vector2d SlopeBlendMapData; -typedef BlendMapEntry SlopeBlendMapEntry; -typedef shared_ptr SlopeBlendMapPtr; -typedef shared_ptr SlopeBlendMapConstPtr; +typedef Vector2d SlopeBlendMapData; +typedef BlendMapEntry SlopeBlendMapEntry; +typedef std::shared_ptr SlopeBlendMapPtr; +typedef std::shared_ptr SlopeBlendMapConstPtr; -typedef TNORMAL* NormalBlendMapData; -typedef BlendMapEntry NormalBlendMapEntry; -typedef shared_ptr NormalBlendMapPtr; -typedef shared_ptr NormalBlendMapConstPtr; +typedef TNORMAL* NormalBlendMapData; +typedef BlendMapEntry NormalBlendMapEntry; +typedef std::shared_ptr NormalBlendMapPtr; +typedef std::shared_ptr NormalBlendMapConstPtr; -struct Tnormal_Struct : public Pattern_Struct +struct Tnormal_Struct final : public Pattern_Struct { GenericNormalBlendMapPtr Blend_Map; SNGL Amount; @@ -127,5 +134,6 @@ void Perturb_Normal (Vector3d& Layer_Normal, const TNORMAL *Tnormal, const Vecto //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_NORMAL_H diff --git a/source/core/material/pattern.cpp b/source/core/material/pattern.cpp index 9dec6f4fd..fb55df1a1 100644 --- a/source/core/material/pattern.cpp +++ b/source/core/material/pattern.cpp @@ -14,7 +14,7 @@ /// ---------------------------------------------------------------------------- /// /// 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 @@ -42,11 +42,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/pattern.h" -#include +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include +#include +// POV-Ray header files (base module) #include "base/fileinputoutput.h" +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/material/blendmap.h" #include "core/material/noise.h" #include "core/material/pigment.h" @@ -65,6 +73,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -1068,8 +1079,8 @@ void BlendMap::Search (DBL value, EntryConstPtr& rpPrev, EntryConstPtr& { // TODO - we might use a binary search instead - typename vector::const_iterator iP; - typename vector::const_iterator iN; + typename std::vector::const_iterator iP; + typename std::vector::const_iterator iN; iP = iN = Blend_Map_Entries.begin(); @@ -9378,3 +9389,4 @@ void InitializePatternGenerators(void) } } +// end of namespace pov diff --git a/source/core/material/pattern.h b/source/core/material/pattern.h index b4286f9b7..95159fd93 100644 --- a/source/core/material/pattern.h +++ b/source/core/material/pattern.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 @@ -38,12 +38,20 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/material/pattern_fwd.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// Boost header files #include // required for crackle #include -#include "base/fileinputoutput.h" +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/material/pigment.h" #include "core/material/warp.h" @@ -309,7 +317,7 @@ struct ContinuousPattern : public BasicPattern /// crackle pattern, store cached data here. /// @return The pattern's value at the given point in space. /// - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override final; /// Evaluates the pattern at a given point in space, without taking into account the wave function. /// @@ -325,34 +333,34 @@ struct ContinuousPattern : public BasicPattern /// virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const = 0; - virtual unsigned int NumDiscreteBlendMapEntries() const; - virtual bool CanMap() const; + virtual unsigned int NumDiscreteBlendMapEntries() const override; + virtual bool CanMap() const override; }; /// Abstract class providing additions to the basic pattern interface, as well as common code, for all /// discrete pattern implementations. struct DiscretePattern : public BasicPattern { - virtual bool CanMap() const; + virtual bool CanMap() const override; }; /// Implements a plain pattern with all-zero values for any point in space. -struct PlainPattern : public DiscretePattern +struct PlainPattern final : public DiscretePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual unsigned int NumDiscreteBlendMapEntries() const; - virtual bool HasSpecialTurbulenceHandling() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; + virtual bool HasSpecialTurbulenceHandling() const override; }; /// Implements a dummy pattern for `average` pseudo-pattern. -struct AveragePattern : public BasicPattern +struct AveragePattern final : public BasicPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual unsigned int NumDiscreteBlendMapEntries() const; - virtual bool HasSpecialTurbulenceHandling() const; - virtual bool CanMap() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; + virtual bool HasSpecialTurbulenceHandling() const override; + virtual bool CanMap() const override; }; /// Class providing additional data members for image-based patterns. @@ -373,34 +381,34 @@ struct ImagePatternImpl // Miscellaneous Patterns /// Implements the `agate` pattern. -struct AgatePattern : public ContinuousPattern +struct AgatePattern final : public ContinuousPattern { /// `agate_turb` parameter. SNGL agateTurbScale; AgatePattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual bool Precompute(); - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual bool Precompute() override; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; }; /// Implements the `aoi` pattern. -struct AOIPattern : public ContinuousPattern +struct AOIPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `boxed` pattern. -struct BoxedPattern : public ContinuousPattern +struct BoxedPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `brick` pattern. -struct BrickPattern : public DiscretePattern +struct BrickPattern final : public DiscretePattern { /// `brick_size` parameter. Vector3d brickSize; @@ -409,30 +417,30 @@ struct BrickPattern : public DiscretePattern SNGL mortar; BrickPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements the `cells` pattern. -struct CellsPattern : public ContinuousPattern +struct CellsPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `checker` pattern. -struct CheckerPattern : public DiscretePattern +struct CheckerPattern final : public DiscretePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements the `crackle` pattern. -struct CracklePattern : public ContinuousPattern +struct CracklePattern final : public ContinuousPattern { Vector3d crackleForm; DBL crackleMetric; @@ -441,34 +449,34 @@ struct CracklePattern : public ContinuousPattern bool crackleIsSolid; CracklePattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `cubic` pattern. -struct CubicPattern : public DiscretePattern +struct CubicPattern final : public DiscretePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements the `cylindrical` pattern. -struct CylindricalPattern : public ContinuousPattern +struct CylindricalPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `density_file` pattern. /// /// @todo The additional member variables should be encapsulated. /// -struct DensityFilePattern : public ContinuousPattern +struct DensityFilePattern final : public ContinuousPattern { /// @todo fix the members to match naming conventions - struct DensityFileDataStruct + struct DensityFileDataStruct final { int References; char *Name; @@ -482,7 +490,7 @@ struct DensityFilePattern : public ContinuousPattern }; }; /// @todo fix the members to match naming conventions - struct DensityFileStruct + struct DensityFileStruct final { int Interpolation; ///< one of @ref DensityFileInterpolationType DensityFileDataStruct *Data; @@ -492,98 +500,98 @@ struct DensityFilePattern : public ContinuousPattern DensityFilePattern(); DensityFilePattern(const DensityFilePattern& obj); - virtual ~DensityFilePattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual ~DensityFilePattern() override; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; -typedef struct DensityFilePattern::DensityFileStruct DENSITY_FILE; ///< @deprecated @ref DensityFilePattern::DensityFileStruct should be used instead. -typedef struct DensityFilePattern::DensityFileDataStruct DENSITY_FILE_DATA; ///< @deprecated @ref DensityFilePattern::DensityFileDataStruct should be used instead. +using DENSITY_FILE = DensityFilePattern::DensityFileStruct; ///< @deprecated @ref DensityFilePattern::DensityFileStruct should be used instead. +using DENSITY_FILE_DATA = DensityFilePattern::DensityFileDataStruct ; ///< @deprecated @ref DensityFilePattern::DensityFileDataStruct should be used instead. /// Implements the `dents` pattern. -struct DentsPattern : public ContinuousPattern +struct DentsPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `facets` pattern. -struct FacetsPattern : public ContinuousPattern +struct FacetsPattern final : public ContinuousPattern { DBL facetsSize, facetsCoords, facetsMetric; FacetsPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } /// @attention As the `facets` pattern is only available for normals, this function is not supposed to be ever /// called, and will throw an exception. /// - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `function` pattern. /// /// @todo The additional member variables should be encapsulated. /// -struct FunctionPattern : public ContinuousPattern +struct FunctionPattern final : public ContinuousPattern { GenericScalarFunctionPtr pFn; FunctionPattern(); FunctionPattern(const FunctionPattern& obj); - virtual ~FunctionPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual ~FunctionPattern() override; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `gradient` pattern. -struct GradientPattern : public ContinuousPattern +struct GradientPattern final : public ContinuousPattern { /// Direction of the gradient. Vector3d gradient; - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `granite` pattern. -struct GranitePattern : public ContinuousPattern +struct GranitePattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `hexagon` pattern. -struct HexagonPattern : public DiscretePattern +struct HexagonPattern final : public DiscretePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements image-based mapped patterns. -struct ImagePattern : public ContinuousPattern, public ImagePatternImpl +struct ImagePattern final : public ContinuousPattern, public ImagePatternImpl { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `leopard` pattern. -struct LeopardPattern : public ContinuousPattern +struct LeopardPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `marble` pattern. -struct MarblePattern : public ContinuousPattern +struct MarblePattern final : public ContinuousPattern { MarblePattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual bool Precompute(); - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual bool HasSpecialTurbulenceHandling() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual bool Precompute() override; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual bool HasSpecialTurbulenceHandling() const override; protected: @@ -593,32 +601,32 @@ struct MarblePattern : public ContinuousPattern /// Base class for the noise-based patterns. struct NoisePattern : public ContinuousPattern { - virtual PatternPtr Clone() const = 0; - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override = 0; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `object` pattern. /// /// @todo The additional member variables should possibly be encapsulated. /// -struct ObjectPattern : public DiscretePattern +struct ObjectPattern final : public DiscretePattern { ObjectPtr pObject; ObjectPattern(); ObjectPattern(const ObjectPattern& obj); - virtual ~ObjectPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual ~ObjectPattern() override; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements the `onion` pattern. -struct OnionPattern : public ContinuousPattern +struct OnionPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `pavement` pattern. @@ -626,7 +634,7 @@ struct OnionPattern : public ContinuousPattern /// @todo We should probably implement this as one class per pavement type, possibly all declared in @ref pattern.cpp /// and instantiated via a static factory method in this class. /// -struct PavementPattern : public ContinuousPattern +struct PavementPattern final : public ContinuousPattern { unsigned char Side; unsigned char Tile; @@ -636,8 +644,8 @@ struct PavementPattern : public ContinuousPattern unsigned char Form; PavementPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; DBL hexagonal (const Vector3d& EPoint) const; DBL trigonal (const Vector3d& EPoint) const; DBL tetragonal (const Vector3d& EPoint) const; @@ -647,70 +655,70 @@ struct PavementPattern : public ContinuousPattern /// /// @todo The additional member variables should possibly be encapsulated. /// -struct PigmentPattern : public ContinuousPattern +struct PigmentPattern final : public ContinuousPattern { PIGMENT *pPigment; PigmentPattern(); PigmentPattern(const PigmentPattern& obj); - virtual ~PigmentPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual ~PigmentPattern() override; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `planar` pattern. -struct PlanarPattern : public ContinuousPattern +struct PlanarPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `potential` pattern. /// /// @todo The additional member variables should possibly be encapsulated. /// -struct PotentialPattern : public ContinuousPattern +struct PotentialPattern final : public ContinuousPattern { ObjectPtr pObject; bool subtractThreshold; PotentialPattern(); PotentialPattern(const PotentialPattern& obj); - virtual ~PotentialPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual ~PotentialPattern() override; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `quilted` pattern. -struct QuiltedPattern : public ContinuousPattern +struct QuiltedPattern final : public ContinuousPattern { SNGL Control0, Control1; QuiltedPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `radial` pattern. -struct RadialPattern : public ContinuousPattern +struct RadialPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; }; /// Implements the `ripples` pattern. -struct RipplesPattern : public ContinuousPattern +struct RipplesPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `slope` pattern. /// /// @todo The additional member variables should be encapsulated, and computed by the class rather than the parser. /// -struct SlopePattern : public ContinuousPattern +struct SlopePattern final : public ContinuousPattern { Vector3d altitudeDirection; Vector3d slopeDirection; @@ -725,24 +733,24 @@ struct SlopePattern : public ContinuousPattern bool pointAt : 1; SlopePattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `spherical` pattern. -struct SphericalPattern : public ContinuousPattern +struct SphericalPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `square` pattern. -struct SquarePattern : public DiscretePattern +struct SquarePattern final : public DiscretePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements the `tiling` pattern. @@ -750,39 +758,39 @@ struct SquarePattern : public DiscretePattern /// @todo We should probably implement this as one class per tiling type, possibly all declared in @ref pattern.cpp /// and instantiated via a static factory method in this class. /// -struct TilingPattern : public ContinuousPattern +struct TilingPattern final : public ContinuousPattern { unsigned char tilingType; - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `triangular` pattern. -struct TriangularPattern : public DiscretePattern +struct TriangularPattern final : public DiscretePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual unsigned int NumDiscreteBlendMapEntries() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual unsigned int NumDiscreteBlendMapEntries() const override; }; /// Implements the `waves` pattern. -struct WavesPattern : public ContinuousPattern +struct WavesPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `wood` pattern. -struct WoodPattern : public ContinuousPattern +struct WoodPattern final : public ContinuousPattern { WoodPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual bool Precompute(); - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; - virtual bool HasSpecialTurbulenceHandling() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual bool Precompute() override; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; + virtual bool HasSpecialTurbulenceHandling() const override; protected: @@ -790,10 +798,10 @@ struct WoodPattern : public ContinuousPattern }; /// Implements the `wrinkles` pattern. -struct WrinklesPattern : public ContinuousPattern +struct WrinklesPattern final : public ContinuousPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; @@ -819,8 +827,8 @@ struct FractalPattern : public ContinuousPattern unsigned char interiorType; FractalPattern(); - virtual PatternPtr Clone() const = 0; - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const = 0; + virtual PatternPtr Clone() const override = 0; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override = 0; protected: @@ -837,7 +845,7 @@ struct FractalPattern : public ContinuousPattern /// /// @param a Final iteration "a" value. /// @param b Final iteration "b" value. - /// @param mindist2 Square of the smallest distance to the origin thoughout all iterations. + /// @param mindist2 Square of the smallest distance to the origin throughout all iterations. /// @return The interior shade. /// DBL InteriorColour(DBL a, DBL b, DBL mindist2) const; @@ -857,38 +865,38 @@ struct JuliaPattern : public FractalPattern JuliaPattern(); JuliaPattern(const JuliaPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Provides an implementation of the `julia` pattern optimized for `exponent 3`. -struct Julia3Pattern : public JuliaPattern +struct Julia3Pattern final : public JuliaPattern { Julia3Pattern(); Julia3Pattern(const JuliaPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Provides an implementation of the `julia` pattern optimized for `exponent 4`. -struct Julia4Pattern : public JuliaPattern +struct Julia4Pattern final : public JuliaPattern { Julia4Pattern(); Julia4Pattern(const JuliaPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Provides a generic implementation of the `julia` pattern for arbitrary exponents. -struct JuliaXPattern : public JuliaPattern +struct JuliaXPattern final : public JuliaPattern { int fractalExponent; JuliaXPattern(); JuliaXPattern(const JuliaPattern& obj); JuliaXPattern(const JuliaXPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; //------------------------------------------------------------------------------ @@ -900,74 +908,74 @@ struct MandelPattern : public FractalPattern }; /// Provides an implementation of the `mandel` pattern optimized for `exponent 2` (default). -struct Mandel2Pattern : public MandelPattern +struct Mandel2Pattern final : public MandelPattern { Mandel2Pattern(); Mandel2Pattern(const MandelPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; }; /// Provides an implementation of the `mandel` pattern optimized for `exponent 3`. -struct Mandel3Pattern : public MandelPattern +struct Mandel3Pattern final : public MandelPattern { Mandel3Pattern(); Mandel3Pattern(const MandelPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Provides an implementation of the `mandel` pattern optimized for `exponent 4`. -struct Mandel4Pattern : public MandelPattern +struct Mandel4Pattern final : public MandelPattern { Mandel4Pattern(); Mandel4Pattern(const MandelPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Provides a generic implementation of the `mandel` pattern for arbitrary exponents. -struct MandelXPattern : public MandelPattern +struct MandelXPattern final : public MandelPattern { int fractalExponent; MandelXPattern(); MandelXPattern(const MandelPattern& obj); MandelXPattern(const MandelXPattern& obj); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; //------------------------------------------------------------------------------ // Magnet Patterns /// Implements the `magnet 1 mandel` pattern. -struct Magnet1MPattern : public MandelPattern +struct Magnet1MPattern final : public MandelPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `magnet 1 julia` pattern. -struct Magnet1JPattern : public JuliaPattern +struct Magnet1JPattern final : public JuliaPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `magnet 2 mandel` pattern. -struct Magnet2MPattern : public MandelPattern +struct Magnet2MPattern final : public MandelPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `magnet 2 julia` pattern. -struct Magnet2JPattern : public JuliaPattern +struct Magnet2JPattern final : public JuliaPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; @@ -975,22 +983,22 @@ struct Magnet2JPattern : public JuliaPattern // Noise-Based Patterns /// Implements the `bozo` pattern. -struct BozoPattern : public NoisePattern +struct BozoPattern final : public NoisePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual ColourBlendMapConstPtr GetDefaultBlendMap() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual ColourBlendMapConstPtr GetDefaultBlendMap() const override; }; /// Implements the `bumps` pattern. -struct BumpsPattern : public NoisePattern +struct BumpsPattern final : public NoisePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } }; /// Implements the `spotted` pattern. -struct SpottedPattern : public NoisePattern +struct SpottedPattern final : public NoisePattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } }; @@ -1003,9 +1011,9 @@ struct SpiralPattern : public ContinuousPattern short arms; SpiralPattern(); - virtual PatternPtr Clone() const = 0; - virtual bool Precompute(); - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const = 0; + virtual PatternPtr Clone() const override = 0; + virtual bool Precompute() override; + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override = 0; protected: @@ -1013,17 +1021,17 @@ struct SpiralPattern : public ContinuousPattern }; /// Implements the `spiral1` pattern. -struct Spiral1Pattern : public SpiralPattern +struct Spiral1Pattern final : public SpiralPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; /// Implements the `spiral2` pattern. -struct Spiral2Pattern : public SpiralPattern +struct Spiral2Pattern final : public SpiralPattern { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual DBL EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; }; @@ -1051,10 +1059,10 @@ struct ColourPattern : public BasicPattern /// crackle pattern, store cached data here. /// @return The pattern's value at the given point in space. /// - virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; + virtual DBL Evaluate(const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override final; - virtual unsigned int NumDiscreteBlendMapEntries() const; - virtual bool CanMap() const; + virtual unsigned int NumDiscreteBlendMapEntries() const override; + virtual bool CanMap() const override; /// Evaluates the pattern at a given point in space. /// @@ -1079,24 +1087,24 @@ struct ColourPattern : public BasicPattern /// /// @todo The additional member variables should possibly be encapsulated. /// -struct ColourFunctionPattern : public ColourPattern +struct ColourFunctionPattern final : public ColourPattern { GenericScalarFunctionPtr pFn[5]; ColourFunctionPattern(); ColourFunctionPattern(const ColourFunctionPattern& obj); - virtual ~ColourFunctionPattern(); - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual bool Evaluate(TransColour& result, const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual bool HasTransparency() const; + virtual ~ColourFunctionPattern() override; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual bool Evaluate(TransColour& result, const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual bool HasTransparency() const override; }; /// Implements the `image_map` pattern. -struct ColourImagePattern : public ColourPattern, public ImagePatternImpl +struct ColourImagePattern final : public ColourPattern, public ImagePatternImpl { - virtual PatternPtr Clone() const { return BasicPattern::Clone(*this); } - virtual bool Evaluate(TransColour& result, const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const; - virtual bool HasTransparency() const; + virtual PatternPtr Clone() const override { return BasicPattern::Clone(*this); } + virtual bool Evaluate(TransColour& result, const Vector3d& EPoint, const Intersection *pIsection, const Ray *pRay, TraceThreadData *pThread) const override; + virtual bool HasTransparency() const override; }; @@ -1104,7 +1112,7 @@ struct ColourImagePattern : public ColourPattern, public ImagePatternImpl // Crackle Pattern Support Types /// Helper class to implement the crackle cache. -class CrackleCellCoord +class CrackleCellCoord final { public: @@ -1159,7 +1167,7 @@ class CrackleCellCoord }; /// Helper class to implement the crackle cache. -struct CrackleCacheEntry +struct CrackleCacheEntry final { /// A kind of timestamp specifying when this particular entry was last used. size_t lastUsed; @@ -1168,7 +1176,7 @@ struct CrackleCacheEntry Vector3d aCellNuclei[81]; }; -typedef boost::unordered_map > CrackleCache; +typedef boost::unordered_map> CrackleCache; //****************************************************************************** @@ -1197,5 +1205,6 @@ void InitializePatternGenerators(void); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_PATTERN_H diff --git a/source/core/material/pattern_fwd.h b/source/core/material/pattern_fwd.h new file mode 100644 index 000000000..17c99923e --- /dev/null +++ b/source/core/material/pattern_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file core/material/pattern_fwd.h +/// +/// Forward declarations related to patterns. +/// +/// @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_CORE_PATTERN_FWD_H +#define POVRAY_CORE_PATTERN_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +struct ImagePattern; + +} +// end of namespace pov + +#endif // POVRAY_CORE_PATTERN_FWD_H diff --git a/source/core/material/pigment.cpp b/source/core/material/pigment.cpp index cf59fe5e4..7d658573a 100644 --- a/source/core/material/pigment.cpp +++ b/source/core/material/pigment.cpp @@ -14,7 +14,7 @@ /// ---------------------------------------------------------------------------- /// /// 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 @@ -42,8 +42,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/pigment.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" +#include "base/povassert.h" +#include "base/image/colourspace.h" +// POV-Ray header files (core module) #include "core/material/blendmap.h" #include "core/material/pattern.h" #include "core/material/warp.h" @@ -57,6 +65,8 @@ namespace pov { +using std::vector; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -157,7 +167,7 @@ PIGMENT *Copy_Pigment (PIGMENT *Old) New = Create_Pigment (); Copy_TPat_Fields (New, Old); - New->Blend_Map = shared_ptr (Old->Blend_Map); + New->Blend_Map = std::shared_ptr (Old->Blend_Map); New->colour = Old->colour; New->Quick_Colour = Old->Quick_Colour; @@ -284,8 +294,8 @@ void Post_Pigment(PIGMENT *Pigment, bool* pHasFilter) break; default: - Pigment->Blend_Map = static_pointer_cast( - const_pointer_cast( + Pigment->Blend_Map = std::static_pointer_cast( + std::const_pointer_cast( Pigment->pattern->GetDefaultBlendMap())); break; } @@ -435,8 +445,8 @@ bool Compute_Pigment (TransColour& colour, const PIGMENT *Pigment, const Vector3 colour.Clear(); - POV_PATTERN_ASSERT(dynamic_pointer_cast(Pigment->pattern)); - Colour_Found = static_pointer_cast(Pigment->pattern)->Evaluate(colour, TPoint, Intersect, ray, Thread); + POV_PATTERN_ASSERT(std::dynamic_pointer_cast(Pigment->pattern)); + Colour_Found = std::dynamic_pointer_cast(Pigment->pattern)->Evaluate(colour, TPoint, Intersect, ray, Thread); break; @@ -671,4 +681,4 @@ PigmentBlendMap::~PigmentBlendMap() } } - +// end of namespace pov diff --git a/source/core/material/pigment.h b/source/core/material/pigment.h index fd5232148..8329ca2cc 100644 --- a/source/core/material/pigment.h +++ b/source/core/material/pigment.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 @@ -39,10 +39,20 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include "base/image/colourspace.h" +// C++ variants of C standard header files +// (none at the moment) +// C++ standard header files +#include +#include + +// POV-Ray header files (base module) +#include "base/image/colourspace_fwd.h" + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/material/blendmap.h" +#include "core/render/ray_fwd.h" namespace pov { @@ -54,10 +64,6 @@ namespace pov /// /// @{ -class Intersection; -class Ray; -class TraceThreadData; - /// Common interface for pigment-like blend maps. /// /// This class provides the common interface for both pigment and colour blend maps. @@ -81,49 +87,49 @@ class GenericPigmentBlendMap }; /// Colour blend map. -class ColourBlendMap : public BlendMap, public GenericPigmentBlendMap +class ColourBlendMap final : public BlendMap, public GenericPigmentBlendMap { public: ColourBlendMap(); ColourBlendMap(int n, const Entry aEntries[]); - virtual bool Compute(TransColour& colour, DBL value, const Vector3d& IPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); - virtual void ComputeAverage(TransColour& colour, const Vector3d& EPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); - virtual bool ComputeUVMapped(TransColour& colour, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); - virtual void Post(bool& rHasFilter); + virtual bool Compute(TransColour& colour, DBL value, const Vector3d& IPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread) override; + virtual void ComputeAverage(TransColour& colour, const Vector3d& EPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread) override; + virtual bool ComputeUVMapped(TransColour& colour, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread) override; + virtual void Post(bool& rHasFilter) override; }; /// Pigment blend map. -class PigmentBlendMap : public BlendMap, public GenericPigmentBlendMap +class PigmentBlendMap final : public BlendMap, public GenericPigmentBlendMap { public: PigmentBlendMap(BlendMapTypeId type); - virtual ~PigmentBlendMap(); + virtual ~PigmentBlendMap() override; - virtual bool Compute(TransColour& colour, DBL value, const Vector3d& IPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); - virtual void ComputeAverage(TransColour& colour, const Vector3d& EPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); - virtual bool ComputeUVMapped(TransColour& colour, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); - virtual void Post(bool& rHasFilter); + virtual bool Compute(TransColour& colour, DBL value, const Vector3d& IPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread) override; + virtual void ComputeAverage(TransColour& colour, const Vector3d& EPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread) override; + virtual bool ComputeUVMapped(TransColour& colour, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread) override; + virtual void Post(bool& rHasFilter) override; }; -typedef shared_ptr GenericPigmentBlendMapPtr; -typedef shared_ptr GenericPigmentBlendMapConstPtr; +typedef std::shared_ptr GenericPigmentBlendMapPtr; +typedef std::shared_ptr GenericPigmentBlendMapConstPtr; -typedef PIGMENT* PigmentBlendMapData; -typedef BlendMapEntry PigmentBlendMapEntry; -typedef shared_ptr PigmentBlendMapPtr; -typedef shared_ptr PigmentBlendMapConstPtr; +typedef PIGMENT* PigmentBlendMapData; +typedef BlendMapEntry PigmentBlendMapEntry; +typedef std::shared_ptr PigmentBlendMapPtr; +typedef std::shared_ptr PigmentBlendMapConstPtr; -typedef TransColour ColourBlendMapData; -typedef BlendMapEntry ColourBlendMapEntry; -typedef shared_ptr ColourBlendMapPtr; -typedef shared_ptr ColourBlendMapConstPtr; +typedef TransColour ColourBlendMapData; +typedef BlendMapEntry ColourBlendMapEntry; +typedef std::shared_ptr ColourBlendMapPtr; +typedef std::shared_ptr ColourBlendMapConstPtr; -struct Pigment_Struct : public Pattern_Struct +struct Pigment_Struct final : public Pattern_Struct { - shared_ptr Blend_Map; + std::shared_ptr Blend_Map; TransColour colour; // may have a filter/transmit component TransColour Quick_Colour; // may have a filter/transmit component // TODO - can't we decide between regular colour and quick_colour at parse time already? }; @@ -131,16 +137,17 @@ struct Pigment_Struct : public Pattern_Struct PIGMENT *Create_Pigment(); PIGMENT *Copy_Pigment(PIGMENT *Old); -void Copy_Pigments (vector& New, const vector& Old); +void Copy_Pigments (std::vector& New, const std::vector& Old); void Destroy_Pigment(PIGMENT *Pigment); void Post_Pigment(PIGMENT *Pigment, bool* pHasFilter = nullptr); bool Compute_Pigment(TransColour& colour, const PIGMENT *Pigment, const Vector3d& IPoint, const Intersection *Intersect, const Ray *ray, TraceThreadData *Thread); -void Evaluate_Density_Pigment(vector& Density, const Vector3d& p, MathColour& c, TraceThreadData *ttd); +void Evaluate_Density_Pigment(std::vector& Density, const Vector3d& p, MathColour& c, TraceThreadData *ttd); /// @} /// //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_PIGMENT_H diff --git a/source/core/material/portablenoise.cpp b/source/core/material/portablenoise.cpp index a4e039620..8e994503f 100644 --- a/source/core/material/portablenoise.cpp +++ b/source/core/material/portablenoise.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 @@ -46,6 +46,14 @@ #include "core/material/portablenoise.h" #endif // PORTABLE_OPTIMIZED_NOISE +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/noise.h" namespace pov @@ -370,3 +378,4 @@ void PortableDNoise(Vector3d& result, const Vector3d& EPoint) } } +// end of namespace pov diff --git a/source/core/material/portablenoise.h b/source/core/material/portablenoise.h index 9a1314dbc..c52193590 100644 --- a/source/core/material/portablenoise.h +++ b/source/core/material/portablenoise.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 @@ -39,4 +39,12 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.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 (core module) +// (none at the moment) + #endif // POVRAY_CORE_PORTABLENOISE_H diff --git a/source/core/material/texture.cpp b/source/core/material/texture.cpp index 6c259873d..561054693 100644 --- a/source/core/material/texture.cpp +++ b/source/core/material/texture.cpp @@ -19,7 +19,7 @@ /// ---------------------------------------------------------------------------- /// /// 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 @@ -47,10 +47,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/texture.h" -#include +// 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" +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/material/pattern.h" #include "core/material/pigment.h" #include "core/material/normal.h" @@ -62,6 +67,8 @@ namespace pov { +using std::vector; + /***************************************************************************** * * FUNCTION @@ -711,3 +718,4 @@ TextureBlendMap::~TextureBlendMap() } } +// end of namespace pov diff --git a/source/core/material/texture.h b/source/core/material/texture.h index 3cbef8fa4..98ce7cbb4 100644 --- a/source/core/material/texture.h +++ b/source/core/material/texture.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 @@ -39,6 +39,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/material/blendmap.h" #include "core/support/simplevector.h" @@ -53,7 +64,6 @@ namespace pov /// /// @{ -typedef struct Turb_Struct TURB; struct GenericTurbulenceWarp; /***************************************************************************** @@ -70,7 +80,7 @@ struct GenericTurbulenceWarp; * Global typedefs ******************************************************************************/ -struct WeightedTexture +struct WeightedTexture final { COLC weight; TEXTURE *texture; @@ -83,19 +93,19 @@ typedef PooledSimpleVector Weighte /// Texture blend map. -class TextureBlendMap : public BlendMap +class TextureBlendMap final : public BlendMap { public: TextureBlendMap(); - ~TextureBlendMap(); + virtual ~TextureBlendMap() override; }; typedef BlendMapEntry TextureBlendMapEntry; -typedef shared_ptr TextureBlendMapPtr; -typedef shared_ptr TextureBlendMapConstPtr; +typedef std::shared_ptr TextureBlendMapPtr; +typedef std::shared_ptr TextureBlendMapConstPtr; -struct Texture_Struct : public Pattern_Struct +struct Texture_Struct final : public Pattern_Struct { TextureBlendMapPtr Blend_Map; int References; @@ -103,10 +113,10 @@ struct Texture_Struct : public Pattern_Struct PIGMENT *Pigment; TNORMAL *Tnormal; FINISH *Finish; - vector Materials; // used for `material_map` (and only there) + std::vector Materials; // used for `material_map` (and only there) }; -struct Finish_Struct +struct Finish_Struct final { SNGL Diffuse, DiffuseBack, Brilliance; #if POV_PARSER_EXPERIMENTAL_BRILLIANCE_OUT @@ -152,5 +162,6 @@ int Test_Opacity (const TEXTURE *Texture); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TEXTURE_H diff --git a/source/core/material/warp.cpp b/source/core/material/warp.cpp index 7e7ea07b1..aac5724aa 100644 --- a/source/core/material/warp.cpp +++ b/source/core/material/warp.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 @@ -39,8 +39,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/material/warp.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) #include "core/material/noise.h" #include "core/material/pattern.h" #include "core/material/texture.h" @@ -687,3 +693,4 @@ void Copy_Warps (WarpList& rNew, const WarpList& old) } } +// end of namespace pov diff --git a/source/core/material/warp.h b/source/core/material/warp.h index 086752e4a..f3ef5561d 100644 --- a/source/core/material/warp.h +++ b/source/core/material/warp.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 @@ -39,6 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/math/vector.h" @@ -67,10 +77,10 @@ struct GenericWarp typedef GenericWarp* WarpPtr; typedef const GenericWarp* ConstWarpPtr; -typedef vector WarpList; +typedef std::vector WarpList; -struct BlackHoleWarp : public GenericWarp +struct BlackHoleWarp final : public GenericWarp { BlackHoleWarp() : GenericWarp(), Center(0.0), Repeat_Vector(0.0), Uncertainty_Vector(0.0), Strength(1.0), Radius(1.0), @@ -83,10 +93,10 @@ struct BlackHoleWarp : public GenericWarp Inverted(old.Inverted), Repeat(old.Repeat), Uncertain(old.Uncertain) {} - virtual GenericWarp* Clone() const { return new BlackHoleWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new BlackHoleWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; Vector3d Center; Vector3d Repeat_Vector; @@ -102,18 +112,18 @@ struct BlackHoleWarp : public GenericWarp bool Uncertain; }; -struct CubicWarp : public GenericWarp +struct CubicWarp final : public GenericWarp { CubicWarp() : GenericWarp() {} CubicWarp(const CubicWarp& old) : GenericWarp(old) {} - virtual GenericWarp* Clone() const { return new CubicWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new CubicWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; }; -struct CylindricalWarp : public GenericWarp +struct CylindricalWarp final : public GenericWarp { CylindricalWarp() : GenericWarp(), Orientation_Vector(0.0, 0.0, 1.0), DistExp(0.0) @@ -122,27 +132,27 @@ struct CylindricalWarp : public GenericWarp GenericWarp(old), Orientation_Vector(old.Orientation_Vector), DistExp(old.DistExp) {} - virtual GenericWarp* Clone() const { return new CylindricalWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new CylindricalWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; Vector3d Orientation_Vector; DBL DistExp; }; -struct IdentityWarp : public GenericWarp +struct IdentityWarp final : public GenericWarp { IdentityWarp() : GenericWarp() {} IdentityWarp(const IdentityWarp& old) : GenericWarp(old) {} - virtual GenericWarp* Clone() const { return new IdentityWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new IdentityWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; }; -struct PlanarWarp : public GenericWarp +struct PlanarWarp final : public GenericWarp { PlanarWarp() : GenericWarp(), Orientation_Vector(0.0, 0.0, 1.0), OffSet(0.0) @@ -151,16 +161,16 @@ struct PlanarWarp : public GenericWarp GenericWarp(old), Orientation_Vector(old.Orientation_Vector), OffSet(old.OffSet) {} - virtual GenericWarp* Clone() const { return new PlanarWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new PlanarWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; Vector3d Orientation_Vector; DBL OffSet; }; -struct RepeatWarp : public GenericWarp +struct RepeatWarp final : public GenericWarp { RepeatWarp() : GenericWarp(), Axis(-1), Width(0.0), Flip(1.0), Offset(0.0) @@ -169,35 +179,35 @@ struct RepeatWarp : public GenericWarp GenericWarp(old), Axis(old.Axis), Width(old.Width), Flip(old.Flip), Offset(old.Offset) {} - virtual GenericWarp* Clone() const { return new RepeatWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new RepeatWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; int Axis; SNGL Width; Vector3d Flip, Offset; }; -struct SphericalWarp : public GenericWarp +struct SphericalWarp final : public GenericWarp { SphericalWarp() : GenericWarp(), Orientation_Vector(0.0, 0.0, 1.0), DistExp(0.0) {} SphericalWarp(const SphericalWarp& old) : GenericWarp(old), Orientation_Vector(old.Orientation_Vector), DistExp(old.DistExp) - {} + {} - virtual GenericWarp* Clone() const { return new SphericalWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new SphericalWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; Vector3d Orientation_Vector; DBL DistExp; }; -struct ToroidalWarp : public GenericWarp +struct ToroidalWarp final : public GenericWarp { ToroidalWarp() : GenericWarp(), Orientation_Vector(0.0, 0.0, 1.0), DistExp(0.0), MajorRadius(1.0) @@ -207,17 +217,17 @@ struct ToroidalWarp : public GenericWarp MajorRadius(old.MajorRadius) {} - virtual GenericWarp* Clone() const { return new ToroidalWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new ToroidalWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; Vector3d Orientation_Vector; DBL DistExp; DBL MajorRadius; }; -struct TransformWarp : public GenericWarp +struct TransformWarp final : public GenericWarp { TransformWarp() : GenericWarp() @@ -229,10 +239,10 @@ struct TransformWarp : public GenericWarp GenericWarp(old), Trans(old.Trans) {} - virtual GenericWarp* Clone() const { return new TransformWarp(*this); } - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override { return new TransformWarp(*this); } + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; TRANSFORM Trans; }; @@ -247,10 +257,10 @@ struct GenericTurbulenceWarp : public GenericWarp GenericWarp(old), Turbulence(old.Turbulence), Octaves(old.Octaves), Lambda(old.Lambda), Omega(old.Omega) {} - virtual GenericWarp* Clone() const = 0; - virtual bool WarpPoint(Vector3d& rP) const; - virtual bool WarpNormal(Vector3d& rN) const; - virtual bool UnwarpNormal(Vector3d& rN) const; + virtual GenericWarp* Clone() const override = 0; + virtual bool WarpPoint(Vector3d& rP) const override; + virtual bool WarpNormal(Vector3d& rN) const override; + virtual bool UnwarpNormal(Vector3d& rN) const override; Vector3d Turbulence; int Octaves; @@ -258,16 +268,16 @@ struct GenericTurbulenceWarp : public GenericWarp }; /// Genuine turbulence warp. -struct TurbulenceWarp : public GenericTurbulenceWarp +struct TurbulenceWarp final : public GenericTurbulenceWarp { TurbulenceWarp() : GenericTurbulenceWarp() {} TurbulenceWarp(const TurbulenceWarp& old) : GenericTurbulenceWarp(old) {} - virtual GenericWarp* Clone() const { return new TurbulenceWarp(*this); } + virtual GenericWarp* Clone() const override { return new TurbulenceWarp(*this); } }; /// Turbulence tied to a pattern. -struct ClassicTurbulence : public GenericTurbulenceWarp +struct ClassicTurbulence final : public GenericTurbulenceWarp { ClassicTurbulence(bool hbp) : GenericTurbulenceWarp(), handledByPattern(hbp) @@ -276,7 +286,7 @@ struct ClassicTurbulence : public GenericTurbulenceWarp GenericTurbulenceWarp(old), handledByPattern(old.handledByPattern) {} - virtual GenericWarp* Clone() const { return new ClassicTurbulence(*this); } + virtual GenericWarp* Clone() const override { return new ClassicTurbulence(*this); } bool handledByPattern; }; @@ -297,5 +307,6 @@ void UnWarp_Normal (Vector3d& TNorm, const Vector3d& ENorm, const TPATTERN *TPat //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_WARP_H diff --git a/source/core/math/chi2.cpp b/source/core/math/chi2.cpp index c80d03061..d14c9b961 100644 --- a/source/core/math/chi2.cpp +++ b/source/core/math/chi2.cpp @@ -10,7 +10,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 @@ -74,8 +74,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/chi2.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) + // this must be the last file included #include "base/povdebug.h" @@ -1029,3 +1037,4 @@ static DBL p1evl(DBL x, const DBL coef[], int N) } } +// end of namespace pov diff --git a/source/core/math/chi2.h b/source/core/math/chi2.h index 8dd824b61..860d4a8a0 100644 --- a/source/core/math/chi2.h +++ b/source/core/math/chi2.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.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 (core module) +// (none at the moment) + namespace pov { @@ -61,5 +69,6 @@ DBL ndtri(DBL y0); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_CHI2_H diff --git a/source/core/math/hypercomplex.cpp b/source/core/math/hypercomplex.cpp index d5c56115b..47e06515f 100644 --- a/source/core/math/hypercomplex.cpp +++ b/source/core/math/hypercomplex.cpp @@ -10,7 +10,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 @@ -38,6 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/hypercomplex.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/shape/fractal.h" // TODO - Where should hcmplx.h/hcmplx.cpp go? Are they really math? [trf] #include "core/shape/sphere.h" // TODO - Move sphere intersection function to math code! [trf] @@ -1338,3 +1346,4 @@ void Complex_Pwr (Complex *target, const Complex *source1, const Complex *source } } +// end of namespace pov diff --git a/source/core/math/hypercomplex.h b/source/core/math/hypercomplex.h index 31b5d5afa..94981cd5f 100644 --- a/source/core/math/hypercomplex.h +++ b/source/core/math/hypercomplex.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/math/vector.h" @@ -59,48 +67,48 @@ typedef void (*COMPLEX_FUNCTION_METHOD) (Complex *, const Complex *, const Compl class HypercomplexBaseFractalRules : public FractalRules { public: - virtual ~HypercomplexBaseFractalRules() {} - virtual bool Bound (const BasicRay&, const Fractal *, DBL *, DBL *) const; + virtual ~HypercomplexBaseFractalRules() override {} + virtual bool Bound (const BasicRay&, const Fractal *, DBL *, DBL *) const override; }; -class HypercomplexFractalRules : public HypercomplexBaseFractalRules +class HypercomplexFractalRules final : public HypercomplexBaseFractalRules { public: - virtual ~HypercomplexFractalRules() {} - virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const; + virtual ~HypercomplexFractalRules() override {} + virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const override; }; -class HypercomplexFunctionFractalRules : public HypercomplexBaseFractalRules +class HypercomplexFunctionFractalRules final : public HypercomplexBaseFractalRules { public: HypercomplexFunctionFractalRules(COMPLEX_FUNCTION_METHOD fn) : ComplexFunction(fn) {} - virtual ~HypercomplexFunctionFractalRules() {} - virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const; + virtual ~HypercomplexFunctionFractalRules() override {} + virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const override; protected: COMPLEX_FUNCTION_METHOD ComplexFunction; void HFunc(DBL *xr, DBL *yr, DBL *zr, DBL *wr, DBL x, DBL y, DBL z, DBL w, const Fractal * f) const; }; -class HypercomplexZ3FractalRules : public HypercomplexBaseFractalRules +class HypercomplexZ3FractalRules final : public HypercomplexBaseFractalRules { public: - virtual ~HypercomplexZ3FractalRules() {} - virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const; + virtual ~HypercomplexZ3FractalRules() override {} + virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const override; }; -class HypercomplexReciprocalFractalRules : public HypercomplexBaseFractalRules +class HypercomplexReciprocalFractalRules final : public HypercomplexBaseFractalRules { public: - virtual ~HypercomplexReciprocalFractalRules() {} - virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const; + virtual ~HypercomplexReciprocalFractalRules() override {} + virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const override; }; void Complex_Exp (Complex *target, const Complex *source, const Complex *); @@ -127,5 +135,6 @@ void Complex_Div (Complex *target, const Complex *source1, const Complex *source //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_HYPERCOMPLEX_H diff --git a/source/core/math/jitter.cpp b/source/core/math/jitter.cpp index 12596fb64..ff12a2f07 100644 --- a/source/core/math/jitter.cpp +++ b/source/core/math/jitter.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 @@ -36,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/jitter.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 (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -79,3 +87,4 @@ const float JitterTable[256] = }; } +// end of namespace pov diff --git a/source/core/math/jitter.h b/source/core/math/jitter.h index e1c69ac79..e02db55e7 100644 --- a/source/core/math/jitter.h +++ b/source/core/math/jitter.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.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 (core module) +// (none at the moment) + namespace pov { @@ -84,5 +92,6 @@ inline void Jitter2d(DBL x, DBL y, DBL& jx, DBL& jy) //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_JITTER_H diff --git a/source/core/math/matrix.cpp b/source/core/math/matrix.cpp index 714c9e24f..914a70465 100644 --- a/source/core/math/matrix.cpp +++ b/source/core/math/matrix.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,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/matrix.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) + // this must be the last file included #include "base/povdebug.h" @@ -1194,3 +1202,4 @@ void MInvers(MATRIX r, const MATRIX m) } } +// end of namespace pov diff --git a/source/core/math/matrix.h b/source/core/math/matrix.h index 9265e3edb..2e720a25d 100644 --- a/source/core/math/matrix.h +++ b/source/core/math/matrix.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/math/vector.h" @@ -59,13 +67,12 @@ namespace pov typedef DBL MATRIX[4][4]; ///< @todo Make this obsolete. -typedef struct Transform_Struct TRANSFORM; - -struct Transform_Struct +struct Transform_Struct final { MATRIX matrix; MATRIX inverse; }; +using TRANSFORM = Transform_Struct; ///< @deprecated /***************************************************************************** @@ -118,5 +125,6 @@ int MInvers3(const Matrix3x3& inM, Matrix3x3& outM); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_MATRIX_H diff --git a/source/core/math/polynomialsolver.cpp b/source/core/math/polynomialsolver.cpp index f2ba43a91..d7a79eb5b 100644 --- a/source/core/math/polynomialsolver.cpp +++ b/source/core/math/polynomialsolver.cpp @@ -10,7 +10,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 @@ -38,6 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/polynomialsolver.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/support/statistics.h" // this must be the last file included @@ -106,7 +114,7 @@ const DBL RELERROR = 1.0e-12; * Local typedefs ******************************************************************************/ -struct polynomial +struct polynomial final { int ord; DBL coef[MAX_ORDER+1]; @@ -1721,3 +1729,4 @@ int Solve_Polynomial(int n, const DBL *c0, DBL *r, int sturm, DBL epsilon, Rende } } +// end of namespace pov diff --git a/source/core/math/polynomialsolver.h b/source/core/math/polynomialsolver.h index 1e299d0c2..c98c70804 100644 --- a/source/core/math/polynomialsolver.h +++ b/source/core/math/polynomialsolver.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.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 (core module) +// (none at the moment) + namespace pov { @@ -69,5 +77,6 @@ int Solve_Polynomial (int n, const DBL *c, DBL *r, int sturm, DBL epsilon, Rende //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_POLYNOMIALSOLVER_H diff --git a/source/core/math/quaternion.cpp b/source/core/math/quaternion.cpp index 915ad7fae..ce6479db8 100644 --- a/source/core/math/quaternion.cpp +++ b/source/core/math/quaternion.cpp @@ -11,7 +11,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 @@ -39,6 +39,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/quaternion.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/shape/fractal.h" #include "core/shape/sphere.h" @@ -566,3 +574,4 @@ bool QuaternionFractalRules::Bound(const BasicRay& ray, const Fractal *fractal, } } +// end of namespace pov diff --git a/source/core/math/quaternion.h b/source/core/math/quaternion.h index 762639606..2ad97646c 100644 --- a/source/core/math/quaternion.h +++ b/source/core/math/quaternion.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/math/vector.h" @@ -52,7 +60,6 @@ namespace pov /// /// @{ -struct BasicRay; class Fractal; /***************************************************************************** @@ -62,26 +69,26 @@ class Fractal; class QuaternionFractalRules : public FractalRules { public: - virtual ~QuaternionFractalRules() {} - virtual bool Bound (const BasicRay&, const Fractal *, DBL *, DBL *) const; + virtual ~QuaternionFractalRules() override {} + virtual bool Bound (const BasicRay&, const Fractal *, DBL *, DBL *) const override; }; -class JuliaFractalRules : public QuaternionFractalRules +class JuliaFractalRules final : public QuaternionFractalRules { public: - virtual ~JuliaFractalRules() {} - virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const; + virtual ~JuliaFractalRules() override {} + virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const override; }; -class Z3FractalRules : public QuaternionFractalRules +class Z3FractalRules final : public QuaternionFractalRules { public: - virtual ~Z3FractalRules() {} - virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const; - virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const; + virtual ~Z3FractalRules() override {} + virtual void CalcNormal (Vector3d&, int, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, DBL **) const override; + virtual bool Iterate (const Vector3d&, const Fractal *, const Vector3d&, DBL *, DBL **) const override; }; /// @} @@ -89,5 +96,6 @@ class Z3FractalRules : public QuaternionFractalRules //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_QUATERNION_H diff --git a/source/core/math/randcosweighted.cpp b/source/core/math/randcosweighted.cpp index 828872ef8..34f3a6791 100644 --- a/source/core/math/randcosweighted.cpp +++ b/source/core/math/randcosweighted.cpp @@ -13,7 +13,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,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/randcosweighted.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 (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -1658,4 +1666,4 @@ BYTE_XYZ kaRandCosWeighted[kRandCosWeightedCount] = { }; } - +// end of namespace pov diff --git a/source/core/math/randcosweighted.h b/source/core/math/randcosweighted.h index 58aa9afb0..be293ed96 100644 --- a/source/core/math/randcosweighted.h +++ b/source/core/math/randcosweighted.h @@ -14,7 +14,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 @@ -45,6 +45,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" namespace pov @@ -66,7 +74,7 @@ namespace pov /// /// @{ -struct BYTE_XYZ +struct BYTE_XYZ final { unsigned char x, y, z; }; @@ -92,5 +100,6 @@ inline void VUnpack(Vector3d& dest_vec, const BYTE_XYZ * pack_vec) //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_RANDCOSWEIGHTED_H diff --git a/source/core/math/randomsequence.cpp b/source/core/math/randomsequence.cpp index dc1b70746..512ab8aae 100644 --- a/source/core/math/randomsequence.cpp +++ b/source/core/math/randomsequence.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,12 +36,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/randomsequence.h" -#include +// C++ variants of C standard header files +// (none at the moment) +// C++ standard header files #include #include #include +// Boost header files #include #include #include @@ -50,6 +53,10 @@ #include #endif +// POV-Ray header files (base module) +#include "base/povassert.h" + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/math/randcosweighted.h" @@ -66,6 +73,9 @@ using boost::uniform_real; using boost::variate_generator; using boost::mt19937; +using std::shared_ptr; +using std::vector; + #define PRIME_TABLE_COUNT 25 unsigned int primeTable[PRIME_TABLE_COUNT] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 }; @@ -118,7 +128,7 @@ vector RandomInts(int minval, int maxval, size_t count) { mt19937 generator; uniform_int distribution(minval, maxval); - variate_generator > sequence(generator, distribution); + variate_generator> sequence(generator, distribution); vector rands(count); for(size_t i = 0; i < count; i++) @@ -131,7 +141,7 @@ vector RandomDoubles(double minval, double maxval, size_t count) { mt19937 generator; uniform_real distribution(minval, maxval); - variate_generator > sequence(generator, distribution); + variate_generator> sequence(generator, distribution); vector rands(count); for(size_t i = 0; i < count; i++) @@ -269,11 +279,11 @@ class HybridNumberGenerator : public SeedableNumberGenerator, public Index public: HybridNumberGenerator(size_t size = 0); - virtual Type operator()(); - virtual shared_ptr > GetSequence(size_t count); - virtual size_t MaxIndex() const; - virtual size_t CycleLength() const; - virtual void Seed(size_t seed); + virtual Type operator()() override; + virtual shared_ptr> GetSequence(size_t count) override; + virtual size_t MaxIndex() const override; + virtual size_t CycleLength() const override; + virtual void Seed(size_t seed) override; protected: @@ -294,7 +304,8 @@ class UniformRandomNumberGenerator : public SeedableNumberGenerator { public: - struct ParameterStruct { + struct ParameterStruct final + { ParameterStruct(Type minval, Type maxval); Type minval, maxval; bool operator< (const ParameterStruct& other) const; @@ -302,16 +313,16 @@ class UniformRandomNumberGenerator : public SeedableNumberGenerator UniformRandomNumberGenerator(const ParameterStruct& param); UniformRandomNumberGenerator(Type minval, Type maxval); - virtual Type operator()(); - virtual size_t CycleLength() const; + virtual Type operator()() override; + virtual size_t CycleLength() const override; virtual void Seed(size_t seed) override; protected: variate_generator generator; }; -typedef UniformRandomNumberGenerator > Mt19937IntGenerator; -typedef UniformRandomNumberGenerator > Mt19937DoubleGenerator; +typedef UniformRandomNumberGenerator> Mt19937IntGenerator; +typedef UniformRandomNumberGenerator> Mt19937DoubleGenerator; /** * Generator for a 1-dimensional Halton sequence (aka van-der-Corput sequence). @@ -333,7 +344,7 @@ class HaltonGenerator : public HybridNumberGenerator HaltonGenerator(const ParameterStruct& param); HaltonGenerator(unsigned int base, Type minval, Type maxval); /// Returns a particular number from the sequence. - virtual double operator[](size_t index) const; + virtual double operator[](size_t index) const override; protected: @@ -366,7 +377,7 @@ class LegacyCosWeightedDirectionGenerator : public HybridNumberGenerator }; Halton2dBasedGenerator(const ParameterStruct& param); - virtual Type operator[](size_t i) const = 0; + virtual Type operator[](size_t i) const override = 0; protected: @@ -409,7 +420,7 @@ class HaltonCosWeightedDirectionGenerator : public Halton2dBasedGenerator }; HaltonOnDiscGenerator(const ParameterStruct& param); - virtual Vector2d operator[](size_t i) const; + virtual Vector2d operator[](size_t i) const override; }; /** @@ -441,7 +452,7 @@ class HaltonUniformDirectionGenerator : public Halton2dBasedGenerator { public: Halton2dGenerator(const ParameterStruct& param); - virtual Vector2d operator[](size_t i) const; + virtual Vector2d operator[](size_t i) const override; }; @@ -470,9 +481,9 @@ class NumberSequenceFactory /// Sets up the factory to use a given sequence. NumberSequenceFactory(shared_ptr const> masterSequence); /// Sets up the factory to use a given number source. - NumberSequenceFactory(shared_ptr > master); + NumberSequenceFactory(shared_ptr> master); /// Sets up the factory to use a given number source, pre-computing a given number of elements. - NumberSequenceFactory(shared_ptr > master, size_t count); + NumberSequenceFactory(shared_ptr> master, size_t count); /// Gets a reference to a table of pre-computed numbers having at least the given size. /// @note The vector returned may contain more elements than requested. shared_ptr const> operator()(size_t count); @@ -505,13 +516,13 @@ class NumberSequenceMetaFactory { public: - static shared_ptr > GetFactory(const typename GeneratorType::ParameterStruct& param); + static shared_ptr> GetFactory(const typename GeneratorType::ParameterStruct& param); protected: typedef NumberSequenceFactory Factory; typedef shared_ptr FactoryPtr; - typedef weak_ptr FactoryWeakPtr; + typedef std::weak_ptr FactoryWeakPtr; typedef std::map FactoryTable; static FactoryTable* lookupTable; @@ -539,24 +550,24 @@ class PrecomputedNumberGenerator : public HybridNumberGenerator public: /// Construct from a sequence factory. - PrecomputedNumberGenerator(shared_ptr > master, size_t size) : + PrecomputedNumberGenerator(shared_ptr> master, size_t size) : HybridNumberGenerator(size), values((*master)(size)) {} /// Returns a particular number from the sequence. - virtual Type operator[](size_t i) const + virtual Type operator[](size_t i) const override { // According to C++ standard, template classes cannot refer to parent template classes' members by unqualified name const size_t& size = HybridNumberGenerator::size; return (*values)[i % size]; } /// Returns a particular subset from the sequence. - virtual shared_ptr > GetSequence(size_t index, size_t count) const + virtual shared_ptr> GetSequence(size_t index, size_t count) const override { // According to C++ standard, template classes cannot refer to parent template classes' members by unqualified name const size_t& size = HybridNumberGenerator::size; - shared_ptr > data(new vector); + shared_ptr> data(new vector); data->reserve(count); size_t i = index % size; while (count >= size - i) // handle wrap-around @@ -600,9 +611,9 @@ Type HybridNumberGenerator::operator()() } template -shared_ptr > HybridNumberGenerator::GetSequence(size_t count) +shared_ptr> HybridNumberGenerator::GetSequence(size_t count) { - shared_ptr > data(IndexedNumberGenerator::GetSequence(index, count)); + shared_ptr> data(IndexedNumberGenerator::GetSequence(index, count)); index += count; if (size != 0) index = index % size; @@ -748,12 +759,12 @@ NumberSequenceFactory::NumberSequenceFactory(shared_ptr const {} template -NumberSequenceFactory::NumberSequenceFactory(shared_ptr > master) : +NumberSequenceFactory::NumberSequenceFactory(shared_ptr> master) : master(master) {} template -NumberSequenceFactory::NumberSequenceFactory(shared_ptr > master, size_t count) : +NumberSequenceFactory::NumberSequenceFactory(shared_ptr> master, size_t count) : master(master) { (*this)(count); // force initial sequence to be generated @@ -802,7 +813,7 @@ shared_ptr const> NumberSequenceFactory::operator()(size_t co *********************************************************************************/ template -std::map > >* NumberSequenceMetaFactory::lookupTable; +std::map>>* NumberSequenceMetaFactory::lookupTable; #if POV_MULTITHREADED template @@ -810,7 +821,7 @@ boost::mutex NumberSequenceMetaFactory::lookupMutex; #endif template -shared_ptr > NumberSequenceMetaFactory::GetFactory(const typename GeneratorType::ParameterStruct& param) +shared_ptr> NumberSequenceMetaFactory::GetFactory(const typename GeneratorType::ParameterStruct& param) { #if POV_MULTITHREADED boost::mutex::scoped_lock lock(lookupMutex); @@ -821,7 +832,7 @@ shared_ptr > NumberSequenceMetaFactory masterGenerator(new GeneratorType(param)); - factory = FactoryPtr(new Factory(shared_ptr >(masterGenerator))); + factory = FactoryPtr(new Factory(shared_ptr>(masterGenerator))); (*lookupTable)[param] = factory; } return factory; @@ -975,7 +986,7 @@ SeedableIntGeneratorPtr GetRandomIntGenerator(int minval, int maxval, size_t cou { POV_RANDOMSEQUENCE_ASSERT(count > 0); Mt19937IntGenerator::ParameterStruct param(minval, maxval); - shared_ptr > factory = Mt19937IntMetaFactory::GetFactory(param); + shared_ptr> factory = Mt19937IntMetaFactory::GetFactory(param); SeedableIntGeneratorPtr generator(new PrecomputedIntGenerator(factory, count)); (void)(*generator)(); // legacy fix return generator; @@ -985,7 +996,7 @@ SeedableDoubleGeneratorPtr GetRandomDoubleGenerator(double minval, double maxval { POV_RANDOMSEQUENCE_ASSERT(count > 0); Mt19937DoubleGenerator::ParameterStruct param(minval, maxval); - shared_ptr > factory(Mt19937DoubleMetaFactory::GetFactory(param)); + shared_ptr> factory(Mt19937DoubleMetaFactory::GetFactory(param)); SeedableDoubleGeneratorPtr generator(new PrecomputedDoubleGenerator(factory, count)); (void)(*generator)(); // legacy fix return generator; @@ -1003,7 +1014,7 @@ IndexedDoubleGeneratorPtr GetIndexedRandomDoubleGenerator(double minval, double { POV_RANDOMSEQUENCE_ASSERT(count > 0); Mt19937DoubleGenerator::ParameterStruct param(minval, maxval); - shared_ptr > factory(Mt19937DoubleMetaFactory::GetFactory(param)); + shared_ptr> factory(Mt19937DoubleMetaFactory::GetFactory(param)); return IndexedDoubleGeneratorPtr(new PrecomputedDoubleGenerator(factory, count)); } @@ -1012,7 +1023,7 @@ SequentialVectorGeneratorPtr GetSubRandomCosWeightedDirectionGenerator(unsigned if ((id == 0) && count && (count < LegacyCosWeightedDirectionGenerator::NumEntries)) { LegacyCosWeightedDirectionGenerator::ParameterStruct param; - shared_ptr > factory(LegacyCosWeightedDirectionMetaFactory::GetFactory(param)); + shared_ptr> factory(LegacyCosWeightedDirectionMetaFactory::GetFactory(param)); return SequentialVectorGeneratorPtr(new PrecomputedVectorGenerator(factory, count)); } else @@ -1020,7 +1031,7 @@ SequentialVectorGeneratorPtr GetSubRandomCosWeightedDirectionGenerator(unsigned HaltonCosWeightedDirectionGenerator::ParameterStruct param(primeTable[id % PRIME_TABLE_COUNT], primeTable[(id+1) % PRIME_TABLE_COUNT]); if (count) { - shared_ptr > factory(HaltonCosWeightedDirectionMetaFactory::GetFactory(param)); + shared_ptr> factory(HaltonCosWeightedDirectionMetaFactory::GetFactory(param)); return SequentialVectorGeneratorPtr(new PrecomputedVectorGenerator(factory, count)); } else @@ -1033,7 +1044,7 @@ SequentialDoubleGeneratorPtr GetSubRandomDoubleGenerator(unsigned int id, double HaltonDoubleGenerator::ParameterStruct param(primeTable[id % PRIME_TABLE_COUNT], minval, maxval); if (count) { - shared_ptr > factory(HaltonUniformDoubleMetaFactory::GetFactory(param)); + shared_ptr> factory(HaltonUniformDoubleMetaFactory::GetFactory(param)); return SequentialDoubleGeneratorPtr(new PrecomputedDoubleGenerator(factory, count)); } else @@ -1045,7 +1056,7 @@ SequentialVectorGeneratorPtr GetSubRandomDirectionGenerator(unsigned int id, siz HaltonUniformDirectionGenerator::ParameterStruct param(primeTable[id % PRIME_TABLE_COUNT], primeTable[(id+1) % PRIME_TABLE_COUNT]); if (count) { - shared_ptr > factory(HaltonUniformDirectionMetaFactory::GetFactory(param)); + shared_ptr> factory(HaltonUniformDirectionMetaFactory::GetFactory(param)); return SequentialVectorGeneratorPtr(new PrecomputedVectorGenerator(factory, count)); } else @@ -1057,7 +1068,7 @@ SequentialVector2dGeneratorPtr GetSubRandomOnDiscGenerator(unsigned int id, doub HaltonOnDiscGenerator::ParameterStruct param(primeTable[id % PRIME_TABLE_COUNT], primeTable[(id+1) % PRIME_TABLE_COUNT], radius); if (count) { - shared_ptr > factory(HaltonOnDiscMetaFactory::GetFactory(param)); + shared_ptr> factory(HaltonOnDiscMetaFactory::GetFactory(param)); return SequentialVector2dGeneratorPtr(new PrecomputedVector2dGenerator(factory, count)); } else @@ -1069,11 +1080,12 @@ SequentialVector2dGeneratorPtr GetSubRandom2dGenerator(unsigned int id, double m Halton2dGenerator::ParameterStruct param(primeTable[id % PRIME_TABLE_COUNT], primeTable[(id+1) % PRIME_TABLE_COUNT], minX, maxX, minY, maxY); if (count) { - shared_ptr > factory(Halton2dMetaFactory::GetFactory(param)); + shared_ptr> factory(Halton2dMetaFactory::GetFactory(param)); return SequentialVector2dGeneratorPtr(new PrecomputedVector2dGenerator(factory, count)); } else return SequentialVector2dGeneratorPtr(new Halton2dGenerator(param)); } -} // end of namespace pov +} +// end of namespace pov diff --git a/source/core/math/randomsequence.h b/source/core/math/randomsequence.h index f507bf8d3..65af6da16 100644 --- a/source/core/math/randomsequence.h +++ b/source/core/math/randomsequence.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 @@ -39,8 +39,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/vector.h" namespace pov @@ -53,17 +62,15 @@ namespace pov /// /// @{ -using namespace pov_base; - -vector RandomInts(int minval, int maxval, size_t count); -vector RandomDoubles(int minval, int maxval, size_t count); +std::vector RandomInts(int minval, int maxval, size_t count); +std::vector RandomDoubles(int minval, int maxval, size_t count); DBL POV_rand(unsigned int& next_rand); // need this to prevent VC++ v8 from thinking that Generator refers to boost::Generator class Generator; -class RandomIntSequence +class RandomIntSequence final { friend class Generator; public: @@ -71,7 +78,7 @@ class RandomIntSequence int operator()(size_t seedindex); - class Generator + class Generator final { public: Generator(RandomIntSequence *seq, size_t seedindex = 0); @@ -84,10 +91,10 @@ class RandomIntSequence size_t index; }; private: - vector values; + std::vector values; }; -class RandomDoubleSequence +class RandomDoubleSequence final { friend class Generator; public: @@ -95,7 +102,7 @@ class RandomDoubleSequence double operator()(size_t seedindex); - class Generator + class Generator final { public: Generator(RandomDoubleSequence *seq, size_t seedindex = 0); @@ -108,7 +115,7 @@ class RandomDoubleSequence size_t index; }; private: - vector values; + std::vector values; }; @@ -127,9 +134,9 @@ class SequentialNumberGenerator /// Returns the next number from the sequence. virtual Type operator()() = 0; /// Returns the next N numbers from the sequence. - virtual shared_ptr > GetSequence(size_t count) + virtual std::shared_ptr> GetSequence(size_t count) { - shared_ptr > data(new vector); + std::shared_ptr> data(new std::vector); data->reserve(count); for (size_t i = 0; i < count; i ++) data->push_back((*this)()); @@ -156,9 +163,9 @@ class IndexedNumberGenerator /// Returns a particular number from the sequence. virtual Type operator[](size_t index) const = 0; /// Returns a particular subsequence from the sequence. - virtual shared_ptr > GetSequence(size_t index, size_t count) const + virtual std::shared_ptr> GetSequence(size_t index, size_t count) const { - shared_ptr > data(new vector); + std::shared_ptr> data(new std::vector); data->reserve(count); for (size_t i = 0; i < count; i ++) data->push_back((*this)[index + i]); @@ -180,20 +187,20 @@ class IndexedNumberGenerator /// /// @{ -typedef shared_ptr > SequentialIntGeneratorPtr; -typedef shared_ptr > SequentialDoubleGeneratorPtr; -typedef shared_ptr > SequentialVectorGeneratorPtr; -typedef shared_ptr > SequentialVector2dGeneratorPtr; +typedef std::shared_ptr> SequentialIntGeneratorPtr; +typedef std::shared_ptr> SequentialDoubleGeneratorPtr; +typedef std::shared_ptr> SequentialVectorGeneratorPtr; +typedef std::shared_ptr> SequentialVector2dGeneratorPtr; -typedef shared_ptr > SeedableIntGeneratorPtr; -typedef shared_ptr > SeedableDoubleGeneratorPtr; -typedef shared_ptr > SeedableVectorGeneratorPtr; -typedef shared_ptr > SeedableVector2dGeneratorPtr; +typedef std::shared_ptr> SeedableIntGeneratorPtr; +typedef std::shared_ptr> SeedableDoubleGeneratorPtr; +typedef std::shared_ptr> SeedableVectorGeneratorPtr; +typedef std::shared_ptr> SeedableVector2dGeneratorPtr; -typedef shared_ptr const> IndexedIntGeneratorPtr; -typedef shared_ptr const> IndexedDoubleGeneratorPtr; -typedef shared_ptr const> IndexedVectorGeneratorPtr; -typedef shared_ptr const> IndexedVector2dGeneratorPtr; +typedef std::shared_ptr const> IndexedIntGeneratorPtr; +typedef std::shared_ptr const> IndexedDoubleGeneratorPtr; +typedef std::shared_ptr const> IndexedVectorGeneratorPtr; +typedef std::shared_ptr const> IndexedVector2dGeneratorPtr; /** * @} @@ -363,5 +370,6 @@ SequentialVector2dGeneratorPtr GetSubRandom2dGenerator(unsigned int id, double m //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_RANDOMSEQUENCE_H diff --git a/source/core/math/spline.cpp b/source/core/math/spline.cpp index 7659714ac..0a4f80619 100644 --- a/source/core/math/spline.cpp +++ b/source/core/math/spline.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 @@ -44,15 +44,22 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/math/spline.h" +// C++ variants of C standard header files #include #include #include +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/pov_err.h" +#include "base/povassert.h" #include "base/types.h" +// POV-Ray header files (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -853,3 +860,4 @@ DBL Get_Spline_Val(GenericSpline *sp, DBL p, EXPRESS& v, int *Terms) } } +// end of namespace pov diff --git a/source/core/math/spline.h b/source/core/math/spline.h index 5d0146dd1..f4ad04ed1 100644 --- a/source/core/math/spline.h +++ b/source/core/math/spline.h @@ -16,7 +16,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 @@ -47,7 +47,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include "base/types.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) +// (none at the moment) namespace pov { @@ -61,14 +71,14 @@ using namespace pov_base; /// /// @{ -struct SplineEntry +struct SplineEntry final { DBL par; // Parameter EXPRESS vec; // Value at the parameter DBL coeff[5]; // Interpolating coefficients at the parameter }; -typedef vector SplineEntryList; +typedef std::vector SplineEntryList; typedef int SplineRefCount; @@ -88,36 +98,36 @@ struct GenericSpline void ReleaseReference(); }; -struct LinearSpline : public GenericSpline +struct LinearSpline final : public GenericSpline { LinearSpline(); LinearSpline(const GenericSpline& o); - virtual void Get(DBL p, EXPRESS& v); - virtual GenericSpline* Clone() const { return new LinearSpline(*this); } + virtual void Get(DBL p, EXPRESS& v) override; + virtual GenericSpline* Clone() const override { return new LinearSpline(*this); } }; -struct QuadraticSpline : public GenericSpline +struct QuadraticSpline final : public GenericSpline { QuadraticSpline(); QuadraticSpline(const GenericSpline& o); - virtual void Get(DBL p, EXPRESS& v); - virtual GenericSpline* Clone() const { return new QuadraticSpline(*this); } + virtual void Get(DBL p, EXPRESS& v) override; + virtual GenericSpline* Clone() const override { return new QuadraticSpline(*this); } }; -struct NaturalSpline : public GenericSpline +struct NaturalSpline final : public GenericSpline { NaturalSpline(); NaturalSpline(const GenericSpline& o); - virtual void Get(DBL p, EXPRESS& v); - virtual GenericSpline* Clone() const { return new NaturalSpline(*this); } + virtual void Get(DBL p, EXPRESS& v) override; + virtual GenericSpline* Clone() const override { return new NaturalSpline(*this); } }; -struct CatmullRomSpline : public GenericSpline +struct CatmullRomSpline final : public GenericSpline { CatmullRomSpline(); CatmullRomSpline(const GenericSpline& o); - virtual void Get(DBL p, EXPRESS& v); - virtual GenericSpline* Clone() const { return new CatmullRomSpline(*this); } + virtual void Get(DBL p, EXPRESS& v) override; + virtual GenericSpline* Clone() const override { return new CatmullRomSpline(*this); } }; @@ -135,5 +145,6 @@ DBL Get_Spline_Val(GenericSpline* sp, DBL p, EXPRESS& v, int *Terms); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SPLINE_H diff --git a/source/core/math/vector.cpp b/source/core/math/vector.cpp new file mode 100644 index 000000000..6789e5c69 --- /dev/null +++ b/source/core/math/vector.cpp @@ -0,0 +1,100 @@ +//****************************************************************************** +/// +/// @file core/math/vector.cpp +/// +/// Implementations related to vector arithmetics. +/// +/// @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 "core/math/vector.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_mem.h" +// POV-Ray header files (core module) +// (none at the moment) + +namespace pov +{ + +//****************************************************************************** + +VECTOR_4D *Create_Vector_4D () +{ + VECTOR_4D *New; + + New = reinterpret_cast(POV_MALLOC(sizeof (VECTOR_4D), "4d vector")); + + (*New)[0]= 0.0; + (*New)[1]= 0.0; + (*New)[2]= 0.0; + (*New)[3]= 0.0; + + return (New); +} + +void Assign_Vector_4D(VECTOR_4D d, const VECTOR_4D s) +{ + d[X] = s[X]; + d[Y] = s[Y]; + d[Z] = s[Z]; + d[T] = s[T]; +} + +void Destroy_Vector_4D(VECTOR_4D *x) +{ + if (x != nullptr) + POV_FREE(x); +} + +// Inverse Scale - Divide Vector by a Scalar +void V4D_InverseScaleEq(VECTOR_4D a, DBL k) +{ + DBL tmp = 1.0 / k; + a[X] *= tmp; + a[Y] *= tmp; + a[Z] *= tmp; + a[T] *= tmp; +} + +// Dot Product - Gives Scalar angle (a) between two vectors (b) and (c) +void V4D_Dot(DBL& a, const VECTOR_4D b, const VECTOR_4D c) +{ + a = b[X] * c[X] + b[Y] * c[Y] + b[Z] * c[Z] + b[T] * c[T]; +} + +//****************************************************************************** + +} +// end of namespace pov diff --git a/source/core/math/vector.h b/source/core/math/vector.h index a581b8226..174868bf7 100644 --- a/source/core/math/vector.h +++ b/source/core/math/vector.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 @@ -39,7 +39,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include "base/types.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) namespace pov { @@ -65,56 +73,23 @@ enum W = 3 }; -typedef DBL VECTOR_4D[4]; ///< @todo Make this obsolete. - -/***************************************************************************** -* Inline functions -******************************************************************************/ +//****************************************************************************** -inline VECTOR_4D *Create_Vector_4D () -{ - VECTOR_4D *New; +typedef DBL VECTOR_4D[4]; ///< @todo Make this obsolete. - New = reinterpret_cast(POV_MALLOC(sizeof (VECTOR_4D), "4d vector")); +VECTOR_4D *Create_Vector_4D (); - (*New)[0]= 0.0; - (*New)[1]= 0.0; - (*New)[2]= 0.0; - (*New)[3]= 0.0; +void Assign_Vector_4D(VECTOR_4D d, const VECTOR_4D s); - return (New); -} - -inline void Assign_Vector_4D(VECTOR_4D d, const VECTOR_4D s) -{ - d[X] = s[X]; - d[Y] = s[Y]; - d[Z] = s[Z]; - d[T] = s[T]; -} - -inline void Destroy_Vector_4D(VECTOR_4D *x) -{ - if (x != nullptr) - POV_FREE(x); -} +void Destroy_Vector_4D(VECTOR_4D *x); // Inverse Scale - Divide Vector by a Scalar -inline void V4D_InverseScaleEq(VECTOR_4D a, DBL k) -{ - DBL tmp = 1.0 / k; - a[X] *= tmp; - a[Y] *= tmp; - a[Z] *= tmp; - a[T] *= tmp; -} +void V4D_InverseScaleEq(VECTOR_4D a, DBL k); // Dot Product - Gives Scalar angle (a) between two vectors (b) and (c) -inline void V4D_Dot(DBL& a, const VECTOR_4D b, const VECTOR_4D c) -{ - a = b[X] * c[X] + b[Y] * c[Y] + b[Z] * c[Z] + b[T] * c[T]; -} +void V4D_Dot(DBL& a, const VECTOR_4D b, const VECTOR_4D c); +//****************************************************************************** template class GenericVector3d; @@ -124,7 +99,7 @@ class GenericVector3d; /// @tparam T Floating-point type to use for the individual vector components. /// template -class GenericVector2d +class GenericVector2d final { public: @@ -343,7 +318,7 @@ class GenericVector2d /// @tparam T Floating-point type to use for the individual vector components. /// template -class GenericVector3d +class GenericVector3d final { public: @@ -680,5 +655,6 @@ inline GenericVector3d max(GenericVector3d& a, const GenericVector3d& b } } +// end of namespace pov #endif // POVRAY_CORE_VECTOR_H diff --git a/source/core/precomp.h b/source/core/precomp.h index d412cbd84..35f6028c6 100644 --- a/source/core/precomp.h +++ b/source/core/precomp.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 @@ -45,8 +45,9 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -#include "base/configbase.h" +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED +// C++ variants of C standard header files #include #include #include @@ -56,6 +57,7 @@ #include #include +// C++ standard header files #include #include #include @@ -68,13 +70,12 @@ #include #include +// Boost header files #include #include #include #include #include -#include -#include #if POV_MULTITHREADED #include #include diff --git a/source/core/render/ray.cpp b/source/core/render/ray.cpp index 9f556a3b0..fcf048998 100644 --- a/source/core/render/ray.cpp +++ b/source/core/render/ray.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 @@ -36,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/render/ray.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/interior.h" // this must be the last file included @@ -158,3 +166,4 @@ void Ray::SetFlags(RayType rt, const Ray& other) } } +// end of namespace pov diff --git a/source/core/render/ray.h b/source/core/render/ray.h index 30afb695a..6f79c07d9 100644 --- a/source/core/render/ray.h +++ b/source/core/render/ray.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 @@ -38,7 +38,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/render/ray_fwd.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/core_fwd.h" #include "core/bounding/boundingbox.h" #include "core/colour/spectral.h" #include "core/support/simplevector.h" @@ -52,11 +62,9 @@ namespace pov /// /// @{ -class Interior; - typedef PooledSimpleVector RayInteriorVector; -class Ray : public BasicRay +class Ray final : public BasicRay { public: @@ -128,5 +136,6 @@ class Ray : public BasicRay //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_RAY_H diff --git a/source/core/render/ray_fwd.h b/source/core/render/ray_fwd.h new file mode 100644 index 000000000..800e4140c --- /dev/null +++ b/source/core/render/ray_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file core/render/ray_fwd.h +/// +/// Forward declarations related to rays. +/// +/// @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_CORE_RAY_FWD_H +#define POVRAY_CORE_RAY_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class Ray; + +} +// end of namespace pov + +#endif // POVRAY_CORE_RAY_FWD_H diff --git a/source/core/render/trace.cpp b/source/core/render/trace.cpp index 3de25937f..468dd2c49 100644 --- a/source/core/render/trace.cpp +++ b/source/core/render/trace.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,10 +36,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/render/trace.h" +// C++ variants of C standard header files #include +// C++ standard header files +#include + +// Boost header files #include +// POV-Ray header files (base module) +#include "base/povassert.h" + +// POV-Ray header files (core module) #include "core/bounding/bsptree.h" #include "core/lighting/lightsource.h" #include "core/lighting/radiosity.h" @@ -67,6 +76,10 @@ namespace pov { +using std::min; +using std::max; +using std::vector; + #define SHADOW_TOLERANCE 1.0e-3 @@ -83,7 +96,7 @@ bool NoSomethingFlagRayObjectCondition::operator()(const Ray& ray, ConstObjectPt return true; } -Trace::Trace(shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, +Trace::Trace(std::shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, CooperateFunctor& cf, MediaFunctor& mf, RadiosityFunctor& rf) : threadData(td), sceneData(sd), @@ -749,7 +762,7 @@ void Trace::ComputeLightedTexture(MathColour& resultColour, ColourChannel& resul MathColour ambBackCol; bool one_colour_found, colour_found; bool tir_occured; - std::auto_ptr surfacePhotonGatherer(nullptr); // TODO FIXME - auto_ptr why? [CLi] why, to auto-destruct it of course! (e.g. in case of exception) + std::unique_ptr surfacePhotonGatherer(nullptr); double relativeIor; ComputeRelativeIOR(ray, isect.Object->interior.get(), relativeIor); @@ -1927,14 +1940,14 @@ void Trace::TraceShadowRay(const LightSource &lightsource, double depth, Ray& li // to link the exe, complaining of an unresolved external. // // TODO: try moving it back in at some point in the future. -struct NoShadowFlagRayObjectCondition : public RayObjectCondition +struct NoShadowFlagRayObjectCondition final : public RayObjectCondition { - virtual bool operator()(const Ray&, ConstObjectPtr object, double) const { return !Test_Flag(object, NO_SHADOW_FLAG); } + virtual bool operator()(const Ray&, ConstObjectPtr object, double) const override { return !Test_Flag(object, NO_SHADOW_FLAG); } }; -struct SmallToleranceRayObjectCondition : public RayObjectCondition +struct SmallToleranceRayObjectCondition final : public RayObjectCondition { - virtual bool operator()(const Ray&, ConstObjectPtr, double dist) const { return dist > SMALL_TOLERANCE; } + virtual bool operator()(const Ray&, ConstObjectPtr, double dist) const override { return dist > SMALL_TOLERANCE; } }; void Trace::TracePointLightShadowRay(const LightSource &lightsource, double& lightsourcedepth, Ray& lightsourceray, MathColour& lightcolour) @@ -3884,4 +3897,5 @@ void Trace::ComputeSubsurfaceScattering(const FINISH *Finish, const MathColour& Eye.GetTicket().subsurfaceRecursionDepth--; } -} // end of namespace +} +// end of namespace pov diff --git a/source/core/render/trace.h b/source/core/render/trace.h index 3b9ed2145..e45a4a7d8 100644 --- a/source/core/render/trace.h +++ b/source/core/render/trace.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 @@ -39,11 +39,22 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/coretypes.h" #include "core/bounding/bsptree.h" #include "core/math/randomsequence.h" #include "core/render/ray.h" +#include "core/scene/atmosphere_fwd.h" namespace pov { @@ -55,18 +66,14 @@ namespace pov /// /// @{ -typedef struct Fog_Struct FOG; class PhotonGatherer; -class SceneData; -class Task; -class ViewData; -struct NoSomethingFlagRayObjectCondition : public RayObjectCondition +struct NoSomethingFlagRayObjectCondition final : public RayObjectCondition { - virtual bool operator()(const Ray& ray, ConstObjectPtr object, double) const; + virtual bool operator()(const Ray& ray, ConstObjectPtr object, double) const override; }; -struct LitInterval +struct LitInterval final { bool lit; double s0, s1, ds; @@ -78,7 +85,7 @@ struct LitInterval lit(nlit), s0(ns0), s1(ns1), ds(ns1 - ns0), l0(nl0), l1(nl1) { } }; -struct MediaInterval +struct MediaInterval final { bool lit; int samples; @@ -98,7 +105,7 @@ struct MediaInterval bool operator<(const MediaInterval& other) const { return (s0 < other.s0); } }; -struct LightSourceIntersectionEntry +struct LightSourceIntersectionEntry final { double s; size_t l; @@ -112,7 +119,7 @@ struct LightSourceIntersectionEntry bool operator<(const LightSourceIntersectionEntry& other) const { return (s < other.s); } }; -struct LightSourceEntry +struct LightSourceEntry final { double s0, s1; LightSource *light; @@ -135,7 +142,7 @@ typedef PooledSimpleVector LightSourceEntryVector; -struct TraceTicket +struct TraceTicket final { /// trace recursion level unsigned int traceLevel; @@ -187,13 +194,15 @@ class Trace class CooperateFunctor { public: + virtual ~CooperateFunctor() {} virtual void operator()() { } }; class MediaFunctor { public: - virtual void ComputeMedia(vector&, const Ray&, Intersection&, MathColour&, ColourChannel&) { } + virtual ~MediaFunctor() {} + virtual void ComputeMedia(std::vector&, const Ray&, Intersection&, MathColour&, ColourChannel&) { } virtual void ComputeMedia(const RayInteriorVector&, const Ray&, Intersection&, MathColour&, ColourChannel&) { } virtual void ComputeMedia(MediaVector&, const Ray&, Intersection&, MathColour&, ColourChannel&) { } }; @@ -201,12 +210,13 @@ class Trace class RadiosityFunctor { public: + virtual ~RadiosityFunctor() {} virtual void ComputeAmbient(const Vector3d& ipoint, const Vector3d& raw_normal, const Vector3d& layer_normal, double brilliance, MathColour& ambient_colour, double weight, TraceTicket& ticket) { } virtual bool CheckRadiosityTraceLevel(const TraceTicket& ticket) { return false; } }; /// @todo TraceThreadData already holds a reference to SceneData. - Trace(shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, + Trace(std::shared_ptr sd, TraceThreadData *td, const QualityFlags& qf, CooperateFunctor& cf, MediaFunctor& mf, RadiosityFunctor& af); virtual ~Trace(); @@ -254,7 +264,7 @@ class Trace protected: // TODO FIXME - should be private /// Structure used to cache reflection information for multi-layered textures. - struct WNRX + struct WNRX final { double weight; Vector3d normal; @@ -265,23 +275,23 @@ class Trace weight(w), normal(n), reflec(r), reflex(x) { } }; - typedef vector TextureVectorData; + typedef std::vector TextureVectorData; typedef RefPool TextureVectorPool; - typedef Ref > TextureVector; + typedef Ref> TextureVector; - typedef vector WNRXVectorData; + typedef std::vector WNRXVectorData; typedef RefPool WNRXVectorPool; - typedef Ref > WNRXVector; + typedef Ref> WNRXVector; /// Structure used to cache shadow test results for complex textures. - struct LightColorCache + struct LightColorCache final { bool tested; MathColour colour; }; - typedef vector LightColorCacheList; - typedef vector LightColorCacheListList; + typedef std::vector LightColorCacheList; + typedef std::vector LightColorCacheListList; /// List (well really vector) of lists of LightColorCaches. /// Each list is expected to have as many elements as there are global light sources. @@ -292,7 +302,7 @@ class Trace int lightColorCacheIndex; /// Scene data. - shared_ptr sceneData; + std::shared_ptr sceneData; /// Maximum trace recursion level found. unsigned int maxFoundTraceLevel; @@ -304,7 +314,7 @@ class Trace /// BSP tree mailbox. BSPTree::Mailbox mailbox; /// Area light grid buffer. - vector lightGrid; + std::vector lightGrid; /// Fast stack pool. IStackPool stackPool; /// Fast texture list pool. @@ -312,9 +322,9 @@ class Trace /// Fast WNRX list pool. WNRXVectorPool wnrxPool; /// Light source shadow cache for shadow tests of first trace level intersections. - vector lightSourceLevel1ShadowCache; + std::vector lightSourceLevel1ShadowCache; /// Light source shadow cache for shadow tests of higher trace level intersections. - vector lightSourceOtherShadowCache; + std::vector lightSourceOtherShadowCache; /// `crand` random number generator. unsigned int crandRandomNumberGenerator; /// Pseudo-random number sequence. @@ -322,11 +332,11 @@ class Trace /// Pseudo-random number generator based on random number sequence. RandomDoubleSequence::Generator randomNumberGenerator; /// Sub-random uniform 3d points on sphere sequence. - vector ssltUniformDirectionGenerator; + std::vector ssltUniformDirectionGenerator; /// Sub-random uniform numbers sequence. - vector ssltUniformNumberGenerator; + std::vector ssltUniformNumberGenerator; /// Sub-random cos-weighted 3d points on hemisphere sequence. - vector ssltCosWeightedDirectionGenerator; + std::vector ssltCosWeightedDirectionGenerator; /// Thread data. TraceThreadData *threadData; @@ -385,7 +395,7 @@ class Trace /// @param[in] shadowflag Whether to perform only computations necessary for shadow testing. /// @param[in] photonpass Whether to deposit photons instead of computing a colour. /// - void ComputeOneTextureColour(MathColour& resultColour, ColourChannel& resultTransm, const TEXTURE *texture, vector& warps, + void ComputeOneTextureColour(MathColour& resultColour, ColourChannel& resultTransm, const TEXTURE *texture, std::vector& warps, const Vector3d& ipoint, const Vector3d& rawnormal, Ray& ray, COLC weight, Intersection& isect, bool shadowflag, bool photonpass); @@ -411,7 +421,7 @@ class Trace /// @param[in] shadowflag Whether to perform only computations necessary for shadow testing. /// @param[in] photonpass Whether to deposit photons instead of computing a colour. /// - void ComputeAverageTextureColours(MathColour& resultColour, ColourChannel& resultTransm, const TEXTURE *texture, vector& warps, + void ComputeAverageTextureColours(MathColour& resultColour, ColourChannel& resultTransm, const TEXTURE *texture, std::vector& warps, const Vector3d& ipoint, const Vector3d& rawnormal, Ray& ray, COLC weight, Intersection& isect, bool shadowflag, bool photonpass); @@ -438,7 +448,7 @@ class Trace /// @param[in] weight Importance of this computation. /// @param[in] isect Intersection information. /// - virtual void ComputeLightedTexture(MathColour& resultColour, ColourChannel& resultTransm, const TEXTURE *texture, vector& warps, + virtual void ComputeLightedTexture(MathColour& resultColour, ColourChannel& resultTransm, const TEXTURE *texture, std::vector& warps, const Vector3d& ipoint, const Vector3d& rawnormal, Ray& ray, COLC weight, Intersection& isect); @@ -459,7 +469,7 @@ class Trace /// @param[in,out] ray Ray and associated information. /// @param[in] isect Intersection information. /// - void ComputeShadowTexture(MathColour& filtercolour, const TEXTURE *texture, vector& warps, + void ComputeShadowTexture(MathColour& filtercolour, const TEXTURE *texture, std::vector& warps, const Vector3d& ipoint, const Vector3d& rawnormal, const Ray& ray, Intersection& isect); @@ -823,5 +833,6 @@ class Trace //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TRACE_H diff --git a/source/core/render/tracepixel.cpp b/source/core/render/tracepixel.cpp index 58bb16910..32a8abcba 100644 --- a/source/core/render/tracepixel.cpp +++ b/source/core/render/tracepixel.cpp @@ -13,7 +13,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 @@ -41,10 +41,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/render/tracepixel.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include -#include +// POV-Ray header files (base module) +#include +// POV-Ray header files (core module) #include "core/material/normal.h" #include "core/material/pigment.h" #include "core/math/chi2.h" @@ -62,6 +68,9 @@ namespace pov { +using std::min; +using std::max; + #ifdef DYNAMIC_HASHTABLE extern unsigned short *hashTable; // GLOBAL VARIABLE #else @@ -192,7 +201,7 @@ bool ContainingInteriorsPointObjectCondition::operator()(const Vector3d& point, } -TracePixel::TracePixel(shared_ptr sd, const Camera* cam, TraceThreadData *td, unsigned int mtl, DBL adcb, const QualityFlags& qf, +TracePixel::TracePixel(std::shared_ptr sd, const Camera* cam, TraceThreadData *td, unsigned int mtl, DBL adcb, const QualityFlags& qf, CooperateFunctor& cf, MediaFunctor& mf, RadiosityFunctor& af, bool pt) : Trace(sd, td, qf, cf, mf, af), sceneData(sd), @@ -934,13 +943,13 @@ void TracePixel::InitRayContainerState(Ray& ray, bool compute) (*sceneData->tree)(ray.Origin, ifn, mailbox); // test infinite objects - for(vector::iterator object = sceneData->objects.begin() + sceneData->numberOfFiniteObjects; object != sceneData->objects.end(); object++) + for(std::vector::iterator object = sceneData->objects.begin() + sceneData->numberOfFiniteObjects; object != sceneData->objects.end(); object++) if (((*object)->interior != nullptr) && Inside_BBox(ray.Origin, (*object)->BBox) && (*object)->Inside(ray.Origin, threadData)) containingInteriors.push_back((*object)->interior.get()); } else if ((sceneData->boundingMethod == 0) || (sceneData->boundingSlabs == nullptr)) { - for(vector::iterator object = sceneData->objects.begin(); object != sceneData->objects.end(); object++) + for(std::vector::iterator object = sceneData->objects.begin(); object != sceneData->objects.end(); object++) if (((*object)->interior != nullptr) && Inside_BBox(ray.Origin, (*object)->BBox) && (*object)->Inside(ray.Origin, threadData)) containingInteriors.push_back((*object)->interior.get()); } @@ -1240,10 +1249,10 @@ TracePixel::FocalBlurData::FocalBlurData(const Camera& camera, TraceThreadData* int Grid_Size = 2 * (int)ceil(minGridRadius) + 1; // Allocate temporary grid. - boost::scoped_array Grid_Data (new char [Grid_Size * Grid_Size]); + std::unique_ptr Grid_Data (new char [Grid_Size * Grid_Size]); char *p = Grid_Data.get(); memset(p, 0, Grid_Size * Grid_Size); - vector Grid(Grid_Size); + std::vector Grid(Grid_Size); for(int i = 0; i < Grid_Size; i++, p += Grid_Size) Grid[i] = p; @@ -1302,3 +1311,4 @@ TracePixel::FocalBlurData::~FocalBlurData() } } +// end of namespace pov diff --git a/source/core/render/tracepixel.h b/source/core/render/tracepixel.h index 69370a995..9e94a6c71 100644 --- a/source/core/render/tracepixel.h +++ b/source/core/render/tracepixel.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 @@ -39,8 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include +// C++ variants of C standard header files +// (none at the moment) +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/render/trace.h" #include "core/scene/camera.h" #include "core/scene/scenedata.h" @@ -55,24 +63,24 @@ namespace pov /// /// @{ -struct HasInteriorPointObjectCondition : public PointObjectCondition +struct HasInteriorPointObjectCondition final : public PointObjectCondition { - virtual bool operator()(const Vector3d& point, ConstObjectPtr object) const; + virtual bool operator()(const Vector3d& point, ConstObjectPtr object) const override; }; -struct ContainingInteriorsPointObjectCondition : public PointObjectCondition +struct ContainingInteriorsPointObjectCondition final : public PointObjectCondition { ContainingInteriorsPointObjectCondition(RayInteriorVector& ci) : containingInteriors(ci) {} - virtual bool operator()(const Vector3d& point, ConstObjectPtr object) const; + virtual bool operator()(const Vector3d& point, ConstObjectPtr object) const override; RayInteriorVector &containingInteriors; }; -class TracePixel : public Trace +class TracePixel final : public Trace { public: - TracePixel(shared_ptr sd, const Camera* cam, TraceThreadData *td, unsigned int mtl, DBL adcb, const QualityFlags& qf, + TracePixel(std::shared_ptr sd, const Camera* cam, TraceThreadData *td, unsigned int mtl, DBL adcb, const QualityFlags& qf, CooperateFunctor& cf, MediaFunctor& mf, RadiosityFunctor& af, bool pt = false); - virtual ~TracePixel(); + virtual ~TracePixel() override; void SetupCamera(const Camera& cam); /// Trace a pixel or sub-pixel. @@ -84,7 +92,7 @@ class TracePixel : public Trace void operator()(DBL x, DBL y, DBL width, DBL height, RGBTColour& colour); private: // Focal blur data - class FocalBlurData + class FocalBlurData final { public: FocalBlurData(const Camera& camera, TraceThreadData* threadData); @@ -124,7 +132,7 @@ class TracePixel : public Trace /// camera Camera camera; /// scene data - shared_ptr sceneData; + std::shared_ptr sceneData; /// thread data TraceThreadData *threadData; @@ -153,5 +161,6 @@ class TracePixel : public Trace //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TRACEPIXEL_H diff --git a/source/core/scene/atmosphere.cpp b/source/core/scene/atmosphere.cpp index 40483ab63..549e3e512 100644 --- a/source/core/scene/atmosphere.cpp +++ b/source/core/scene/atmosphere.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,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/scene/atmosphere.h" -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/pattern.h" #include "core/material/warp.h" #include "core/material/pigment.h" @@ -418,7 +424,7 @@ SKYSPHERE *Copy_Skysphere(const SKYSPHERE *Old) // The standard assignment operator of SKYSPHERE has created a shallow copy of the Pigments vector, but we need a // deep copy in case Old gets destroyed. - for (vector::iterator i = New->Pigments.begin(); i != New->Pigments.end(); ++ i) + for (std::vector::iterator i = New->Pigments.begin(); i != New->Pigments.end(); ++ i) { *i = Copy_Pigment(*i); } @@ -464,7 +470,7 @@ void Destroy_Skysphere(SKYSPHERE *Skysphere) Skysphere_Struct::~Skysphere_Struct() { - for (vector::iterator i = Pigments.begin(); i != Pigments.end(); ++ i) + for (std::vector::iterator i = Pigments.begin(); i != Pigments.end(); ++ i) delete *i; Destroy_Transform(Trans); } @@ -634,3 +640,4 @@ void Transform_Skysphere(SKYSPHERE *Skysphere, const TRANSFORM *Trans) } } +// end of namespace pov diff --git a/source/core/scene/atmosphere.h b/source/core/scene/atmosphere.h index ec240a4fb..0d9fb303a 100644 --- a/source/core/scene/atmosphere.h +++ b/source/core/scene/atmosphere.h @@ -2,13 +2,13 @@ /// /// @file core/scene/atmosphere.h /// -/// Declarations related to atmospheric effets and sky spheres. +/// Declarations related to atmospheric effects and sky spheres. /// /// @copyright /// @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 @@ -38,7 +38,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/scene/atmosphere_fwd.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/pigment.h" namespace pov @@ -65,13 +76,9 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct Fog_Struct FOG; -typedef struct Rainbow_Struct RAINBOW; -typedef struct Skysphere_Struct SKYSPHERE; - struct TurbulenceWarp; // full declaration in core/material/warp.h -struct Fog_Struct +struct Fog_Struct final { Fog_Struct(); ~Fog_Struct(); @@ -86,7 +93,7 @@ struct Fog_Struct FOG *Next; }; -struct Rainbow_Struct +struct Rainbow_Struct final { Rainbow_Struct() : Pigment(nullptr), Next(nullptr) {} ~Rainbow_Struct() { if (Pigment) delete Pigment; } @@ -100,13 +107,13 @@ struct Rainbow_Struct RAINBOW *Next; }; -struct Skysphere_Struct +struct Skysphere_Struct final { Skysphere_Struct() : Trans(nullptr) {} ~Skysphere_Struct(); - MathColour Emission; ///< Brightness adjustment. - vector Pigments; ///< Pigment(s) to use. - TRANSFORM * Trans; ///< Skysphere transformation. + MathColour Emission; ///< Brightness adjustment. + std::vector Pigments; ///< Pigment(s) to use. + TRANSFORM* Trans; ///< Skysphere transformation. }; /***************************************************************************** @@ -134,5 +141,6 @@ void Transform_Skysphere (SKYSPHERE *Skysphere, const TRANSFORM *Trans); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_ATMOSPHERE_H diff --git a/source/core/scene/atmosphere_fwd.h b/source/core/scene/atmosphere_fwd.h new file mode 100644 index 000000000..d9db8e4fe --- /dev/null +++ b/source/core/scene/atmosphere_fwd.h @@ -0,0 +1,57 @@ +//****************************************************************************** +/// +/// @file core/scene/atmosphere_fwd.h +/// +/// Forward declarations related to atmospheric effects and sky spheres. +/// +/// @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_CORE_ATMOSPHERE_FWD_H +#define POVRAY_CORE_ATMOSPHERE_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +struct Fog_Struct; +struct Rainbow_Struct; +struct Skysphere_Struct; + +using FOG = Fog_Struct; ///< @deprecated +using RAINBOW = Rainbow_Struct; ///< @deprecated +using SKYSPHERE = Skysphere_Struct; ///< @deprecated + +} +// end of namespace pov + +#endif // POVRAY_CORE_ATMOSPHERE_FWD_H diff --git a/source/core/scene/camera.cpp b/source/core/scene/camera.cpp index d863d3ea5..8ff3b885c 100644 --- a/source/core/scene/camera.cpp +++ b/source/core/scene/camera.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,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/scene/camera.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/normal.h" #include "core/material/pigment.h" #include "core/math/matrix.h" @@ -444,3 +452,4 @@ Camera::~Camera() } } +// end of namespace pov diff --git a/source/core/scene/camera.h b/source/core/scene/camera.h index 38bcc8c66..4d83220ae 100644 --- a/source/core/scene/camera.h +++ b/source/core/scene/camera.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 @@ -39,6 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/vector.h" #include "core/material/normal.h" @@ -76,7 +86,7 @@ namespace pov * Global typedefs ******************************************************************************/ -class Camera +class Camera final { public: Vector3d Location; @@ -105,10 +115,10 @@ class Camera unsigned int Face_Distribution_Method; // how to associate a pixel to a face within a mesh unsigned int Rays_Per_Pixel; // cast this many rays per pixel; never less than 1 bool Smooth; // if true, interpolate normals for dist #3 - vector Meshes; // list of the meshes to be used as the camera - vector Mesh_Index; // used with distribution #1 to keep track of accumulated meshes - vector U_Xref[10]; // used to speed up location of a matching face for distribution #3 - vector V_Xref[10]; // used to speed up location of a matching face for distribution #3 + std::vector Meshes; // list of the meshes to be used as the camera + std::vector Mesh_Index; // used with distribution #1 to keep track of accumulated meshes + std::vector U_Xref[10]; // used to speed up location of a matching face for distribution #3 + std::vector V_Xref[10]; // used to speed up location of a matching face for distribution #3 DBL Max_Ray_Distance; // if not 0.0, then maximum distance to look along the ray for an intersection // end of mesh camera declarations @@ -130,5 +140,6 @@ class Camera //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_CAMERA_H diff --git a/source/core/scene/object.cpp b/source/core/scene/object.cpp index ccc7b6c84..55a74be24 100644 --- a/source/core/scene/object.cpp +++ b/source/core/scene/object.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,6 +36,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/scene/object.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/povassert.h" + +// POV-Ray header files (core module) #include "core/material/interior.h" #include "core/material/texture.h" #include "core/math/matrix.h" @@ -51,6 +61,8 @@ namespace pov { +using std::vector; + template FORCEINLINE bool Intersect_BBox_Dir(const BoundingBox& bbox, const BBoxVector3d& origin, const BBoxVector3d& invdir, BBoxScalar mind, BBoxScalar maxd); @@ -1096,3 +1108,4 @@ FORCEINLINE bool Intersect_BBox_Dir(const BoundingBox& bbox, const BBoxVector3d& } } +// end of namespace pov diff --git a/source/core/scene/object.h b/source/core/scene/object.h index dc246dc34..9ad1efa27 100644 --- a/source/core/scene/object.h +++ b/source/core/scene/object.h @@ -4,13 +4,11 @@ /// /// Declarations related to geometric shapes. /// -/// @note `frame.h` contains other object stuff. -/// /// @copyright /// @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 @@ -41,14 +39,19 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.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/messenger_fwd.h" + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/material/texture.h" -namespace pov_base -{ - class GenericMessenger; -} - namespace pov { @@ -174,9 +177,9 @@ class ObjectBase TEXTURE *Texture; TEXTURE *Interior_Texture; InteriorPtr interior; - vector Bound; - vector Clip; - vector LLights; ///< Used for light groups. + std::vector Bound; + std::vector Clip; + std::vector LLights; ///< Used for light groups. BoundingBox BBox; TRANSFORM *Trans; SNGL Ph_Density; @@ -286,7 +289,7 @@ class NonsolidObject : public ObjectBase { public: NonsolidObject(int t) : ObjectBase(t) {} - virtual ObjectPtr Invert(); + virtual ObjectPtr Invert() override; }; /// Abstract base class for compound geometric objects. @@ -298,14 +301,14 @@ class CompoundObject : public ObjectBase public: CompoundObject(int t) : ObjectBase(t) {} CompoundObject(int t, CompoundObject& o, bool transplant) : ObjectBase(t, o, transplant), children(o.children) { if (transplant) o.children.clear(); } - vector children; - virtual ObjectPtr Invert(); + std::vector children; + virtual ObjectPtr Invert() override; }; /// Light source. /// @ingroup PovCoreLightingLightsource -class LightSource : public CompoundObject +class LightSource final : public CompoundObject { public: size_t index; @@ -330,19 +333,19 @@ class LightSource : public CompoundObject bool lightGroupLight : 1; LightSource(); - virtual ~LightSource(); - - virtual ObjectPtr Copy(); - - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox() {} + virtual ~LightSource() override; + + virtual ObjectPtr Copy() override; + + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override {} }; @@ -359,49 +362,49 @@ struct ContainedByShape }; /// Class used for containing inherently infinite objects (isosurface, parametric) in a box. -struct ContainedByBox : public ContainedByShape +struct ContainedByBox final : public ContainedByShape { Vector3d corner1; Vector3d corner2; ContainedByBox() : corner1(-1,-1,-1), corner2(1,1,1) {} - virtual void ComputeBBox(BoundingBox& rBox) const; - virtual bool Intersect(const Ray& ray, const TRANSFORM* pTrans, DBL& rDepth1, DBL& rDepth2, int& rSide1, int& sSide2) const; - virtual bool Inside(const Vector3d& IPoint) const; - virtual void Normal(const Vector3d& IPoint, const TRANSFORM* pTrans, int side, Vector3d& rNormal) const; - virtual ContainedByShape* Copy() const; + virtual void ComputeBBox(BoundingBox& rBox) const override; + virtual bool Intersect(const Ray& ray, const TRANSFORM* pTrans, DBL& rDepth1, DBL& rDepth2, int& rSide1, int& sSide2) const override; + virtual bool Inside(const Vector3d& IPoint) const override; + virtual void Normal(const Vector3d& IPoint, const TRANSFORM* pTrans, int side, Vector3d& rNormal) const override; + virtual ContainedByShape* Copy() const override; }; /// Class used for containing inherently infinite objects (isosurface, parametric) in a sphere. -struct ContainedBySphere : public ContainedByShape +struct ContainedBySphere final : public ContainedByShape { Vector3d center; DBL radius; ContainedBySphere() : center(0,0,0), radius(1) {} - virtual void ComputeBBox(BoundingBox& rBox) const; - virtual bool Intersect(const Ray& ray, const TRANSFORM* pTrans, DBL& rDepth1, DBL& rDepth2, int& rSide1, int& sSide2) const; - virtual bool Inside(const Vector3d& IPoint) const; - virtual void Normal(const Vector3d& IPoint, const TRANSFORM* pTrans, int side, Vector3d& rNormal) const; - virtual ContainedByShape* Copy() const; + virtual void ComputeBBox(BoundingBox& rBox) const override; + virtual bool Intersect(const Ray& ray, const TRANSFORM* pTrans, DBL& rDepth1, DBL& rDepth2, int& rSide1, int& sSide2) const override; + virtual bool Inside(const Vector3d& IPoint) const override; + virtual void Normal(const Vector3d& IPoint, const TRANSFORM* pTrans, int side, Vector3d& rNormal) const override; + virtual ContainedByShape* Copy() const override; }; bool Find_Intersection(Intersection *Ray_Intersection, ObjectPtr Object, const Ray& ray, TraceThreadData *Thread); bool Find_Intersection(Intersection *Ray_Intersection, ObjectPtr Object, const Ray& ray, const RayObjectCondition& postcondition, TraceThreadData *Thread); bool Find_Intersection(Intersection *isect, ObjectPtr object, const Ray& ray, BBoxDirection variant, const BBoxVector3d& origin, const BBoxVector3d& invdir, TraceThreadData *ThreadData); bool Find_Intersection(Intersection *isect, ObjectPtr object, const Ray& ray, BBoxDirection variant, const BBoxVector3d& origin, const BBoxVector3d& invdir, const RayObjectCondition& postcondition, TraceThreadData *ThreadData); -bool Ray_In_Bound(const Ray& ray, const vector& Bounding_Object, TraceThreadData *Thread); -bool Point_In_Clip(const Vector3d& IPoint, const vector& Clip, TraceThreadData *Thread); +bool Ray_In_Bound(const Ray& ray, const std::vector& Bounding_Object, TraceThreadData *Thread); +bool Point_In_Clip(const Vector3d& IPoint, const std::vector& Clip, TraceThreadData *Thread); ObjectPtr Copy_Object(ObjectPtr Old); -vector Copy_Objects(vector& Src); +std::vector Copy_Objects(std::vector& Src); void Translate_Object(ObjectPtr Object, const Vector3d& Vector, const TRANSFORM *Trans); void Rotate_Object(ObjectPtr Object, const Vector3d& Vector, const TRANSFORM *Trans); void Scale_Object(ObjectPtr Object, const Vector3d& Vector, const TRANSFORM *Trans); void Transform_Object(ObjectPtr Object, const TRANSFORM *Trans); bool Inside_Object(const Vector3d& IPoint, ObjectPtr Object, TraceThreadData *Thread); -void Destroy_Object(vector& Object); +void Destroy_Object(std::vector& Object); void Destroy_Object(ObjectPtr Object); void Destroy_Single_Object(ObjectPtr *ObjectPtr); @@ -410,5 +413,6 @@ void Destroy_Single_Object(ObjectPtr *ObjectPtr); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_OBJECT_H diff --git a/source/core/scene/scenedata.cpp b/source/core/scene/scenedata.cpp index 6e7132280..2b93c3edf 100644 --- a/source/core/scene/scenedata.cpp +++ b/source/core/scene/scenedata.cpp @@ -36,14 +36,23 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/scene/scenedata.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// Boost header files #include +// POV-Ray header files (base module) +#include "base/types.h" #include "base/version_info.h" +#include "base/image/colourspace.h" -#include "core/material/pattern.h" +// POV-Ray header files (core module) #include "core/material/noise.h" +#include "core/material/pattern.h" #include "core/scene/atmosphere.h" // this must be the last file included @@ -120,7 +129,7 @@ SceneData::~SceneData() } if (boundingSlabs != nullptr) Destroy_BBox_Tree(boundingSlabs); - for (vector::iterator i = TTFonts.begin(); i != TTFonts.end(); ++i) + for (std::vector::iterator i = TTFonts.begin(); i != TTFonts.end(); ++i) delete *i; // TODO: perhaps ObjectBase::~ObjectBase would be a better place // to handle cleanup of individual objects ? @@ -131,3 +140,4 @@ SceneData::~SceneData() } } +// end of namespace pov diff --git a/source/core/scene/scenedata.h b/source/core/scene/scenedata.h index 61e92272d..b93f77fee 100644 --- a/source/core/scene/scenedata.h +++ b/source/core/scene/scenedata.h @@ -39,11 +39,20 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include +#include -#include "base/image/colourspace.h" +// POV-Ray header files (base module) +#include "base/image/colourspace_fwd.h" +// POV-Ray header files (core module) #include "core/lighting/radiosity.h" +#include "core/scene/atmosphere_fwd.h" #include "core/scene/camera.h" #include "core/shape/truetype.h" @@ -60,10 +69,6 @@ using namespace pov_base; class BSPTree; -struct Fog_Struct; -struct Rainbow_Struct; -struct Skysphere_Struct; - /// Class holding scene specific data. /// /// "For private use by Scene, View and Renderer classes only! @@ -80,17 +85,17 @@ class SceneData { public: - typedef std::map DeclaredVariablesMap; + typedef std::map DeclaredVariablesMap; /// Destructor. - ~SceneData(); + virtual ~SceneData(); /// list of all shape objects - vector objects; + std::vector objects; /// list of all global light sources - vector lightSources; + std::vector lightSources; /// list of all lights that are part of light groups - vector lightGroupLightSources; + std::vector lightGroupLightSources; /// factory generating contexts for legacy VM-based functions in scene GenericFunctionContextFactoryIPtr functionContextFactory; /// atmosphere index of refraction @@ -98,7 +103,7 @@ class SceneData /// atmosphere dispersion DBL atmosphereDispersion; /// atmospheric media - vector atmosphere; + std::vector atmosphere; /// background color - TODO - allow pattern here (useful for background image maps) [trf] TransColour backgroundColour; // may have a filter/transmit component (but filter is ignored) /// ambient light in scene @@ -190,7 +195,7 @@ class SceneData // TODO - decide if we want to keep this here // (we can't move it to the parser though, as part of the data needs to survive into rendering) - vector TTFonts; + std::vector TTFonts; // name of the parsed file UCS2String inputFile; // TODO - handle differently @@ -205,7 +210,7 @@ class SceneData DeclaredVariablesMap declaredVariables; // TODO - move to parser Camera parsedCamera; // TODO - handle differently or move to parser bool clocklessAnimation; // TODO - this is support for an experimental feature and may be changed or removed - vector cameras; // TODO - this is support for an experimental feature and may be changed or removed + std::vector cameras; // TODO - this is support for an experimental feature and may be changed or removed // this is for fractal support int Fractal_Iteration_Stack_Length; // TODO - move somewhere else @@ -252,11 +257,8 @@ class SceneData private: - /// not available - SceneData(const SceneData&); - - /// not available - SceneData& operator=(const SceneData&); + SceneData(const SceneData&) = delete; + SceneData& operator=(const SceneData&) = delete; }; /// @} @@ -264,5 +266,6 @@ class SceneData //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SCENEDATA_H diff --git a/source/core/scene/tracethreaddata.cpp b/source/core/scene/tracethreaddata.cpp index fb060b32e..203d87b51 100644 --- a/source/core/scene/tracethreaddata.cpp +++ b/source/core/scene/tracethreaddata.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,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/scene/tracethreaddata.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/noise.h" #include "core/scene/scenedata.h" #include "core/shape/blob.h" @@ -50,7 +58,7 @@ namespace pov { -TraceThreadData::TraceThreadData(shared_ptr sd, size_t seed) : +TraceThreadData::TraceThreadData(std::shared_ptr sd, size_t seed) : sceneData(sd), qualityFlags(9), stochasticRandomGenerator(GetRandomDoubleGenerator(0.0,1.0)), @@ -86,7 +94,7 @@ TraceThreadData::TraceThreadData(shared_ptr sd, size_t seed) : stochasticRandomGenerator->Seed(stochasticRandomSeedBase); - for(vector::iterator it = sceneData->lightSources.begin(); it != sceneData->lightSources.end(); it++) + for(std::vector::iterator it = sceneData->lightSources.begin(); it != sceneData->lightSources.end(); it++) lightSources.push_back(static_cast (Copy_Object(*it))); // all of these are for photons @@ -120,7 +128,7 @@ TraceThreadData::TraceThreadData(shared_ptr sd, size_t seed) : TraceThreadData::~TraceThreadData() { - for(vector::iterator i = functionContextPool.begin(); i != functionContextPool.end(); ++i) + for(std::vector::iterator i = functionContextPool.begin(); i != functionContextPool.end(); ++i) delete *i; POV_FREE(Blob_Coefficients); @@ -130,7 +138,7 @@ TraceThreadData::~TraceThreadData() delete surfacePhotonMap; delete mediaPhotonMap; delete[] Blob_Intervals; - for(vector::iterator it = lightSources.begin(); it != lightSources.end(); it++) + for(std::vector::iterator it = lightSources.begin(); it != lightSources.end(); it++) Destroy_Object(*it); } @@ -172,3 +180,4 @@ void TraceThreadData::AfterTile() } } +// end of namespace pov diff --git a/source/core/scene/tracethreaddata.h b/source/core/scene/tracethreaddata.h index 211541c6e..b7c0c76fd 100644 --- a/source/core/scene/tracethreaddata.h +++ b/source/core/scene/tracethreaddata.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 @@ -39,11 +39,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +#include +// POV-Ray header files (base module) #include "base/types.h" +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/bounding/boundingcylinder.h" #include "core/bounding/bsptree.h" @@ -63,7 +70,6 @@ namespace pov using namespace pov_base; -class SceneData; struct ISO_ThreadData; class PhotonMap; @@ -82,10 +88,10 @@ class TraceThreadData : public ThreadData /// @param sd Scene data defining scene attributes. /// @param seed Seed for the stochastic random number generator; /// should be unique for each render. - TraceThreadData(shared_ptr sd, size_t seed); + TraceThreadData(std::shared_ptr sd, size_t seed); /// Destructor. - ~TraceThreadData(); + virtual ~TraceThreadData() override; /// Get the statistics. /// @return Reference to statistic counters. @@ -100,11 +106,11 @@ class TraceThreadData : public ThreadData int Blob_Coefficient_Count; int Blob_Interval_Count; ISO_ThreadData *isosurfaceData; ///< @todo We may want to move this data block to the isosurface code as a local variable. - vector BCyl_Intervals; - vector BCyl_RInt; - vector BCyl_HInt; + std::vector BCyl_Intervals; + std::vector BCyl_RInt; + std::vector BCyl_HInt; IStackPool stackPool; - vector functionContextPool; + std::vector functionContextPool; int Facets_Last_Seed; int Facets_CVC; Vector3d Facets_Cube[81]; @@ -118,7 +124,7 @@ class TraceThreadData : public ThreadData // to the lightsource object passed to them (this is not confined // just to the area light shadow code). This code ought to be fixed // to treat the lightsource as const, after which this can go away. - vector lightSources; + std::vector lightSources; // all of these are for photons // most of them should be refactored into parameters, return values, or other objects @@ -139,8 +145,8 @@ class TraceThreadData : public ThreadData // data for waves and ripples pattern unsigned int numberOfWaves; - vector waveFrequencies; - vector waveSources; + std::vector waveFrequencies; + std::vector waveSources; /// Called after a rectangle is finished. /// Used for crackle cache expiry. @@ -166,23 +172,19 @@ class TraceThreadData : public ThreadData POV_LONG realTime; QualityFlags qualityFlags; // TODO FIXME - remove again - inline shared_ptr GetSceneData() const { return sceneData; } + inline std::shared_ptr GetSceneData() const { return sceneData; } protected: /// scene data - shared_ptr sceneData; + std::shared_ptr sceneData; /// render statistics RenderStatistics renderStats; private: - /// not available - TraceThreadData(); - - /// not available - TraceThreadData(const TraceThreadData&); - /// not available - TraceThreadData& operator=(const TraceThreadData&); + TraceThreadData() = delete; + TraceThreadData(const TraceThreadData&) = delete; + TraceThreadData& operator=(const TraceThreadData&) = delete; /// current number of Tiles to expire crackle cache entries after size_t CrCache_MaxAge; @@ -195,5 +197,6 @@ class TraceThreadData : public ThreadData //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TRACETHREADDATA_H diff --git a/source/core/shape/bezier.cpp b/source/core/shape/bezier.cpp index 1b1a8a9d3..a57f5ddf0 100644 --- a/source/core/shape/bezier.cpp +++ b/source/core/shape/bezier.cpp @@ -10,7 +10,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 @@ -38,10 +38,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/bezier.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/pov_err.h" +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -52,6 +58,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -2176,3 +2185,4 @@ void BicubicPatch::Compute_Texture_UV(const Vector2d& p, const Vector2d st[4], V } } +// end of namespace pov diff --git a/source/core/shape/bezier.h b/source/core/shape/bezier.h index 0d410e632..41725d7d1 100644 --- a/source/core/shape/bezier.h +++ b/source/core/shape/bezier.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -68,31 +76,31 @@ namespace pov ******************************************************************************/ typedef DBL BEZIER_WEIGHTS[4][4]; -typedef struct Bezier_Node_Struct BEZIER_NODE; -typedef struct Bezier_Child_Struct BEZIER_CHILDREN; -typedef struct Bezier_Vertices_Struct BEZIER_VERTICES; -struct Bezier_Child_Struct +struct Bezier_Node_Struct final { - BEZIER_NODE *Children[4]; + int Node_Type; // Is this an interior node, or a leaf + Vector3d Center; // Center of sphere bounding the (sub)patch + DBL Radius_Squared; // Radius of bounding sphere (squared) + int Count; // # of subpatches associated with this node + void *Data_Ptr; // Either pointer to vertices or pointer to children }; +using BEZIER_NODE = Bezier_Node_Struct; ///< @deprecated -struct Bezier_Vertices_Struct +struct Bezier_Child_Struct final { - float uvbnds[4]; - Vector3d Vertices[4]; + BEZIER_NODE *Children[4]; }; +using BEZIER_CHILDREN = Bezier_Child_Struct; ///< @deprecated -struct Bezier_Node_Struct +struct Bezier_Vertices_Struct final { - int Node_Type; // Is this an interior node, or a leaf - Vector3d Center; // Center of sphere bounding the (sub)patch - DBL Radius_Squared; // Radius of bounding sphere (squared) - int Count; // # of subpatches associated with this node - void *Data_Ptr; // Either pointer to vertices or pointer to children + float uvbnds[4]; + Vector3d Vertices[4]; }; +using BEZIER_VERTICES = Bezier_Vertices_Struct; ///< @deprecated -class BicubicPatch : public NonsolidObject +class BicubicPatch final : public NonsolidObject { public: typedef Vector3d ControlPoints[4][4]; @@ -106,19 +114,19 @@ class BicubicPatch : public NonsolidObject BEZIER_WEIGHTS *Weights; BicubicPatch(); - virtual ~BicubicPatch(); + virtual ~BicubicPatch() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Precompute_Patch_Values(); protected: @@ -152,5 +160,6 @@ class BicubicPatch : public NonsolidObject //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BEZIER_H diff --git a/source/core/shape/blob.cpp b/source/core/shape/blob.cpp index 44dea1b13..6c11a8490 100644 --- a/source/core/shape/blob.cpp +++ b/source/core/shape/blob.cpp @@ -11,7 +11,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 @@ -97,10 +97,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/blob.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/pov_err.h" +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/bounding/boundingsphere.h" #include "core/material/texture.h" @@ -115,6 +122,10 @@ namespace pov { +using std::min; +using std::max; +using std::vector; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -3262,3 +3273,4 @@ void Blob::getLocalIPoint(Vector3d& lip, Intersection *isect) const } } +// end of namespace pov diff --git a/source/core/shape/blob.h b/source/core/shape/blob.h index 6bb3d3598..6d5bfdb06 100644 --- a/source/core/shape/blob.h +++ b/source/core/shape/blob.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 @@ -39,6 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingsphere.h" #include "core/scene/object.h" @@ -88,7 +98,7 @@ namespace pov * Global typedefs ******************************************************************************/ -class Blob_Element +class Blob_Element final { public: short Type; /* Type of component: sphere, hemisphere, cylinder */ @@ -104,13 +114,13 @@ class Blob_Element ~Blob_Element(); }; -class Blob_Data +class Blob_Data final { public: - int Number_Of_Components; /* Number of components */ - DBL Threshold; /* Blob threshold */ - vector Entry; /* Array of blob components */ - BSPHERE_TREE *Tree; /* Bounding hierarchy */ + int Number_Of_Components; /* Number of components */ + DBL Threshold; /* Blob threshold */ + std::vector Entry; /* Array of blob components */ + BSPHERE_TREE *Tree; /* Bounding hierarchy */ Blob_Data(int count = 0); ~Blob_Data(); @@ -122,42 +132,42 @@ class Blob_Data int References; /* Number of references */ }; -struct Blob_List_Struct +struct Blob_List_Struct final { Blob_Element elem; /* Current element */ Blob_List_Struct *next; /* Pointer to next element */ }; -struct Blob_Interval_Struct +struct Blob_Interval_Struct final { int type; DBL bound; const Blob_Element *Element; }; -class Blob : public ObjectBase +class Blob final : public ObjectBase { public: Blob_Data *Data; - vector Element_Texture; + std::vector Element_Texture; Blob(); - virtual ~Blob(); - - virtual ObjectPtr Copy(); - - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual double GetPotential (const Vector3d&, bool subtractThreshold, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual ~Blob() override; + + virtual ObjectPtr Copy() override; + + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual double GetPotential (const Vector3d&, bool subtractThreshold, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; virtual bool IsOpaque() const override; - void Determine_Textures(Intersection *, bool, WeightedTextureVector&, TraceThreadData *); + virtual void Determine_Textures(Intersection *, bool, WeightedTextureVector&, TraceThreadData *) override; Blob_List_Struct *Create_Blob_List_Element(); void Create_Blob_Element_Texture_List(Blob_List_Struct *BlobList, int npoints); @@ -196,5 +206,6 @@ class Blob : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BLOB_H diff --git a/source/core/shape/box.cpp b/source/core/shape/box.cpp index 54b6fad89..6e4e96770 100644 --- a/source/core/shape/box.cpp +++ b/source/core/shape/box.cpp @@ -10,7 +10,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 @@ -38,8 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/box.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) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -1075,3 +1081,4 @@ bool Box::Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d& } } +// end of namespace pov diff --git a/source/core/shape/box.h b/source/core/shape/box.h index e6b154937..045845030 100644 --- a/source/core/shape/box.h +++ b/source/core/shape/box.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -62,7 +70,7 @@ namespace pov /// //****************************************************************************** -class Box : public ObjectBase +class Box final : public ObjectBase { public: @@ -82,20 +90,20 @@ class Box : public ObjectBase Vector3d bounds[2]; Box(); - virtual ~Box(); + virtual ~Box() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); - virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; + virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const override; static bool Intersect(const BasicRay& ray, const TRANSFORM *Trans, const Vector3d& Corner1, const Vector3d& Corner2, DBL *Depth1, DBL *Depth2, int *Side1, int *Side2); }; @@ -105,5 +113,6 @@ class Box : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_BOX_H diff --git a/source/core/shape/cone.cpp b/source/core/shape/cone.cpp index a0588892e..f5acc49d0 100644 --- a/source/core/shape/cone.cpp +++ b/source/core/shape/cone.cpp @@ -10,7 +10,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 @@ -38,8 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/cone.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) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -1056,3 +1062,4 @@ void Cone::CalcUV(const Vector3d& IPoint, Vector2d& Result) const #endif // POV_ENABLE_CONE_UV } +// end of namespace pov diff --git a/source/core/shape/cone.h b/source/core/shape/cone.h index 9b016569a..27b81ea54 100644 --- a/source/core/shape/cone.h +++ b/source/core/shape/cone.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -62,9 +70,9 @@ namespace pov /// //****************************************************************************** -class Cone : public ObjectBase +class Cone final : public ObjectBase { - struct CONE_INT + struct CONE_INT final { DBL d; /* Distance of intersection point */ int t; /* Type of intersection: base/cap plane or side */ @@ -77,27 +85,27 @@ class Cone : public ObjectBase DBL dist; ///< Distance to end of cone in canonical coords. Cone(); - virtual ~Cone(); + virtual ~Cone() override; void Cylinder(); - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; #ifdef POV_ENABLE_CONE_UV /// @attention /// UV mapping of this primitive should not be enabled until the primary /// parameterization has been amended so that users have full control over the /// primitive's orientation, rather than just the axis of rotational symmetry. - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; #endif // POV_ENABLE_CONE_UV - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Cone_Data(); void Compute_Cylinder_Data(); @@ -113,5 +121,6 @@ class Cone : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_CONE_H diff --git a/source/core/shape/csg.cpp b/source/core/shape/csg.cpp index 157a1aa75..a6e3c15e1 100644 --- a/source/core/shape/csg.cpp +++ b/source/core/shape/csg.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,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/csg.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include + +// POV-Ray header files (base module) +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/lighting/lightgroup.h" #include "core/math/matrix.h" @@ -53,6 +62,10 @@ namespace pov { +using std::min; +using std::max; +using std::vector; + /***************************************************************************** * Global preprocessor defines ******************************************************************************/ @@ -1020,3 +1033,4 @@ void CSG::Determine_Textures(Intersection *isect, bool hitinside, WeightedTextur } } +// end of namespace pov diff --git a/source/core/shape/csg.h b/source/core/shape/csg.h index 6e775cc48..8287f1365 100644 --- a/source/core/shape/csg.h +++ b/source/core/shape/csg.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 @@ -38,7 +38,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/shape/csg_fwd.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -76,15 +85,15 @@ class CSG : public CompoundObject int do_split; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const { } - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual ObjectPtr Invert() = 0; - virtual void Compute_BBox(); + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override { } + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual ObjectPtr Invert() override = 0; + virtual void Compute_BBox() override; - void Determine_Textures(Intersection *isect, bool hitinside, WeightedTextureVector& textures, TraceThreadData *Threaddata); + virtual void Determine_Textures(Intersection *isect, bool hitinside, WeightedTextureVector& textures, TraceThreadData *Threaddata) override; }; class CSGUnion : public CSG @@ -94,35 +103,35 @@ class CSGUnion : public CSG CSGUnion(int t); CSGUnion(int t, CompoundObject& o, bool transplant) : CSG(t, o, transplant) {} - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual ObjectPtr Invert(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual ObjectPtr Invert() override; }; -class CSGMerge : public CSGUnion +class CSGMerge final : public CSGUnion { public: CSGMerge(); CSGMerge(CompoundObject& o, bool transplant); - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; }; -class CSGIntersection : public CSG +class CSGIntersection final : public CSG { public: CSGIntersection(bool diff); CSGIntersection(bool diff, CompoundObject& o, bool transplant); - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual ObjectPtr Invert(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual ObjectPtr Invert() override; bool isDifference; }; @@ -132,5 +141,6 @@ class CSGIntersection : public CSG //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_CSG_H diff --git a/source/core/shape/csg_fwd.h b/source/core/shape/csg_fwd.h new file mode 100644 index 000000000..40decc76d --- /dev/null +++ b/source/core/shape/csg_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file core/shape/csg_fwd.h +/// +/// Forward declarations related to constructive solid geometry (csg) shapes. +/// +/// @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_CORE_CSG_FWD_H +#define POVRAY_CORE_CSG_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class CSG; + +} +// end of namespace pov + +#endif // POVRAY_CORE_CSG_FWD_H diff --git a/source/core/shape/disc.cpp b/source/core/shape/disc.cpp index f96e3df5b..fd84c7fec 100644 --- a/source/core/shape/disc.cpp +++ b/source/core/shape/disc.cpp @@ -10,7 +10,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,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/disc.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -587,3 +595,4 @@ void Disc::Compute_BBox() } } +// end of namespace pov diff --git a/source/core/shape/disc.h b/source/core/shape/disc.h index e1f0b0349..8a9aafebb 100644 --- a/source/core/shape/disc.h +++ b/source/core/shape/disc.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -62,7 +70,7 @@ namespace pov /// //****************************************************************************** -class Disc : public ObjectBase +class Disc final : public ObjectBase { public: Vector3d center; ///< Center of the disc. @@ -72,22 +80,22 @@ class Disc : public ObjectBase DBL oradius2; ///< Distance from center to outer circle of the disc. Disc(); - virtual ~Disc(); + virtual ~Disc() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; // NOTE: UV mapping of this primitive should not be implemented without also amending // the primary parameterization so that users have full control over the primitive's // orientation, rather than just the normal vector. - // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Disc(); protected: @@ -99,5 +107,6 @@ class Disc : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_DISC_H diff --git a/source/core/shape/fractal.cpp b/source/core/shape/fractal.cpp index c7b5e4ffb..9601f3ca1 100644 --- a/source/core/shape/fractal.cpp +++ b/source/core/shape/fractal.cpp @@ -10,7 +10,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 @@ -38,8 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/fractal.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) #include "core/bounding/boundingbox.h" #include "core/math/hypercomplex.h" #include "core/math/matrix.h" @@ -874,3 +880,4 @@ void Fractal::Free_Iteration_Stack(DBL **IStack) } } +// end of namespace pov diff --git a/source/core/shape/fractal.h b/source/core/shape/fractal.h index ac6b237f3..e2d749d25 100644 --- a/source/core/shape/fractal.h +++ b/source/core/shape/fractal.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/math/vector.h" #include "core/scene/object.h" @@ -87,12 +95,12 @@ namespace pov class Fractal; -struct Complex +struct Complex final { DBL x,y; }; -class Fractal : public ObjectBase +class Fractal final : public ObjectBase { public: Vector3d Center; @@ -109,18 +117,18 @@ class Fractal : public ObjectBase FractalRulesPtr Rules; Fractal(); - virtual ~Fractal(); + virtual ~Fractal() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; static void Free_Iteration_Stack(DBL **IStack); static void Allocate_Iteration_Stack(DBL **IStack, int Len); @@ -133,5 +141,6 @@ class Fractal : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_FRACTAL_H diff --git a/source/core/shape/heightfield.cpp b/source/core/shape/heightfield.cpp index 77d63083a..a91ec7236 100644 --- a/source/core/shape/heightfield.cpp +++ b/source/core/shape/heightfield.cpp @@ -12,7 +12,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 @@ -58,10 +58,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/heightfield.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/pov_err.h" +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -74,6 +80,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -94,14 +103,14 @@ const DBL HFIELD_TOLERANCE = 1.0e-6; typedef short HF_Normals[3]; -struct HFBlock +struct HFBlock final { int xmin, xmax; int zmin, zmax; DBL ymin, ymax; }; -struct HFData +struct HFData final { int References; int Normals_Height; /* Needed for Destructor */ @@ -2081,3 +2090,4 @@ bool HField::block_traversal(const BasicRay &ray, const Vector3d& Start, IStack } } +// end of namespace pov diff --git a/source/core/shape/heightfield.h b/source/core/shape/heightfield.h index 8404bd391..f5c765cbd 100644 --- a/source/core/shape/heightfield.h +++ b/source/core/shape/heightfield.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -82,7 +90,7 @@ class ImageData; /// then follows the line from one intersection point to the other, testing the two triangles which form the pixel for /// an intersection with the ray at each step. /// -class HField : public ObjectBase +class HField final : public ObjectBase { public: Vector3d bounding_corner1; @@ -90,18 +98,18 @@ class HField : public ObjectBase HFData *Data; HField(); - virtual ~HField(); + virtual ~HField() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_HField(const ImageData *image); protected: @@ -119,5 +127,6 @@ class HField : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_HEIGHTFIELD_H diff --git a/source/core/shape/isosurface.cpp b/source/core/shape/isosurface.cpp index f04d292bc..5bd9bc9e0 100644 --- a/source/core/shape/isosurface.cpp +++ b/source/core/shape/isosurface.cpp @@ -12,7 +12,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 @@ -40,10 +40,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/isosurface.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/messenger.h" +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -54,11 +60,14 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ -struct ISO_Max_Gradient +struct ISO_Max_Gradient final { DBL max_gradient, gradient; DBL eval_max, eval_cnt, eval_gradient_sum, eval_var; @@ -571,7 +580,7 @@ IsoSurface::IsoSurface() : ObjectBase(ISOSURFACE_OBJECT), positivePolarity(false) { - container = shared_ptr(new ContainedByBox()); + container = std::shared_ptr(new ContainedByBox()); Make_BBox(BBox, -1.0, -1.0, -1.0, 2.0, 2.0, 2.0); @@ -591,7 +600,7 @@ IsoSurface::IsoSurface() : gradient = 0.0; threshold = 0.0; - mginfo = intrusive_ptr(new ISO_Max_Gradient()); + mginfo = boost::intrusive_ptr(new ISO_Max_Gradient()); } @@ -635,7 +644,7 @@ ObjectPtr IsoSurface::Copy() New->positivePolarity = positivePolarity; - New->container = shared_ptr(container->Copy()); + New->container = std::shared_ptr(container->Copy()); return (New); } @@ -1040,4 +1049,4 @@ bool IsoSurface::IsInside (GenericScalarFunctionInstance& fn, Vector3d& p) const } } - +// end of namespace pov diff --git a/source/core/shape/isosurface.h b/source/core/shape/isosurface.h index 5d1551dc3..eae370554 100644 --- a/source/core/shape/isosurface.h +++ b/source/core/shape/isosurface.h @@ -12,7 +12,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,8 +43,19 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// Boost header files #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/scene/object.h" @@ -80,11 +91,14 @@ class IsoSurface; typedef unsigned char IsosurfaceMaxTrace; -struct ISO_Pair { DBL t,f; }; +struct ISO_Pair final +{ + DBL t, f; +}; struct ISO_Max_Gradient; -struct ISO_ThreadData +struct ISO_ThreadData final { const IsoSurface *current; GenericScalarFunctionInstance* pFn; @@ -97,7 +111,7 @@ struct ISO_ThreadData int Inv3; }; -class IsoSurface : public ObjectBase +class IsoSurface final : public ObjectBase { public: @@ -112,24 +126,24 @@ class IsoSurface : public ObjectBase bool eval : 1; bool positivePolarity : 1; ///< `true` if values above threshold are considered inside, `false` if considered outside. - shared_ptr container; + std::shared_ptr container; IsoSurface(); - virtual ~IsoSurface(); + virtual ~IsoSurface() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual double GetPotential (const Vector3d&, bool subtractThreshold, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual double GetPotential (const Vector3d&, bool subtractThreshold, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; - virtual void DispatchShutdownMessages(GenericMessenger& messenger); + virtual void DispatchShutdownMessages(GenericMessenger& messenger) override; protected: bool Function_Find_Root(ISO_ThreadData& itd, const Vector3d&, const Vector3d&, DBL*, DBL*, DBL& max_gradient, bool in_shadow_test, TraceThreadData* pThreadData); @@ -142,7 +156,7 @@ class IsoSurface : public ObjectBase private: - intrusive_ptr mginfo; // global, but just a statistic (read: not thread safe but we don't care) [trf] + boost::intrusive_ptr mginfo; // global, but just a statistic (read: not thread safe but we don't care) [trf] }; /// @} @@ -150,5 +164,6 @@ class IsoSurface : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_ISOSURFACE_H diff --git a/source/core/shape/lathe.cpp b/source/core/shape/lathe.cpp index ee023569f..9b009ae8b 100644 --- a/source/core/shape/lathe.cpp +++ b/source/core/shape/lathe.cpp @@ -10,7 +10,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 @@ -121,10 +121,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/lathe.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/bounding/boundingcylinder.h" #include "core/math/matrix.h" @@ -139,6 +146,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -280,9 +290,9 @@ bool Lathe::Intersect(const BasicRay& ray, IStack& Depth_Stack, TraceThreadData return false; // Intersect all cylindrical bounds. - vector& intervals = Thread->BCyl_Intervals; - vector& rint = Thread->BCyl_RInt; - vector& hint = Thread->BCyl_HInt; + std::vector& intervals = Thread->BCyl_Intervals; + std::vector& rint = Thread->BCyl_RInt; + std::vector& hint = Thread->BCyl_HInt; if((cnt = Intersect_BCyl(Spline->BCyl, intervals, rint, hint, P, D)) == 0) return false; @@ -1377,3 +1387,4 @@ void Lathe::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData } } +// end of namespace pov diff --git a/source/core/shape/lathe.h b/source/core/shape/lathe.h index 741ed9b63..180537e34 100644 --- a/source/core/shape/lathe.h +++ b/source/core/shape/lathe.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 @@ -39,6 +39,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/bounding/boundingcylinder_fwd.h" #include "core/scene/object.h" namespace pov @@ -77,25 +86,21 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct BCyl_Struct BCYL; - -typedef struct Lathe_Struct LATHE; -typedef struct Lathe_Spline_Struct LATHE_SPLINE; -typedef struct Lathe_Spline_Entry_Struct LATHE_SPLINE_ENTRY; - -struct Lathe_Spline_Entry_Struct +struct Lathe_Spline_Entry_Struct final { Vector2d A, B, C, D; /* Coefficients of segment */ }; +using LATHE_SPLINE_ENTRY = Lathe_Spline_Entry_Struct; -struct Lathe_Spline_Struct +struct Lathe_Spline_Struct final { int References; /* Count references to this structure. */ LATHE_SPLINE_ENTRY *Entry; /* Array of spline segments. */ BCYL *BCyl; /* bounding cylinder. */ }; +using LATHE_SPLINE = Lathe_Spline_Struct; -class Lathe : public ObjectBase +class Lathe final : public ObjectBase { public: int Spline_Type; /* Spline type (linear, quadratic ...) */ @@ -105,19 +110,19 @@ class Lathe : public ObjectBase DBL Radius1, Radius2; /* Min./Max. radius */ Lathe(); - virtual ~Lathe(); + virtual ~Lathe() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Lathe(Vector2d *P, TraceThreadData *); protected: @@ -130,5 +135,6 @@ class Lathe : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_LATHE_H diff --git a/source/core/shape/lemon.cpp b/source/core/shape/lemon.cpp index 862c62755..e3355399b 100644 --- a/source/core/shape/lemon.cpp +++ b/source/core/shape/lemon.cpp @@ -10,7 +10,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 @@ -38,8 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/lemon.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/messenger.h" +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/math/polynomialsolver.h" #include "core/render/ray.h" @@ -881,3 +887,4 @@ void Lemon::CalcUV(const Vector3d& IPoint, Vector2d& Result) const #endif // POV_ENABLE_LEMON_UV } +// end of namespace pov diff --git a/source/core/shape/lemon.h b/source/core/shape/lemon.h index ffd144ac7..42b882169 100644 --- a/source/core/shape/lemon.h +++ b/source/core/shape/lemon.h @@ -10,7 +10,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 @@ -41,15 +41,17 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/messenger_fwd.h" + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/scene/object.h" -namespace pov_base -{ -class GenericMessenger; -class MessageContext; -}; - namespace pov { @@ -71,35 +73,35 @@ namespace pov /// //****************************************************************************** -class Lemon : public ObjectBase +class Lemon final : public ObjectBase { private: - struct LEMON_INT + struct LEMON_INT final { DBL d; /* Distance of intersection point */ Vector3d n;/* Normal */ }; public: Lemon(); - virtual ~Lemon(); + virtual ~Lemon() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; #ifdef POV_ENABLE_LEMON_UV /// @attention /// UV mapping of this primitive should not be enabled until the primary /// parameterization has been amended so that users have full control over the /// primitive's orientation, rather than just the axis of rotational symmetry. - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; #endif // POV_ENABLE_LEMON_UV - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Lemon_Data(GenericMessenger& messenger, const MessageContext& context); @@ -122,5 +124,6 @@ class Lemon : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_OVUS_H diff --git a/source/core/shape/mesh.cpp b/source/core/shape/mesh.cpp index f1ad19c4c..b8b7540d6 100644 --- a/source/core/shape/mesh.cpp +++ b/source/core/shape/mesh.cpp @@ -10,7 +10,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 @@ -60,11 +60,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/mesh.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include #include +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/material/texture.h" #include "core/math/matrix.h" @@ -2448,3 +2454,4 @@ void Mesh::Determine_Textures(Intersection *isect, bool hitinside, WeightedTextu } } +// end of namespace pov diff --git a/source/core/shape/mesh.h b/source/core/shape/mesh.h index aaaa6e7e7..f6493e138 100644 --- a/source/core/shape/mesh.h +++ b/source/core/shape/mesh.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 @@ -39,6 +39,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/bounding/boundingbox_fwd.h" #include "core/scene/object.h" namespace pov @@ -62,40 +71,18 @@ namespace pov /// //****************************************************************************** -typedef struct BBox_Tree_Struct BBOX_TREE; - /***************************************************************************** * Global typedefs ******************************************************************************/ -typedef struct Mesh_Data_Struct MESH_DATA; -typedef struct Mesh_Triangle_Struct MESH_TRIANGLE; - -typedef struct Hash_Table_Struct HASH_TABLE; -typedef struct UV_Hash_Table_Struct UV_HASH_TABLE; - // TODO - a SnglVector2d should probably suffice for MeshUVVector, and reduce the Mesh's memory footprint by 8 bytes per triangle. // TODO - on systems with 64-bit int type, int is probably overkill for MeshIndex; maybe we even want to make Mesh a template, using short for small meshes. -typedef SnglVector3d MeshVector; ///< Data type used to store vertices and normals. -typedef Vector2d MeshUVVector; ///< Data type used to store UV coordinates. -typedef signed int MeshIndex; ///< Data type used to store indices into vertices / normals / uv coordinate / texture tables. Must be signed and able to hold 2*max. +using MeshVector = SnglVector3d; ///< Data type used to store vertices and normals. +using MeshUVVector = Vector2d; ///< Data type used to store UV coordinates. +using MeshIndex = signed int; ///< Data type used to store indices into vertices / normals / uv coordinate / texture tables. Must be signed and able to hold 2*max. -struct Mesh_Data_Struct -{ - int References; ///< Number of references to the mesh. - MeshIndex Number_Of_UVCoords; ///< Number of UV coords in the mesh. - MeshIndex Number_Of_Normals; ///< Number of normals in the mesh. - MeshIndex Number_Of_Triangles; ///< Number of trinagles in the mesh. - MeshIndex Number_Of_Vertices; ///< Number of vertices in the mesh. - MeshVector *Normals, *Vertices; ///< Arrays of normals and vertices. - MeshUVVector *UVCoords; ///< Array of UV coordinates - MESH_TRIANGLE *Triangles; ///< Array of triangles. - BBOX_TREE *Tree; ///< Bounding box tree for mesh. - Vector3d Inside_Vect; ///< vector to use to test 'inside' -}; - -struct Mesh_Triangle_Struct +struct Mesh_Triangle_Struct final { MeshVector Perp; ///< Vector used for smooth triangles. @@ -113,22 +100,40 @@ struct Mesh_Triangle_Struct unsigned int vAxis:2; ///< Axis for smooth triangle. unsigned int ThreeTex:1; ///< Color Triangle Patch. }; +using MESH_TRIANGLE = Mesh_Triangle_Struct; ///< @deprecated + +struct Mesh_Data_Struct final +{ + int References; ///< Number of references to the mesh. + MeshIndex Number_Of_UVCoords; ///< Number of UV coords in the mesh. + MeshIndex Number_Of_Normals; ///< Number of normals in the mesh. + MeshIndex Number_Of_Triangles; ///< Number of trinagles in the mesh. + MeshIndex Number_Of_Vertices; ///< Number of vertices in the mesh. + MeshVector *Normals, *Vertices; ///< Arrays of normals and vertices. + MeshUVVector *UVCoords; ///< Array of UV coordinates + MESH_TRIANGLE *Triangles; ///< Array of triangles. + BBOX_TREE *Tree; ///< Bounding box tree for mesh. + Vector3d Inside_Vect; ///< vector to use to test 'inside' +}; +using MESH_DATA = Mesh_Data_Struct; ///< @deprecated -struct Hash_Table_Struct +struct Hash_Table_Struct final { MeshIndex Index; MeshVector P; - HASH_TABLE *Next; + Hash_Table_Struct *Next; }; +using HASH_TABLE = Hash_Table_Struct; ///< @deprecated -struct UV_Hash_Table_Struct +struct UV_Hash_Table_Struct final { MeshIndex Index; MeshUVVector P; - UV_HASH_TABLE *Next; + UV_Hash_Table_Struct *Next; }; +using UV_HASH_TABLE = UV_Hash_Table_Struct; ///< @deprecated -class Mesh : public ObjectBase +class Mesh final : public ObjectBase { public: MESH_DATA *Data; ///< Mesh data holding triangles. @@ -137,19 +142,19 @@ class Mesh : public ObjectBase bool has_inside_vector; Mesh(); - virtual ~Mesh(); - - virtual ObjectPtr Copy(); - - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual ~Mesh() override; + + virtual ObjectPtr Copy() override; + + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; virtual bool IsOpaque() const override; void Create_Mesh_Hash_Tables(); @@ -167,7 +172,7 @@ class Mesh : public ObjectBase MeshIndex Mesh_Hash_UV(MeshIndex *Number, MeshIndex *Max, MeshUVVector **Elements, const Vector2d& aPoint); void Smooth_Mesh_Normal(Vector3d& Result, const MESH_TRIANGLE *Triangle, const Vector3d& IPoint) const; - void Determine_Textures(Intersection *, bool, WeightedTextureVector&, TraceThreadData *); + virtual void Determine_Textures(Intersection *, bool, WeightedTextureVector&, TraceThreadData *) override; protected: bool Intersect(const BasicRay& ray, IStack& Depth_Stack, TraceThreadData *Thread); void Compute_Mesh_BBox(); @@ -196,5 +201,6 @@ class Mesh : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_MESH_H diff --git a/source/core/shape/ovus.cpp b/source/core/shape/ovus.cpp index 9edd1bb15..f42e461b5 100644 --- a/source/core/shape/ovus.cpp +++ b/source/core/shape/ovus.cpp @@ -10,7 +10,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 @@ -69,6 +69,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/ovus.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/math/polynomialsolver.h" #include "core/render/ray.h" @@ -986,3 +994,4 @@ void Ovus::CalcUV(const Vector3d& IPoint, Vector2d& Result) const } } +// end of namespace pov diff --git a/source/core/shape/ovus.h b/source/core/shape/ovus.h index 84bdfb3c5..b89663d91 100644 --- a/source/core/shape/ovus.h +++ b/source/core/shape/ovus.h @@ -10,7 +10,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 @@ -41,6 +41,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -64,24 +72,24 @@ namespace pov /// //****************************************************************************** -class Ovus : public ObjectBase +class Ovus final : public ObjectBase { public: Ovus(); - virtual ~Ovus(); + virtual ~Ovus() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; /// radius of bottom sphere (provided in SDL) DBL BottomRadius; @@ -117,5 +125,6 @@ class Ovus : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_OVUS_H diff --git a/source/core/shape/parametric.cpp b/source/core/shape/parametric.cpp index c72bd8dc7..065dd5c82 100644 --- a/source/core/shape/parametric.cpp +++ b/source/core/shape/parametric.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,9 +36,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/parametric.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -49,6 +57,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -663,7 +674,7 @@ ObjectPtr Parametric::Copy() New->Trans = Copy_Transform(Trans); New->PData = Copy_PrecompParVal(); - New->container = shared_ptr(container->Copy()); + New->container = std::shared_ptr(container->Copy()); return (New); } @@ -728,7 +739,7 @@ Parametric::~Parametric() Parametric::Parametric() : NonsolidObject(PARAMETRIC_OBJECT) { - container = shared_ptr(new ContainedByBox()); + container = std::shared_ptr(new ContainedByBox()); Make_BBox(BBox, -1.0, -1.0, -1.0, 2.0, 2.0, 2.0); @@ -1123,3 +1134,4 @@ void Parametric::Evaluate_Function_Interval_UV(GenericScalarFunctionInstance& fn } } +// end of namespace pov diff --git a/source/core/shape/parametric.h b/source/core/shape/parametric.h index 128383c84..b51186936 100644 --- a/source/core/shape/parametric.h +++ b/source/core/shape/parametric.h @@ -12,7 +12,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,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/scene/object.h" @@ -72,18 +82,15 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct PrecompParValues_Struct PRECOMP_PAR_DATA; - -struct PrecompParValues_Struct +struct PrecompParValues_Struct final { int use, depth; char flags; DBL *Low[3], *Hi[3]; /* X,Y,Z */ }; +using PRECOMP_PAR_DATA = PrecompParValues_Struct; ///< @deprecated -class FPUContext; - -class Parametric : public NonsolidObject +class Parametric final : public NonsolidObject { public: @@ -92,22 +99,22 @@ class Parametric : public NonsolidObject DBL accuracy; DBL max_gradient; - shared_ptr container; + std::shared_ptr container; Parametric(); - virtual ~Parametric(); + virtual ~Parametric() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Precompute_Parametric_Values(char flags, int depth, TraceThreadData *Thread); protected: @@ -127,5 +134,6 @@ class Parametric : public NonsolidObject //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_PARAMETRIC_H diff --git a/source/core/shape/plane.cpp b/source/core/shape/plane.cpp index bbbbef7ed..f1f3c2f03 100644 --- a/source/core/shape/plane.cpp +++ b/source/core/shape/plane.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,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/plane.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -623,3 +631,4 @@ bool Plane::Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3 } } +// end of namespace pov diff --git a/source/core/shape/plane.h b/source/core/shape/plane.h index 7e8098f6d..cc8de3041 100644 --- a/source/core/shape/plane.h +++ b/source/core/shape/plane.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -62,28 +70,28 @@ namespace pov /// //****************************************************************************** -class Plane : public ObjectBase +class Plane final : public ObjectBase { public: Vector3d Normal_Vector; DBL Distance; Plane(); - virtual ~Plane(); - - virtual ObjectPtr Copy(); - - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; // TODO FIXME - document that it uses the default (it does, right?) [trf] - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual ObjectPtr Invert(); - virtual void Compute_BBox(); - virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const; + virtual ~Plane() override; + + virtual ObjectPtr Copy() override; + + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; // TODO FIXME - document that it uses the default (it does, right?) [trf] + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual ObjectPtr Invert() override; + virtual void Compute_BBox() override; + virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const override; protected: bool Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) const; }; @@ -93,5 +101,6 @@ class Plane : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_PLANE_H diff --git a/source/core/shape/polygon.cpp b/source/core/shape/polygon.cpp index aa7f04ebd..5aef6ba8e 100644 --- a/source/core/shape/polygon.cpp +++ b/source/core/shape/polygon.cpp @@ -10,7 +10,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 @@ -61,10 +61,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/polygon.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/pov_err.h" +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -974,3 +980,4 @@ bool Polygon::in_polygon(int number, Vector2d *points, DBL u, DBL v) } } +// end of namespace pov diff --git a/source/core/shape/polygon.h b/source/core/shape/polygon.h index 721aea12e..3252b0d9c 100644 --- a/source/core/shape/polygon.h +++ b/source/core/shape/polygon.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -67,35 +75,34 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct Polygon_Data_Struct POLYGON_DATA; - -struct Polygon_Data_Struct +struct Polygon_Data_Struct final { int References; int Number; Vector2d *Points; }; +using POLYGON_DATA = Polygon_Data_Struct; ///< @deprecated -class Polygon : public NonsolidObject +class Polygon final : public NonsolidObject { public: Vector3d S_Normal; POLYGON_DATA *Data; Polygon(); - virtual ~Polygon(); + virtual ~Polygon() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; // TODO FIXME - does this use the default mapping? [trf] - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; // TODO FIXME - does this use the default mapping? [trf] + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Polygon(int number, Vector3d *points); protected: @@ -108,5 +115,6 @@ class Polygon : public NonsolidObject //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_POLYGON_H diff --git a/source/core/shape/polynomial.cpp b/source/core/shape/polynomial.cpp index 83381e903..de466ca24 100644 --- a/source/core/shape/polynomial.cpp +++ b/source/core/shape/polynomial.cpp @@ -10,7 +10,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 @@ -38,6 +38,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/polynomial.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/math/polynomialsolver.h" @@ -1504,3 +1512,4 @@ bool Poly::Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d } } +// end of namespace pov diff --git a/source/core/shape/polynomial.h b/source/core/shape/polynomial.h index 576f01a25..d4e9c61c7 100644 --- a/source/core/shape/polynomial.h +++ b/source/core/shape/polynomial.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -74,26 +82,26 @@ inline int term_counts(int x) { return ((x+1)*(x+2)*(x+3)/6); } * Global typedefs ******************************************************************************/ -class Poly : public ObjectBase +class Poly final : public ObjectBase { public: int Order; DBL *Coeffs; Poly(int order); - virtual ~Poly(); + virtual ~Poly() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); - virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; + virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const override; bool Set_Coeff(const unsigned int x,const unsigned int y, const unsigned int z, const DBL value); protected: @@ -113,5 +121,6 @@ class Poly : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_POLYNOMIAL_H diff --git a/source/core/shape/prism.cpp b/source/core/shape/prism.cpp index ff8a7a059..381a83200 100644 --- a/source/core/shape/prism.cpp +++ b/source/core/shape/prism.cpp @@ -10,7 +10,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 @@ -115,10 +115,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/prism.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/pov_err.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/math/polynomialsolver.h" @@ -131,6 +137,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -1727,3 +1736,4 @@ void Prism::Compute_Prism(Vector2d *P, TraceThreadData *Thread) } } +// end of namespace pov diff --git a/source/core/shape/prism.h b/source/core/shape/prism.h index 88787994b..c134a40fa 100644 --- a/source/core/shape/prism.h +++ b/source/core/shape/prism.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -80,23 +88,22 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct Prism_Spline_Struct PRISM_SPLINE; -typedef struct Prism_Spline_Entry_Struct PRISM_SPLINE_ENTRY; - -struct Prism_Spline_Entry_Struct +struct Prism_Spline_Entry_Struct final { DBL x1, y1, x2, y2; /* Min./Max. coordinates of segment */ DBL v1, u2, v2; /* Min./Max. coordinates of segment in , u1 not needed */ Vector2d A, B, C, D; /* Coefficients of segment */ }; +using PRISM_SPLINE_ENTRY = Prism_Spline_Entry_Struct; ///< @deprecated -struct Prism_Spline_Struct +struct Prism_Spline_Struct final { int References; PRISM_SPLINE_ENTRY *Entry; }; +using PRISM_SPLINE = Prism_Spline_Struct; ///< @deprecated -class Prism : public ObjectBase +class Prism final : public ObjectBase { public: int Number; @@ -108,18 +115,18 @@ class Prism : public ObjectBase DBL u1, v1, u2, v2; /* Overall bounding rectangle of spline */ Prism(); - virtual ~Prism(); + virtual ~Prism() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Prism(Vector2d *P, TraceThreadData *Thread); protected: @@ -132,5 +139,6 @@ class Prism : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_PRISM_H diff --git a/source/core/shape/quadric.cpp b/source/core/shape/quadric.cpp index e1b24a835..a2f1146e6 100644 --- a/source/core/shape/quadric.cpp +++ b/source/core/shape/quadric.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,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/quadric.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include + +// POV-Ray header files (base module) +// (none at the moment) +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -50,6 +59,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -760,7 +772,7 @@ void Quadric::Compute_BBox(Vector3d& ClipMin, Vector3d& ClipMax) if(!Clip.empty()) { /* Intersect the members bounding boxes. */ - for(vector::iterator it = Clip.begin(); it != Clip.end(); it++) + for(std::vector::iterator it = Clip.begin(); it != Clip.end(); it++) { ObjectPtr p = *it; if (Test_Flag(p, INVERTED_FLAG) == false) @@ -1474,3 +1486,4 @@ void Quadric::Compute_Plane_Min_Max(const Plane *plane, Vector3d& Min, Vector3d& } } +// end of namespace pov diff --git a/source/core/shape/quadric.h b/source/core/shape/quadric.h index 3ea92bacd..e26f438ef 100644 --- a/source/core/shape/quadric.h +++ b/source/core/shape/quadric.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/scene/object.h" @@ -65,7 +73,7 @@ class Plane; /// //****************************************************************************** -class Quadric : public ObjectBase +class Quadric final : public ObjectBase { public: Vector3d Square_Terms; @@ -75,19 +83,19 @@ class Quadric : public ObjectBase bool Automatic_Bounds; Quadric(); - virtual ~Quadric(); + virtual ~Quadric() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual ObjectPtr Invert(); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual ObjectPtr Invert() override; + virtual void Compute_BBox() override; static void Compute_Plane_Min_Max(const Plane *plane, Vector3d& Min, Vector3d& Max); void Compute_BBox(Vector3d& ClipMin, Vector3d& ClipMax); @@ -102,5 +110,6 @@ class Quadric : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_QUADRIC_H diff --git a/source/core/shape/sor.cpp b/source/core/shape/sor.cpp index ff74dee0b..3342ee951 100644 --- a/source/core/shape/sor.cpp +++ b/source/core/shape/sor.cpp @@ -10,7 +10,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 @@ -98,10 +98,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/sor.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include +#include +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/bounding/boundingcylinder.h" #include "core/math/matrix.h" @@ -115,6 +122,9 @@ namespace pov { +using std::min; +using std::max; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -336,9 +346,9 @@ bool Sor::Intersect(const BasicRay& ray, IStack& Depth_Stack, TraceThreadData *T } /* Intersect all cylindrical bounds. */ - vector& intervals = Thread->BCyl_Intervals; - vector& rint = Thread->BCyl_RInt; - vector& hint = Thread->BCyl_HInt; + std::vector& intervals = Thread->BCyl_Intervals; + std::vector& rint = Thread->BCyl_RInt; + std::vector& hint = Thread->BCyl_HInt; if ((cnt = Intersect_BCyl(Spline->BCyl, intervals, rint, hint, P, D)) == 0) { @@ -1302,3 +1312,4 @@ void Sor::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData * } } +// end of namespace pov diff --git a/source/core/shape/sor.h b/source/core/shape/sor.h index 856f6f9a9..794c39d95 100644 --- a/source/core/shape/sor.h +++ b/source/core/shape/sor.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 @@ -39,6 +39,15 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) +#include "core/bounding/boundingcylinder_fwd.h" #include "core/scene/object.h" namespace pov @@ -72,24 +81,21 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct BCyl_Struct BCYL; - -typedef struct Sor_Spline_Entry_Struct SOR_SPLINE_ENTRY; -typedef struct Sor_Spline_Struct SOR_SPLINE; - -struct Sor_Spline_Entry_Struct +struct Sor_Spline_Entry_Struct final { DBL A, B, C, D; }; +using SOR_SPLINE_ENTRY = Sor_Spline_Entry_Struct; ///< @deprecated -struct Sor_Spline_Struct +struct Sor_Spline_Struct final { int References; SOR_SPLINE_ENTRY *Entry; BCYL *BCyl; /* bounding cylinder. */ }; +using SOR_SPLINE = Sor_Spline_Struct; ///< @deprecated -class Sor : public ObjectBase +class Sor final : public ObjectBase { public: int Number; @@ -100,19 +106,19 @@ class Sor : public ObjectBase DBL Cap_Radius_Squared; /* Radius**2 of the cap plane */ Sor(); - virtual ~Sor(); + virtual ~Sor() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute_Sor(Vector2d *P, TraceThreadData *Thread); protected: @@ -125,5 +131,6 @@ class Sor : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SOR_H diff --git a/source/core/shape/sphere.cpp b/source/core/shape/sphere.cpp index 9a61b90a6..e79e01fdb 100644 --- a/source/core/shape/sphere.cpp +++ b/source/core/shape/sphere.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,6 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/sphere.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -604,48 +612,6 @@ void Sphere::Transform(const TRANSFORM *tr) -/***************************************************************************** -* -* FUNCTION -* -* Destroy_Sphere -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* ? -* -* DESCRIPTION -* -* - -* -* CHANGES -* -* - -* -******************************************************************************/ - -Sphere::~Sphere() -{ -#if(DUMP_OBJECT_DATA == 1) - Debug_Info("{ // SPHERE \n"); - DUMP_OBJECT_FIELDS(this); - Debug_Info("\t{ %f, %f, %f }, // Center\n", \ - (DBL)Center[X], \ - (DBL)Center[Y], \ - (DBL)Center[Z]); \ - Debug_Info("\t%f // Radius\n", (DBL)Radius); - Debug_Info("}\n"); -#endif -} - - - /***************************************************************************** * * FUNCTION @@ -789,3 +755,4 @@ bool Sphere::Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector } } +// end of namespace pov diff --git a/source/core/shape/sphere.h b/source/core/shape/sphere.h index b523ab64a..088f83115 100644 --- a/source/core/shape/sphere.h +++ b/source/core/shape/sphere.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -62,27 +70,26 @@ namespace pov /// //****************************************************************************** -class Sphere : public ObjectBase +class Sphere final : public ObjectBase { public: Vector3d Center; DBL Radius; Sphere(); - virtual ~Sphere(); - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); - virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; + virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const override; static bool Intersect(const BasicRay& ray, const Vector3d& Center, DBL Radius2, DBL *Depth1, DBL *Depth2); @@ -108,5 +115,6 @@ class Sphere : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SPHERE_H diff --git a/source/core/shape/spheresweep.cpp b/source/core/shape/spheresweep.cpp index 9ff0d791b..13d6d1412 100644 --- a/source/core/shape/spheresweep.cpp +++ b/source/core/shape/spheresweep.cpp @@ -13,7 +13,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 @@ -81,8 +81,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/spheresweep.h" +// C++ variants of C standard header files +#include + +// C++ standard header files #include +// POV-Ray header files (base module) +#include "base/povassert.h" + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/math/polynomialsolver.h" @@ -224,7 +232,7 @@ bool SphereSweep::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceTh if(Num_Isect > 0) { // Sort intersections - QSORT(reinterpret_cast(Isect), Num_Isect, sizeof(SPHSWEEP_INT), Comp_Isects); + std::qsort(Isect, Num_Isect, sizeof(SPHSWEEP_INT), Comp_Isects); // Delete invalid intersections inside the sphere sweep Num_Isect = Find_Valid_Points(Isect, Num_Isect, New_Ray); @@ -1817,3 +1825,4 @@ int SphereSweep::bezier_01(int degree, const DBL* Coef, DBL* Roots, bool sturm, } } +// end of namespace pov diff --git a/source/core/shape/spheresweep.h b/source/core/shape/spheresweep.h index 33b6faaa0..00a23abd9 100644 --- a/source/core/shape/spheresweep.h +++ b/source/core/shape/spheresweep.h @@ -10,7 +10,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 @@ -41,6 +41,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -83,19 +91,16 @@ namespace pov * Global typedefs ******************************************************************************/ -typedef struct Sphere_Sweep_Sphere_Struct SPHSWEEP_SPH; -typedef struct Sphere_Sweep_Segment_Struct SPHSWEEP_SEG; -typedef struct Sphere_Sweep_Intersection_Structure SPHSWEEP_INT; - /* Single sphere, used to connect two adjacent segments */ -struct Sphere_Sweep_Sphere_Struct +struct Sphere_Sweep_Sphere_Struct final { Vector3d Center; DBL Radius; }; +using SPHSWEEP_SPH = Sphere_Sweep_Sphere_Struct; ///< @deprecated /* One segment of the sphere sweep */ -struct Sphere_Sweep_Segment_Struct +struct Sphere_Sweep_Segment_Struct final { SPHSWEEP_SPH Closing_Sphere[2]; /* Spheres closing the segment */ Vector3d Center_Deriv[2]; /* Derivatives of center funcs for 0 and 1 */ @@ -104,17 +109,19 @@ struct Sphere_Sweep_Segment_Struct Vector3d Center_Coef[SPH_SWP_MAX_COEFS]; /* Coefs of center polynomial */ DBL Radius_Coef[SPH_SWP_MAX_COEFS]; /* Coefs of radius polynomial */ }; +using SPHSWEEP_SEG = Sphere_Sweep_Segment_Struct; ///< @deprecated // Temporary storage for intersection values -struct Sphere_Sweep_Intersection_Structure +struct Sphere_Sweep_Intersection_Structure final { DBL t; // Distance along ray Vector3d Point; // Intersection point Vector3d Normal; // Normal at intersection point }; +using SPHSWEEP_INT = Sphere_Sweep_Intersection_Structure; ///< @deprecated /* The complete object */ -class SphereSweep : public ObjectBase +class SphereSweep final : public ObjectBase { public: int Interpolation; @@ -127,18 +134,18 @@ class SphereSweep : public ObjectBase DBL Depth_Tolerance; /* Preferred depth tolerance */ SphereSweep(); - virtual ~SphereSweep(); + virtual ~SphereSweep() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; void Compute(); protected: @@ -177,5 +184,6 @@ class SphereSweep : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SPHERESWEEP_H diff --git a/source/core/shape/superellipsoid.cpp b/source/core/shape/superellipsoid.cpp index 6563ca0a9..d1d94ddc2 100644 --- a/source/core/shape/superellipsoid.cpp +++ b/source/core/shape/superellipsoid.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 @@ -66,6 +66,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/superellipsoid.h" +// C++ variants of C standard header files +#include + +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -1294,7 +1304,7 @@ int Superellipsoid::find_ray_plane_points(const Vector3d& P, const Vector3d& D, /* Sort the results for further processing. */ - QSORT(reinterpret_cast(dists), cnt, sizeof(DBL), compdists); + std::qsort(dists, cnt, sizeof(DBL), compdists); return(cnt); } @@ -1548,3 +1558,4 @@ bool Superellipsoid::check_hit2(const Vector3d& P, const Vector3d& D, DBL t0, Ve } } +// end of namespace pov diff --git a/source/core/shape/superellipsoid.h b/source/core/shape/superellipsoid.h index 927b81de8..2dc25fad1 100644 --- a/source/core/shape/superellipsoid.h +++ b/source/core/shape/superellipsoid.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -62,24 +70,24 @@ namespace pov /// //****************************************************************************** -class Superellipsoid : public ObjectBase +class Superellipsoid final : public ObjectBase { public: Vector3d Power; Superellipsoid(); - virtual ~Superellipsoid(); - - virtual ObjectPtr Copy(); - - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual ~Superellipsoid() override; + + virtual ObjectPtr Copy() override; + + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; protected: bool Intersect(const BasicRay& ray, IStack& Depth_Stack, TraceThreadData *Thread); static bool intersect_box(const Vector3d& P, const Vector3d& D, DBL *dmin, DBL *dmax); @@ -98,5 +106,6 @@ class Superellipsoid : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SUPERELLIPSOID_H diff --git a/source/core/shape/torus.cpp b/source/core/shape/torus.cpp index c2943a04d..4a084ee88 100644 --- a/source/core/shape/torus.cpp +++ b/source/core/shape/torus.cpp @@ -10,7 +10,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 @@ -48,6 +48,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/torus.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/math/polynomialsolver.h" @@ -1131,3 +1139,4 @@ void Torus::CalcUV(const Vector3d& IPoint, Vector2d& Result) const } } +// end of namespace pov diff --git a/source/core/shape/torus.h b/source/core/shape/torus.h index fbb11f198..8d60b93be 100644 --- a/source/core/shape/torus.h +++ b/source/core/shape/torus.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -72,19 +80,19 @@ class Torus : public ObjectBase DBL MajorRadius, MinorRadius; Torus(); - virtual ~Torus(); - - virtual ObjectPtr Copy(); - - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual ~Torus() override; + + virtual ObjectPtr Copy() override; + + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; protected: int Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) const; bool Test_Thick_Cylinder(const Vector3d& P, const Vector3d& D, DBL h1, DBL h2, DBL r1, DBL r2) const; @@ -92,7 +100,7 @@ class Torus : public ObjectBase }; /// @todo This class may need its own UVCoord() function. -class SpindleTorus : public Torus +class SpindleTorus final : public Torus { protected: @@ -124,15 +132,15 @@ class SpindleTorus : public Torus SpindleMode mSpindleMode; SpindleTorus(); - virtual ~SpindleTorus(); + virtual ~SpindleTorus() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool Precompute(); - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Compute_BBox(); + virtual bool Precompute() override; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Compute_BBox() override; protected: @@ -144,5 +152,6 @@ class SpindleTorus : public Torus //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TORUS_H diff --git a/source/core/shape/triangle.cpp b/source/core/shape/triangle.cpp index e06b0a5bc..be771c7a2 100644 --- a/source/core/shape/triangle.cpp +++ b/source/core/shape/triangle.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 @@ -36,10 +36,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/triangle.h" -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) #include "base/mathutil.h" +// POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" @@ -1417,3 +1421,4 @@ bool Triangle::Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVect } } +// end of namespace pov diff --git a/source/core/shape/triangle.h b/source/core/shape/triangle.h index d68ce71f8..0f633fed0 100644 --- a/source/core/shape/triangle.h +++ b/source/core/shape/triangle.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 @@ -39,6 +39,14 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/scene/object.h" namespace pov @@ -75,20 +83,20 @@ class Triangle : public NonsolidObject Triangle(); Triangle(int t); - virtual ~Triangle(); + virtual ~Triangle() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; // TODO FIXME - why is there no UV-mapping for this trivial object? [trf] - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); - virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const; + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; // TODO FIXME - why is there no UV-mapping for this trivial object? [trf] + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; + virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const override; virtual bool Compute_Triangle(); protected: @@ -96,22 +104,22 @@ class Triangle : public NonsolidObject void find_triangle_dominant_axis(); }; -class SmoothTriangle : public Triangle +class SmoothTriangle final : public Triangle { public: Vector3d N1, N2, N3, Perp; SmoothTriangle(); - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; - virtual bool Compute_Triangle(); + virtual bool Compute_Triangle() override; static DBL Calculate_Smooth_T(const Vector3d& IPoint, const Vector3d& P1, const Vector3d& P2, const Vector3d& P3); protected: @@ -123,5 +131,6 @@ class SmoothTriangle : public Triangle //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TRIANGLE_H diff --git a/source/core/shape/truetype.cpp b/source/core/shape/truetype.cpp index fec71e1c2..bd225c33c 100644 --- a/source/core/shape/truetype.cpp +++ b/source/core/shape/truetype.cpp @@ -38,11 +38,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/shape/truetype.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include #include +// POV-Ray header files (base module) #include "base/fileinputoutput.h" +#include "base/povassert.h" +#include "base/stringutilities.h" +// POV-Ray header files (core module) #include "core/bounding/boundingbox.h" #include "core/math/matrix.h" #include "core/render/ray.h" @@ -55,6 +63,8 @@ namespace pov { +using namespace pov_base; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -126,32 +136,32 @@ typedef int Fixed; using GlyphIndex = POV_UINT32; -typedef struct +struct sfnt_OffsetTable final { Fixed version; /* 0x10000 (1.0) */ USHORT numTables; /* number of tables */ USHORT searchRange; /* (max2 <= numTables)*16 */ USHORT entrySelector; /* log2 (max2 <= numTables) */ USHORT rangeShift; /* numTables*16-searchRange */ -} sfnt_OffsetTable; +}; -typedef struct +struct sfnt_TableDirectory final { BYTE tag[4]; ULONG checkSum; ULONG offset; ULONG length; -} sfnt_TableDirectory; +}; typedef sfnt_TableDirectory *sfnt_TableDirectoryPtr; -typedef struct +struct longDateTime final { ULONG bc; ULONG ad; -} longDateTime; +}; -typedef struct +struct sfnt_FontHeader final { Fixed version; /* for this table, set to 1.0 */ Fixed fontRevision; /* For Font Manufacturer */ @@ -174,25 +184,25 @@ typedef struct SHORT fontDirectionHint; SHORT indexToLocFormat; /* 0 - short offsets, 1 - long offsets */ SHORT glyphDataFormat; -} sfnt_FontHeader; +}; -typedef struct +struct sfnt_platformEntry final { USHORT platformID; USHORT specificID; ULONG offset; -} sfnt_platformEntry; +}; typedef sfnt_platformEntry *sfnt_platformEntryPtr; -typedef struct +struct sfnt_mappingTable final { USHORT format; USHORT length; USHORT language; -} sfnt_mappingTable; +}; -typedef struct +struct sfnt_HorizHeader final { Fixed version; @@ -215,9 +225,9 @@ typedef struct SHORT metricDataFormat; USHORT numberOfHMetrics; /* number of hMetrics in the hmtx table */ -} sfnt_HorizHeader; +}; -struct GlyphHeader +struct GlyphHeader final { SHORT numContours; SHORT xMin; @@ -227,7 +237,7 @@ struct GlyphHeader GlyphHeader() : numContours(0), xMin(0), yMin(0), xMax(0), yMax(0) {} }; -struct GlyphOutline +struct GlyphOutline final { GlyphHeader header; std::vector endPoints; @@ -240,17 +250,17 @@ struct GlyphOutline {} }; -typedef struct +struct Contour final { BYTE inside_flag; /* 1 if this an inside contour, 0 if outside */ USHORT count; /* Number of points in the contour */ - vector flags; /* On/off curve flags */ - vector x, y; /* Coordinates of control vertices */ -} Contour; + std::vector flags; /* On/off curve flags */ + std::vector x, y; /* Coordinates of control vertices */ +}; /* Contour information for a single glyph */ -struct GlyphStruct +struct GlyphStruct final { GlyphHeader header; /* Count and sizing information about this glyph */ GlyphIndex glyph_index; /* Internal glyph index for this character */ @@ -259,40 +269,40 @@ struct GlyphStruct GlyphIndex myMetrics; /* Which glyph index this is for metrics */ }; -typedef struct KernData_struct +struct KernData final { USHORT left, right; /* Glyph index of left/right to kern */ FWord value; /* Delta in FUnits to apply in between */ -} KernData; +}; /* * [esp] There's already a "KernTable" on the Mac... renamed to TTKernTable for * now in memoriam to its author. */ -typedef struct KernStruct +struct TTKernTable final { USHORT coverage; /* Coverage bit field of this subtable */ USHORT nPairs; /* # of kerning pairs in this table */ KernData *kern_pairs; /* Array of kerning values */ -} TTKernTable; +}; -typedef struct KernTableStruct +struct KernTables final { USHORT nTables; /* # of subtables in the kerning table */ TTKernTable *tables; -} KernTables; +}; -typedef struct longHorMertric +struct longHorMetric final { uFWord advanceWidth; /* Total width of a glyph in FUnits */ FWord lsb; /* FUnits to the left of the glyph */ -} longHorMetric; +}; typedef std::map GlyphPtrMap; -struct CMAPSelector +struct CMAPSelector final { CMAPSelector() = default; CMAPSelector(USHORT pid, USHORT sid, CharsetID cs); @@ -310,7 +320,7 @@ struct CMAPInfo using CMAPInfoPtr = CMAPInfo*; -struct CMAP4Info : public CMAPInfo +struct CMAP4Info final : public CMAPInfo { CMAP4Info(); virtual ~CMAP4Info() override; @@ -322,7 +332,7 @@ struct CMAP4Info : public CMAPInfo *idDelta, *idRangeOffset; }; -struct TrueTypeInfo +struct TrueTypeInfo final { TrueTypeInfo(); ~TrueTypeInfo(); @@ -339,7 +349,7 @@ struct TrueTypeInfo KernTables kerning_tables; /* Kerning info for this font */ USHORT numberOfHMetrics; /* The number of explicit spacings */ longHorMetric *hmtx_table; /* Horizontal spacing info */ - vector cmapInfo; + std::vector cmapInfo; }; /***************************************************************************** @@ -3078,7 +3088,7 @@ void TrueType::Compute_BBox() } -TrueTypeFont::TrueTypeFont(const UCS2String& fn, const shared_ptr& f, +TrueTypeFont::TrueTypeFont(const UCS2String& fn, const std::shared_ptr& f, POV_UINT32 cm, CharsetID cs, LegacyCharset scs) : filename(fn), file(f), @@ -3179,4 +3189,4 @@ TrueTypeInfo::~TrueTypeInfo() } } - +// end of namespace pov diff --git a/source/core/shape/truetype.h b/source/core/shape/truetype.h index d2dbc7f1e..4fdd19b86 100644 --- a/source/core/shape/truetype.h +++ b/source/core/shape/truetype.h @@ -39,14 +39,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include "core/scene/object.h" +// C++ variants of C standard header files +// (none at the moment) -namespace pov_base -{ +// C++ standard header files +#include -class IStream; +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" -} +// POV-Ray header files (core module) +#include "core/scene/object.h" +#include "core/shape/csg_fwd.h" namespace pov { @@ -57,10 +61,6 @@ namespace pov /// /// @{ -class CSG; - -using pov_base::IStream; - //****************************************************************************** /// /// @name Object Types @@ -78,44 +78,45 @@ using pov_base::IStream; * Global typedefs ******************************************************************************/ -typedef struct GlyphStruct *GlyphPtr; +struct GlyphStruct; +using GlyphPtr = GlyphStruct*; struct TrueTypeInfo; -struct TrueTypeFont +struct TrueTypeFont final { static constexpr POV_UINT32 kAnyCMAP = 0xFFFFFFFFu; - TrueTypeFont(const UCS2String& fn, const shared_ptr& f, POV_UINT32 cm, CharsetID cs, LegacyCharset scs); + TrueTypeFont(const UCS2String& fn, const std::shared_ptr& f, POV_UINT32 cm, CharsetID cs, LegacyCharset scs); ~TrueTypeFont(); UCS2String filename; - shared_ptr file; + std::shared_ptr file; POV_UINT32 cmap; CharsetID charset; LegacyCharset legacyCharset; TrueTypeInfo* info; }; -class TrueType : public ObjectBase +class TrueType final : public ObjectBase { public: GlyphPtr glyph; /* (GlyphPtr) Pointer to the glyph */ DBL depth; /* Amount of extrusion */ TrueType(); - virtual ~TrueType(); + virtual ~TrueType() override; - virtual ObjectPtr Copy(); + virtual ObjectPtr Copy() override; - virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *); - virtual bool Inside(const Vector3d&, TraceThreadData *) const; - virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const; - virtual void Translate(const Vector3d&, const TRANSFORM *); - virtual void Rotate(const Vector3d&, const TRANSFORM *); - virtual void Scale(const Vector3d&, const TRANSFORM *); - virtual void Transform(const TRANSFORM *); - virtual void Compute_BBox(); + virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; + virtual bool Inside(const Vector3d&, TraceThreadData *) const override; + virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; + virtual void Translate(const Vector3d&, const TRANSFORM *) override; + virtual void Rotate(const Vector3d&, const TRANSFORM *) override; + virtual void Scale(const Vector3d&, const TRANSFORM *) override; + virtual void Transform(const TRANSFORM *) override; + virtual void Compute_BBox() override; static void ProcessNewTTF(CSG *Object, TrueTypeFont* font, const UCS2 *text_string, DBL depth, const Vector3d& offset); protected: @@ -130,5 +131,6 @@ class TrueType : public ObjectBase //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_TRUETYPE_H diff --git a/source/core/support/imageutil.cpp b/source/core/support/imageutil.cpp index d4fa117f0..ae50e194e 100644 --- a/source/core/support/imageutil.cpp +++ b/source/core/support/imageutil.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,10 +36,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/support/imageutil.h" -#include +// 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" +#include "base/povassert.h" +#include "base/image/encoding.h" +#include "base/image/image.h" +// POV-Ray header files (core module) #include "core/colour/spectral.h" #include "core/material/normal.h" #include "core/material/pattern.h" @@ -1398,5 +1405,5 @@ ImageData::~ImageData() delete data; } - } +// end of namespace pov diff --git a/source/core/support/imageutil.h b/source/core/support/imageutil.h index 2e557a378..b4bf41bc2 100644 --- a/source/core/support/imageutil.h +++ b/source/core/support/imageutil.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 @@ -40,17 +40,21 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include "base/image/image.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) +#include "base/image/image_fwd.h" + +// POV-Ray header files (core module) #include "core/coretypes.h" +#include "core/material/pattern_fwd.h" #include "core/math/vector.h" namespace pov { -class ImageData; -struct ImagePattern; - //############################################################################## /// /// @defgroup PovCoreSupportImageUtil Image Handling Utilities @@ -97,7 +101,7 @@ enum USE_ALPHA = 3 }; -class ImageData +class ImageData final { public: int References; // Keeps track of number of pointers to this structure @@ -145,5 +149,6 @@ void Destroy_Image(ImageData *image); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_IMAGEUTIL_H diff --git a/source/core/support/octree.cpp b/source/core/support/octree.cpp index 797b1533d..c78cd673c 100644 --- a/source/core/support/octree.cpp +++ b/source/core/support/octree.cpp @@ -10,7 +10,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 @@ -41,7 +41,7 @@ * To understand the relationship between an ot_id (x,y,z,size) and * a place in model space, you have to scale the integer values: * The nominal space occupied is given as follows: -* fsize = pow(2,size-127); +* fsize = pow(2,size-Pow2Bias); * lox = (float)x *fsize; loy = (float)y * fsize; loz = (float)z * fsize; * hix = lox + fsize; hiy = loy + fsize; hiz = loz + fsize; * All elements within this node are guaranteed to stick outside of the @@ -57,15 +57,22 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/support/octree.h" +// C++ variants of C standard header files #include -#include +#include +#include +// C++ standard header files #include +#include +// POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/mathutil.h" #include "base/pov_err.h" +#include "base/pov_mem.h" +// POV-Ray header files (core module) #include "core/colour/spectral.h" // this must be the last file included @@ -81,117 +88,372 @@ namespace pov #define SAFE_METHOD 1 // #define OT_DEBUG 1 -// WARNING: The default uses POV-Ray's own tricks which only work if -// "float" is a 32 bit IEEE 754 floating point number! If your platform -// does not use 32 bit IEEE 754 floating point numbers, radiosity will -// be broken!!! If you have this problem, your only other choice is to -// use an ISO C99 standard revision compatible compiler and library: -// -// Define this to 1 to use ISO C99 functions logbf and copysign. -// Define this to 2 to use ISO C99 functions ilogbf and copysign. -// Define this to 3 to use ISO C99 functions logb and copysign. -// Define this to 4 to use ISO C99 functions ilogb and copysign. -// -// You may want to try 1 to 4 as it cannot be generally said which one -// will be faster, but it is most likely that either 1 or 2 will perform -// slightly less well than POV-Ray's trick. In any case, testing all -// variants (0, 1 to 4) is recommended if possible on your platform! -// -// NOTE: Of course you should put the define for C99_COMPATIBLE_RADIOSITY -// into config.h and *not* mess around with this file!!! -#ifndef C99_COMPATIBLE_RADIOSITY -#define C99_COMPATIBLE_RADIOSITY 0 -#endif +//****************************************************************************** // compiler / target platform sanity checks // (note that these don't necessarily catch all possible quirks; they should be quite reliable though) -#if(C99_COMPATIBLE_RADIOSITY == 0) - #if( (INT_MAX != SIGNED32_MAX) || (INT_MIN + SIGNED32_MAX != -1) ) - #error "'int' is not 32 bit or does not use two's complement encoding; try a different C99_COMPATIBLE_RADIOSITY setting in config.h" - #endif - #if(FLT_RADIX != 2) - #error "'float' does not conform to IEEE 754 single-precision format; try a different C99_COMPATIBLE_RADIOSITY setting in config.h" - #endif - #if(FLT_MANT_DIG != 24) - #error "'float' does not conform to IEEE 754 single-precision format; try a different C99_COMPATIBLE_RADIOSITY setting in config.h" - #endif - #if(FLT_MAX_EXP != 128) - #error "'float' does not conform to IEEE 754 single-precision format; try a different C99_COMPATIBLE_RADIOSITY setting in config.h" - #endif - #if(FLT_MIN_EXP != -125) - #error "'float' does not conform to IEEE 754 single-precision format; try a different C99_COMPATIBLE_RADIOSITY setting in config.h" - #endif -#else - #if(FLT_RADIX != 2) - // logb family of functions will not work as expected - #error "floating point arithmetic uses an uncommon radix; this file will not compile on your machine" - #endif +#if (POV_PORTABLE_RADIOSITY == 0) + +// Needs IEEE 754 binary32 (aka single precision) floating-point format +// and an unpadded integer of same size. + +// According to the C++11 standard `std::uint32_t` must be exactly 32 bits wide, +// unpadded and unsigned, _or_ be undefined if the platform does not support +// such a type. In the latter case, we expect a compile error here complaining +// about `std::uint32_t`. +// If that's what you are seeing, do _not_ try to substitute a different type, +// as it is unlikely to work. Instead, try a different setting for +// POV_PORTABLE_RADIOSITY. + +static_assert( + (sizeof(float) == sizeof(std::uint32_t)) && + (std::numeric_limits::radix == 2) && + (std::numeric_limits::digits == 24) && + (std::numeric_limits::min_exponent == -125) && + (std::numeric_limits::max_exponent == 128), + "POV_PORTABLE_RADIOSITY setting 0 requires 'float' to conform to IEEE 754 binary32 " + "(aka single precision) format, which it doesn't. Try a different setting." + ); + +#elif (POV_PORTABLE_RADIOSITY == 5) + +// Needs IEEE 754 binary64 (aka double precision) floating-point format +// and an unpadded integer of same size. + +// According to the C++11 standard `std::uint64_t` must be exactly 32 bits wide, +// unpadded and unsigned, _or_ be undefined if the platform does not support +// such a type. In the latter case, we expect a compile error here complaining +// about `std::uint64_t`. +// If that's what you are seeing, do _not_ try to substitute a different type, +// as it is unlikely to work. Instead, try a different setting for +// POV_PORTABLE_RADIOSITY. + +static_assert( + (sizeof(double) == sizeof(std::uint64_t)) && + (std::numeric_limits::radix == 2) && + (std::numeric_limits::digits == 53) && + (std::numeric_limits::min_exponent == -1021) && + (std::numeric_limits::max_exponent == 1024), + "POV_PORTABLE_RADIOSITY setting 5 requires 'double' to conform to IEEE 754 binary64 " + "(aka double precision) format, which it doesn't. Try a different setting." + ); + +#elif (POV_PORTABLE_RADIOSITY == 1) || (POV_PORTABLE_RADIOSITY == 2) || (POV_PORTABLE_RADIOSITY == 7) + +// Needs Radix-2 floating-point format. + +static_assert( + (std::numeric_limits::radix == 2), + "POV_PORTABLE_RADIOSITY settings 1, 2 and 7 require 'float' to be a radix-2 type, " + "which it isn't. Try a different setting." + ); + +#elif (POV_PORTABLE_RADIOSITY == 3) || (POV_PORTABLE_RADIOSITY == 4) || (POV_PORTABLE_RADIOSITY == 9) + +// Needs Radix-2 floating-point format. + +static_assert( + (std::numeric_limits::radix == 2), + "POV_PORTABLE_RADIOSITY settings 3, 4 and 9 requires 'double' to be a radix-2 type, " + "which it isn't. Try a different setting." + ); + #endif -#if(C99_COMPATIBLE_RADIOSITY == 0) - // hacks exploiting IEEE standard float encoding properties - #define POW2OP_DECLARE() \ - union { float f; int l; } nodesize_hack; // MUST be float, NOT DBL - // This hex operation does a floor to next lower power of 2, by clearing - // all of the mantissa bits. Works only on IEEE single precision floats - #define POW2OP_FLOOR(dest,src) \ - nodesize_hack.f = (float)(src); \ - nodesize_hack.l &= 0xff800000; \ - (dest) = (DBL)nodesize_hack.f; - // This magic hex operation extracts the exponent, which gives us an - // integer number suitable for labelling a range of a power of 2. In IEEE - // format, value = pow(2,exponent-127). Therefore, if our index is, say, - // 129, then the item has a maximum extent of (2 to the (129-127)), or - // about 4 space units. - #define POW2OP_ENCODE(dest,src) \ - nodesize_hack.f = (float) (src); \ - (dest) = (nodesize_hack.l & 0x7f800000) >> 23; - #define POW2OP_DECODE(dest,src) \ - nodesize_hack.l = (src) << 23; \ - (dest) = (DBL) (size).f; -#elif(C99_COMPATIBLE_RADIOSITY == 1) - #define POW2OP_DECLARE() // nothing - #define POW2OP_FLOOR(dest,src) \ - (dest) = pow(2.0, logbf(src)); \ - (dest) = copysign((dest), (src)); - #define POW2OP_ENCODE(dest,src) \ - (dest) = ((int)logbf(src)) + 127; - #define POW2OP_DECODE(dest,src) \ - if( (src) >= 127 ) (dest) = (DBL)(1 << ((src) - 127)); \ - else (dest) = 1.0 / (DBL)(1 << (127 - (src))); -#elif(C99_COMPATIBLE_RADIOSITY == 2) - #define POW2OP_DECLARE() // nothing - #define POW2OP_FLOOR(dest,src) \ - (dest) = (DBL)(1 << ilogbf(src)); \ - (dest) = copysign((dest), (src)); - #define POW2OP_ENCODE(dest,src) \ - (dest) = ilogbf(src) + 127; - #define POW2OP_DECODE(dest,src) \ - if( (src) >= 127 ) (dest) = (DBL)(1 << ((src) - 127)); \ - else (dest) = 1.0 / (DBL)(1 << (127 - (src))); -#elif(C99_COMPATIBLE_RADIOSITY == 3) - #define POW2OP_DECLARE() // nothing - #define POW2OP_FLOOR(dest,src) \ - (dest) = pow(2.0, logb(src)); \ - (dest) = copysign((dest), (src)); - #define POW2OP_ENCODE(dest,src) \ - (dest) = ((int)logb(src)) + 127; - #define POW2OP_DECODE(dest,src) \ - if( (src) >= 127 ) (dest) = (DBL)(1 << ((src) - 127)); \ - else (dest) = 1.0 / (DBL)(1 << (127 - (src))); +//------------------------------------------------------------------------------ + +#if (POV_PORTABLE_RADIOSITY == 0) + +/// Bias inherent in @ref BiasedLog2() and @ref BiasedPow2(). +static constexpr auto Pow2Bias = 127; + +union FloatHack { float f; std::uint32_t i; }; + +/// Round down to power of 2. +/// +/// This function rounds a value down to a power of 2: +/// +/// @f[ +/// f(a) = 2 ^{ \left \lfloor log_2 a \right \rfloor } +/// @f] +/// +/// @note +/// The function signature may differ depending on +/// @ref POV_PORTABLE_RADIOSITY. +/// +/// @pre +/// The parameter value shall be finite and positive. +/// +static inline float Pow2Floor(float a) +{ + FloatHack hack; + hack.f = a; + // Directly clear all mantissa bits (= 1.0) + // while leaving sign and exponent intact. + hack.i &= 0xFF800000; + return hack.f; +} + +/// Compute biased integer base 2 logarithm. +/// +/// This function computes the integer part of the base 2 logarithm of the +/// parameter's magnitude, plus a constant bias: +/// +/// @f[ +/// f(a) = \left \lfloor log_2 \left | a \right | \right \rfloor + b +/// @f] +/// +/// The value of the bias _b_ depends on @ref POV_PORTABLE_RADIOSITY, bit is +/// the same value as used by @BiasedIntPow2(). +/// +/// @note +/// The function signature may differ depending on +/// @ref POV_PORTABLE_RADIOSITY. +/// +/// @pre +/// The parameter value shall be finite and positive. +/// +static inline int BiasedIntLog2(float a) +{ + FloatHack hack; + hack.f = a; + // Directly extract the (biased) float exponent as the final result. + return (hack.i & 0x7F800000u) >> 23; +} + +/// Compute biased integer power of 2. +/// +/// This function computes 2 raised to the power of the integer parameter +/// minus a constant bias: +/// +/// @f[ +/// f(a) = 2 ^{ a - b } +/// @f] +/// +/// The value of the bias _b_ depends on @ref POV_PORTABLE_RADIOSITY, bit is +/// the same value as used by @BiasedIntLog2(). +/// +/// @note +/// The function signature may differ depending on +/// @ref POV_PORTABLE_BIASEDINTPOW2. +/// +static inline float BiasedIntPow2(int a) +{ + FloatHack hack; + // Directly copy `a` into the (biased) float exponent, + // while clearing sign and mantissa bits (= positive, 1.0). + hack.i = uint32_t(a) << 23; + return hack.f; +} + +#elif (POV_PORTABLE_RADIOSITY == 1) + +static constexpr auto Pow2Bias = 0; + +static inline float Pow2Floor(float a) +{ + return std::powf(2.0f, std::logbf(a)); +} + +static inline int BiasedIntLog2(float a) +{ + return (int)std::logbf(a); +} + +static inline float BiasedIntPow2(int a) +{ + if (a >= 0) + return float(1 << a); + else + return 1.0f / float(1 << -a); +} + +#elif (POV_PORTABLE_RADIOSITY == 2) + +static constexpr auto Pow2Bias = 0; + +static inline float Pow2Floor(float a) +{ + return float(1 << std::ilogbf(a)); +} + +static inline int BiasedIntLog2(float a) +{ + return std::ilogbf(a); +} + +static inline float BiasedIntPow2(int a) +{ + if (a >= 0) + return float(1 << a); + else + return 1.0f / float(1 << -a); +} + +#elif (POV_PORTABLE_RADIOSITY == 3) + +static constexpr auto Pow2Bias = 0; + +static inline double Pow2Floor(double a) +{ + return std::pow(2.0, std::logb(a)); +} + +static inline int BiasedIntLog2(double a) +{ + return (int)std::logb(a); +} + +static inline double BiasedIntPow2(int a) +{ + if (a >= 0) + return double(1 << a); + else + return 1.0 / double(1 << -a); +} + +#elif (POV_PORTABLE_RADIOSITY == 4) + +static constexpr auto Pow2Bias = 0; + +static inline double Pow2Floor(double a) +{ + return double(1 << std::ilogb(a)); +} + +static inline int BiasedIntLog2(double a) +{ + return std::ilogb(a); +} + +static inline double BiasedIntPow2(int a) +{ + if (a >= 0) + return double(1 << a); + else + return 1.0 / double(1 << -a); +} + +#elif (POV_PORTABLE_RADIOSITY == 5) + +static constexpr auto Pow2Bias = 1023; + +union DoubleHack { double f; std::uint64_t i; }; + +static inline double Pow2Floor(double a) +{ + DoubleHack hack; + hack.f = a; + // Directly clear all mantissa bits (= 1.0) + // while leaving sign and exponent intact. + hack.i &= 0xFFF0000000000000; + return hack.f; +} + +static inline int BiasedIntLog2(double a) +{ + DoubleHack hack; + hack.f = a; + // Directly extract the (biased) float exponent as the final result. + return ((hack.i & 0x7FF0000000000000u) >> 52); +} + +static inline double BiasedIntPow2(int a) +{ + DoubleHack hack; + // Directly copy `a` into the (biased) float exponent, + // while clearing sign and mantissa bits (= positive, 1.0). + hack.i = uint64_t(a) << 52; + return hack.f; +} + +#elif (POV_PORTABLE_RADIOSITY == 6) + +static constexpr auto Pow2Bias = 0; + +static inline float Pow2Floor(float a) +{ + int e; + (void)std::frexpf(a, &e); + return std::ldexpf(0.5f, e); +} + +static inline int BiasedIntLog2(float a) +{ + int e; + (void)std::frexpf(a, &e); + return e - 1; +} + +static inline float BiasedIntPow2(int a) +{ + return std::ldexpf(1.0f, a); +} + +#elif (POV_PORTABLE_RADIOSITY == 7) + +static constexpr auto Pow2Bias = 0; + +static inline float Pow2Floor(float a) +{ + return std::ldexpf(1.0f, std::ilogbf(a)); +} + +static inline int BiasedIntLog2(float a) +{ + return std::ilogbf(a); +} + +static inline float BiasedIntPow2(int a) +{ + return std::ldexpf(1.0f, a); +} + +#elif (POV_PORTABLE_RADIOSITY == 8) + +static constexpr auto Pow2Bias = 0; + +static inline double Pow2Floor(double a) +{ + int e; + (void)std::frexp(a, &e); + return std::ldexp(0.5, e); +} +static inline int BiasedIntLog2(double a) +{ + int e; + (void)std::frexp(a, &e); + return e - 1; +} +static inline double BiasedIntPow2(int a) +{ + return std::ldexpf(1.0, a); +} + +#elif (POV_PORTABLE_RADIOSITY == 9) + +static constexpr auto Pow2Bias = 0; + +static inline double Pow2Floor(double a) +{ + return std::ldexp(1.0, std::ilogb(a)); +} + +static inline int BiasedIntLog2(double a) +{ + return std::ilogb(a); +} + +static inline double BiasedIntPow2(int a) +{ + return std::ldexp(1.0, a); +} + #else - #define POW2OP_DECLARE() // nothing - #define POW2OP_FLOOR(dest,src) \ - (dest) = (DBL)(1 << ilogb(src)); \ - (dest) = copysign((dest), (src)); - #define POW2OP_ENCODE(dest,src) \ - (dest) = ilogb(src) + 127; - #define POW2OP_DECODE(dest,src) \ - if( (src) >= 127 ) (dest) = (DBL)(1 << ((src) - 127)); \ - else (dest) = 1.0 / (DBL)(1 << (127 - (src))); +#error "Unsupported POV_PORTABLE_RADIOSITY setting." #endif - +//****************************************************************************** bool ot_save_node (const Vector3d& point, OT_ID *node); bool ot_traverse (OT_NODE *subtree, bool (*function)(OT_BLOCK *block, void * handle1), void * handle2); @@ -258,19 +520,6 @@ void ot_ins(OT_NODE **root_ptr, OT_BLOCK *new_block, const OT_ID *new_id) if (*root_ptr == nullptr) { -// CLi moved C99_COMPATIBLE_RADIOSITY check from ot_newroot() to ot_ins() `nullptr` root handling section -// (no need to do this again and again for every new node inserted) -#if(C99_COMPATIBLE_RADIOSITY == 0) - if((sizeof(int) != 4) || (sizeof(float) != 4)) - { - throw POV_EXCEPTION_STRING("Radiosity is not available in this unofficial version because\n" - "the person who made this unofficial version available did not\n" - "properly check for compatibility on your platform.\n" - "Look for C99_COMPATIBLE_RADIOSITY in the source code to find\n" - "out how to correct this."); - } -#endif - *root_ptr = new OT_NODE; #ifdef RADSTATS @@ -482,9 +731,6 @@ void ot_newroot(OT_NODE **root_ptr) index = dx + dy + dz; newroot->Kids[index] = *root_ptr; *root_ptr = newroot; - -// CLi moved C99_COMPATIBLE_RADIOSITY check from ot_newroot() to ot_ins() `nullptr` root handling section -// (no need to do this again and again for every new node inserted) } @@ -588,7 +834,7 @@ bool ot_dist_traverse(OT_NODE *subtree, const Vector3d& point, int bounce_depth, while (this_block != nullptr) { #ifdef RADSTATS - if (subtree->Id.Size < 100 || subtree->Id.Size > 140 ) + if ((subtree->Id.Size < Pow2Bias - 27) || (subtree->Id.Size > Pow2Bias + 13)) { Debug_Info("bounds error, unreasonable size %d\n", subtree->Id.Size); } @@ -739,21 +985,8 @@ inline bool ot_point_in_node(const Vector3d& point, const OT_ID *id) { DBL sized; - // sized = 2.0^(size-127) -#if(C99_COMPATIBLE_RADIOSITY == 0) - // speed hack exploiting standard IEEE float binary representation - union - { - float f; // MUST be float, NOT DBL - int l; - } size; - size.l = id->Size << 23; - sized = (DBL) size.f; -#else - // can't use speed hack, do it the official way - if( id->Size >= 127 ) sized = (DBL)(1 << (id->Size - 127)); - else sized = 1.0 / (DBL)(1 << (127 - id->Size)); -#endif + // sized = 2.0^(size-Pow2Bias) + sized = BiasedIntPow2(id->Size); if (fabs(point.x() + OT_BIAS - ((DBL) id->x + 0.5) * sized) >= sized) return false; if (fabs(point.y() + OT_BIAS - ((DBL) id->y + 0.5) * sized) >= sized) return false; @@ -785,7 +1018,7 @@ inline bool ot_point_in_node(const Vector3d& point, const OT_ID *id) * Return the oct-tree index for an object with the specified bounding * sphere. This is the smallest box in the tree that this object fits in with * a maximum 50% hand-over in any (or all) directions. For example, an object -* at (.49, .49, 49) of radius 1 fits in the box (0,0,0) size 127 (length 1). +* at (.49, .49, 49) of radius 1 fits in the box (0,0,0) size Pow2Bias (length 1). * * THREAD SAFETY * @@ -802,6 +1035,9 @@ void ot_index_sphere(const Vector3d& point, DBL radius, OT_ID *id) { Vector3d min_point, max_point; + // TODO FIXME - This transformation from center/radius to min/max is a waste of effort, + // as `ot_index_box` will actually convert it back to center/radius anyway. + min_point = point - radius; max_point = point + radius; @@ -845,16 +1081,7 @@ void ot_index_sphere(const Vector3d& point, DBL radius, OT_ID *id) * smallest box in the tree that this object fits in with a maximum 50% * hang-over in any (or all) directions. For example, an object with extent * (-.49, -.49, -49) to (1.49, 1.49, 1.49) is the largest that fits in the -* box (0,0,0) with size 127 (length 1). -* -* PORTABILITY WARNING: this function REQUIRES IEEE single precision floating -* point format to work. This is true of most common systems except VAXen, -* Crays, and Alpha AXP in VAX compatibility mode. Local "float" variables -* can NOT be made double precision "double" or "DBL". -* -* NOTE: In general the above note is no longer valid, you can use the -* C99_COMPATIBLE_RADIOSITY define explained near the top of this file -* to resolve this problem with recent compilers and libraries [trf] +* box (0,0,0) with size Pow2Bias (length 1). * * THREAD SAFETY * @@ -873,10 +1100,9 @@ void ot_index_box(const Vector3d& min_point, const Vector3d& max_point, OT_ID *i DBL dx, dy, dz, desiredSize; DBL bsized, maxord; - POW2OP_DECLARE() // Calculate the absolute minimum required size of the node, assuming it is perfectly centered within the node; - // Node size must be a power of 2, and be large enough to accomodate box's biggest dimensions with maximum overhang to all sides + // Node size must be a power of 2, and be large enough to accommodate box's biggest dimensions with maximum overhang to all sides // compute ideal size of the node for a perfect fit without any overhang dx = max_point.x() - min_point.x(); @@ -890,7 +1116,7 @@ void ot_index_box(const Vector3d& min_point, const Vector3d& max_point, OT_ID *i // compute best-matching power-of-two size for a perfect fit with overhang // (Note: theoretically this might pick a size larger than required if desiredSize is already a power of two) // desiredSize *= 2.0; - POW2OP_FLOOR(bsized,desiredSize) + bsized = Pow2Floor(desiredSize); // avoid divisions by zero if(bsized == 0.0) @@ -919,7 +1145,7 @@ void ot_index_box(const Vector3d& min_point, const Vector3d& max_point, OT_ID *i id->x = (int) floor((center[X] + OT_BIAS) / bsized); id->y = (int) floor((center[Y] + OT_BIAS) / bsized); id->z = (int) floor((center[Z] + OT_BIAS) / bsized); - POW2OP_ENCODE(id->Size, bsized) + id->Size = BiasedIntLog2(bsized); #ifdef RADSTATS thisloops = 0; @@ -943,7 +1169,7 @@ void ot_index_box(const Vector3d& min_point, const Vector3d& max_point, OT_ID *i #endif #ifdef OT_DEBUG - if (id->Size > 139) + if (id->Size > Pow2Bias + 12) { Debug_Info("unusually large id, maxdel=%.4f, bsized=%.4f, isize=%d\n", maxdel, bsized, id->Size); @@ -1397,4 +1623,5 @@ bool ot_read_file(OT_NODE **root, IStream *fd, const OT_READ_PARAM* param, OT_RE return retval; } -} // end of namespace +} +// end of namespace pov diff --git a/source/core/support/octree.h b/source/core/support/octree.h index 5ec8f2088..9944c05d8 100644 --- a/source/core/support/octree.h +++ b/source/core/support/octree.h @@ -10,7 +10,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 @@ -45,18 +45,21 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/support/octree_fwd.h" +// C++ variants of C standard header files #include +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput_fwd.h" + +// POV-Ray header files (core module) #include "core/coretypes.h" #include "core/math/vector.h" -namespace pov_base -{ -class IStream; -class OStream; -} - namespace pov { @@ -73,8 +76,7 @@ using namespace pov_base; * Global preprocessor defines ******************************************************************************/ -// The addressing scheme of the nodes has a fundamental problem in that it is -// incapable of providing a common root for nodes which have IDs with differing signs. +// The addressing scheme of the nodes has an issue near the origin that impedes performance. // We're working around this by adding a large positive bias when computing node IDs. #define OT_BIAS 10000000. @@ -86,26 +88,20 @@ using namespace pov_base; typedef unsigned short OT_TILE; #define OT_TILE_MAX USHRT_MAX -typedef unsigned char OT_PASS; -#define OT_PASS_INVALID 0 -#define OT_PASS_FIRST 1 -#define OT_PASS_FINAL UCHAR_MAX -#define OT_PASS_MAX (OT_PASS_FINAL-2) // OT_PASS_FINAL-1 is reserved - -typedef unsigned char OT_DEPTH; -#define OT_DEPTH_MAX UCHAR_MAX +using OT_PASS = OctreePass; ///< @deprecated +constexpr auto OT_PASS_INVALID = kOctreePassInvalid; ///< @deprecated +constexpr auto OT_PASS_FIRST = kOctreePassFirst; ///< @deprecated +constexpr auto OT_PASS_FINAL = kOctreePassFinal; ///< @deprecated +constexpr auto OT_PASS_MAX = kOctreePassMax; ///< @deprecated -typedef struct ot_block_struct OT_BLOCK; -typedef struct ot_id_struct OT_ID; -typedef struct ot_node_struct OT_NODE; -typedef struct ot_read_param_struct OT_READ_PARAM; -typedef struct ot_read_info_struct OT_READ_INFO; +using OT_DEPTH = OctreeDepth; +constexpr auto OT_DEPTH_MAX = kOctreeDepthMax; ///< @deprecated // Each node in the oct-tree has a (possibly null) linked list of these data blocks off it. -struct ot_block_struct +struct ot_block_struct final { // TODO for memory efficiency we could probably use single-precision data types for the vector stuff - OT_BLOCK *next; // next block in the same node + ot_block_struct* next; // next block in the same node Vector3d Point; Vector3d S_Normal; Vector3d To_Nearest_Surface; @@ -119,40 +115,45 @@ struct ot_block_struct OT_PASS Pass; // pass during which this sample was taken (OT_PASS_FINAL for final render) OT_DEPTH Bounce_Depth; }; +using OT_BLOCK = ot_block_struct; ///< @deprecated // This is the information necessary to name an oct-tree node. -struct ot_id_struct +struct ot_id_struct final { int x, y, z; int Size; ot_id_struct() : x(0), y(0), z(0), Size(0) {} }; +using OT_ID = ot_id_struct; ///< @deprecated // These are the structures that make up the oct-tree itself, known as nodes -struct ot_node_struct +struct ot_node_struct final { OT_ID Id; OT_BLOCK *Values; - OT_NODE *Kids[8]; + ot_node_struct *Kids[8]; ot_node_struct() : Id(), Values(nullptr) { for (unsigned int i = 0; i < 8; i ++) { Kids[i] = nullptr; } } }; +using OT_NODE = ot_node_struct; ///< @deprecated // These are informations the octree reader needs to know -struct ot_read_param_struct +struct ot_read_param_struct final { DBL RealErrorBound; }; +using OT_READ_PARAM = ot_read_param_struct; ///< @deprecated // These are informations the octree reader generates -struct ot_read_info_struct +struct ot_read_info_struct final { MathColour Gather_Total; long Gather_Total_Count; DBL Brightness; bool FirstRadiosityPass; }; +using OT_READ_INFO = ot_read_info_struct; ///< @deprecated /***************************************************************************** * Global functions @@ -174,5 +175,6 @@ void ot_parent (OT_ID *dad, OT_ID *kid); //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_OCTREE_H diff --git a/source/core/support/octree_fwd.h b/source/core/support/octree_fwd.h new file mode 100644 index 000000000..5020b9c14 --- /dev/null +++ b/source/core/support/octree_fwd.h @@ -0,0 +1,62 @@ +//****************************************************************************** +/// +/// @file core/support/octree_fwd.h +/// +/// Forward declarations related to the radiosity sample octree. +/// +/// @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_CORE_OCTREE_FWD_H +#define POVRAY_CORE_OCTREE_FWD_H + +// C++ standard header files +#include + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +using OctreePass = unsigned short; +constexpr auto kOctreePassInvalid = 0; +constexpr auto kOctreePassFirst = 1; +constexpr auto kOctreePassFinal = std::numeric_limits::max(); +constexpr auto kOctreePassReserved = kOctreePassFinal - 1; +constexpr auto kOctreePassMax = kOctreePassReserved - 1; + +using OctreeDepth = unsigned char; +constexpr auto kOctreeDepthMax = std::numeric_limits::max(); + +} +// end of namespace pov + +#endif // POVRAY_CORE_OCTREE_FWD_H diff --git a/source/core/support/simplevector.h b/source/core/support/simplevector.h index 39c0422b8..645d4b4e5 100644 --- a/source/core/support/simplevector.h +++ b/source/core/support/simplevector.h @@ -29,7 +29,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 @@ -60,10 +60,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +// C++ variants of C standard header files +#include + +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/pov_err.h" +// POV-Ray header files (core module) #include "core/coretypes.h" namespace pov @@ -86,8 +92,8 @@ namespace pov // This is intentional as we currently do not store any objects in it that // require this functionality. // TODO FIXME //////////////////////////////////////////////////////////////////////////// -template > -class SimpleVector +template> +class SimpleVector final { public: typedef SimpleVector MyType; @@ -406,7 +412,7 @@ class SimpleVector // require this functionality. //////////////////////////////////////////////////////////////////////////// template -class FixedSimpleVector +class FixedSimpleVector final { public: typedef FixedSimpleVector MyType; @@ -623,7 +629,7 @@ class FixedSimpleVector /// such cases gracefully. /// template -class VectorPool +class VectorPool final { public: @@ -670,7 +676,7 @@ class VectorPool private: - vector mPool; + std::vector mPool; size_t mSizeHint; }; @@ -684,7 +690,7 @@ class VectorPool /// require this functionality. /// template -class PooledSimpleVector +class PooledSimpleVector final { public: @@ -792,5 +798,6 @@ class PooledSimpleVector //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_SIMPLEVECTOR_H diff --git a/source/core/support/statisticids.cpp b/source/core/support/statisticids.cpp index 36ff391c4..439e00864 100644 --- a/source/core/support/statisticids.cpp +++ b/source/core/support/statisticids.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 @@ -37,6 +37,14 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/support/statisticids.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 (core module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -167,3 +175,4 @@ const INTERSECTION_STATS_INFO intersection_stats[kPOVList_Stat_Last] = }; } +// end of namespace pov diff --git a/source/core/support/statisticids.h b/source/core/support/statisticids.h index 01841f14f..f9e41a73c 100644 --- a/source/core/support/statisticids.h +++ b/source/core/support/statisticids.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 @@ -40,7 +40,13 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include "base/types.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 (core module) +// (none at the moment) namespace pov { @@ -332,13 +338,14 @@ typedef enum FPSTATS MaxFPStat } FPStatsIndex; -typedef struct intersection_stats_info +struct intersection_stats_info final { int povms_id; IntStatsIndex stat_test_id; IntStatsIndex stat_suc_id; const char *infotext; -} INTERSECTION_STATS_INFO; +}; +using INTERSECTION_STATS_INFO = intersection_stats_info; ///< @deprecated extern const INTERSECTION_STATS_INFO intersection_stats[]; @@ -347,5 +354,6 @@ extern const INTERSECTION_STATS_INFO intersection_stats[]; //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_STATISTICIDS_H diff --git a/source/core/support/statistics.cpp b/source/core/support/statistics.cpp index 9dfeaecd7..86bd0fe51 100644 --- a/source/core/support/statistics.cpp +++ b/source/core/support/statistics.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 @@ -36,10 +36,13 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "core/support/statistics.h" -#include -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) -#include "base/types.h" +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) // this must be the last file included #include "base/povdebug.h" @@ -104,3 +107,4 @@ template class StatisticsBase; template class StatisticsBase; } +// end of namespace pov diff --git a/source/core/support/statistics.h b/source/core/support/statistics.h index db6ff6b25..dd076f6f1 100644 --- a/source/core/support/statistics.h +++ b/source/core/support/statistics.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 @@ -39,8 +39,16 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" -#include +// C++ variants of C standard header files +#include +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/support/statisticids.h" namespace pov @@ -53,10 +61,8 @@ namespace pov /// /// @{ -using namespace pov_base; - template -class Counter +class Counter final { public: Counter() { value = 0; } // assumes for all types of T that 0 is a valid assignment @@ -76,14 +82,14 @@ class Counter }; template -class StatisticsBase +class StatisticsBase final { public: StatisticsBase() {} virtual ~StatisticsBase() {} - inline Counter& operator[](size_t idx) { return counters[idx]; } - inline Counter operator[](size_t idx) const { return counters[idx]; } + inline Counter& operator[](std::size_t idx) { return counters[idx]; } + inline Counter operator[](std::size_t idx) const { return counters[idx]; } void operator+=(const StatisticsBase& other); StatisticsBase operator+(const StatisticsBase& other); @@ -97,7 +103,7 @@ class StatisticsBase typedef StatisticsBase IntStatistics; typedef StatisticsBase FPStatistics; -class RenderStatistics +class RenderStatistics final { public: RenderStatistics() {} @@ -123,5 +129,6 @@ class RenderStatistics //############################################################################## } +// end of namespace pov #endif // POVRAY_CORE_STATISTICS_H diff --git a/source/frontend/animationprocessing.cpp b/source/frontend/animationprocessing.cpp index 4f341000c..b067cbd55 100644 --- a/source/frontend/animationprocessing.cpp +++ b/source/frontend/animationprocessing.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 @@ -36,8 +36,21 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/animationprocessing.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmsid.h" +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -49,20 +62,20 @@ AnimationProcessing::AnimationProcessing(POVMS_Object& options) : { bool cyclic = renderOptions.TryGetBool(kPOVAttrib_CyclicAnimation, false); - initialFrame = max(renderOptions.TryGetInt(kPOVAttrib_InitialFrame, 1), 0); + initialFrame = std::max(renderOptions.TryGetInt(kPOVAttrib_InitialFrame, 1), 0); initialClock = renderOptions.TryGetFloat(kPOVAttrib_InitialClock, 0.0); - finalFrame = max(renderOptions.TryGetInt(kPOVAttrib_FinalFrame, 1), initialFrame); + finalFrame = std::max(renderOptions.TryGetInt(kPOVAttrib_FinalFrame, 1), initialFrame); finalClock = renderOptions.TryGetFloat(kPOVAttrib_FinalClock, 1.0); - frameStep = max(renderOptions.TryGetInt(kPOVAttrib_FrameStep, 1), 1); + frameStep = std::max(renderOptions.TryGetInt(kPOVAttrib_FrameStep, 1), 1); if(cyclic == true) finalFrame++; if(renderOptions.Exist(kPOVAttrib_SubsetStartFrame) == true) { - POVMSFloat subsetStartPercent = max(renderOptions.GetFloat(kPOVAttrib_SubsetStartFrame), POVMSFloat(0.0)); + POVMSFloat subsetStartPercent = std::max(renderOptions.GetFloat(kPOVAttrib_SubsetStartFrame), POVMSFloat(0.0)); if((subsetStartPercent == 0.0) || (subsetStartPercent >= 1.0)) subsetStartFrame = POVMSInt(subsetStartPercent); else @@ -75,7 +88,7 @@ AnimationProcessing::AnimationProcessing(POVMS_Object& options) : if(options.Exist(kPOVAttrib_SubsetEndFrame) == true) { - POVMSFloat subsetEndPercent = max(renderOptions.GetFloat(kPOVAttrib_SubsetEndFrame), POVMSFloat(0.0)); + POVMSFloat subsetEndPercent = std::max(renderOptions.GetFloat(kPOVAttrib_SubsetEndFrame), POVMSFloat(0.0)); if((subsetEndPercent == 0.0) || (subsetEndPercent >= 1.0)) subsetEndFrame = POVMSInt(subsetEndPercent); else @@ -218,3 +231,4 @@ int AnimationProcessing::GetFrameNumberDigits() } } +// end of namespace pov_frontend diff --git a/source/frontend/animationprocessing.h b/source/frontend/animationprocessing.h index cc5dbd4d0..10022c431 100644 --- a/source/frontend/animationprocessing.h +++ b/source/frontend/animationprocessing.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 @@ -39,16 +39,25 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" -#include "base/types.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) +// (none at the moment) + namespace pov_frontend { using namespace pov_base; -class AnimationProcessing +class AnimationProcessing final { public: AnimationProcessing(POVMS_Object& options); @@ -100,5 +109,6 @@ class AnimationProcessing }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_ANIMATIONPROCESSING_H diff --git a/source/frontend/configfrontend.h b/source/frontend/configfrontend.h index adc5e3981..d4d2a0da7 100644 --- a/source/frontend/configfrontend.h +++ b/source/frontend/configfrontend.h @@ -10,7 +10,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,7 @@ #ifndef POVRAY_FRONTEND_CONFIGFRONTEND_H #define POVRAY_FRONTEND_CONFIGFRONTEND_H +// Pull in other compile-time config header files first #include "base/configbase.h" #include "syspovconfigfrontend.h" diff --git a/source/frontend/console.cpp b/source/frontend/console.cpp index 90456a683..b7c0cf356 100644 --- a/source/frontend/console.cpp +++ b/source/frontend/console.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 @@ -36,13 +36,22 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/console.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 (POVMS module) +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" namespace pov_frontend { -Console::Console(unsigned int wrapwidth) : TextStreamBuffer(1024*8, wrapwidth) +Console::Console(unsigned int wrapwidth) : pov_base::TextStreamBuffer(1024*8, wrapwidth) { // nothing to do } @@ -54,7 +63,8 @@ Console::~Console() void Console::lineoutput(const char *str, unsigned int chars) { - Output(string(str, chars)); + Output(std::string(str, chars)); } } +// end of namespace pov_frontend diff --git a/source/frontend/console.h b/source/frontend/console.h index 7eae4850b..a3039fe78 100644 --- a/source/frontend/console.h +++ b/source/frontend/console.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 @@ -38,28 +38,37 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +#include "frontend/console_fwd.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/textstreambuffer.h" +// POV-Ray header files (POVMS module) +// POV-Ray header files (frontend module) +// (none at the moment) + namespace pov_frontend { -using namespace pov_base; - -class Console : public TextStreamBuffer +class Console : public pov_base::TextStreamBuffer { public: Console(unsigned int wrapwidth = 80); - virtual ~Console(); + virtual ~Console() override; virtual void Initialise() = 0; - virtual void Output(const string&) = 0; + virtual void Output(const std::string&) = 0; private: - void lineoutput(const char *str, unsigned int chars); + virtual void lineoutput(const char *str, unsigned int chars) override; }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_CONSOLE_H diff --git a/source/frontend/console_fwd.h b/source/frontend/console_fwd.h new file mode 100644 index 000000000..0b55c30d4 --- /dev/null +++ b/source/frontend/console_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file frontend/console_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_FRONTEND_CONSOLE_FWD_H +#define POVRAY_FRONTEND_CONSOLE_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_frontend +{ + +class Console; + +} +// end of namespace pov_frontend + +#endif // POVRAY_FRONTEND_CONSOLE_FWD_H diff --git a/source/frontend/display.cpp b/source/frontend/display.cpp index 865baa293..9e1b18c97 100644 --- a/source/frontend/display.cpp +++ b/source/frontend/display.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,6 +36,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/display.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 (POVMS module) +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -105,3 +114,4 @@ void Display::Clear() } } +// end of namespace pov_frontend diff --git a/source/frontend/display.h b/source/frontend/display.h index 71c9a403b..84ec9acb8 100644 --- a/source/frontend/display.h +++ b/source/frontend/display.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 @@ -39,13 +39,25 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.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 (POVMS module) +// POV-Ray header files (frontend module) +// (none at the moment) + namespace pov_frontend { class Display { public: - struct RGBA8 { unsigned char red, green, blue, alpha; }; + struct RGBA8 final + { + unsigned char red, green, blue, alpha; + }; Display(unsigned int w, unsigned int h); virtual ~Display(); @@ -69,10 +81,10 @@ class Display /// display height unsigned int height; - /// not available - Display(); + Display() = delete; }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_DISPLAY_H diff --git a/source/frontend/filemessagehandler.cpp b/source/frontend/filemessagehandler.cpp index 0d6f5950a..974e2a7e5 100644 --- a/source/frontend/filemessagehandler.cpp +++ b/source/frontend/filemessagehandler.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 @@ -36,8 +36,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/filemessagehandler.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/fileinputoutput.h" +// POV-Ray header files (POVMS module) +// (none at the moment) + +// POV-Ray header files (frontend module) #include "frontend/renderfrontend.h" // this must be the last file included @@ -46,6 +55,10 @@ namespace pov_frontend { +using namespace pov_base; + +using std::list; + FileMessageHandler::FileMessageHandler() { } @@ -138,3 +151,4 @@ Path FileMessageHandler::FindFilePath(const list& lps, const Path& f) } } +// end of namespace pov_frontend diff --git a/source/frontend/filemessagehandler.h b/source/frontend/filemessagehandler.h index 528cf5793..08d26b0f3 100644 --- a/source/frontend/filemessagehandler.h +++ b/source/frontend/filemessagehandler.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 @@ -39,22 +39,24 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.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/path_fwd.h" + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" -namespace pov_base -{ -class Path; -} +// POV-Ray header files (frontend module) +#include "frontend/renderfrontend_fwd.h" namespace pov_frontend { -using namespace pov_base; - -struct SceneData; - class FileMessageHandler { public: @@ -63,13 +65,14 @@ class FileMessageHandler void HandleMessage(const SceneData&, POVMSType, POVMS_Object&, POVMS_Object&); protected: - virtual bool FindFile(const list&, POVMS_Object&, POVMS_Object&); - virtual bool ReadFile(const list&, POVMS_Object&, POVMS_Object&); + virtual bool FindFile(const std::list&, POVMS_Object&, POVMS_Object&); + virtual bool ReadFile(const std::list&, POVMS_Object&, POVMS_Object&); virtual void CreatedFile(POVMS_Object&); - Path FindFilePath(const list&, const Path&); + pov_base::Path FindFilePath(const std::list&, const pov_base::Path&); }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_FILEMESSAGEHANDLER_H diff --git a/source/frontend/imagemessagehandler.cpp b/source/frontend/imagemessagehandler.cpp index 084601d86..d99357fee 100644 --- a/source/frontend/imagemessagehandler.cpp +++ b/source/frontend/imagemessagehandler.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,12 +36,23 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/imagemessagehandler.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/fileinputoutput.h" +#include "base/types.h" #include "base/image/colourspace.h" #include "base/image/dither.h" #include "base/image/encoding.h" #include "base/image/image.h" +// POV-Ray header files (POVMS module) +// (none at the moment) + // POV-Ray header files (frontend module) #include "frontend/display.h" #include "frontend/renderfrontend.h" @@ -52,6 +63,8 @@ namespace pov_frontend { +using std::vector; + ImageMessageHandler::ImageMessageHandler() { } @@ -260,3 +273,4 @@ void ImageMessageHandler::DrawFilledRectangleSet(const SceneData& sd, const View } } +// end of namespace pov_frontend diff --git a/source/frontend/imagemessagehandler.h b/source/frontend/imagemessagehandler.h index a189ee067..16a68ad95 100644 --- a/source/frontend/imagemessagehandler.h +++ b/source/frontend/imagemessagehandler.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 @@ -39,16 +39,24 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) +#include "frontend/renderfrontend_fwd.h" + namespace pov_frontend { using namespace pov_base; -struct SceneData; -struct ViewData; - class ImageMessageHandler { public: @@ -65,5 +73,6 @@ class ImageMessageHandler }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_IMAGEMESSAGEHANDLER_H diff --git a/source/frontend/imageprocessing.cpp b/source/frontend/imageprocessing.cpp index 7ea34bde3..6979dafa2 100644 --- a/source/frontend/imageprocessing.cpp +++ b/source/frontend/imageprocessing.cpp @@ -36,16 +36,23 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/imageprocessing.h" -// Standard C++ header files -#include +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) // POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/path.h" +#include "base/image/colourspace.h" #include "base/image/dither.h" #include "base/image/image.h" // POV-Ray header files (POVMS module) #include "povms/povmsid.h" +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -56,6 +63,8 @@ namespace pov_frontend { +using std::shared_ptr; + enum { X = 0, @@ -65,7 +74,7 @@ enum ImageProcessing::ImageProcessing(unsigned int width, unsigned int height) { - image = shared_ptr(Image::Create(width, height, Image::RGBFT_Float)); + image = shared_ptr(Image::Create(width, height, ImageDataType::RGBFT_Float)); toStderr = toStdout = false; // TODO FIXME - find a better place for this @@ -79,7 +88,7 @@ ImageProcessing::ImageProcessing(POVMS_Object& ropts) unsigned int blockSize(ropts.TryGetInt(kPOVAttrib_RenderBlockSize, 32)); unsigned int maxBufferMem(ropts.TryGetInt(kPOVAttrib_MaxImageBufferMem, 128)); // number is megabytes - image = shared_ptr(Image::Create(width, height, Image::RGBFT_Float, maxBufferMem, blockSize * blockSize)); + image = shared_ptr(Image::Create(width, height, ImageDataType::RGBFT_Float, maxBufferMem, blockSize * blockSize)); toStdout = OutputIsStdout(ropts); toStderr = OutputIsStderr(ropts); @@ -104,12 +113,12 @@ UCS2String ImageProcessing::WriteImage(POVMS_Object& ropts, POVMSInt frame, int { if(ropts.TryGetBool(kPOVAttrib_OutputToFile, true) == true) { - Image::WriteOptions wopts; + ImageWriteOptions wopts; Image::ImageFileType imagetype = Image::SYS; unsigned int filetype = POV_File_Image_System; wopts.bitsPerChannel = clip(ropts.TryGetInt(kPOVAttrib_BitsPerColor, 8), 1, 16); - wopts.alphaMode = (ropts.TryGetBool(kPOVAttrib_OutputAlpha, false) ? Image::kAlphaMode_Default : Image::kAlphaMode_None ); + wopts.alphaMode = (ropts.TryGetBool(kPOVAttrib_OutputAlpha, false) ? ImageAlphaMode::Default : ImageAlphaMode::None ); wopts.compression = (ropts.Exist(kPOVAttrib_Compression) ? clip(ropts.GetInt(kPOVAttrib_Compression), 0, 255) : -1); wopts.grayscale = ropts.TryGetBool(kPOVAttrib_GrayscaleOutput, false); @@ -347,3 +356,4 @@ UCS2String ImageProcessing::GetOutputFilename(POVMS_Object& ropts, POVMSInt fram } } +// end of namespace pov_frontend diff --git a/source/frontend/imageprocessing.h b/source/frontend/imageprocessing.h index f47d70e19..29b5e13ad 100644 --- a/source/frontend/imageprocessing.h +++ b/source/frontend/imageprocessing.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 @@ -39,14 +39,21 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" -#include "base/stringutilities.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/stringtypes.h" +#include "base/image/image_fwd.h" + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" -namespace pov_base -{ -class Image; -} +// POV-Ray header files (frontend module) +// (none at the moment) namespace pov_frontend { @@ -58,12 +65,12 @@ class ImageProcessing public: ImageProcessing(unsigned int width, unsigned int height); ImageProcessing(POVMS_Object& ropts); - ImageProcessing(shared_ptr& img); + ImageProcessing(std::shared_ptr& img); virtual ~ImageProcessing(); UCS2String WriteImage(POVMS_Object& ropts, POVMSInt frame = 0, int digits = 0); - shared_ptr& GetImage(); + std::shared_ptr& GetImage(); UCS2String GetOutputFilename(POVMS_Object& ropts, POVMSInt frame, int digits); bool OutputIsStdout(void) { return toStdout; } @@ -72,16 +79,18 @@ class ImageProcessing virtual bool OutputIsStderr(POVMS_Object& ropts); protected: - shared_ptr image; + std::shared_ptr image; bool toStdout; bool toStderr; private: - ImageProcessing(); - ImageProcessing(const ImageProcessing&); - ImageProcessing& operator=(const ImageProcessing&); + + ImageProcessing() = delete; + ImageProcessing(const ImageProcessing&) = delete; + ImageProcessing& operator=(const ImageProcessing&) = delete; }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_IMAGEPROCESSING_H diff --git a/source/frontend/parsermessagehandler.cpp b/source/frontend/parsermessagehandler.cpp index 5af2bd611..5cdcdf304 100644 --- a/source/frontend/parsermessagehandler.cpp +++ b/source/frontend/parsermessagehandler.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,6 +36,17 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/parsermessagehandler.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// POV-Ray header files (base module) +// POV-Ray header files (POVMS module) +// (none at the moment) + +// POV-Ray header files (frontend module) #include "frontend/renderfrontend.h" // this must be the last file included @@ -196,9 +207,10 @@ void ParserMessageHandler::DebugInfo(Console *console, POVMS_Object& obj, bool c if(conout == true) { // TODO FIXME HACK - string str(obj.GetString(kPOVAttrib_EnglishText)); + std::string str(obj.GetString(kPOVAttrib_EnglishText)); console->Output(str); } } } +// end of namespace pov_frontend diff --git a/source/frontend/parsermessagehandler.h b/source/frontend/parsermessagehandler.h index 6606ee6ce..721c949c0 100644 --- a/source/frontend/parsermessagehandler.h +++ b/source/frontend/parsermessagehandler.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 @@ -39,14 +39,20 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) +#include "frontend/console_fwd.h" +#include "frontend/renderfrontend_fwd.h" + namespace pov_frontend { -class Console; -struct SceneData; - class ParserMessageHandler { public: @@ -65,5 +71,6 @@ class ParserMessageHandler }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_PARSERMESSAGEHANDLER_H diff --git a/source/frontend/precomp.h b/source/frontend/precomp.h index c593b2096..70db91f1e 100644 --- a/source/frontend/precomp.h +++ b/source/frontend/precomp.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 @@ -45,8 +45,9 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -#include "base/configbase.h" +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED +// C++ variants of C standard header files #include #include #include @@ -56,6 +57,7 @@ #include #include +// C++ standard header files #include #include #include @@ -68,13 +70,11 @@ #include #include +// Boost header files #include #include #include #include -#include -#include -#include #if POV_MULTITHREADED #include #include diff --git a/source/frontend/processoptions.cpp b/source/frontend/processoptions.cpp index 807a354d5..2c0bcdb3e 100644 --- a/source/frontend/processoptions.cpp +++ b/source/frontend/processoptions.cpp @@ -36,12 +36,29 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/processoptions.h" +// C++ variants of C standard header files +#include #include +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/platformbase.h" +#include "base/povassert.h" +#include "base/stringutilities.h" +#include "base/textstream.h" + +// POV-Ray header files (core module) +// (none at the moment) +// POV-Ray header files (POVMS module) #include "povms/povmsid.h" +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -1498,3 +1515,4 @@ int ProcessOptions::Process_Switch(Cmd_Parser_Table *option, char *param, POVMSO } } +// end of namespace pov_frontend diff --git a/source/frontend/processoptions.h b/source/frontend/processoptions.h index c131c49b4..4bdb57ed2 100644 --- a/source/frontend/processoptions.h +++ b/source/frontend/processoptions.h @@ -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,16 +34,29 @@ /// //****************************************************************************** -#ifndef PROCESSOPTIONS_H -#define PROCESSOPTIONS_H +#ifndef POVRAY_FRONTEND_PROCESSOPTIONS_H +#define POVRAY_FRONTEND_PROCESSOPTIONS_H // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" -#include "base/textstream.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/textstream_fwd.h" + +// POV-Ray header files (core module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) +// (none at the moment) + namespace pov_frontend { @@ -60,7 +73,7 @@ enum { class ProcessOptions { public: - struct INI_Parser_Table + struct INI_Parser_Table final { const char *keyword; POVMSType key; @@ -68,7 +81,7 @@ class ProcessOptions int flags; }; - struct Cmd_Parser_Table + struct Cmd_Parser_Table final { const char *command; POVMSType key; @@ -78,7 +91,7 @@ class ProcessOptions }; ProcessOptions(INI_Parser_Table *, Cmd_Parser_Table *); - ~ProcessOptions(); + virtual ~ProcessOptions(); int ParseFile(const char *, POVMSObjectPtr); int ParseString(const char *, POVMSObjectPtr, bool singleswitch = false); @@ -141,5 +154,6 @@ class ProcessOptions }; } +// end of namespace pov_frontend -#endif +#endif // POVRAY_FRONTEND_PROCESSOPTIONS_H diff --git a/source/frontend/processrenderoptions.cpp b/source/frontend/processrenderoptions.cpp index f3b264b20..818633d54 100644 --- a/source/frontend/processrenderoptions.cpp +++ b/source/frontend/processrenderoptions.cpp @@ -39,16 +39,28 @@ // C++ variants of C standard header files #include +// C++ standard header files +// (none at the moment) + // POV-Ray header files (base module) #include "base/fileutil.h" #include "base/platformbase.h" +#include "base/stringutilities.h" #include "base/image/colourspace.h" #include "base/image/dither.h" #include "base/image/encoding.h" +// POV-Ray header files (core module) +#include "base/fileinputoutput.h" +#include "base/path.h" +#include "base/textstream.h" + // POV-Ray header files (POVMS module) #include "povms/povmsid.h" +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -1221,3 +1233,4 @@ const char* ProcessRenderOptions::GetParameterCodeText(const ProcessRenderOption } } +// end of namespace pov_frontend diff --git a/source/frontend/processrenderoptions.h b/source/frontend/processrenderoptions.h index 4c2d7995b..9c92aee08 100644 --- a/source/frontend/processrenderoptions.h +++ b/source/frontend/processrenderoptions.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 @@ -39,8 +39,18 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.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 (core module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) #include "frontend/processoptions.h" namespace pov_frontend @@ -52,15 +62,15 @@ class ProcessRenderOptions : public ProcessOptions { public: ProcessRenderOptions(); - ~ProcessRenderOptions(); + virtual ~ProcessRenderOptions() override; protected: - virtual int ReadSpecialOptionHandler(INI_Parser_Table *, char *, POVMSObjectPtr); - virtual int ReadSpecialSwitchHandler(Cmd_Parser_Table *, char *, POVMSObjectPtr, bool); - virtual int WriteSpecialOptionHandler(INI_Parser_Table *, POVMSObjectPtr, OTextStream *); - virtual int ProcessUnknownString(char *, POVMSObjectPtr); + virtual int ReadSpecialOptionHandler(INI_Parser_Table *, char *, POVMSObjectPtr) override; + virtual int ReadSpecialSwitchHandler(Cmd_Parser_Table *, char *, POVMSObjectPtr, bool) override; + virtual int WriteSpecialOptionHandler(INI_Parser_Table *, POVMSObjectPtr, OTextStream *) override; + virtual int ProcessUnknownString(char *, POVMSObjectPtr) override; - virtual ITextStream *OpenFileForRead(const char *, POVMSObjectPtr); - virtual OTextStream *OpenFileForWrite(const char *, POVMSObjectPtr); + virtual ITextStream *OpenFileForRead(const char *, POVMSObjectPtr) override; + virtual OTextStream *OpenFileForWrite(const char *, POVMSObjectPtr) override; ITextStream *OpenINIFileStream(const char *, unsigned int, POVMSObjectPtr); public: @@ -94,5 +104,6 @@ class ProcessRenderOptions : public ProcessOptions }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_PROCESSRENDEROPTIONS_H diff --git a/source/frontend/renderfrontend.cpp b/source/frontend/renderfrontend.cpp index a3a5f4319..f0cb9c2d2 100644 --- a/source/frontend/renderfrontend.cpp +++ b/source/frontend/renderfrontend.cpp @@ -36,13 +36,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/renderfrontend.h" -// Standard C++ header files -#include +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include // POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/platformbase.h" #include "base/textstream.h" #include "base/textstreambuffer.h" +#include "base/types.h" +#include "base/image/colourspace.h" #include "base/image/dither.h" #include "base/image/encoding.h" @@ -60,6 +66,9 @@ namespace pov_frontend { +using std::min; +using std::max; + const int gStreamTypeUtilDataCount = 6; static const POVMSType gStreamTypeUtilData[gStreamTypeUtilDataCount] = @@ -101,14 +110,15 @@ void FileMessage(TextStreamBuffer *tsb, int stream, POVMSObjectPtr msg); const char *GetOptionSwitchString(POVMSObjectPtr msg, POVMSType key, bool defaultstate); } +// end of namespace Message2Console -class FileTextStreamBuffer : public TextStreamBuffer +class FileTextStreamBuffer final : public TextStreamBuffer { public: FileTextStreamBuffer(const UCS2 *filename, bool append) : stream(filename, POV_File_Text_Stream, append) { } - virtual ~FileTextStreamBuffer() { flush(); stream.flush(); } + virtual ~FileTextStreamBuffer() override { flush(); stream.flush(); } protected: - virtual void lineoutput(const char *str, unsigned int chars) { stream.printf("%s\n", string(str, chars).c_str()); stream.flush(); } + virtual void lineoutput(const char *str, unsigned int chars) override { stream.printf("%s\n", std::string(str, chars).c_str()); stream.flush(); } private: OTextStream stream; }; @@ -153,7 +163,7 @@ RenderFrontendBase::~RenderFrontendBase() // nothing to do } -void RenderFrontendBase::ConnectToBackend(POVMSAddress backendaddress, POVMS_Object& obj, POVMS_Object *resultobj, shared_ptr& console) +void RenderFrontendBase::ConnectToBackend(POVMSAddress backendaddress, POVMS_Object& obj, POVMS_Object *resultobj, std::shared_ptr& console) { POVMS_Message msg(obj, kPOVMsgClass_BackendControl, kPOVMsgIdent_InitInfo); POVMS_Message result(kPOVObjectClass_ResultData); @@ -610,7 +620,7 @@ void RenderFrontendBase::NewBackup(POVMS_Object& ropts, ViewData& vd, const Path MakeBackupPath(ropts, vd, outputpath); if (!pov_base::PlatformBase::GetInstance().AllowLocalFileAccess (vd.imageBackupFile(), POV_File_Data_Backup, true)) throw POV_EXCEPTION(kCannotOpenFileErr, "Permission denied to create render state output file."); - vd.imageBackup = shared_ptr(new OStream(vd.imageBackupFile().c_str())); + vd.imageBackup = std::shared_ptr(new OStream(vd.imageBackupFile().c_str())); if(vd.imageBackup != nullptr) { Backup_File_Header hdr; @@ -631,14 +641,14 @@ void RenderFrontendBase::NewBackup(POVMS_Object& ropts, ViewData& vd, const Path // we do this test even if the file doesn't exist as we need to write there // eventually anyhow. might as well test if before the render starts ... if(CheckIfFileExists(filename.c_str())) - PlatformBase::GetInstance().DeleteLocalFile (filename.c_str()); + pov_base::Filesystem::DeleteFile(filename); } } else throw POV_EXCEPTION(kCannotOpenFileErr, "Cannot create render state output file."); } -void RenderFrontendBase::ContinueBackup(POVMS_Object& ropts, ViewData& vd, ViewId vid, POVMSInt& serial, vector& skip, const Path& outputpath) +void RenderFrontendBase::ContinueBackup(POVMS_Object& ropts, ViewData& vd, ViewId vid, POVMSInt& serial, std::vector& skip, const Path& outputpath) { bool outputToFile = ropts.TryGetBool(kPOVAttrib_OutputToFile, true); @@ -725,7 +735,7 @@ void RenderFrontendBase::ContinueBackup(POVMS_Object& ropts, ViewData& vd, ViewI // if there isn't going to be an output file, we don't write to the state file if(outputToFile == true) { - vd.imageBackup = shared_ptr(new OStream(vd.imageBackupFile().c_str(), IOBase::append)); + vd.imageBackup = std::shared_ptr(new OStream(vd.imageBackupFile().c_str(), IOBase::append)); if(vd.imageBackup != nullptr) { if(!*vd.imageBackup) @@ -1935,14 +1945,14 @@ void DebugInfo(POVMS_Object& cppmsg, TextStreamBuffer *tsb) tsb->printf("%s\n", str.c_str()); } -string GetProgressTime(POVMS_Object& obj, POVMSType key) +std::string GetProgressTime(POVMS_Object& obj, POVMSType key) { int sec = int(obj.TryGetLong(kPOVAttrib_RealTime, 0) / (POV_LONG)(1000)); char buffer[32]; sprintf(buffer, "%3d:%02d:%02d", int(sec / 3600), int((sec / 60) % 60), int(sec % 60)); - return string(buffer); + return std::string(buffer); } void RenderDone(TextStreamBuffer *tsb, POVMSObjectPtr msg) @@ -2060,5 +2070,7 @@ void Progress(TextStreamBuffer *tsb, POVMSObjectPtr msg) } } +// end of namespace Message2Console } +// end of namespace pov_frontend diff --git a/source/frontend/renderfrontend.h b/source/frontend/renderfrontend.h index 63ac87518..efcabd6cb 100644 --- a/source/frontend/renderfrontend.h +++ b/source/frontend/renderfrontend.h @@ -38,26 +38,38 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +#include "frontend/renderfrontend_fwd.h" -#include +// C++ variants of C standard header files +// (none at the moment) -#include "povms/povmscpp.h" -#include "povms/povmsid.h" +// C++ standard header files +#include +#include +#include +#include +#include +#include +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/filesystem.h" #include "base/path.h" #include "base/platformbase.h" +#include "base/stringutilities.h" +#include "base/textstreambuffer_fwd.h" +#include "base/types.h" +#include "base/image/colourspace.h" #include "base/image/image.h" +// POV-Ray header files (POVMS module) +#include "povms/povmscpp.h" +#include "povms/povmsid.h" + +// POV-Ray header files (frontend module) #include "frontend/console.h" #include "frontend/imageprocessing.h" -namespace pov_base -{ -class TextStreamBuffer; -class Image; -class OStream; -} - namespace pov_frontend { @@ -78,7 +90,7 @@ enum MAX_STREAMS }; -struct SceneData +struct SceneData final { enum SceneState { @@ -96,24 +108,24 @@ struct SceneData SceneState state; - mutable shared_ptr console; + mutable std::shared_ptr console; - mutable list readfiles; - mutable list createdfiles; + mutable std::list readfiles; + mutable std::list createdfiles; Path scenepath; Path outputpath; - list searchpaths; + std::list searchpaths; - shared_ptr streams[MAX_STREAMS]; + std::shared_ptr streams[MAX_STREAMS]; UCS2String streamnames[MAX_STREAMS]; bool consoleoutput[MAX_STREAMS]; bool verbose; - struct + struct final { int legacyGammaMode; // TODO FIXME - conversion from working gamma to linear should be moved to back-end @@ -122,7 +134,7 @@ struct SceneData } backwardCompatibilityData; }; -struct ViewData +struct ViewData final { enum ViewState { @@ -139,9 +151,9 @@ struct ViewData ViewState state; - mutable shared_ptr image; - mutable shared_ptr display; - mutable shared_ptr imageBackup; + mutable std::shared_ptr image; + mutable std::shared_ptr display; + mutable std::shared_ptr imageBackup; GammaCurvePtr displayGamma; bool greyscaleDisplay; @@ -168,23 +180,24 @@ void RenderTime(POVMS_Object& cppmsg, TextStreamBuffer *tsb); void DebugInfo(POVMS_Object& cppmsg, TextStreamBuffer *tsb); -string GetProgressTime(POVMS_Object& obj, POVMSType key); +std::string GetProgressTime(POVMS_Object& obj, POVMSType key); } +// end of namespace Message2Console #define RENDER_STATE_SIG "POV-Ray Render State File\0\0" #define RENDER_STATE_VER "0001" -typedef struct +struct Backup_File_Header final { unsigned char sig[28]; unsigned char ver[4]; unsigned char reserved[480]; -} Backup_File_Header; +}; class RenderFrontendBase : public POVMS_MessageReceiver { - class Id + class Id final { public: Id() : address(POVMSInvalidAddress), identifier(0) { } @@ -212,12 +225,12 @@ class RenderFrontendBase : public POVMS_MessageReceiver RenderFrontendBase(POVMSContext); virtual ~RenderFrontendBase(); - void ConnectToBackend(POVMSAddress, POVMS_Object&, POVMS_Object *, shared_ptr&); + void ConnectToBackend(POVMSAddress, POVMS_Object&, POVMS_Object *, std::shared_ptr&); void DisconnectFromBackend(POVMSAddress); - virtual shared_ptr GetConsole(SceneId) = 0; - virtual shared_ptr GetImage(ViewId) = 0; - virtual shared_ptr GetDisplay(ViewId) = 0; + virtual std::shared_ptr GetConsole(SceneId) = 0; + virtual std::shared_ptr GetImage(ViewId) = 0; + virtual std::shared_ptr GetDisplay(ViewId) = 0; protected: typedef std::set BackendAddressSet; @@ -248,17 +261,19 @@ class RenderFrontendBase : public POVMS_MessageReceiver virtual void HandleRenderMessage(ViewId, POVMSType, POVMS_Object&) = 0; virtual void HandleImageMessage(ViewId, POVMSType, POVMS_Object&) = 0; - virtual void OutputFatalError(const string&, int) = 0; + virtual void OutputFatalError(const std::string&, int) = 0; void MakeBackupPath(POVMS_Object& ropts, ViewData& vd, const Path& outputpath); void NewBackup(POVMS_Object& ropts, ViewData& vd, const Path& outputpath); - void ContinueBackup(POVMS_Object& ropts, ViewData& vd, ViewId vid, POVMSInt& serial, vector& skip, const Path& outputpath); + void ContinueBackup(POVMS_Object& ropts, ViewData& vd, ViewId vid, POVMSInt& serial, std::vector& skip, const Path& outputpath); }; +// TODO - Do we really need this to be a template? + template class RenderFrontend : public RenderFrontendBase { - struct SceneHandler + struct SceneHandler final { SceneData data; @@ -266,7 +281,7 @@ class RenderFrontend : public RenderFrontendBase FILE_MH file; }; - struct ViewHandler + struct ViewHandler final { ViewData data; @@ -275,7 +290,7 @@ class RenderFrontend : public RenderFrontendBase }; public: RenderFrontend(POVMSContext ctx); - ~RenderFrontend(); + virtual ~RenderFrontend() override; SceneId CreateScene(POVMSAddress backendaddress, POVMS_Object& obj, boost::function fn); void CloseScene(SceneId sid); @@ -287,7 +302,7 @@ class RenderFrontend : public RenderFrontendBase void ResumeParser(SceneId sid); void StopParser(SceneId sid); - ViewId CreateView(SceneId sid, POVMS_Object& obj, shared_ptr& imageProcessing, boost::function fn); + ViewId CreateView(SceneId sid, POVMS_Object& obj, std::shared_ptr& imageProcessing, boost::function fn); void CloseView(ViewId vid); ViewData::ViewState GetViewState(ViewId vid); @@ -297,15 +312,15 @@ class RenderFrontend : public RenderFrontendBase void ResumeRender(ViewId vid); void StopRender(ViewId vid); - virtual shared_ptr GetConsole(SceneId sid); - virtual shared_ptr GetImage(ViewId vid); - virtual shared_ptr GetDisplay(ViewId vid); + virtual std::shared_ptr GetConsole(SceneId sid) override; + virtual std::shared_ptr GetImage(ViewId vid) override; + virtual std::shared_ptr GetDisplay(ViewId vid) override; protected: - virtual void HandleParserMessage(SceneId sid, POVMSType ident, POVMS_Object& msg); - virtual void HandleFileMessage(SceneId sid, POVMSType ident, POVMS_Object& msg, POVMS_Object& result); - virtual void HandleRenderMessage(ViewId vid, POVMSType ident, POVMS_Object& msg); - virtual void HandleImageMessage(ViewId vid, POVMSType ident, POVMS_Object& msg); - virtual void OutputFatalError(const string& msg, int err); + virtual void HandleParserMessage(SceneId sid, POVMSType ident, POVMS_Object& msg) override; + virtual void HandleFileMessage(SceneId sid, POVMSType ident, POVMS_Object& msg, POVMS_Object& result) override; + virtual void HandleRenderMessage(ViewId vid, POVMSType ident, POVMS_Object& msg) override; + virtual void HandleImageMessage(ViewId vid, POVMSType ident, POVMS_Object& msg) override; + virtual void OutputFatalError(const std::string& msg, int err) override; private: typedef std::set ViewIdSet; @@ -346,7 +361,7 @@ RenderFrontendBase::SceneId RenderFrontend(fn()); + sh.data.console = std::shared_ptr(fn()); scenehandler[sid] = sh; scene2views[sid] = ViewIdSet(); @@ -436,7 +451,7 @@ void RenderFrontend::StopParser(SceneId } template -RenderFrontendBase::ViewId RenderFrontend::CreateView(SceneId sid, POVMS_Object& obj, shared_ptr& imageProcessing, boost::function fn) +RenderFrontendBase::ViewId RenderFrontend::CreateView(SceneId sid, POVMS_Object& obj, std::shared_ptr& imageProcessing, boost::function fn) { typename SceneHandlerMap::iterator shi(scenehandler.find(sid)); @@ -535,7 +550,7 @@ RenderFrontendBase::ViewId RenderFrontend img(imageProcessing->GetImage()); + std::shared_ptr img(imageProcessing->GetImage()); if (img != nullptr) { if((img->GetWidth() != width) || (img->GetHeight() != height)) @@ -544,11 +559,11 @@ RenderFrontendBase::ViewId RenderFrontend(Image::Create(width, height, Image::RGBFT_Float)); + vh.data.image = std::shared_ptr(Image::Create(width, height, ImageDataType::RGBFT_Float)); } if(obj.TryGetBool(kPOVAttrib_Display, true) == true) - vh.data.display = shared_ptr(fn(width, height)); + vh.data.display = std::shared_ptr(fn(width, height)); viewhandler[vid] = vh; view2scene[vid] = sid; @@ -639,7 +654,7 @@ void RenderFrontend::StartRender(ViewId try { POVMSInt serial; - vector skip; + std::vector skip; ContinueBackup(obj, vhi->second.data, vid, serial, skip, outputpath); @@ -722,33 +737,33 @@ void RenderFrontend::StopRender(ViewId } template -shared_ptr RenderFrontend::GetConsole(SceneId sid) +std::shared_ptr RenderFrontend::GetConsole(SceneId sid) { typename SceneHandlerMap::iterator shi(scenehandler.find(sid)); if(shi != scenehandler.end()) return shi->second.data.console; else - return shared_ptr(); + return std::shared_ptr(); } template -shared_ptr RenderFrontend::GetImage(ViewId vid) +std::shared_ptr RenderFrontend::GetImage(ViewId vid) { typename ViewHandlerMap::iterator vhi(viewhandler.find(vid)); if(vhi != viewhandler.end()) return vhi->second.data.image; else - return shared_ptr(); + return std::shared_ptr(); } template -shared_ptr RenderFrontend::GetDisplay(ViewId vid) +std::shared_ptr RenderFrontend::GetDisplay(ViewId vid) { typename ViewHandlerMap::iterator vhi(viewhandler.find(vid)); if(vhi != viewhandler.end()) return vhi->second.data.display; else - return shared_ptr(); + return std::shared_ptr(); } template @@ -764,7 +779,7 @@ void RenderFrontend::HandleParserMessag } else if(ident == kPOVMsgIdent_Failed) { - string str("Fatal error in parser: "); + std::string str("Fatal error in parser: "); str += msg.TryGetString(kPOVAttrib_EnglishText, "Unknown failure!"); shi->second.data.console->Output(str); shi->second.data.state = SceneData::Scene_Failed; @@ -798,12 +813,12 @@ void RenderFrontend::HandleRenderMessag if (vhi->second.data.imageBackup != nullptr) { vhi->second.data.imageBackup.reset(); - PlatformBase::GetInstance().DeleteLocalFile (vhi->second.data.imageBackupFile().c_str()); + pov_base::Filesystem::DeleteFile(vhi->second.data.imageBackupFile()); } } else if(ident == kPOVMsgIdent_Failed) { - string str("Fatal error in renderer: "); + std::string str("Fatal error in renderer: "); str += msg.TryGetString(kPOVAttrib_EnglishText, "Unknown failure!"); sceneData.console->Output(str); vhi->second.data.state = ViewData::View_Failed; @@ -826,7 +841,7 @@ void RenderFrontend::HandleImageMessage } template -void RenderFrontend::OutputFatalError(const string& msg, int err) +void RenderFrontend::OutputFatalError(const std::string& msg, int err) { // TODO FIXME CONSOLE::OutputFatalError(msg, err); } @@ -856,7 +871,9 @@ namespace Message2TSB void FileMessage(TextStreamBuffer *, int stream, POVMSObjectPtr); const char *GetOptionSwitchString(POVMSObjectPtr, POVMSType, bool defaultstate = false); } +// end of namespace Message2TSB } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_RENDERFRONTEND_H diff --git a/source/frontend/renderfrontend_fwd.h b/source/frontend/renderfrontend_fwd.h new file mode 100644 index 000000000..f0df590d9 --- /dev/null +++ b/source/frontend/renderfrontend_fwd.h @@ -0,0 +1,52 @@ +//****************************************************************************** +/// +/// @file frontend/renderfrontend_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_FRONTEND_RENDERFRONTEND_FWD_H +#define POVRAY_FRONTEND_RENDERFRONTEND_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_frontend +{ + +struct SceneData; +struct ViewData; + +} +// end of namespace pov_frontend + +#endif // POVRAY_FRONTEND_RENDERFRONTEND_FWD_H diff --git a/source/frontend/rendermessagehandler.cpp b/source/frontend/rendermessagehandler.cpp index 8e2a0e5b3..3437853b2 100644 --- a/source/frontend/rendermessagehandler.cpp +++ b/source/frontend/rendermessagehandler.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,6 +36,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/rendermessagehandler.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 (POVMS module) +// (none at the moment) + +// POV-Ray header files (frontend module) #include "frontend/renderfrontend.h" // this must be the last file included @@ -192,3 +201,4 @@ void RenderMessageHandler::FatalError(Console *console, POVMS_Object& obj, bool } } +// end of namespace pov_frontend diff --git a/source/frontend/rendermessagehandler.h b/source/frontend/rendermessagehandler.h index 72769c08c..8514a57c0 100644 --- a/source/frontend/rendermessagehandler.h +++ b/source/frontend/rendermessagehandler.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 @@ -39,15 +39,23 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) +#include "frontend/console_fwd.h" +#include "frontend/renderfrontend_fwd.h" + namespace pov_frontend { -class Console; -struct SceneData; -struct ViewData; - class RenderMessageHandler { public: @@ -65,5 +73,6 @@ class RenderMessageHandler }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_RENDERMESSAGEHANDLER_H diff --git a/source/frontend/shelloutprocessing.cpp b/source/frontend/shelloutprocessing.cpp index 7fbb84d83..5e11f9076 100644 --- a/source/frontend/shelloutprocessing.cpp +++ b/source/frontend/shelloutprocessing.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,10 +36,23 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "frontend/shelloutprocessing.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// Boost header files +#include #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmsid.h" +// POV-Ray header files (frontend module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -85,7 +98,7 @@ ShelloutAction::ShelloutAction(const ShelloutProcessing *sp, unsigned int attrib // expand the parameters in the rawParameters member into the parameters member, applying the escapes // documented below. scene is the scene name, ofn the output file name, w/h the width/height, clock the // current animation clock value, and frame the current frame number. -void ShelloutAction::ExpandParameters(const string& scene, const string& ofn, unsigned int w, unsigned int h, float clock, unsigned int frame) +void ShelloutAction::ExpandParameters(const std::string& scene, const std::string& ofn, unsigned int w, unsigned int h, float clock, unsigned int frame) { // %o: output file name in full // %s: scene name without path or extension @@ -143,7 +156,7 @@ void ShelloutAction::ExpandParameters(const string& scene, const string& ofn, un // ------------------------------------------------------------------ -ShelloutProcessing::ShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height): sceneName(scene), imageWidth(width), imageHeight(height) +ShelloutProcessing::ShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height): sceneName(scene), imageWidth(width), imageHeight(height) { skipReturn = cancelReturn = exitCode = 0; clockVal = 0.0; @@ -185,7 +198,7 @@ ShelloutProcessing::~ShelloutProcessing() // parameters start will not be removed. // // this method should return true if the command is non-empty upon completion. -bool ShelloutProcessing::ExtractCommand(const string& src, string& command, string& parameters) const +bool ShelloutProcessing::ExtractCommand(const std::string& src, std::string& command, std::string& parameters) const { bool inSQ = false; bool inDQ = false; @@ -194,7 +207,7 @@ bool ShelloutProcessing::ExtractCommand(const string& src, string& command, stri command.clear(); parameters.clear(); - string str = boost::trim_copy(src); + std::string str = boost::trim_copy(src); for (s = str.c_str(); *s != '\0'; s++) { if (hadEscape) @@ -234,11 +247,11 @@ bool ShelloutProcessing::ExtractCommand(const string& src, string& command, stri } } - parameters = boost::trim_copy(string(s)); + parameters = boost::trim_copy(std::string(s)); return true; } -string ShelloutProcessing::GetPhaseName(shelloutEvent event) +std::string ShelloutProcessing::GetPhaseName(shelloutEvent event) { switch (event) { @@ -274,7 +287,7 @@ bool ShelloutProcessing::HandleProcessEvent(shelloutEvent event, bool internalCa event = preScene; bool skipWasSet(skipCallouts); - string phaseName(GetPhaseName(event)); + std::string phaseName(GetPhaseName(event)); ShelloutPtr sh(shellouts[event]); switch (event) @@ -366,9 +379,9 @@ bool ShelloutProcessing::HandleProcessEvent(shelloutEvent event, bool internalCa bool ShelloutProcessing::PostProcessEvent(void) { int ret; - string output; + std::string output; shelloutEvent event = postProcessEvent; - string phaseName(GetPhaseName(event)); + std::string phaseName(GetPhaseName(event)); processStartRequested = false; runningProcessName.clear(); @@ -581,7 +594,7 @@ bool ShelloutProcessing::ShelloutRunning(void) // 7: the command parameters (CAUTION: may contain escape codes) // 8: the command return code (as an integer) // 9: output text from the command, as returned by LastShelloutResult() -string ShelloutProcessing::GetCancelMessage(void) +std::string ShelloutProcessing::GetCancelMessage(void) { return str( cancelFormat % cancelPhase @@ -603,7 +616,7 @@ string ShelloutProcessing::GetCancelMessage(void) // 4: the command parameters (CAUTION: may contain escape codes) // 5: the command return code (as an integer) // 6: output text from the command, as returned by LastShelloutResult() -string ShelloutProcessing::GetSkipMessage(void) +std::string ShelloutProcessing::GetSkipMessage(void) { return str( skipFormat % skipPhase @@ -642,9 +655,10 @@ bool ShelloutProcessing::KillShellouts(int timeout, bool force) // if the platform implemeting a subclass of this method has the equivalent of a // system log (e.g. syslog on unix, event log on windows), the implementation should // consider providing a user-controllable option to log any commands using such. -bool ShelloutProcessing::ExecuteCommand(const string& cmd, const string& params) +bool ShelloutProcessing::ExecuteCommand(const std::string& cmd, const std::string& params) { throw POV_EXCEPTION(kCannotOpenFileErr, "Shellouts not implemented on this platform"); } } +// end of namespace pov_frontend diff --git a/source/frontend/shelloutprocessing.h b/source/frontend/shelloutprocessing.h index f2420f308..0096ad57f 100644 --- a/source/frontend/shelloutprocessing.h +++ b/source/frontend/shelloutprocessing.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 @@ -39,16 +39,31 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include +#include + +// Boost header files #include +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (POVMS module) #include "povms/povmscpp.h" +// POV-Ray header files (frontend module) +// (none at the moment) + namespace pov_frontend { class ShelloutProcessing; -class ShelloutAction +class ShelloutAction final { public: typedef enum @@ -66,23 +81,23 @@ class ShelloutAction Action ReturnAction(void) const { return returnAction; } bool IsSet(void) const { return isSet; } - const string& RawCommand(void) const { return rawCommand; } - const string& Command(void) const { return command; } - const string& RawParameters(void) const { return rawParameters; } - const string& Parameters(void) const { return parameters; } + const std::string& RawCommand(void) const { return rawCommand; } + const std::string& Command(void) const { return command; } + const std::string& RawParameters(void) const { return rawParameters; } + const std::string& Parameters(void) const { return parameters; } bool ReturnNegate(void) const { return returnNegate; } - void ExpandParameters(const string& scene, const string& ofn, unsigned int w, unsigned int h, float clock, unsigned int frame); + void ExpandParameters(const std::string& scene, const std::string& ofn, unsigned int w, unsigned int h, float clock, unsigned int frame); private: bool isSet; bool returnNegate; - string command; - string rawCommand; - string parameters; - string rawParameters; + std::string command; + std::string rawCommand; + std::string parameters; + std::string rawParameters; Action returnAction; - ShelloutAction(); + ShelloutAction() = delete; }; class ShelloutProcessing @@ -90,7 +105,7 @@ class ShelloutProcessing friend class ShelloutAction; public: - typedef shared_ptr ShelloutPtr; + typedef std::shared_ptr ShelloutPtr; typedef enum { @@ -105,7 +120,7 @@ class ShelloutProcessing // we use strings rather than UCS2Strings for the scene name and parameters since the passed // parameters (via POVMS) are also strings. - ShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height); + ShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height); // you should reap any processes here as needed, and forcefully terminate ones still running. virtual ~ShelloutProcessing(); @@ -117,17 +132,17 @@ class ShelloutProcessing ShelloutAction::Action ReturnAction(shelloutEvent which) const { return shellouts[which]->ReturnAction(); } // return the command string as passed from the option parser; i.e. complete with parameters - string RawCommand(shelloutEvent which) const { return shellouts[which]->RawCommand(); } + std::string RawCommand(shelloutEvent which) const { return shellouts[which]->RawCommand(); } // the command itself, separated from its parameters. quotes around the command will have been removed. - string Command(shelloutEvent which) const { return shellouts[which]->Command(); } + std::string Command(shelloutEvent which) const { return shellouts[which]->Command(); } // the raw parameters after separation from the command. any quotes will remain in place. - string RawParameters(shelloutEvent which) const { return shellouts[which]->RawParameters(); } + std::string RawParameters(shelloutEvent which) const { return shellouts[which]->RawParameters(); } // the parameters after expansion of terms; e.g. %s to scene name. SetOutputFile() and // SetFrameClock() (if relevant) must be called prior to calling this method. - string Parameters(shelloutEvent which) const { return shellouts[which]->Parameters(); } + std::string Parameters(shelloutEvent which) const { return shellouts[which]->Parameters(); } // returns true if all frames should be skipped. if so, any subsequent calls for // pre-frame and post-frame actions will be ignored (and preferebly should not be @@ -145,7 +160,7 @@ class ShelloutProcessing int ExitCode(void) const { return exitCode; } // returns a string representation of the exit code; e.g. 'user abort' - string ExitDesc(void) const { return exitCode == 0 ? "SUCCESS" : exitCode == 2 ? "USER ABORT" : "FATAL ERROR"; } + std::string ExitDesc(void) const { return exitCode == 0 ? "SUCCESS" : exitCode == 2 ? "USER ABORT" : "FATAL ERROR"; } // returns true if the render should be halted. bool RenderCancelled(void) const { return cancelRender; } @@ -160,7 +175,7 @@ class ShelloutProcessing // if there is an output file, this method must be called prior to the pre-scene // action with the value of the first output file, and prior to pre-frame for each // subsequent output file if the render is an animation. - void SetOutputFile(const string& filename) { outputFile = filename; } + void SetOutputFile(const std::string& filename) { outputFile = filename; } // if the render is not an animation, there is no need to call SetFrameClock(). // if it is an animation, it must be called prior to the pre-scene action, and @@ -185,8 +200,8 @@ class ShelloutProcessing // 7: the command parameters (CAUTION: may contain escape codes) // 8: the command return code (as an integer) // 9: output text from the command, as returned by LastShelloutResult() - virtual string GetCancelMessage(void); - virtual void SetCancelMessage(const string& format) { cancelFormat.parse(format); } + virtual std::string GetCancelMessage(void); + virtual void SetCancelMessage(const std::string& format) { cancelFormat.parse(format); } // the positional parameters are as follows: // 1: the event causing the skip (as a string), e.g. "pre-scene" @@ -195,8 +210,8 @@ class ShelloutProcessing // 4: the command parameters (CAUTION: may contain escape codes) // 5: the command return code (as an integer) // 6: output text from the command, as returned by LastShelloutResult() - virtual string GetSkipMessage(void); - virtual void SetSkipMessage(const string& format) { skipFormat.parse(format); } + virtual std::string GetSkipMessage(void); + virtual void SetSkipMessage(const std::string& format) { skipFormat.parse(format); } // advise the code that a particular event should be handled now; e.g. pre-scene, post-scene // and so forth. this method should be called even if the platform indicates it does not @@ -218,7 +233,7 @@ class ShelloutProcessing // return the name of the currently running shellout (without parameters) // if no shellout is running, an empty string should be returned. - virtual string ProcessName(void) { return ShelloutRunning() ? runningProcessName : string(); } + virtual std::string ProcessName(void) { return ShelloutRunning() ? runningProcessName : std::string(); } // return the PID of the currently running shellout (or equivalent thereof). // returns 0 if no process is running, and -1 of the platform has no PID equivalent @@ -229,7 +244,7 @@ class ShelloutProcessing // in a form suitable for display on the console or UI message log - preferably // no more than a single line (width unimportant). if not implemented, an empty // string should be returned. - virtual string LastShelloutResult(void) { return string(); } + virtual std::string LastShelloutResult(void) { return std::string(); } // return true if this platform supports shellouts. virtual bool ShelloutsSupported(void) { return false; } @@ -252,25 +267,25 @@ class ShelloutProcessing unsigned int imageWidth; unsigned int imageHeight; float clockVal; - string sceneName; - string outputFile; - string runningProcessName; - string cancelPhase; - string cancelReason; - string cancelCommand; - string cancelParameters; - string cancelOutput; - string skipPhase; - string skipReason; - string skipCommand; - string skipParameters; - string skipOutput; + std::string sceneName; + std::string outputFile; + std::string runningProcessName; + std::string cancelPhase; + std::string cancelReason; + std::string cancelCommand; + std::string cancelParameters; + std::string cancelOutput; + std::string skipPhase; + std::string skipReason; + std::string skipCommand; + std::string skipParameters; + std::string skipOutput; boost::format cancelFormat; boost::format skipFormat; ShelloutPtr shellouts[lastShelloutEvent]; // helper method - string GetPhaseName(shelloutEvent event); + std::string GetPhaseName(shelloutEvent event); // execute the given command with the supplied parameters, which have already // been expanded as per the docs, and immediately return true without waiting @@ -291,7 +306,7 @@ class ShelloutProcessing // if the platform implemeting a subclass of this method has the equivalent of a // system log (e.g. syslog on unix, event log on windows), the implementation should // consider providing a user-controllable option to log any commands using such. - virtual bool ExecuteCommand(const string& cmd, const string& params); + virtual bool ExecuteCommand(const std::string& cmd, const std::string& params); // shutdown any currently-running shellouts. if force is true, force them to exit. // in either case, don't wait more than timeout milliseconds. return true if there @@ -312,13 +327,13 @@ class ShelloutProcessing // // if the platform does not support capturing output of processes (or the // processes are GUI-based), there is no requirement to return any output. - virtual int CollectCommand(string& output) { return -2; } + virtual int CollectCommand(std::string& output) { return -2; } virtual int CollectCommand(void) { return -2; } // return true if the requested shellout command is permitted. this method is // called just before a shellout runs. if it fails, an exception will generally // be thrown by the caller (the method itself should not throw an exception). - virtual bool CommandPermitted(const string& command, const string& parameters) { return true; } + virtual bool CommandPermitted(const std::string& command, const std::string& parameters) { return true; } // called by the internal parser during construction to separate commands from parameters. // given a raw string in the form returned from the POV INI file, extract the command and any parameters. @@ -340,16 +355,17 @@ class ShelloutProcessing // parameters start will not be removed. // // this method should return true if the command is non-empty upon completion. - virtual bool ExtractCommand(const string& src, string& command, string& parameters) const; + virtual bool ExtractCommand(const std::string& src, std::string& command, std::string& parameters) const; private: bool processStartRequested; shelloutEvent postProcessEvent; bool HandleProcessEvent(shelloutEvent which, bool internalCall); - bool PostProcessEvent(void); + bool PostProcessEvent(); }; } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_SHELLOUTPROCESSING_H diff --git a/source/frontend/simplefrontend.h b/source/frontend/simplefrontend.h index 65d2f0aed..e6fc7a3f8 100644 --- a/source/frontend/simplefrontend.h +++ b/source/frontend/simplefrontend.h @@ -39,17 +39,25 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "frontend/configfrontend.h" -#include +// C++ variants of C standard header files +// (none at the moment) +// C++ standard header files +#include + +// POV-Ray header files (base module) +#include "base/povassert.h" +#include "base/stringutilities.h" +#include "base/image/image_fwd.h" + +// POV-Ray header files (POVMS module) +// (none at the moment) + +// POV-Ray header files (frontend module) #include "frontend/animationprocessing.h" #include "frontend/renderfrontend.h" #include "frontend/shelloutprocessing.h" -namespace pov_base -{ -class Image; -} - namespace pov_frontend { @@ -80,16 +88,16 @@ enum State }; template -class SimpleFrontend +class SimpleFrontend final { public: SimpleFrontend(POVMSContext ctx, POVMSAddress addr, POVMS_Object& msg, boost::function cfn, boost::function dfn, - POVMS_Object *result = nullptr, shared_ptr console = shared_ptr()); + POVMS_Object *result = nullptr, std::shared_ptr console = std::shared_ptr()); ~SimpleFrontend(); - bool Start(POVMS_Object& opts, shared_ptr img = shared_ptr()); + bool Start(POVMS_Object& opts, std::shared_ptr img = std::shared_ptr()); bool Stop(); bool Pause(); bool Resume(); @@ -98,9 +106,9 @@ class SimpleFrontend State GetState() const; - shared_ptr GetConsole(); - shared_ptr GetImage(); - shared_ptr GetDisplay(); + std::shared_ptr GetConsole(); + std::shared_ptr GetImage(); + std::shared_ptr GetDisplay(); private: RenderFrontend renderFrontend; POVMSAddress backendAddress; @@ -108,9 +116,9 @@ class SimpleFrontend POVMS_Object options; RenderFrontendBase::SceneId sceneId; RenderFrontendBase::ViewId viewId; - shared_ptr imageProcessing; - shared_ptr animationProcessing; - shared_ptr shelloutProcessing; + std::shared_ptr imageProcessing; + std::shared_ptr animationProcessing; + std::shared_ptr shelloutProcessing; boost::function createConsole; boost::function createDisplay; }; @@ -119,7 +127,7 @@ template SimpleFrontend::SimpleFrontend(POVMSContext ctx, POVMSAddress addr, POVMS_Object& msg, boost::function cfn, boost::function dfn, - POVMS_Object *result, shared_ptr console) : + POVMS_Object *result, std::shared_ptr console) : renderFrontend(ctx), backendAddress(addr), state(kReady), @@ -137,7 +145,7 @@ SimpleFrontend::~SimpleFrontend() } template -bool SimpleFrontend::Start(POVMS_Object& opts, shared_ptr img) +bool SimpleFrontend::Start(POVMS_Object& opts, std::shared_ptr img) { int width; int height; @@ -164,16 +172,16 @@ bool SimpleFrontend::Start(POVMS_Object opts.Set(kPOVAttrib_Declare, declares); if(opts.TryGetInt(kPOVAttrib_FinalFrame, 0) > 0) - animationProcessing = shared_ptr(new AnimationProcessing(opts)); + animationProcessing = std::shared_ptr(new AnimationProcessing(opts)); options = opts; if(opts.TryGetBool(kPOVAttrib_OutputToFile, true)) { if (img != nullptr) - imageProcessing = shared_ptr(new ImageProcessing(img)); + imageProcessing = std::shared_ptr(new ImageProcessing(img)); else - imageProcessing = shared_ptr(new ImageProcessing(options)); + imageProcessing = std::shared_ptr(new ImageProcessing(options)); } Path ip (opts.TryGetString(kPOVAttrib_InputFile, "")); @@ -453,23 +461,24 @@ State SimpleFrontend::GetState() const } template -shared_ptr SimpleFrontend::GetConsole() +std::shared_ptr SimpleFrontend::GetConsole() { return renderFrontend.GetConsole(sceneId); } template -shared_ptr SimpleFrontend::GetImage() +std::shared_ptr SimpleFrontend::GetImage() { return renderFrontend.GetImage(viewId); } template -shared_ptr SimpleFrontend::GetDisplay() +std::shared_ptr SimpleFrontend::GetDisplay() { return renderFrontend.GetDisplay(viewId); } } +// end of namespace pov_frontend #endif // POVRAY_FRONTEND_SIMPLEFRONTEND_H diff --git a/source/parser/configparser.h b/source/parser/configparser.h index c81729c54..c89a7c8f6 100644 --- a/source/parser/configparser.h +++ b/source/parser/configparser.h @@ -10,7 +10,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 @@ -38,6 +38,7 @@ #ifndef POVRAY_PARSER_CONFIGPARSER_H #define POVRAY_PARSER_CONFIGPARSER_H +// Pull in other compile-time config header files first #include "core/configcore.h" #include "syspovconfigparser.h" diff --git a/source/parser/fncode.cpp b/source/parser/fncode.cpp index 9032dda71..41fe13e26 100644 --- a/source/parser/fncode.cpp +++ b/source/parser/fncode.cpp @@ -38,19 +38,27 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "parser/fncode.h" +// C++ variants of C standard header files #include #include #include + +// C++ standard header files #include // POV-Ray header files (base module) +#include "base/pov_mem.h" +#include "base/povassert.h" #include "base/stringutilities.h" +// POV-Ray header files (core module) #include "core/scene/scenedata.h" +// POV-Ray header files (VM module) #include "vm/fnintern.h" #include "vm/fnpovfpu.h" +// POV-Ray header files (parser module) #include "parser/parser.h" // this must be the last header file included @@ -59,6 +67,9 @@ namespace pov_parser { +using std::min; +using std::max; + using namespace pov; /***************************************************************************** @@ -2236,6 +2247,7 @@ void FNCode::disassemble_instruction(FILE *f, Instruction& i) #include "fnasm.cpp" -#endif +#endif // DEBUG_FLOATFUNCTION } +// end of namespace pov_parser diff --git a/source/parser/fncode.h b/source/parser/fncode.h index ab0792eaa..0b4d2bdbb 100644 --- a/source/parser/fncode.h +++ b/source/parser/fncode.h @@ -10,7 +10,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 @@ -41,16 +41,23 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "parser/configparser.h" -#include "vm/fnpovfpu.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) -#include "parser/reservedwords.h" +// Boost header files +#include -namespace pov -{ +// POV-Ray header files (base module) +// POV-Ray header files (core module) +// (none at the moment) -class FunctionVM; +// POV-Ray header files (VM module) +#include "vm/fnpovfpu_fwd.h" -} +// POV-Ray header files (parser module) +#include "parser/parser_fwd.h" +#include "parser/reservedwords.h" namespace pov_parser { @@ -96,11 +103,9 @@ enum OP_TRAP // 23 }; -class Parser; - void FNCode_Copy(FunctionCode *, FunctionCode *); -struct ExprNode +struct ExprNode final { ExprNode *parent; ExprNode *child; @@ -122,7 +127,7 @@ struct ExprNode }; }; -class FNCode +class FNCode final { public: FNCode(Parser *, FunctionCode *, bool, const char *); @@ -137,7 +142,7 @@ class FNCode private: FunctionCode *function; Parser *parser; - intrusive_ptr functionVM; + boost::intrusive_ptr functionVM; unsigned int max_program_size; unsigned int max_stack_size; @@ -153,8 +158,8 @@ class FNCode #endif - FNCode(); - FNCode(FNCode&); + FNCode() = delete; + FNCode(FNCode&) = delete; void compile_recursive(ExprNode *expr); void compile_member(char *name); @@ -191,5 +196,6 @@ class FNCode }; } +// end of namespace pov_parser #endif // POVRAY_PARSER_FNCODE_H diff --git a/source/parser/parser.cpp b/source/parser/parser.cpp index 4dbeb5a0b..27e4c0c36 100644 --- a/source/parser/parser.cpp +++ b/source/parser/parser.cpp @@ -48,11 +48,16 @@ // Boost header files #include -#include // POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/fileutil.h" +#include "base/path.h" +#include "base/povassert.h" +#include "base/stringutilities.h" #include "base/types.h" +#include "base/image/colourspace.h" +#include "base/image/image.h" // POV-Ray header files (core module) #include "core/bounding/boundingcylinder.h" @@ -108,6 +113,9 @@ // POV-Ray header files (VM module) #include "vm/fnpovfpu.h" +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -116,6 +124,11 @@ namespace pov_parser using namespace pov; +using std::min; +using std::max; +using std::shared_ptr; +using std::vector; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -125,23 +138,7 @@ using namespace pov; const DBL INFINITE_VOLUME = BOUND_HUGE; -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** Parser::Parser(shared_ptr sd, const Options& opts, GenericMessenger& mf, FileResolver& fr, ProgressReporter& pr, TraceThreadData& td) : @@ -176,7 +173,7 @@ Parser::~Parser() /* Parse the file. */ void Parser::Run() { - SourceInfo errorInfo(UCS2String(POV_FILENAME_BUFFER_CHARS, 0), // Pre-claim some memory, so we can handle an out-of-memory error. + SourceInfo errorInfo(UCS2String(POV_FILENAME_BUFFER_CHARS, u'\0'), // Pre-claim some memory, so we can handle an out-of-memory error. SourcePosition(-1,-1,-1)); // Outer try/catch block to handle out-of-memory conditions @@ -216,7 +213,7 @@ void Parser::Run() if(i->second[0] == '\"') { - string tmp(i->second, 1, i->second.length() - 2); + std::string tmp(i->second, 1, i->second.length() - 2); Temp_Entry = mSymbolStack.GetGlobalTable()->Add_Symbol(i->first, STRING_ID_TOKEN); Temp_Entry->Data = String_Literal_To_UCS2(tmp); } @@ -515,24 +512,7 @@ void Parser::Finish() Cleanup(); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** /* Set up the fields in the frame to default values. */ void Parser::Frame_Init() @@ -551,8 +531,7 @@ void Parser::Frame_Init() sceneData->skysphere = nullptr; } - -/****************************************************************************/ +//****************************************************************************** void Parser::InitDefaults(int version) { @@ -619,24 +598,7 @@ void Parser::InitDefaults(int version) defaultsVersion = newDefaults; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Destroy_Frame() { @@ -699,24 +661,7 @@ void Parser::Destroy_Frame() } } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** bool Parser::Parse_Begin (TokenId tokenId, bool mandatory) { @@ -738,24 +683,7 @@ bool Parser::Parse_Begin (TokenId tokenId, bool mandatory) } } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_End(TokenId openTokenId, TokenId expectTokenId) { @@ -781,23 +709,7 @@ void Parser::Parse_End(TokenId openTokenId, TokenId expectTokenId) Error("No matching %s, %s found instead", Get_Token_String(expectTokenId), Get_Token_String(CurrentTrueTokenId())); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Bicubic_Patch () { @@ -1219,25 +1131,7 @@ void Parser::Parse_Blob_Element_Mods(Blob_Element *Element) Post_Textures(Element->Texture); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Box () { @@ -1425,23 +1319,7 @@ void Parser::Parse_User_Defined_Camera (Camera& Cam) END_EXPECT } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Camera (Camera& Cam) { @@ -2303,24 +2181,7 @@ bool Parser::Parse_Camera_Mods(Camera& New) return true; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_CSG(int CSG_Type) { @@ -2378,23 +2239,7 @@ ObjectPtr Parser::Parse_CSG(int CSG_Type) return (reinterpret_cast(Object)); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Cone () { @@ -2427,24 +2272,7 @@ ObjectPtr Parser::Parse_Cone () return (reinterpret_cast(Object)); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Cylinder () { @@ -2476,24 +2304,7 @@ ObjectPtr Parser::Parse_Cylinder () return (reinterpret_cast(Object)); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Disc () { @@ -2537,25 +2348,7 @@ ObjectPtr Parser::Parse_Disc () return (reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_HField () { @@ -3191,23 +2984,7 @@ ObjectPtr Parser::Parse_Lathe() return (reinterpret_cast(Object)); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Lemon () { @@ -3432,25 +3209,7 @@ ObjectPtr Parser::Parse_Light_Group() return (reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Light_Source () { @@ -5204,24 +4963,7 @@ ObjectPtr Parser::Parse_Parametric(void) return (reinterpret_cast(Object)); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Plane () { @@ -5252,25 +4994,7 @@ ObjectPtr Parser::Parse_Plane () return (reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Poly (int order) { @@ -5300,23 +5024,7 @@ ObjectPtr Parser::Parse_Poly (int order) return (reinterpret_cast(Object)); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Polynom () { @@ -5785,25 +5493,7 @@ ObjectPtr Parser::Parse_Prism() return(reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Quadric () { @@ -5833,25 +5523,7 @@ ObjectPtr Parser::Parse_Quadric () return (reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Smooth_Triangle () { @@ -6027,25 +5699,7 @@ ObjectPtr Parser::Parse_Sor() return (reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Sphere() { @@ -6353,25 +6007,7 @@ ObjectPtr Parser::Parse_Torus() return (reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Triangle() { @@ -6401,25 +6037,7 @@ ObjectPtr Parser::Parse_Triangle() return(reinterpret_cast(Object)); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_TrueType () { @@ -6634,24 +6252,7 @@ TrueTypeFont *Parser::OpenFontFile(const char *asciifn, const int font_id, POV_U return font; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Object () { @@ -6849,25 +6450,7 @@ ObjectPtr Parser::Parse_Object () return Object; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Default () { @@ -6952,25 +6535,7 @@ void Parser::Parse_Default () Not_In_Default = true; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Frame () { @@ -7115,33 +6680,15 @@ void Parser::Parse_Frame () END_EXPECT } +//****************************************************************************** - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ - -void Parser::Parse_Global_Settings() -{ - Parse_Begin(); - EXPECT - CASE (IRID_WAVELENGTH_TOKEN) - Parse_Wavelengths (sceneData->iridWavelengths); - END_CASE +void Parser::Parse_Global_Settings() +{ + Parse_Begin(); + EXPECT + CASE (IRID_WAVELENGTH_TOKEN) + Parse_Wavelengths (sceneData->iridWavelengths); + END_CASE CASE (CHARSET_TOKEN) Warning("Encountered 'charset' global setting. As of POV-Ray v3.8, this mechanism " @@ -7620,25 +7167,7 @@ void Parser::Parse_Global_Settings() Parse_End(); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** // be aware that this method may change the address of Object // (this will only happen if Object is CSG and the invert_object keyword is parsed) @@ -8100,25 +7629,7 @@ ObjectPtr Parser::Parse_Object_Mods (ObjectPtr Object) return Object; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Matrix(MATRIX Matrix) { @@ -8151,25 +7662,7 @@ void Parser::Parse_Matrix(MATRIX Matrix) } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** TRANSFORM *Parser::Parse_Transform(TRANSFORM *Trans) { @@ -8194,23 +7687,8 @@ TRANSFORM *Parser::Parse_Transform(TRANSFORM *Trans) } return Trans; } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ + +//****************************************************************************** TRANSFORM *Parser::Parse_Transform_Block(TRANSFORM *New) { @@ -8282,25 +7760,7 @@ TRANSFORM *Parser::Parse_Transform_Block(TRANSFORM *New) return (New); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Bound_Clip(vector& dest, bool notexture) { @@ -8420,24 +7880,7 @@ bool Parser::Parse_Three_UVCoords(Vector2d& UV1, Vector2d& UV2, Vector2d& UV3) } } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** bool Parser::Parse_Comma (void) { @@ -8472,24 +7915,7 @@ bool Parser::Peek_Token (TokenId tokenId) return tokenMatches; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Semi_Colon (bool force_semicolon) { @@ -8510,25 +7936,7 @@ void Parser::Parse_Semi_Colon (bool force_semicolon) } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Coeffs(int order, DBL *Coeffs) { @@ -8546,24 +7954,7 @@ void Parser::Parse_Coeffs(int order, DBL *Coeffs) Parse_Angle_End(); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** ObjectPtr Parser::Parse_Object_Id () { @@ -8579,24 +7970,7 @@ ObjectPtr Parser::Parse_Object_Id () return (Object); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Declare(bool is_local, bool after_hash) { @@ -9458,49 +8832,14 @@ bool Parser::Parse_RValue (TokenId Previous, TokenId *NumberPtr, void **DataPtr, return(Found); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Link(ObjectPtr New_Object, vector& Object_List_Root) { Object_List_Root.push_back(New_Object); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Link_Textures (TEXTURE **Old_Textures, TEXTURE *New_Textures) { @@ -9586,48 +8925,14 @@ void Parser::Test_Redefine(TokenId Previous, TokenId *NumberPtr, void *Data, boo } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Error(TokenId Token_Id) { Expectation_Error(Get_Token_String(Token_Id)); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Found_Instead_Error(const char *exstr, const char *extokstr) { @@ -9656,24 +8961,7 @@ void Parser::Found_Instead_Error(const char *exstr, const char *extokstr) } } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Warn_State(TokenId Type) { @@ -9693,50 +8981,14 @@ void Parser::Warn_State(TokenId Type) POV_FREE(str); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::MAError (const char *, long) { throw std::bad_alloc(); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Post_Process (ObjectPtr Object, ObjectPtr Parent) { @@ -10179,50 +9431,14 @@ void Parser::Link_To_Frame(ObjectPtr Object) Destroy_Object(Object); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Only_In(const char *s1, const char *s2) { Error("Keyword '%s' can only be used in a %s statement.",s1,s2); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Not_With(const char *s1, const char *s2) { @@ -10354,25 +9570,7 @@ void Parser::Set_CSG_Tree_Flag(ObjectPtr Object, unsigned int f, int val) } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** /* NK layers - 1999 June 10 - for backwards compatibility with layered textures */ void Parser::Convert_Filter_To_Transmit(PIGMENT *Pigment) @@ -10418,24 +9616,7 @@ void Parser::Convert_Filter_To_Transmit(GenericPigmentBlendMap *pBlendMap) POV_BLEND_MAP_ASSERT(false); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Expectation_Error(const char *s) { @@ -10770,16 +9951,16 @@ shared_ptr Parser::Locate_File(const UCS2String& filename, unsigned int } */ -/*****************************************************************************/ +//****************************************************************************** OStream *Parser::CreateFile(const UCS2String& filename, unsigned int stype, bool append) { return mFileResolver.CreateFile(filename, stype, append); } -/*****************************************************************************/ +//****************************************************************************** -Image *Parser::Read_Image(int filetype, const UCS2 *filename, const Image::ReadOptions& options) +Image *Parser::Read_Image(int filetype, const UCS2 *filename, const ImageReadOptions& options) { unsigned int stype; Image::ImageFileType type; @@ -10851,14 +10032,14 @@ Image *Parser::Read_Image(int filetype, const UCS2 *filename, const Image::ReadO return Image::Read(type, file.get(), options); } -/*****************************************************************************/ +//****************************************************************************** RGBFTColour *Parser::Create_Colour () { return new RGBFTColour(); } -/*****************************************************************************/ +//****************************************************************************** bool Parser::POV_ARRAY::IsInitialized() const { @@ -10966,6 +10147,31 @@ Parser::POV_ARRAY* Parser::POV_ARRAY::Clone() const return new POV_ARRAY(*this); } -/*****************************************************************************/ +//****************************************************************************** + +Parser::AssignableFunction::AssignableFunction(const AssignableFunction& obj) : + fn(obj.vm->CopyFunction(obj.fn)), + vm(obj.vm) +{} + +Parser::AssignableFunction::AssignableFunction(FUNCTION_PTR fn, boost::intrusive_ptr vm) : + fn(fn), + vm(vm) +{} + +Parser::AssignableFunction::~AssignableFunction() +{ + vm->DestroyFunction(fn); +} + +//****************************************************************************** + +UCS2String Parser::BraceStackEntry::GetFileName() const +{ + return file->Name(); +} -} // end of namespace +//****************************************************************************** + +} +// end of namespace pov_parser diff --git a/source/parser/parser.h b/source/parser/parser.h index a882ec5bf..1353e9ff6 100644 --- a/source/parser/parser.h +++ b/source/parser/parser.h @@ -40,20 +40,40 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "parser/configparser.h" +#include "parser/parser_fwd.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include #include +#include + +// Boost headers +#include -#include "base/image/image.h" -#include "base/messenger.h" -#include "base/stringutilities.h" -#include "base/textstream.h" +// POV-Ray header files (base module) +#include "base/base_fwd.h" +#include "base/messenger_fwd.h" +#include "base/povassert.h" +#include "base/stringtypes.h" +#include "base/textstream_fwd.h" #include "base/textstreambuffer.h" +#include "base/image/image_fwd.h" +// POV-Ray header files (core module) +#include "core/core_fwd.h" #include "core/material/blendmap.h" #include "core/material/pigment.h" #include "core/material/warp.h" +#include "core/scene/atmosphere_fwd.h" #include "core/scene/camera.h" +// POV-Ray header files (VM module) +#include "vm/fnpovfpu_fwd.h" + +// POV-Ray header files (parser module) #include "parser/fncode.h" #include "parser/parsertypes.h" #include "parser/reservedwords.h" @@ -65,18 +85,15 @@ namespace pov class Blob_Element; struct ContainedByShape; -struct Fog_Struct; struct GenericSpline; class ImageData; class Mesh; struct PavementPattern; -struct Rainbow_Struct; -class SceneData; -struct Skysphere_Struct; struct TilingPattern; struct TrueTypeFont; } +// end of namespace pov namespace pov_parser { @@ -155,7 +172,7 @@ const int TOKEN_OVERFLOW_RESET_COUNT = 2500; } -struct ExperimentalFlags +struct ExperimentalFlags final { bool backsideIllumination : 1; bool functionHf : 1; @@ -180,7 +197,7 @@ struct ExperimentalFlags {} }; -struct BetaFlags +struct BetaFlags final { bool realTimeRaytracing : 1; bool videoCapture : 1; @@ -195,34 +212,20 @@ struct BetaFlags * Global typedefs ******************************************************************************/ -class Parser +class Parser final { public: using Options = ParserOptions; - struct FileResolver - { - virtual ~FileResolver() {} - virtual UCS2String FindFile(UCS2String parsedFileName, unsigned int fileType) = 0; - virtual IStream* ReadFile(const UCS2String& parsedFileName, const UCS2String& foundFileName, unsigned int fileType) = 0; - virtual OStream* CreateFile(const UCS2String& parsedFileName, unsigned int fileType, bool append) = 0; - }; - - struct ProgressReporter - { - virtual ~ProgressReporter() {} - virtual void ReportProgress(POV_LONG tokenCount) = 0; - }; - - class DebugTextStreamBuffer : public TextStreamBuffer + class DebugTextStreamBuffer final : public TextStreamBuffer { public: DebugTextStreamBuffer(GenericMessenger& m); - ~DebugTextStreamBuffer(); + virtual ~DebugTextStreamBuffer() override; protected: - virtual void lineoutput(const char *str, unsigned int chars); - virtual void directoutput(const char *str, unsigned int chars); + virtual void lineoutput(const char *str, unsigned int chars) override; + virtual void directoutput(const char *str, unsigned int chars) override; GenericMessenger& mMessenger; }; @@ -230,7 +233,7 @@ class Parser // tokenize.h/tokenize.cpp /// Structure holding information about the current token - struct Token_Struct : MessageContext + struct Token_Struct final : MessageContext { RawToken raw; ConstStreamPtr sourceFile; @@ -256,7 +259,7 @@ class Parser /// Token category if applicable, otherwise equal to @ref mTrueTokenId. TokenId GetCategorizedTokenId() const; - virtual UCS2String GetFileName() const override { return sourceFile->Name(); } + virtual UCS2String GetFileName() const override; virtual POV_LONG GetLine() const override { return raw.lexeme.position.line; } virtual POV_LONG GetColumn() const override { return raw.lexeme.position.column; } virtual POV_OFF_T GetOffset() const override { return raw.lexeme.position.offset; } @@ -267,7 +270,7 @@ class Parser TokenId mCategorizedTokenId; ///< Token category if applicable, otherwise equal to @ref mTrueTokenId. }; - struct LValue + struct LValue final { TokenId* numberPtr; void** dataPtr; @@ -277,34 +280,34 @@ class Parser bool optional : 1; }; - struct MacroParameter + struct MacroParameter final { char* name; bool optional; }; - struct Macro : public Assignable + struct Macro final : public Assignable { Macro(const char *); - virtual ~Macro(); + virtual ~Macro() override; virtual Macro* Clone() const override { POV_PARSER_PANIC(); return nullptr; } char *Macro_Name; RawTokenizer::ColdBookmark source; LexemePosition endPosition; ///< The position _after_ the `#` in the terminating `#end` directive. - vector parameters; + std::vector parameters; unsigned char *Cache; size_t CacheSize; }; - struct POV_ARRAY : public Assignable + struct POV_ARRAY final : public Assignable { static const int kMaxDimensions = 5; int maxDim; ///< Index of highest dimension. TokenId Type_; int Sizes[kMaxDimensions]; size_t Mags[kMaxDimensions]; - vector DataPtrs; - vector Types; + std::vector DataPtrs; + std::vector Types; bool resizable : 1; bool mixedType : 1; bool IsInitialized() const; @@ -318,21 +321,21 @@ class Parser void Shrink(); POV_ARRAY() = default; POV_ARRAY(const POV_ARRAY& obj); - virtual ~POV_ARRAY(); + virtual ~POV_ARRAY() override; virtual POV_ARRAY* Clone() const override; }; - struct POV_PARAM + struct POV_PARAM final { TokenId *NumberPtr; void **DataPtr; }; - struct DATA_FILE : public Assignable + struct DATA_FILE final : public Assignable { - shared_ptr inTokenizer; - RawToken inToken; - shared_ptr Out_File; + std::shared_ptr inTokenizer; + RawToken inToken; + std::shared_ptr Out_File; bool inUngetToken : 1; bool busyParsing : 1; ///< `true` if parsing a statement related to the file, `false` otherwise. @@ -359,18 +362,18 @@ class Parser }; /// @todo Refactor code to use @ref FunctionVM::CustomFunction instead. - struct AssignableFunction : public Assignable + struct AssignableFunction final : public Assignable { - FUNCTION_PTR fn; - intrusive_ptr vm; - AssignableFunction(const AssignableFunction& obj) : fn(obj.vm->CopyFunction(obj.fn)), vm(obj.vm) {} - AssignableFunction(FUNCTION_PTR fn, intrusive_ptr vm) : fn(fn), vm(vm) {} - virtual ~AssignableFunction() { vm->DestroyFunction(fn); } + FUNCTION_PTR fn; + boost::intrusive_ptr vm; + AssignableFunction(const AssignableFunction& obj); + AssignableFunction(FUNCTION_PTR fn, boost::intrusive_ptr vm); + virtual ~AssignableFunction() override; virtual AssignableFunction* Clone() const override { return new AssignableFunction(*this); } }; // constructor - Parser(shared_ptr sd, const Options& opts, + Parser(std::shared_ptr sd, const Options& opts, GenericMessenger& mf, FileResolver& fnr, ProgressReporter& pr, TraceThreadData& td); ~Parser(); @@ -419,7 +422,7 @@ class Parser ObjectPtr Parse_Object_Mods (ObjectPtr Object); ObjectPtr Parse_Object (void); - void Parse_Bound_Clip (vector& objects, bool notexture = true); + void Parse_Bound_Clip (std::vector& objects, bool notexture = true); void Parse_Default (void); void Parse_Declare (bool is_local, bool after_hash); void Parse_Matrix (MATRIX Matrix); @@ -452,10 +455,10 @@ class Parser /// @param[in] formalFileName Name by which the file is known to the user. /// @param[out] actualFileName Name by which the file is known to the parsing computer. - shared_ptr Locate_File(const UCS2String& formalFileName, unsigned int stype, UCS2String& actualFileName, bool err_flag = false); + std::shared_ptr Locate_File(const UCS2String& formalFileName, unsigned int stype, UCS2String& actualFileName, bool err_flag = false); OStream *CreateFile(const UCS2String& filename, unsigned int stype, bool append); - Image *Read_Image(int filetype, const UCS2 *filename, const Image::ReadOptions& options); + Image *Read_Image(int filetype, const UCS2 *filename, const ImageReadOptions& options); // tokenize.h/tokenize.cpp void Get_Token (void); @@ -486,7 +489,7 @@ class Parser const LexemePosition& CurrentFilePosition() const; bool HaveCurrentMessageContext() const; const MessageContext& CurrentMessageContext() const; - void SetInputStream(const shared_ptr& stream); + void SetInputStream(const std::shared_ptr& stream); RawTokenizer::HotBookmark GetHotBookmark(); bool GoToBookmark(const RawTokenizer::HotBookmark& bookmark); @@ -512,10 +515,10 @@ class Parser void Parse_Pigment (PIGMENT **); void Parse_Tnormal (TNORMAL **); void Parse_Finish (FINISH **); - void Parse_Media (vector&); + void Parse_Media (std::vector&); void Parse_Interior (InteriorPtr&); void Parse_Media_Density_Pattern (PIGMENT **); - void Parse_Media_Density_Pattern (vector&); + void Parse_Media_Density_Pattern (std::vector&); Fog_Struct *Parse_Fog (void); Rainbow_Struct *Parse_Rainbow (void); Skysphere_Struct *Parse_Skysphere(void); @@ -531,12 +534,12 @@ class Parser void Parse_Colour (MathColour& colour); void Parse_Wavelengths (MathColour& colour); template void Parse_BlendMapData (BlendMapTypeId Blend_Type, DATA_T& rData); - template shared_ptr Parse_Blend_Map (BlendMapTypeId Blend_Type, int Pat_Type); - template shared_ptr Parse_Colour_Map (void); + template std::shared_ptr Parse_Blend_Map (BlendMapTypeId Blend_Type, int Pat_Type); + template std::shared_ptr Parse_Colour_Map (void); template void Parse_BlendListData (BlendMapTypeId Blend_Type, DATA_T& rData); template void Parse_BlendListData_Default (const ColourBlendMapData& Def_Entry, BlendMapTypeId Blend_Type, DATA_T& rData); - template shared_ptr Parse_Blend_List (int Count, ColourBlendMapConstPtr Def_Map, BlendMapTypeId Blend_Type); - template shared_ptr Parse_Item_Into_Blend_List (BlendMapTypeId Blend_Type); + template std::shared_ptr Parse_Blend_List (int Count, ColourBlendMapConstPtr Def_Map, BlendMapTypeId Blend_Type); + template std::shared_ptr Parse_Item_Into_Blend_List (BlendMapTypeId Blend_Type); GenericSpline *Parse_Spline (void); /// Parses a FLOAT. @@ -574,7 +577,7 @@ class Parser FUNCTION_PTR Parse_FunctionOrContent(void); void Parse_FunctionOrContentList(GenericScalarFunctionPtr* apFn, unsigned int count, bool mandatory = true); FUNCTION_PTR Parse_DeclareFunction(TokenId *token_id, const char *fn_name, bool is_local); - intrusive_ptr GetFunctionVM() const; + boost::intrusive_ptr GetFunctionVM() const; // parsestr.h/parsestr.cpp char *Parse_C_String(bool pathname = false); @@ -587,7 +590,6 @@ class Parser char *UCS2_To_String(const UCS2 *str); static UCS2 *UCS2_strcat(UCS2 *s1, const UCS2 *s2); - static int UCS2_strcmp(const UCS2 *s1, const UCS2 *s2); static void UCS2_strcpy(UCS2 *s1, const UCS2 *s2); static void UCS2_strncpy(UCS2 *s1, const UCS2 *s2, int n); void UCS2_strupr(UCS2 *str); // not static because it may issue a parse warning @@ -603,7 +605,7 @@ class Parser bool expr_ret(ExprNode *¤t, int stage, int op); bool expr_err(ExprNode *¤t, int stage, int op); - shared_ptr sceneData; + std::shared_ptr sceneData; private: @@ -616,19 +618,19 @@ class Parser Token_Struct mToken; - struct BraceStackEntry : LexemePosition, MessageContext + struct BraceStackEntry final : LexemePosition, MessageContext { TokenId openToken; ConstStreamPtr file; BraceStackEntry(const Token_Struct& token) : LexemePosition(token.raw.lexeme.position), openToken(token.GetTrueTokenId()), file(token.sourceFile) {} - virtual UCS2String GetFileName() const override { return file->Name(); } + virtual UCS2String GetFileName() const override; virtual POV_LONG GetLine() const override { return line; } virtual POV_LONG GetColumn() const override { return column; } virtual POV_OFF_T GetOffset() const override { return offset; } }; - intrusive_ptr mpFunctionVM; + boost::intrusive_ptr mpFunctionVM; FPUContext *fnVMContext; bool Had_Max_Trace_Level; @@ -648,7 +650,7 @@ class Parser /// true if a #version statement is being parsed bool parsingVersionDirective; - vector maBraceStack; + std::vector maBraceStack; bool Destroying_Frame; Camera Default_Camera; @@ -676,7 +678,7 @@ class Parser POV_LONG mTokenCount; int mTokensSinceLastProgressReport; - struct IncludeStackEntry + struct IncludeStackEntry final { RawTokenizer::HotBookmark returnToBookmark; int condStackSize; @@ -686,9 +688,9 @@ class Parser returnToBookmark(rtb), condStackSize(css), braceStackSize(bss) {} }; - vector maIncludeStack; + std::vector maIncludeStack; - struct CS_ENTRY + struct CS_ENTRY final { COND_TYPE Cond_Type; DBL Switch_Value; @@ -703,7 +705,7 @@ class Parser ~CS_ENTRY() {} }; - vector Cond_Stack; + std::vector Cond_Stack; bool Skipping, Inside_Ifdef, Inside_MacroDef, Parsing_Directive, parseRawIdentifiers, parseOptionalRValue; bool Got_EOF; // WARNING: Changes to the use of this variable are very dangerous as it is used in many places assuming certain non-obvious side effects! [trf] @@ -789,7 +791,7 @@ class Parser bool Parse_Camera_Mods(Camera& Cam); void Parse_Frame(); - void Link(ObjectPtr New_Object, vector& Object_List_Root); + void Link(ObjectPtr New_Object, std::vector& Object_List_Root); void Link_To_Frame(ObjectPtr Object); void Post_Process(ObjectPtr Object, ObjectPtr Parent); @@ -801,7 +803,7 @@ class Parser ObjectPtr Parse_Isosurface(); ObjectPtr Parse_Parametric(); - void ParseContainedBy(shared_ptr& container, ObjectPtr obj); + void ParseContainedBy(std::shared_ptr& container, ObjectPtr obj); ObjectPtr Parse_Sphere_Sweep(void); bool Parse_Three_UVCoords(Vector2d& UV1, Vector2d& UV2, Vector2d& UV3); @@ -844,8 +846,8 @@ class Parser PatternPtr ParsePotentialPattern(); PatternPtr ParseSlopePattern(); template PatternPtr ParseSpiralPattern(); - void VerifyPavementPattern(shared_ptr pattern); - void VerifyTilingPattern(shared_ptr pattern); + void VerifyPavementPattern(std::shared_ptr pattern); + void VerifyTilingPattern(std::shared_ptr pattern); void VerifyPattern(PatternPtr pattern); void Parse_Bump_Map (TNORMAL *Tnormal); void Parse_Image_Map (PIGMENT *Pigment); @@ -931,5 +933,6 @@ class Parser }; } +// end of namespace pov_parser #endif // POVRAY_PARSER_PARSE_H diff --git a/source/parser/parser_expressions.cpp b/source/parser/parser_expressions.cpp index 96cfb3b9e..357c7e3f6 100644 --- a/source/parser/parser_expressions.cpp +++ b/source/parser/parser_expressions.cpp @@ -38,6 +38,7 @@ // C++ variants of C standard header files #include +#include #include // C++ standard header files @@ -49,7 +50,9 @@ // POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/mathutil.h" +#include "base/pov_mem.h" #include "base/stringutilities.h" +#include "base/image/colourspace.h" // POV-Ray header files (core module) #include "core/material/blendmap.h" @@ -71,6 +74,9 @@ // POV-Ray header files (VM module) #include "vm/fnpovfpu.h" +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -80,30 +86,17 @@ namespace pov_parser using namespace pov_base; using namespace pov; +using std::min; +using std::max; +using std::shared_ptr; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ #define FTRUE(f) ((int)(fabs(f)>EPSILON)) - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** DBL Parser::Parse_Float_Param() { @@ -131,25 +124,7 @@ DBL Parser::Parse_Float_Param() return (Local); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Float_Param2(DBL *Val1,DBL *Val2) { @@ -165,25 +140,7 @@ void Parser::Parse_Float_Param2(DBL *Val1,DBL *Val2) Allow_Identifier_In_Call = old_allow_id; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Vector_Param(Vector3d& Vector) { @@ -192,25 +149,7 @@ void Parser::Parse_Vector_Param(Vector3d& Vector) Parse_Paren_End(); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Vector_Param2(Vector3d& Val1, Vector3d& Val2) { @@ -221,23 +160,7 @@ void Parser::Parse_Vector_Param2(Vector3d& Val1, Vector3d& Val2) Parse_Paren_End(); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Trace(Vector3d& Res) { @@ -285,23 +208,7 @@ void Parser::Parse_Trace(Vector3d& Res) Parse_Paren_End(); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** int Parser::Parse_Inside() { @@ -606,23 +513,7 @@ void Parser::Parse_Spline_Call(EXPRESS& Express, int *Terms) } } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) { @@ -735,15 +626,15 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) break; case ACOSH_TOKEN: - Val = acosh(Parse_Float_Param()); + Val = std::acosh(Parse_Float_Param()); break; case ASINH_TOKEN: - Val = asinh(Parse_Float_Param()); + Val = std::asinh(Parse_Float_Param()); break; case ATANH_TOKEN: - Val = atanh(Parse_Float_Param()); + Val = std::atanh(Parse_Float_Param()); break; case CEIL_TOKEN: @@ -1445,25 +1336,7 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** /* Promote_Express promotes Express to the requested number of terms. If *Old_Terms==1, then it sets all terms to Express[0]. Otherwise, it pads @@ -1640,24 +1513,7 @@ void Parser::Parse_Rel_Factor (EXPRESS& Express,int *Terms) } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** DBL Parser::Parse_Rel_String_Term (const UCS2 *lhs) { @@ -1721,23 +1577,7 @@ DBL Parser::Parse_Rel_String_Term (const UCS2 *lhs) END_EXPECT } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Rel_Term (EXPRESS& Express,int *Terms) { @@ -1821,25 +1661,7 @@ void Parser::Parse_Rel_Term (EXPRESS& Express,int *Terms) } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Logical (EXPRESS& Express,int *Terms) { @@ -1874,25 +1696,7 @@ void Parser::Parse_Logical (EXPRESS& Express,int *Terms) } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Express (EXPRESS& Express,int *Terms) { @@ -1928,25 +1732,7 @@ void Parser::Parse_Express (EXPRESS& Express,int *Terms) } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** DBL Parser::Parse_Float () { @@ -2028,25 +1814,7 @@ bool Parser::Parse_Bool(const char* parameterName) return value; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** DBL Parser::Allow_Float (DBL defval) { @@ -2066,24 +1834,7 @@ DBL Parser::Allow_Float (DBL defval) return (retval); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** int Parser::Allow_Vector (Vector3d& Vect) { @@ -2104,25 +1855,7 @@ int Parser::Allow_Vector (Vector3d& Vect) return (retval); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Vector (Vector3d& Vector) { @@ -2154,24 +1887,7 @@ void Parser::Parse_Vector (Vector3d& Vector) Allow_Identifier_In_Call = old_allow_id; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Vector4D (VECTOR_4D Vector) { @@ -2203,26 +1919,7 @@ void Parser::Parse_Vector4D (VECTOR_4D Vector) Allow_Identifier_In_Call = old_allow_id; } - - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_UV_Vect (Vector2d& UV_Vect) { @@ -2254,25 +1951,7 @@ void Parser::Parse_UV_Vect (Vector2d& UV_Vect) Allow_Identifier_In_Call = old_allow_id; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** int Parser::Parse_Unknown_Vector(EXPRESS& Express, bool allow_identifier, bool *had_identifier) { @@ -2302,24 +1981,7 @@ int Parser::Parse_Unknown_Vector(EXPRESS& Express, bool allow_identifier, bool * return(Terms); } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Scale_Vector (Vector3d& Vector) { @@ -2342,25 +2004,7 @@ void Parser::Parse_Scale_Vector (Vector3d& Vector) } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Parse_Colour (RGBFTColour& colour, bool expectFT) { @@ -2856,7 +2500,7 @@ shared_ptr Parser::Parse_Blend_Map (BlendMapTypeId Blend_Type,int Pat_Typ Error ("Must have at least one entry in map."); New = Create_Blend_Map (Blend_Type); New->Set(tempList); - pigmentBlendMap = dynamic_pointer_cast(New); + pigmentBlendMap = std::dynamic_pointer_cast(New); if (pigmentBlendMap) { pigmentBlendMap->blendMode = blendMode; @@ -2915,23 +2559,7 @@ template SlopeBlendMapPtr Parser::Parse_Blend_Map (BlendMa template NormalBlendMapPtr Parser::Parse_Blend_Map (BlendMapTypeId Blend_Type,int Pat_Type); template TextureBlendMapPtr Parser::Parse_Blend_Map (BlendMapTypeId Blend_Type,int Pat_Type); -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** template<> void Parser::Parse_BlendListData (BlendMapTypeId Blend_Type, ColourBlendMapData& rData) @@ -3346,7 +2974,7 @@ ColourBlendMapPtr Parser::Parse_Colour_Map () EXPRESS Express; int Terms; ColourBlendMapEntry Temp_Ent, Temp_Ent_2; - vector tempList; + std::vector tempList; bool old_allow_id = Allow_Identifier_In_Call; Allow_Identifier_In_Call = false; int blendMode = 0; @@ -3653,25 +3281,7 @@ GenericSpline *Parser::Parse_Spline() return New; } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::POV_strupr(char *s) { @@ -3679,29 +3289,11 @@ void Parser::POV_strupr(char *s) for (i = 0,len = (int)strlen(s); i < len; i++) { - s[i] = (char)toupper((int)s[i]); + s[i] = (char)std::toupper((int)s[i]); } } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::POV_strlwr(char *s) { @@ -3709,7 +3301,7 @@ void Parser::POV_strlwr(char *s) for (i = 0,len = (int)strlen(s); i < len; i++) { - s[i] = (char)tolower((int)s[i]); + s[i] = (char)std::tolower((int)s[i]); } } @@ -3863,3 +3455,4 @@ void Parser::Destroy_Random_Generators() } } +// end of namespace pov_parser diff --git a/source/parser/parser_functions.cpp b/source/parser/parser_functions.cpp index 122b83907..a66b614fa 100644 --- a/source/parser/parser_functions.cpp +++ b/source/parser/parser_functions.cpp @@ -39,12 +39,25 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "parser/parser.h" +// C++ variants of C standard header files +#include + +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) #include "base/mathutil.h" +#include "base/pov_mem.h" +// POV-Ray header files (core module) #include "core/scene/scenedata.h" +// POV-Ray header files (VM module) #include "vm/fnpovfpu.h" +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -57,7 +70,7 @@ using namespace pov; * Local typedefs ******************************************************************************/ -struct ExprParserTableEntry +struct ExprParserTableEntry final { int stage; TokenId token; @@ -66,7 +79,7 @@ struct ExprParserTableEntry int op; }; -struct ExprParserErrorEntry +struct ExprParserErrorEntry final { int stage; const char *expected; @@ -1187,13 +1200,13 @@ void Parser::optimise_call(ExprNode *node) result = tanh(node->child->number); break; case ASINH_TOKEN: - result = asinh(node->child->number); + result = std::asinh(node->child->number); break; case ACOSH_TOKEN: - result = acosh(node->child->number); + result = std::acosh(node->child->number); break; case ATANH_TOKEN: - result = atanh(node->child->number); + result = std::atanh(node->child->number); break; case ABS_TOKEN: result = fabs(node->child->number); @@ -1491,3 +1504,4 @@ void Parser::dump_expr(FILE *f, ExprNode *node) } } +// end of namespace pov_parser diff --git a/source/parser/parser_functions_utilities.cpp b/source/parser/parser_functions_utilities.cpp index 89d6e6d04..a6c3e0fca 100644 --- a/source/parser/parser_functions_utilities.cpp +++ b/source/parser/parser_functions_utilities.cpp @@ -39,13 +39,25 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "parser/parser.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/pigment.h" #include "core/math/matrix.h" #include "core/math/spline.h" #include "core/scene/scenedata.h" +// POV-Ray header files (VM module) #include "vm/fnpovfpu.h" +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -346,9 +358,10 @@ FUNCTION_PTR Parser::Parse_DeclareFunction(TokenId *token_id, const char *fn_nam return ptr; } -intrusive_ptr Parser::GetFunctionVM() const +boost::intrusive_ptr Parser::GetFunctionVM() const { return mpFunctionVM; } } +// end of namespace pov_parser diff --git a/source/parser/parser_fwd.h b/source/parser/parser_fwd.h new file mode 100644 index 000000000..48042d7d4 --- /dev/null +++ b/source/parser/parser_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file parser/parser_fwd.h +/// +/// Forward declarations of core module referenced by other modules. +/// +/// @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_PARSER_FWD_H +#define POVRAY_PARSER_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov_parser +{ + +class Parser; + +} +// end of namespace pov + +#endif // POVRAY_PARSER_FWD_H diff --git a/source/parser/parser_materials.cpp b/source/parser/parser_materials.cpp index 9852661f6..8fc1ddd16 100644 --- a/source/parser/parser_materials.cpp +++ b/source/parser/parser_materials.cpp @@ -36,10 +36,19 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "parser/parser.h" +// C++ variants of C standard header files +// C++ standard header files +// (none at the moment) + +// POV-Ray header files (base module) +#include "base/fileinputoutput.h" #include "base/fileutil.h" +#include "base/image/colourspace.h" #include "base/image/image.h" #include "base/path.h" +#include "base/stringutilities.h" +// POV-Ray header files (core module) #include "core/lighting/lightgroup.h" #include "core/material/blendmap.h" #include "core/material/interior.h" @@ -58,9 +67,14 @@ #include "core/shape/isosurface.h" #include "core/support/imageutil.h" +// POV-Ray header files (VM module) #include "vm/fnpovfpu.h" -#include "povms/povmsid.h" +// POV-Ray header files (parser module) +// (none at the moment) + +// POV-Ray header files (POVMS module) +#include "povms/povmsid.h" // TODO - only here for kPOVList_FileType_XXX #ifdef SYS_IMAGE_HEADER #include SYS_IMAGE_HEADER @@ -74,6 +88,9 @@ namespace pov_parser using namespace pov; +using std::shared_ptr; +using std::vector; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -115,7 +132,7 @@ void Parser::Make_Pattern_Image(ImageData *image, FUNCTION_PTR fn, int token) image->iheight = image->height; if(token == FUNCT_ID_TOKEN) { - image->data =Image::Create(image->iwidth, image->iheight, Image::Gray_Int16); + image->data =Image::Create(image->iwidth, image->iheight, ImageDataType::Gray_Int16); point[Z] = 0; @@ -137,7 +154,7 @@ void Parser::Make_Pattern_Image(ImageData *image, FUNCTION_PTR fn, int token) } else if((token == VECTFUNCT_ID_TOKEN) && (f->return_size == 5)) { - image->data =Image::Create(image->iwidth, image->iheight, Image::RGBA_Int16); // TODO - we should probably use a HDR format + image->data = Image::Create(image->iwidth, image->iheight, ImageDataType::RGBA_Int16); // TODO - we should probably use an HDR format image->data->SetPremultiplied(false); // We're storing the data in non-premultiplied alpha format, as this preserves all the data we're getting from the function. point[Z] = 0; @@ -364,7 +381,7 @@ ImageData *Parser::Parse_Image(int Legal, bool GammaCorrect) Error("File type not supported here."); UCS2String filename = SysToUCS2String(Name); - Image::ReadOptions options; + ImageReadOptions options; switch (sceneData->gammaMode) { @@ -483,7 +500,7 @@ ImageData *Parser::Parse_Image(int Legal, bool GammaCorrect) image->data = Read_Image(filetype, filename.c_str(), options); if (!options.warnings.empty()) - for (vector::iterator it = options.warnings.begin(); it != options.warnings.end(); it++) + for (vector::iterator it = options.warnings.begin(); it != options.warnings.end(); it++) Warning("%s: %s", Name, it->c_str()); POV_FREE(Name); @@ -1242,9 +1259,9 @@ void Parser::VerifyTilingPattern(shared_ptr pattern) void Parser::VerifyPattern(PatternPtr basicPattern) { - if (shared_ptr pattern = dynamic_pointer_cast(basicPattern)) + if (shared_ptr pattern = std::dynamic_pointer_cast(basicPattern)) VerifyPavementPattern(pattern); - else if (shared_ptr pattern = dynamic_pointer_cast(basicPattern)) + else if (shared_ptr pattern = std::dynamic_pointer_cast(basicPattern)) VerifyTilingPattern(pattern); } @@ -5406,3 +5423,4 @@ void Parser::Parse_PatternFunction(TPATTERN *New) } } +// end of namespace pov_parser diff --git a/source/parser/parser_obj.cpp b/source/parser/parser_obj.cpp index c67c5d5da..e43d68960 100644 --- a/source/parser/parser_obj.cpp +++ b/source/parser/parser_obj.cpp @@ -38,11 +38,22 @@ #if POV_PARSER_EXPERIMENTAL_OBJ_IMPORT +// C++ variants of C standard header files #include +// C++ standard header files +#include + +// POV-Ray header files (base module) +// (none at the moment) + +// POV-Ray header files (core module) #include "core/material/interior.h" #include "core/shape/mesh.h" +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -51,25 +62,28 @@ namespace pov_parser using namespace pov; +using std::max; +using std::vector; + static const int kMaxObjBufferSize = 1024; #define PAIR(c1,c2) ( ((int)(c1)) + (((int)(c2))<<8) ) #define TRIPLET(c1,c2,c3) ( ((int)(c1)) + (((int)(c2))<<8) + (((int)(c3))<<16) ) -struct FaceVertex +struct FaceVertex final { MeshIndex vertexId; MeshIndex normalId; MeshIndex uvId; }; -struct FaceData +struct FaceData final { FaceVertex vertexList[3]; MeshIndex materialId; }; -struct MaterialData +struct MaterialData final { std::string mtlName; TEXTURE *texture; @@ -574,5 +588,6 @@ void Parser::Parse_Obj (Mesh* mesh) } } +// end of namespace pov_parser #endif // POV_PARSER_EXPERIMENTAL_OBJ_IMPORT diff --git a/source/parser/parser_strings.cpp b/source/parser/parser_strings.cpp index a7de2f5f9..89c128421 100644 --- a/source/parser/parser_strings.cpp +++ b/source/parser/parser_strings.cpp @@ -41,15 +41,22 @@ #include #include +// C++ standard header files +// (none at the moment) + // Boost header files #include // POV-Ray header files (base module) +#include "base/pov_mem.h" #include "base/stringutilities.h" // POV-Ray header files (core module) #include "core/scene/scenedata.h" +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -58,23 +65,7 @@ namespace pov_parser using namespace pov; -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** char *Parser::Parse_C_String(bool pathname) { @@ -98,24 +89,7 @@ void Parser::ParseString(UTF8String& s, bool pathname) POV_FREE(str); } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_String(bool pathname, bool require) { @@ -238,9 +212,7 @@ UCS2 *Parser::Parse_String(bool pathname, bool require) return New; } - -//**************************************************************************** - +//****************************************************************************** std::string Parser::Parse_SysString(bool pathname, bool require) { @@ -250,24 +222,7 @@ std::string Parser::Parse_SysString(bool pathname, bool require) return ret; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_Str(bool pathname) { @@ -318,24 +273,7 @@ UCS2 *Parser::Parse_Str(bool pathname) return String_To_UCS2(temp4); } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_VStr(bool pathname) { @@ -417,24 +355,7 @@ UCS2 *Parser::Parse_VStr(bool pathname) return New; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_Concat(bool pathname) { @@ -465,24 +386,7 @@ UCS2 *Parser::Parse_Concat(bool pathname) return New; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_Chr(bool /*pathname*/) { @@ -501,24 +405,7 @@ UCS2 *Parser::Parse_Chr(bool /*pathname*/) return New; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** #define PARSE_NOW_VAL_LENGTH 200 @@ -596,24 +483,7 @@ UCS2 *Parser::Parse_Datetime(bool pathname) return String_To_UCS2(val); } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_Substr(bool pathname) { @@ -643,24 +513,7 @@ UCS2 *Parser::Parse_Substr(bool pathname) return New; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_Strupr(bool pathname) { @@ -676,24 +529,7 @@ UCS2 *Parser::Parse_Strupr(bool pathname) return New; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::Parse_Strlwr(bool pathname) { @@ -709,24 +545,7 @@ UCS2 *Parser::Parse_Strlwr(bool pathname) return New; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::String_To_UCS2(const char *str) { @@ -778,8 +597,7 @@ UCS2 *Parser::String_To_UCS2(const char *str) return char_string; } - -/*****************************************************************************/ +//****************************************************************************** UCS2 *Parser::String_Literal_To_UCS2(const std::string& str) { @@ -893,24 +711,7 @@ UCS2 *Parser::String_Literal_To_UCS2(const std::string& str) return char_string; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** char *Parser::UCS2_To_String(const UCS2 *str) { @@ -986,24 +787,7 @@ UCS2 *Parser::Convert_UTF8_To_UCS2(const unsigned char *text_array, int *char_ar return char_array; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** UCS2 *Parser::UCS2_strcat(UCS2 *s1, const UCS2 *s2) { @@ -1019,56 +803,7 @@ UCS2 *Parser::UCS2_strcat(UCS2 *s1, const UCS2 *s2) return s1; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ - -int Parser::UCS2_strcmp(const UCS2 *s1, const UCS2 *s2) -{ - UCS2 t1, t2; - - while((t1 = *s1++) == (t2 = *s2++)) - { - if(t1 == 0) - return 0; - } - - return (t1 - t2); -} - - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** void Parser::UCS2_strcpy(UCS2 *s1, const UCS2 *s2) { @@ -1078,24 +813,7 @@ void Parser::UCS2_strcpy(UCS2 *s1, const UCS2 *s2) *s1 = 0; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** void Parser::UCS2_strncpy(UCS2 *s1, const UCS2 *s2, int n) { @@ -1105,24 +823,7 @@ void Parser::UCS2_strncpy(UCS2 *s1, const UCS2 *s2, int n) *s1 = 0; } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** void Parser::UCS2_strupr(UCS2 *str) { @@ -1143,24 +844,7 @@ void Parser::UCS2_strupr(UCS2 *str) Warning("Non-ASCII character in string, strupr may not work as expected."); } - -/***************************************************************************** - * - * FUNCTION - * - * INPUT - * - * OUTPUT - * - * RETURNS - * - * AUTHOR - * - * DESCRIPTION - * - * CHANGES - * -******************************************************************************/ +//****************************************************************************** void Parser::UCS2_strlwr(UCS2 *str) { @@ -1191,3 +875,4 @@ UCS2 *Parser::UCS2_strdup(const UCS2 *s) } } +// end of namespace pov_parser diff --git a/source/parser/parser_tokenizer.cpp b/source/parser/parser_tokenizer.cpp index 49cb6a218..f57a605ef 100644 --- a/source/parser/parser_tokenizer.cpp +++ b/source/parser/parser_tokenizer.cpp @@ -42,18 +42,24 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "parser/parser.h" -#include +// C++ variants of C standard header files +// (none at the moment) +// C++ standard header files #include -#include +// POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/stringutilities.h" +#include "base/textstream.h" +#include "base/types.h" #include "base/version_info.h" +// POV-Ray header files (core module) #include "core/material/noise.h" #include "core/scene/scenedata.h" +// POV-Ray header files (parser module) #include "parser/scanner.h" #include "parser/rawtokenizer.h" @@ -66,6 +72,8 @@ namespace pov_parser using namespace pov_base; using namespace pov; +using std::shared_ptr; + #if POV_DEBUG unsigned int gBreakpointCounter = 0; #endif @@ -76,23 +84,7 @@ unsigned int gBreakpointCounter = 0; #define CALL(x) { if (!(x)) return (false); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Initialize_Tokenizer() { @@ -128,10 +120,8 @@ void Parser::Initialize_Tokenizer() CheckFileSignature(); } - //****************************************************************************** - void Parser::CheckFileSignature() { RawToken signature; @@ -151,24 +141,7 @@ void Parser::CheckFileSignature() } } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::pre_init_tokenizer () { @@ -192,24 +165,7 @@ void Parser::pre_init_tokenizer () MaxCachedMacroSize = POV_PARSER_MAX_CACHED_MACRO_SIZE; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Terminate_Tokenizer() { @@ -747,7 +703,6 @@ inline void Parser::Write_Token(TokenId Token_Id, const RawToken& rawToken, Symb mToken.table = table; } - //****************************************************************************** void Parser::Token_Struct::SetTokenId(const RawToken& rawToken) @@ -774,6 +729,11 @@ TokenId Parser::Token_Struct::GetCategorizedTokenId() const return mCategorizedTokenId; } +UCS2String Parser::Token_Struct::GetFileName() const +{ + return sourceFile->Name(); +} + //------------------------------------------------------------------------------ TokenId Parser::CurrentCategorizedTokenId() const @@ -912,23 +872,7 @@ bool Parser::GoToBookmark(const RawTokenizer::HotBookmark& bookmark) return true; } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** const char *Parser::Get_Token_String (TokenId Token_Id) { @@ -940,26 +884,7 @@ const char *Parser::Get_Token_String (TokenId Token_Id) return (""); } - - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** bool Parser::GetRawToken(RawToken& rawToken, bool fastForwardToDirective) { @@ -986,24 +911,7 @@ bool Parser::PeekRawToken(RawToken& rawToken) return true; } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::UngetRawToken(const RawToken& rawToken) { @@ -1743,7 +1651,7 @@ void Parser::Parse_Directive() } } -/*****************************************************************************/ +//****************************************************************************** #if POV_DEBUG void Parser::Parse_Breakpoint() @@ -1763,7 +1671,7 @@ void Parser::Parse_Breakpoint() } #endif -/*****************************************************************************/ +//****************************************************************************** void Parser::Parse_Version() { @@ -1851,23 +1759,7 @@ void Parser::Parse_Version() parsingVersionDirective = wasParsingVersionDirective; } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Open_Include() { @@ -1881,25 +1773,7 @@ void Parser::Open_Include() IncludeHeader(formalFileName); } - - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Skip_Tokens(COND_TYPE cond) { @@ -1926,24 +1800,7 @@ void Parser::Skip_Tokens(COND_TYPE cond) } } - -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::Break() { @@ -2764,8 +2621,8 @@ int Parser::Parse_Read_Value(DATA_FILE *User_File, TokenId Previous, TokenId *Nu case STRING_LITERAL_TOKEN: *NumberPtr = STRING_ID_TOKEN; Test_Redefine(Previous,NumberPtr,*DataPtr); - POV_PARSER_ASSERT(dynamic_pointer_cast(User_File->inToken.value) != nullptr); - *DataPtr = UCS2_strdup(dynamic_pointer_cast(User_File->inToken.value)->GetData().c_str()); + POV_PARSER_ASSERT(std::dynamic_pointer_cast(User_File->inToken.value) != nullptr); + *DataPtr = UCS2_strdup(std::dynamic_pointer_cast(User_File->inToken.value)->GetData().c_str()); break; default: @@ -3106,23 +2963,7 @@ int Parser::Parse_For_Param (UTF8String& identifierName, DBL* EndPtr, DBL* StepP ((*StepPtr < 0) && (*CurrentPtr > *EndPtr - EPSILON)); } -/***************************************************************************** -* -* FUNCTION -* -* INPUT -* -* OUTPUT -* -* RETURNS -* -* AUTHOR -* -* DESCRIPTION -* -* CHANGES -* -******************************************************************************/ +//****************************************************************************** void Parser::IncludeHeader(const UCS2String& formalFileName) { @@ -3147,3 +2988,4 @@ void Parser::IncludeHeader(const UCS2String& formalFileName) } } +// end of namespace pov_parser diff --git a/source/parser/parsertypes.cpp b/source/parser/parsertypes.cpp index 7e573ca4c..5bdc6aa18 100644 --- a/source/parser/parsertypes.cpp +++ b/source/parser/parsertypes.cpp @@ -43,7 +43,9 @@ // POV-Ray header files (base module) #include "base/fileinputoutput.h" +#include "base/povassert.h" +// POV-Ray header files (core module) // POV-Ray header files (parser module) // (none at the moment) @@ -129,3 +131,4 @@ InvalidEscapeSequenceException::InvalidEscapeSequenceException(const UCS2String& {} } +// end of namespace pov_parser diff --git a/source/parser/parsertypes.h b/source/parser/parsertypes.h index 0c0c719ae..4fcf84a17 100644 --- a/source/parser/parsertypes.h +++ b/source/parser/parsertypes.h @@ -40,21 +40,24 @@ #include "parser/configparser.h" // C++ variants of C standard header files +// (none at the moment) + // C++ standard header files +#include + // Boost header files // (none at the moment) // POV-Ray header files (base module) -#include "base/types.h" +#include "base/fileinputoutput_fwd.h" #include "base/messenger.h" +#include "base/stringtypes.h" // POV-Ray header files (core module) #include "core/coretypes.h" -namespace pov_base -{ -class IStream; -} +// POV-Ray header files (parser module) +// (none at the moment) namespace pov_parser { @@ -65,8 +68,8 @@ enum TokenId : int; //------------------------------------------------------------------------------ -using StreamPtr = shared_ptr; -using ConstStreamPtr = shared_ptr; +using StreamPtr = std::shared_ptr; +using ConstStreamPtr = std::shared_ptr; //------------------------------------------------------------------------------ @@ -113,7 +116,7 @@ struct TokenizerException : std::exception, MessageContext /// (`/*`) was encountered without a matching end sequence (`*/`), implying a /// broken comment or a comment nesting error. /// -struct IncompleteCommentException : TokenizerException +struct IncompleteCommentException final : TokenizerException { IncompleteCommentException(const UCS2String& osn, const LexemePosition& op); }; @@ -124,7 +127,7 @@ struct IncompleteCommentException : TokenizerException /// @ref RawTokenizer) to indicate that an unbalanced double quote (`"`) was /// encountered, implying a broken string literal. /// -struct IncompleteStringLiteralException : TokenizerException +struct IncompleteStringLiteralException final : TokenizerException { IncompleteStringLiteralException(const UCS2String& osn, const LexemePosition& op); }; @@ -136,7 +139,7 @@ struct IncompleteStringLiteralException : TokenizerException /// in the data stream does not conform to the expected character encoding /// scheme, implying a broken or malformed file. /// -struct InvalidEncodingException : TokenizerException +struct InvalidEncodingException final : TokenizerException { /// Descriptive name of the expected encoding scheme. const char* encodingName; @@ -155,7 +158,7 @@ struct InvalidEncodingException : TokenizerException /// @ref RawTokenizer) to indicate that an unexpected ASCII control character /// or non-ASCII character was encountered outside a string literal or comment. /// -struct InvalidCharacterException : TokenizerException +struct InvalidCharacterException final : TokenizerException { /// UCS code point corresponding to the unexpected character. UCS4 offendingCharacter; @@ -172,7 +175,7 @@ struct InvalidCharacterException : TokenizerException /// literal, malformed escape sequence or failure to properly escape a literal /// backslash character. /// -struct InvalidEscapeSequenceException : TokenizerException +struct InvalidEscapeSequenceException final : TokenizerException { /// Offending escape sequence, including leading escape character. UTF8String offendingText; @@ -187,13 +190,13 @@ struct InvalidEscapeSequenceException : TokenizerException /// Base class for miscellaneous things that can be assigned to a symbol. struct Assignable { - virtual ~Assignable() {} + virtual ~Assignable() = default; virtual Assignable* Clone() const = 0; }; //------------------------------------------------------------------------------ -struct ParserOptions +struct ParserOptions final { bool useClock; DBL clock; @@ -222,6 +225,25 @@ enum class CharacterEncodingID //------------------------------------------------------------------------------ -} // end of namespace +struct FileResolver +{ + virtual ~FileResolver() = default; + virtual pov_base::UCS2String FindFile(pov_base::UCS2String parsedFileName, unsigned int fileType) = 0; + virtual pov_base::IStream* ReadFile(const pov_base::UCS2String& parsedFileName, + const pov_base::UCS2String& foundFileName, unsigned int fileType) = 0; + virtual pov_base::OStream* CreateFile(const pov_base::UCS2String& parsedFileName, + unsigned int fileType, bool append) = 0; +}; + +struct ProgressReporter +{ + virtual ~ProgressReporter() = default; + virtual void ReportProgress(POV_LONG tokenCount) = 0; +}; + +//------------------------------------------------------------------------------ + +} +// end of namespace pov_parser #endif // POVRAY_PARSER_PARSERTYPES_H diff --git a/source/parser/precomp.h b/source/parser/precomp.h index a8a89c6b3..a8f5d0853 100644 --- a/source/parser/precomp.h +++ b/source/parser/precomp.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 @@ -45,8 +45,9 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -#include "parser/configparser.h" +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED +// C++ variants of C standard header files #include #include #include @@ -56,6 +57,7 @@ #include #include +// C++ standard header files #include #include #include @@ -68,13 +70,12 @@ #include #include +// Boost header files #include #include #include #include #include -#include -#include #if POV_MULTITHREADED #include #include diff --git a/source/parser/rawtokenizer.cpp b/source/parser/rawtokenizer.cpp index 40591afbd..64040782f 100644 --- a/source/parser/rawtokenizer.cpp +++ b/source/parser/rawtokenizer.cpp @@ -39,7 +39,14 @@ // C++ variants of C standard header files // C++ standard header files // Boost header files +// (none at the moment) + // POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/povassert.h" +#include "base/stringutilities.h" + +// POV-Ray header files (core module) // (none at the moment) // POV-Ray header files (parser module) @@ -68,6 +75,13 @@ static bool IsUCS4ScalarValue(UCS4 c) //****************************************************************************** +void AmbiguousStringValue::InvalidEscapeSequenceInfo::Throw() const +{ + throw InvalidEscapeSequenceException(stream->Name(), position, text); +} + +//****************************************************************************** + TokenId RawToken::GetTokenId() const { if (id <= TOKEN_COUNT) @@ -200,8 +214,8 @@ bool RawTokenizer::ProcessStringLiteralLexeme(RawToken& token) token.id = int(STRING_LITERAL_TOKEN); token.expressionId = STRING_LITERAL_TOKEN; - shared_ptr pValue(std::make_shared()); - shared_ptr pAmbiguousValue; + std::shared_ptr pValue(std::make_shared()); + std::shared_ptr pAmbiguousValue; UCS4 c; pValue->data.reserve(token.lexeme.text.size() - 2); @@ -467,3 +481,4 @@ bool RawTokenizer::GoToBookmark(const ColdBookmark& bookmark) } } +// end of namespace pov_parser diff --git a/source/parser/rawtokenizer.h b/source/parser/rawtokenizer.h index e9e42fb88..80bece576 100644 --- a/source/parser/rawtokenizer.h +++ b/source/parser/rawtokenizer.h @@ -43,10 +43,16 @@ // (none at the moment) // C++ standard header files +#include #include // Boost header files +// (none at the moment) + // POV-Ray header files (base module) +#include "base/stringtypes.h" + +// POV-Ray header files (core module) // (none at the moment) // POV-Ray header files (parser module) @@ -68,8 +74,8 @@ struct Value Value() {} }; -using ValuePtr = shared_ptr; -using ConstValuePtr = shared_ptr; +using ValuePtr = std::shared_ptr; +using ConstValuePtr = std::shared_ptr; /// Structure representing a string value. struct StringValue : Value @@ -82,9 +88,9 @@ struct StringValue : Value }; /// Structure representing a string value with backslashes. -struct AmbiguousStringValue : StringValue +struct AmbiguousStringValue final : StringValue { - struct InvalidEscapeSequenceInfo + struct InvalidEscapeSequenceInfo final { ConstStreamPtr stream; LexemePosition position; @@ -92,7 +98,7 @@ struct AmbiguousStringValue : StringValue InvalidEscapeSequenceInfo(ConstStreamPtr s, LexemePosition p, UTF8String t) : stream(s), position(p), text(t) {} InvalidEscapeSequenceInfo(ConstStreamPtr s, LexemePosition p, const UTF8String::const_iterator& b, const UTF8String::const_iterator& e) : stream(s), position(p), text(b, e) {} - void Throw() const { throw InvalidEscapeSequenceException(stream->Name(), position, text); } + void Throw() const; }; UCS2String data; @@ -100,7 +106,7 @@ struct AmbiguousStringValue : StringValue InvalidEscapeSequenceInfo* invalidEscapeSequence; AmbiguousStringValue(const StringValue& o) : data(o.GetData()), fileName(o.GetFileName()), invalidEscapeSequence(nullptr) {} AmbiguousStringValue(const AmbiguousStringValue& o) : data(o.data), fileName(o.fileName), invalidEscapeSequence(o.invalidEscapeSequence) {} - ~AmbiguousStringValue() { if (invalidEscapeSequence != nullptr) delete invalidEscapeSequence; } + virtual ~AmbiguousStringValue() override { if (invalidEscapeSequence != nullptr) delete invalidEscapeSequence; } virtual const UCS2String& GetData() const override { if (invalidEscapeSequence != nullptr) invalidEscapeSequence->Throw(); return data; } virtual const UCS2String& GetFileName() const override { return fileName; } virtual bool IsAmbiguous() const override { return true; } @@ -110,7 +116,7 @@ struct AmbiguousStringValue : StringValue //------------------------------------------------------------------------------ /// Structure representing an individual raw token. -struct RawToken +struct RawToken final { /// The original lexeme from which this raw token was created. Lexeme lexeme; @@ -182,7 +188,7 @@ struct RawToken /// In addition, literal lexemes are evaluated, converting their textual /// representation into the corresponding internal value representation. /// -class RawTokenizer +class RawTokenizer final { public: @@ -235,7 +241,7 @@ class RawTokenizer private: - struct KnownWordInfo + struct KnownWordInfo final { int id; TokenId expressionId; @@ -258,5 +264,6 @@ class RawTokenizer }; } +// end of namespace pov_parser #endif // POVRAY_PARSER_RAWTOKENIZER_H diff --git a/source/parser/reservedwords.cpp b/source/parser/reservedwords.cpp index 356cd2c42..b716600bc 100644 --- a/source/parser/reservedwords.cpp +++ b/source/parser/reservedwords.cpp @@ -38,6 +38,15 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "parser/parser.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 (core module) +// POV-Ray header files (parser module) +// (none at the moment) + // this must be the last file included #include "base/povdebug.h" @@ -751,4 +760,5 @@ TokenId GetCategorizedTokenId(TokenId tokenId) return tokenId; } -} // end of namespace pov_parser +} +// end of namespace pov_parser diff --git a/source/parser/reservedwords.h b/source/parser/reservedwords.h index 9bb1dd081..91031d49a 100644 --- a/source/parser/reservedwords.h +++ b/source/parser/reservedwords.h @@ -40,18 +40,26 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "parser/configparser.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 (core module) +// (none at the moment) + +// POV-Ray header files (parser module) #include "parser/parsertypes.h" namespace pov_parser { -typedef struct Reserved_Word_Struct RESERVED_WORD; - -struct Reserved_Word_Struct +struct Reserved_Word_Struct final { TokenId Token_Number; const char *Token_Name; }; +using RESERVED_WORD = Reserved_Word_Struct; ///< @deprecated // Token Definitions for Parser enum TokenId : int @@ -757,6 +765,7 @@ extern const RESERVED_WORD Reserved_Words[]; TokenId GetCategorizedTokenId(TokenId tokenId); -} // end of namespace pov_parser +} +// end of namespace pov_parser #endif // POVRAY_PARSER_RESERVEDWORDS_H diff --git a/source/parser/scanner.cpp b/source/parser/scanner.cpp index 0ea6da8f3..885c55fb9 100644 --- a/source/parser/scanner.cpp +++ b/source/parser/scanner.cpp @@ -49,8 +49,12 @@ // (none at the moment) // POV-Ray header files (base module) +#include "base/fileinputoutput.h" +#include "base/povassert.h" +#include "base/stringutilities.h" #include "base/textstream.h" +// POV-Ray header files (core module) // POV-Ray header files (parser module) // (none at the moment) @@ -561,6 +565,13 @@ static bool IsASCIIIdentifierChar2(Scanner::Character c) //****************************************************************************** +UCS2String Scanner::HotBookmark::GetFileName() const +{ + return pStream->Name(); +} + +//****************************************************************************** + Scanner::Buffer::Buffer() : mpEnd(maData), mpPos(maData) @@ -1469,4 +1480,5 @@ bool Scanner::IsNextCharacterIdentifierChar2() const //------------------------------------------------------------------------------ -} // end of namespace pov_parser +} +// end of namespace pov_parser diff --git a/source/parser/scanner.h b/source/parser/scanner.h index e14d1ccbc..68365cd32 100644 --- a/source/parser/scanner.h +++ b/source/parser/scanner.h @@ -44,15 +44,18 @@ // C++ standard header files #include -#include +#include // Boost header files // (none at the moment) // POV-Ray header files (base module) -#include "base/messenger.h" -#include "base/types.h" -#include "base/textstream.h" +#include "base/messenger_fwd.h" +#include "base/stringtypes.h" +#include "base/textstream_fwd.h" + +// POV-Ray header files (core module) +// (none at the moment) // POV-Ray header files (parser module) #include "parser/parsertypes.h" @@ -68,7 +71,7 @@ struct CharacterEncoding; //****************************************************************************** -struct Lexeme +struct Lexeme final { enum Category : unsigned char { @@ -116,7 +119,7 @@ struct Lexeme /// - Single octets in the range 0x00 0x7F must always encode the /// corresponding ASCII character. /// -class Scanner +class Scanner final { public: @@ -143,18 +146,18 @@ class Scanner }; /// Structure representing an open input stream and a rewindable position. - struct HotBookmark : Bookmark + struct HotBookmark final : Bookmark { StreamPtr pStream; HotBookmark() = default; HotBookmark(const StreamPtr& s, const LexemePosition& lp, CharacterEncodingPtr se, Character neol, bool anbc) : Bookmark(lp, se, neol, anbc), pStream(s) {} - virtual UCS2String GetFileName() const override { return pStream->Name(); } + virtual UCS2String GetFileName() const override; }; /// Structure representing an input stream name and a rewindable position. - struct ColdBookmark : Bookmark + struct ColdBookmark final : Bookmark { UCS2String fileName; ColdBookmark() = default; @@ -787,5 +790,6 @@ class Scanner }; } +// end of namespace pov_parser #endif // POVRAY_PARSER_SCANNER_H diff --git a/source/parser/symboltable.cpp b/source/parser/symboltable.cpp index dbeab7976..071c7acf3 100644 --- a/source/parser/symboltable.cpp +++ b/source/parser/symboltable.cpp @@ -42,6 +42,8 @@ // (none at the moment) // POV-Ray header files (base module) +#include "base/pov_mem.h" +#include "base/povassert.h" #include "base/stringutilities.h" // POV-Ray header files (core module) @@ -661,4 +663,5 @@ SymbolTable& SymbolStack::GetGlobalTable() //****************************************************************************** -} // end of namespace +} +// end of namespace pov_parser diff --git a/source/parser/symboltable.h b/source/parser/symboltable.h index bd9c08c11..de34cbb23 100644 --- a/source/parser/symboltable.h +++ b/source/parser/symboltable.h @@ -49,7 +49,10 @@ // (none at the moment) // POV-Ray header files (base module) -#include "base/types.h" +#include "base/stringtypes.h" + +// POV-Ray header files (core module) +// (none at the moment) // POV-Ray header files (parser module) #include "parser/parsertypes.h" @@ -65,7 +68,6 @@ using namespace pov_base; const int MAX_NUMBER_OF_TABLES = 100; const int SYM_TABLE_SIZE = 257; -typedef struct Sym_Table_Entry SYM_ENTRY; typedef unsigned short SymTableEntryRefCount; // Special symbol tables @@ -75,9 +77,9 @@ enum }; /// Structure holding information about a symbol -struct Sym_Table_Entry +struct Sym_Table_Entry final { - SYM_ENTRY *next; ///< Reference to next symbol with same hash + Sym_Table_Entry *next; ///< Reference to next symbol with same hash UTF8String name; ///< Symbol name char *Deprecation_Message; ///< Warning to print if the symbol is deprecated void *Data; ///< Reference to the symbol value @@ -87,10 +89,11 @@ struct Sym_Table_Entry bool deprecatedShown : 1; SymTableEntryRefCount ref_count; ///< normally 1, but may be greater when passing symbols out of macros }; +using SYM_ENTRY = Sym_Table_Entry; ///< @deprecated //------------------------------------------------------------------------------ -struct SymbolTable +struct SymbolTable final { SymbolTable(); SymbolTable(const SymbolTable& obj); @@ -137,7 +140,7 @@ using SymbolTablePtr = std::shared_ptr; //------------------------------------------------------------------------------ -class SymbolStack +class SymbolStack final { public: @@ -180,6 +183,7 @@ class SymbolStack int Table_Index; }; -} // end of namespace +} +// end of namespace pov_parser #endif // POVRAY_PARSER_SYMBOLTABLE_H diff --git a/source/povmain.cpp b/source/povmain.cpp index acf16adfd..3f296b697 100644 --- a/source/povmain.cpp +++ b/source/povmain.cpp @@ -38,13 +38,18 @@ #include +#include + // configfrontend.h must always be the first POV file included in frontend sources (pulls in platform config) #include "frontend/configfrontend.h" +// POV-Ray header files (base module) #include "base/timer.h" +// POV-Ray header files (backend module) #include "backend/povray.h" +// POV-Ray header files (frontend module) #include "frontend/console.h" #include "frontend/display.h" #include "frontend/filemessagehandler.h" @@ -63,18 +68,18 @@ class DefaultConsole : public pov_frontend::Console { public: DefaultConsole() { } - ~DefaultConsole() { } - void Initialise() { } - void Output(const string& str) { std::printf("%s\n", str.c_str()); std::fflush(stdout); } + virtual ~DefaultConsole() override { } + virtual void Initialise() override { } + virtual void Output (const string& str) override { std::printf("%s\n", str.c_str()); std::fflush(stdout); } }; class DefaultDisplay : public pov_frontend::Display { public: DefaultDisplay(unsigned int w, unsigned int h) : Display(w, h) { } - ~DefaultDisplay() { } - void Initialise() { } - void DrawPixel(unsigned int, unsigned int, const RGBA8&) { } + virtual ~DefaultDisplay() override { } + virtual void Initialise() override { } + virtual void DrawPixel (unsigned int, unsigned int, const RGBA8&) override { } }; pov_frontend::Console *CreateDefaultConsole(); diff --git a/source/povms/configpovms.h b/source/povms/configpovms.h index 0237d8512..0a3eb94b4 100644 --- a/source/povms/configpovms.h +++ b/source/povms/configpovms.h @@ -10,7 +10,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 @@ -44,6 +44,7 @@ #error "povms.c must be compiled as a C++ file when used as part of the POV-Ray project." #endif +// Pull in other compile-time config header files first #include "base/configbase.h" #include "syspovconfigpovms.h" @@ -83,7 +84,7 @@ #endif #ifndef POVMSUCS2 - #define POVMSUCS2 UCS2 + #define POVMSUCS2 char16_t #endif #ifndef kDefaultTimeout diff --git a/source/povms/povmscpp.h b/source/povms/povmscpp.h index 685437282..25ef1ab53 100644 --- a/source/povms/povmscpp.h +++ b/source/povms/povmscpp.h @@ -37,10 +37,11 @@ #ifndef POVMSCPP_H #define POVMSCPP_H +#include "povms/povms.h" // pulls in config + #include #include -#include "povms/povms.h" #include "base/pov_err.h" /// @file @@ -78,7 +79,7 @@ class POVMS_Container void DetachData(); }; -class POVMS_Attribute : public POVMS_Container +class POVMS_Attribute final : public POVMS_Container { public: POVMS_Attribute(); @@ -95,7 +96,7 @@ class POVMS_Attribute : public POVMS_Container POVMS_Attribute(std::vector& value); POVMS_Attribute(POVMSAttribute& convert); POVMS_Attribute(const POVMS_Attribute& source); - virtual ~POVMS_Attribute() noexcept(false); + virtual ~POVMS_Attribute() noexcept(false) override; POVMS_Attribute& operator=(const POVMS_Attribute& source); @@ -122,13 +123,13 @@ class POVMS_Attribute : public POVMS_Container int GetVectorSize() const; }; -class POVMS_List : public POVMS_Container +class POVMS_List final : public POVMS_Container { public: POVMS_List(); POVMS_List(POVMSAttributeList& convert); POVMS_List(const POVMS_List& source); - virtual ~POVMS_List() noexcept(false); + virtual ~POVMS_List() noexcept(false) override; POVMS_List& operator=(const POVMS_List& source); @@ -171,22 +172,22 @@ class POVMS_Object : public POVMS_Container virtual bool write(void *, int) = 0; }; - template class InputStreamT : public InputStream + template class InputStreamT final : public InputStream { public: InputStreamT(T& s) : stream(s) { } - virtual ~InputStreamT() { } - virtual bool read(void *ptr, int cnt) { return !(!stream.read(ptr, (size_t)cnt)); } + virtual ~InputStreamT() override { } + virtual bool read(void *ptr, int cnt) override { return !(!stream.read(ptr, (size_t)cnt)); } private: T& stream; }; - template class OutputStreamT : public OutputStream + template class OutputStreamT final : public OutputStream { public: OutputStreamT(T& s) : stream(s) { } - virtual ~OutputStreamT() { } - virtual bool write(void *ptr, int cnt) { return !(!stream.write(ptr, (size_t)cnt)); } + virtual ~OutputStreamT() override { } + virtual bool write(void *ptr, int cnt) override { return !(!stream.write(ptr, (size_t)cnt)); } private: T& stream; }; @@ -275,7 +276,7 @@ class POVMS_Object : public POVMS_Container void Write(OutputStream& stream, bool append, bool compress); }; -class POVMS_Message : public POVMS_Object +class POVMS_Message final : public POVMS_Object { public: POVMS_Message(); @@ -312,7 +313,7 @@ class POVMS_MessageReceiver virtual void Call(POVMSObjectPtr, POVMSObjectPtr, int) = 0; }; protected: - template class MemberHandlerOO : public HandlerOO + template class MemberHandlerOO final : public HandlerOO { public: typedef void (T::*MemberHandlerPtr)(POVMS_Message&, POVMS_Message&, int); @@ -329,7 +330,7 @@ class POVMS_MessageReceiver handlerptr = hptr; } - void Call(POVMS_Message& msg, POVMS_Message& result, int mode) + virtual void Call(POVMS_Message& msg, POVMS_Message& result, int mode) override { if ((classptr != nullptr) && (handlerptr != nullptr)) (classptr->*handlerptr)(msg, result, mode); @@ -341,7 +342,7 @@ class POVMS_MessageReceiver T *classptr; }; - template class MemberHandler : public Handler + template class MemberHandler final : public Handler { public: typedef void (T::*MemberHandlerPtr)(POVMSObjectPtr, POVMSObjectPtr, int); @@ -358,7 +359,7 @@ class POVMS_MessageReceiver handlerptr = hptr; } - void Call(POVMSObjectPtr msg, POVMSObjectPtr result, int mode) + virtual void Call(POVMSObjectPtr msg, POVMSObjectPtr result, int mode) override { if ((classptr != nullptr) && (handlerptr != nullptr)) (classptr->*handlerptr)(msg, result, mode); @@ -370,7 +371,7 @@ class POVMS_MessageReceiver T *classptr; }; - class FunctionHandlerOO : public HandlerOO + class FunctionHandlerOO final : public HandlerOO { public: typedef void (*FunctionHandlerPtr)(POVMS_Message&, POVMS_Message&, int, void *); @@ -387,7 +388,7 @@ class POVMS_MessageReceiver privatedata = pptr; } - void Call(POVMS_Message& msg, POVMS_Message& result, int mode) + virtual void Call(POVMS_Message& msg, POVMS_Message& result, int mode) override { if (handlerptr != nullptr) handlerptr(msg, result, mode, privatedata); @@ -399,7 +400,7 @@ class POVMS_MessageReceiver void *privatedata; }; - class FunctionHandler : public Handler + class FunctionHandler final : public Handler { public: typedef void (*FunctionHandlerPtr)(POVMSObjectPtr, POVMSObjectPtr, int, void *); @@ -416,7 +417,7 @@ class POVMS_MessageReceiver privatedata = pptr; } - void Call(POVMSObjectPtr msg, POVMSObjectPtr result, int mode) + virtual void Call(POVMSObjectPtr msg, POVMSObjectPtr result, int mode) override { if (handlerptr != nullptr) handlerptr(msg, result, mode, privatedata); @@ -473,7 +474,7 @@ class POVMS_MessageReceiver void Remove(POVMSType hclass, POVMSType hid); private: - struct HandlerNode + struct HandlerNode final { struct HandlerNode *last; struct HandlerNode *next; @@ -486,9 +487,9 @@ class POVMS_MessageReceiver POVMSContext context; HandlerNode *receivers; - POVMS_MessageReceiver(); // default constructor not allowed - POVMS_MessageReceiver(const POVMS_MessageReceiver&); // no copies allowed - POVMS_MessageReceiver& operator=(const POVMS_MessageReceiver&); // no copy assignments allowed + POVMS_MessageReceiver() = delete; + POVMS_MessageReceiver(const POVMS_MessageReceiver&) = delete; + POVMS_MessageReceiver& operator=(const POVMS_MessageReceiver&) = delete; static POVMSResult ReceiveHandler(POVMSObjectPtr msg, POVMSObjectPtr result, int mode, void *privatedataptr); diff --git a/source/povms/povmsutil.cpp b/source/povms/povmsutil.cpp index 8f7b5b6c1..f813509fd 100644 --- a/source/povms/povmsutil.cpp +++ b/source/povms/povmsutil.cpp @@ -10,7 +10,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 @@ -74,3 +74,4 @@ int POVMSUtil_SetFormatString(POVMSObjectPtr object, POVMSType key, const char * } } +// end of namespace pov diff --git a/source/povms/povmsutil.h b/source/povms/povmsutil.h index 1eab5687f..215700ffd 100644 --- a/source/povms/povmsutil.h +++ b/source/povms/povmsutil.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 @@ -37,7 +37,7 @@ #ifndef POV_POVMSUTIL_H #define POV_POVMSUTIL_H -#include "povms/povms.h" +#include "povms/povms.h" // pulls in config namespace pov { @@ -48,5 +48,6 @@ int Send_Progress(const char *statusString, int progressState); int Send_ProgressUpdate(int progressState, int timeDiff = 1); } +// end of namespace pov #endif // POV_POVMSUTIL_H diff --git a/source/povms/precomp.h b/source/povms/precomp.h index 1dfec67ba..9ad2a0b3e 100644 --- a/source/povms/precomp.h +++ b/source/povms/precomp.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 @@ -45,8 +45,9 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -#include "base/configbase.h" +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED +// C++ variants of C standard header files #include #include #include @@ -56,6 +57,7 @@ #include #include +// C++ standard header files #include #include #include @@ -68,16 +70,13 @@ #include #include +// Boost header files #include #include #include #include -#include -#include -#include #if POV_MULTITHREADED #include #include #endif #include - diff --git a/source/vm/configvm.h b/source/vm/configvm.h index d086f78e8..503bb3d41 100644 --- a/source/vm/configvm.h +++ b/source/vm/configvm.h @@ -10,7 +10,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,7 @@ #ifndef POVRAY_VM_CONFIGVM_H #define POVRAY_VM_CONFIGVM_H +// Pull in other compile-time config header files first #include "core/configcore.h" #include "syspovconfigvm.h" diff --git a/source/vm/fnintern.cpp b/source/vm/fnintern.cpp index 839fb77e7..c09c84cc2 100644 --- a/source/vm/fnintern.cpp +++ b/source/vm/fnintern.cpp @@ -12,7 +12,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 @@ -40,10 +40,16 @@ // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "vm/fnintern.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/mathutil.h" +// POV-Ray header files (core module) #include "core/material/noise.h" #include "core/material/pigment.h" #include "core/material/warp.h" @@ -52,6 +58,7 @@ #include "core/scene/scenedata.h" #include "core/scene/tracethreaddata.h" +// POV-Ray header files (VM module) #include "vm/fnpovfpu.h" // this must be the last file included @@ -60,6 +67,9 @@ namespace pov { +using std::max; +using std::min; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -1291,3 +1301,4 @@ void f_spline(FPUContext *ctx, DBL *ptr, unsigned int fn, unsigned int sp) // 2 } } +// end of namespace pov diff --git a/source/vm/fnintern.h b/source/vm/fnintern.h index 3b935d47a..a112841bf 100644 --- a/source/vm/fnintern.h +++ b/source/vm/fnintern.h @@ -12,7 +12,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,28 +37,37 @@ /// //****************************************************************************** -#ifndef POVRAY_BACKEND_FNINTERN_H -#define POVRAY_BACKEND_FNINTERN_H +#ifndef POVRAY_VM_FNINTERN_H +#define POVRAY_VM_FNINTERN_H // Module config header file must be the first file included within POV-Ray unit header files #include "vm/configvm.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 (core module) +// (none at the moment) + +// POV-Ray header files (VM module) +#include "vm/fnpovfpu_fwd.h" + namespace pov { -class FPUContext; - -typedef struct +struct Trap final { DBL (*fn)(FPUContext *ctx, DBL *ptr, unsigned int fn); unsigned int parameter_cnt; -} Trap; +}; -typedef struct +struct TrapS final { void (*fn)(FPUContext *ctx, DBL *ptr, unsigned int fn, unsigned int sp); unsigned int parameter_cnt; -} TrapS; +}; extern const Trap POVFPU_TrapTable[]; extern const TrapS POVFPU_TrapSTable[]; @@ -67,5 +76,6 @@ extern const unsigned int POVFPU_TrapTableSize; extern const unsigned int POVFPU_TrapSTableSize; } +// end of namespace pov -#endif // POVRAY_BACKEND_FNINTERN_H +#endif // POVRAY_VM_FNINTERN_H diff --git a/source/vm/fnpovfpu.cpp b/source/vm/fnpovfpu.cpp index 1212cd93c..3cfd68789 100644 --- a/source/vm/fnpovfpu.cpp +++ b/source/vm/fnpovfpu.cpp @@ -10,7 +10,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 @@ -231,16 +231,23 @@ Density of instruction set: 916 / 1024 = 0.8945 // Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config) #include "vm/fnpovfpu.h" +// C++ variants of C standard header files +#include #include #include #include +// C++ standard header files #include +// POV-Ray header files (base module) #include "base/mathutil.h" +#include "base/povassert.h" +// POV-Ray header files (core module) #include "core/scene/tracethreaddata.h" +// POV-Ray header files (VM module) #include "vm/fnintern.h" // this must be the last file included @@ -249,6 +256,10 @@ Density of instruction set: 916 / 1024 = 0.8945 namespace pov { +using std::min; +using std::max; +using std::vector; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -477,9 +488,9 @@ const Sys1 POVFPU_Sys1Table[] = sinh, // 6 cosh, // 7 tanh, // 8 - asinh, // 9 - acosh, // 10 - atanh, // 11 + std::asinh, // 9 + std::acosh, // 10 + std::atanh, // 11 floor, // 12 ceil, // 13 sqrt, // 14 @@ -1650,3 +1661,4 @@ FPUContext::~FPUContext() } } +// end of namespace pov diff --git a/source/vm/fnpovfpu.h b/source/vm/fnpovfpu.h index 1d71679d3..2e459a2f0 100644 --- a/source/vm/fnpovfpu.h +++ b/source/vm/fnpovfpu.h @@ -11,7 +11,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 @@ -41,19 +41,30 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "vm/configvm.h" +#include "vm/fnpovfpu_fwd.h" +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files #include #include -#include "base/textstream.h" +// Boost header files +#include + +// POV-Ray header files (base module) +#include "base/textstream_fwd.h" +// POV-Ray header files (core module) #include "core/coretypes.h" +// POV-Ray header files (VM module) +// (none at the moment) + namespace pov { -class FunctionVM; - #define MAX_CALL_STACK_SIZE 1024 #define INITIAL_DBL_STACK_SIZE 256 @@ -134,9 +145,6 @@ struct FunctionCode void *private_data; }; -typedef unsigned int FUNCTION; -typedef FUNCTION * FUNCTION_PTR; - struct FunctionEntry { FunctionCode fn; // valid if reference_count != 0 @@ -155,12 +163,12 @@ class FPUContext : public GenericFunctionContext { public: FPUContext(FunctionVM* pVm, TraceThreadData* pThreadData); - virtual ~FPUContext(); + virtual ~FPUContext() override; StackFrame *pstackbase; DBL *dblstackbase; unsigned int maxdblstacksize; - intrusive_ptr functionvm; + boost::intrusive_ptr functionvm; TraceThreadData *threaddata; #if (SYS_FUNCTIONS == 1) DBL *dblstack; @@ -257,22 +265,22 @@ class FunctionVM : public GenericFunctionContextFactory { public: CustomFunction(FunctionVM* pVm, FUNCTION_PTR pFn); - virtual ~CustomFunction(); - virtual GenericFunctionContextPtr AcquireContext(TraceThreadData* pThreadData); - virtual void ReleaseContext(GenericFunctionContextPtr pContext); - virtual void InitArguments(GenericFunctionContextPtr pContext); - virtual void PushArgument(GenericFunctionContextPtr pContext, DBL arg); - virtual DBL Execute(GenericFunctionContextPtr pContext); - virtual GenericScalarFunctionPtr Clone() const; - virtual const CustomFunctionSourceInfo* GetSourceInfo() const; + virtual ~CustomFunction() override; + virtual GenericFunctionContextPtr AcquireContext(TraceThreadData* pThreadData) override; + virtual void ReleaseContext(GenericFunctionContextPtr pContext) override; + virtual void InitArguments(GenericFunctionContextPtr pContext) override; + virtual void PushArgument(GenericFunctionContextPtr pContext, DBL arg) override; + virtual DBL Execute(GenericFunctionContextPtr pContext) override; + virtual GenericScalarFunctionPtr Clone() const override; + virtual const CustomFunctionSourceInfo* GetSourceInfo() const override; protected: - intrusive_ptr mpVm; + boost::intrusive_ptr mpVm; FUNCTION_PTR mpFn; static inline FPUContext* GetFPUContextPtr(GenericFunctionContextPtr pContext); }; FunctionVM(); - virtual ~FunctionVM(); + virtual ~FunctionVM() override; void Reset(); @@ -290,16 +298,17 @@ class FunctionVM : public GenericFunctionContextFactory FUNCTION_PTR CopyFunction(FUNCTION_PTR pK); void DestroyFunction(FUNCTION_PTR pK); - virtual GenericFunctionContextPtr CreateFunctionContext(TraceThreadData* pTd); + virtual GenericFunctionContextPtr CreateFunctionContext(TraceThreadData* pTd) override; private: - vector functions; + std::vector functions; FUNCTION nextUnreferenced; - vector globals; - vector consts; + std::vector globals; + std::vector consts; }; } +// end of namespace pov #endif // POVRAY_VM_FNPOVFPU_H diff --git a/source/vm/fnpovfpu_fwd.h b/source/vm/fnpovfpu_fwd.h new file mode 100644 index 000000000..06a58d4c9 --- /dev/null +++ b/source/vm/fnpovfpu_fwd.h @@ -0,0 +1,57 @@ +//****************************************************************************** +/// +/// @file vm/fnpovfpu_fwd.h +/// +/// Forward declarations related to the virtual machine executing render-time +/// functions. +/// +/// @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_VM_FNPOVFPU_FWD_H +#define POVRAY_VM_FNPOVFPU_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class FPUContext; +struct FunctionCode; +class FunctionVM; + +using FUNCTION = unsigned int; +using FUNCTION_PTR = FUNCTION*; + +} +// end of namespace pov + +#endif // POVRAY_VM_FNPOVFPU_FWD_H diff --git a/source/vm/precomp.h b/source/vm/precomp.h index bd882d311..46e5b0738 100644 --- a/source/vm/precomp.h +++ b/source/vm/precomp.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 @@ -45,8 +45,9 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock -#include "base/configbase.h" // for POV_MULTITHREADED setting +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED +// C++ variants of C standard header files #include #include #include @@ -56,6 +57,7 @@ #include #include +// C++ standard header files #include #include #include @@ -68,13 +70,12 @@ #include #include +// Boost header files #include #include #include #include #include -#include -#include #if POV_MULTITHREADED #include #include diff --git a/unix/configure.ac b/unix/configure.ac index 7b284720b..bf4d62fe8 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -111,7 +111,7 @@ AX_ARG_WITH([--with-openexr], [DIR], [use the OpenEXR library (in director AC_ARG_VAR([COMPILED_BY], [customize the "unofficial version" message]) AC_ARG_VAR([NON_REDISTRIBUTABLE_BUILD], [see the installation documentation]) -AC_ARG_VAR([C99_COMPATIBLE_RADIOSITY], [adapt radiosity code to non-IEEE 754 floating point, requires ISO C99 compiler and library (see octree.cpp for details)]) +AC_ARG_VAR([C99_COMPATIBLE_RADIOSITY], [adapt radiosity code to non-IEEE 754 floating point (see configcore.h for details)]) ############################################################################### @@ -654,47 +654,25 @@ AC_CHECK_DECLS([RUSAGE_SELF, RUSAGE_THREAD, RUSAGE_LWP], # gettimeofday AC_CHECK_FUNCS([gettimeofday]) -# asinh and friends (requires libm) -AC_CHECK_FUNCS([asinh], - [], - [AC_DEFINE([NEED_INVHYP], [], [Inverse hyperbolic functions.])] -) +# (Not checking for `asinh` and friends anymore, as they are mandatory as of C++11. [CLi]) -# support for non-IEEE compilers (requires libm) +# support for non-IEEE compilers +# TODO FIXME - We should actually check for existence of `int32_t` rather than size of `int` now. if test x"$C99_COMPATIBLE_RADIOSITY" != x"" || test x"$ac_cv_sizeof_int" != x"4" || test x"$ac_cv_sizeof_float" != x"4"; then - AC_CHECK_FUNCS([copysign], - [], - [AC_MSG_ERROR([ -*** Cannot find the 'copysign' function required for non-ieee platform -])] - ) + # (Not checking for `copysign` anymore as we're no longer using it. [CLi]) if test x"$C99_COMPATIBLE_RADIOSITY" = x""; then # auto-detection - AC_CHECK_FUNCS([ilogbf], - [AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [2], [See source/backend/support/octree.cpp for details.])], - [AC_CHECK_FUNCS([ilogb], - [AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [4], [See source/backend/support/octree.cpp for details.])], - [AC_CHECK_FUNCS([logbf], - [AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [1], [See source/backend/support/octree.cpp for details.])], - [AC_CHECK_FUNCS([logb], - [AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [3], [See source/backend/support/octree.cpp for details.])], - [AC_MSG_ERROR([ -*** Cannot find a 'logb' or equivalent function required for non-ieee platform -])] - )] - )] - )] - ) - else # check value of C99_COMPATIBLE_RADIOSITY and function presence + # Simply choose `frexpf`/`ldexpf` variant; C++11 requires their existence, + # and they provide maximum portability at good performance. + AC_DEFINE([C99_COMPATIBLE_RADIOSITY], [6], [See source/core/configcore.h for details.]) + else # check value of C99_COMPATIBLE_RADIOSITY + # (Not checking function presence anymore, as they are all mandatory as of C++11. [CLi]) case "$C99_COMPATIBLE_RADIOSITY" in - 1) AC_CHECK_FUNCS([logbf], [], [AC_MSG_ERROR([logbf not found])]) ;; - 2) AC_CHECK_FUNCS([ilogbf], [], [AC_MSG_ERROR([ilogbf not found])]) ;; - 3) AC_CHECK_FUNCS([logb], [], [AC_MSG_ERROR([logb not found])]) ;; - 4) AC_CHECK_FUNCS([ilogb], [], [AC_MSG_ERROR([ilogb not found])]) ;; + 1|2|3|4|5|6|7|8|9) ;; *) AC_MSG_ERROR([Unsupported C99_COMPATIBLE_RADIOSITY value]) ;; esac AC_DEFINE_UNQUOTED([C99_COMPATIBLE_RADIOSITY], [$C99_COMPATIBLE_RADIOSITY], - [See source/backend/support/octree.cpp for details.] + [See source/core/configcore.h for details.] ) fi fi @@ -736,6 +714,7 @@ if test x"$pov_compiler_vendor" = x"gnu"; then AX_TEST_COMPILER_FLAGS([-fno-enforce-eh-specs]) AX_TEST_COMPILER_FLAGS([-Wno-non-template-friend]) fi +AX_TEST_COMPILER_FLAGS([-Wsuggest-override]) # I/O restrictions. diff --git a/unix/disp.h b/unix/disp.h index b01178119..9cba70b1c 100644 --- a/unix/disp.h +++ b/unix/disp.h @@ -11,7 +11,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 @@ -39,24 +39,27 @@ #ifndef POVRAY_UNIX_DISP_H #define POVRAY_UNIX_DISP_H +#include + #include "vfe.h" namespace pov_frontend { using namespace vfe; - extern shared_ptr gDisplay; + extern std::shared_ptr gDisplay; class UnixDisplay : public vfeDisplay { public: UnixDisplay(unsigned int w, unsigned int h, vfeSession *session, bool visible) : vfeDisplay(w, h, session, visible) {}; - virtual ~UnixDisplay() {} ; - virtual void Initialise() = 0; - virtual void Close() = 0; - virtual void Show() = 0; - virtual void Hide() = 0; + virtual ~UnixDisplay() override {} ; + virtual void Initialise() override = 0; + virtual void Close() override = 0; + virtual void Show() override = 0; + virtual void Hide() override = 0; + virtual bool TakeOver(UnixDisplay *display) = 0; /** @@ -98,5 +101,6 @@ namespace pov_frontend return dynamic_cast(p) ; } } +// end of namespace pov_frontend #endif // POVRAY_UNIX_DISP_H diff --git a/unix/disp_sdl.cpp b/unix/disp_sdl.cpp index a1d8a0539..936ec5854 100644 --- a/unix/disp_sdl.cpp +++ b/unix/disp_sdl.cpp @@ -10,7 +10,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 @@ -115,7 +115,7 @@ namespace pov_frontend // allocate a new pixel counters, dropping influence of previous picture m_PxCount.clear(); // not useful, vector was created empty, just to be sure m_PxCount.reserve(width*height); // we need that, and the loop! - for(vector::iterator iter = m_PxCount.begin(); iter != m_PxCount.end(); iter++) + for(std::vector::iterator iter = m_PxCount.begin(); iter != m_PxCount.end(); iter++) (*iter) = 0; } @@ -219,7 +219,7 @@ namespace pov_frontend m_PxCount.clear(); m_PxCount.reserve(width*height); - for(vector::iterator iter = m_PxCount.begin(); iter != m_PxCount.end(); iter++) + for(std::vector::iterator iter = m_PxCount.begin(); iter != m_PxCount.end(); iter++) (*iter) = 0; m_update_rect.x = 0; @@ -516,7 +516,7 @@ namespace pov_frontend void UnixSDLDisplay::Clear() { - for(vector::iterator iter = m_PxCount.begin(); iter != m_PxCount.end(); iter++) + for(std::vector::iterator iter = m_PxCount.begin(); iter != m_PxCount.end(); iter++) (*iter) = 0; m_update_rect.x = 0; @@ -627,5 +627,6 @@ namespace pov_frontend } } +// end of namespace pov_frontend #endif /* HAVE_LIBSDL */ diff --git a/unix/disp_sdl.h b/unix/disp_sdl.h index dbbfe2742..63118ed54 100644 --- a/unix/disp_sdl.h +++ b/unix/disp_sdl.h @@ -10,7 +10,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 @@ -40,6 +40,8 @@ #ifdef HAVE_LIBSDL +#include + #include "vfe.h" #include "unixoptions.h" #include "disp.h" @@ -51,29 +53,29 @@ namespace pov_frontend using namespace vfe; using namespace vfePlatform; - class UnixSDLDisplay : public UnixDisplay + class UnixSDLDisplay final : public UnixDisplay { public: static const UnixOptionsProcessor::Option_Info Options[]; static bool Register(vfeUnixSession *session); UnixSDLDisplay(unsigned int w, unsigned int h, vfeSession *session, bool visible); - virtual ~UnixSDLDisplay(); - void Initialise(); - void Close(); - void Show(); - void Hide(); - bool TakeOver(UnixDisplay *display); - void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour); - void DrawRectangleFrame(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour); - void DrawFilledRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour); - void DrawPixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8 *colour); - void Clear(); - bool HandleEvents(); - void UpdateScreen(bool Force); - void PauseWhenDoneNotifyStart(); - bool PauseWhenDoneResumeIsRequested(); - void PauseWhenDoneNotifyEnd(); + virtual ~UnixSDLDisplay() override; + virtual void Initialise() override; + virtual void Close() override; + virtual void Show() override; + virtual void Hide() override; + virtual bool TakeOver(UnixDisplay *display) override; + virtual void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour) override; + virtual void DrawRectangleFrame(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour) override; + virtual void DrawFilledRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour) override; + virtual void DrawPixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8 *colour) override; + virtual void Clear() override; + virtual bool HandleEvents() override; + virtual void UpdateScreen(bool Force) override; + virtual void PauseWhenDoneNotifyStart() override; + virtual bool PauseWhenDoneResumeIsRequested() override; + virtual void PauseWhenDoneNotifyEnd() override; protected: /// Number of Pixels before the display is updated @@ -109,9 +111,10 @@ namespace pov_frontend SDL_Rect m_screen_rect; SDL_Rect m_update_rect; /// for mixing colors in scaled down display - vector m_PxCount; + std::vector m_PxCount; }; } +// end of namespace pov_frontend #endif /* HAVE_LIBSDL */ diff --git a/unix/disp_text.cpp b/unix/disp_text.cpp index 742fa1c34..0833487f3 100644 --- a/unix/disp_text.cpp +++ b/unix/disp_text.cpp @@ -10,7 +10,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 @@ -65,3 +65,4 @@ namespace pov_frontend //fprintf(stderr, "DrawPixel(%d,%d)\n", x, y); } } +// end of namespace pov_frontend diff --git a/unix/disp_text.h b/unix/disp_text.h index bce8af57e..64ce18515 100644 --- a/unix/disp_text.h +++ b/unix/disp_text.h @@ -10,7 +10,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 @@ -47,7 +47,7 @@ namespace pov_frontend using namespace vfe; using namespace vfePlatform; - class UnixTextDisplay : public UnixDisplay + class UnixTextDisplay final : public UnixDisplay { public: static const UnixOptionsProcessor::Option_Info Options[]; @@ -55,19 +55,20 @@ namespace pov_frontend UnixTextDisplay(unsigned int w, unsigned int h, vfeSession *session, bool visible) : UnixDisplay(w, h, session, visible) {}; - virtual ~UnixTextDisplay() {} ; - void Initialise() {}; - void Close() {}; - void Show() {}; - void Hide() {}; - bool TakeOver(UnixDisplay *display) { return false; }; - void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour); - bool HandleEvents() { return false; }; - void UpdateScreen(bool Force = false) {}; - void PauseWhenDoneNotifyStart() {}; - bool PauseWhenDoneResumeIsRequested() { return true; }; - void PauseWhenDoneNotifyEnd() {}; + virtual ~UnixTextDisplay() override {} ; + virtual void Initialise() override {}; + virtual void Close() override {}; + virtual void Show() override {}; + virtual void Hide() override {}; + virtual bool TakeOver(UnixDisplay *display) override { return false; }; + virtual void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour) override; + virtual bool HandleEvents() override { return false; }; + virtual void UpdateScreen(bool Force = false) override {}; + virtual void PauseWhenDoneNotifyStart() override {}; + virtual bool PauseWhenDoneResumeIsRequested() override { return true; }; + virtual void PauseWhenDoneNotifyEnd() override {}; }; } +// end of namespace pov_frontend #endif // POVRAY_UNIX_DISP_TEXT_H diff --git a/unix/install.txt b/unix/install.txt index c023eb753..4450db2eb 100644 --- a/unix/install.txt +++ b/unix/install.txt @@ -485,17 +485,15 @@ NON_REDISTRIBUTABLE_BUILD=yes options. Using this option means you acknowledge that the generated POV-Ray executable must *not* be redistributed. -C99_COMPATIBLE_RADIOSITY={1,2,3,4} +C99_COMPATIBLE_RADIOSITY={1,2,3,4,5,6,7,8,9} adapts the POV-Ray radiosity code to use non-IEEE 754 floating point on machines that do not support this standard. You must specify one of the possible values given above (e.g. C99_COMPATIBLE_RADIOSITY=2). - Each value corresponds to the C function 'logbf', 'ilogbf', 'logb', - and 'ilogb', respectively, to be used with the C function 'copysign'. - This option requires having an ISO C99 compiler and its accompanying - C library installed on your machine. More details are given near the - top of the octree.cpp source file. On platforms where integer ('int') - and single-precision floating-point ('float') numbers are not 32-bit, - configure will try to determine automatically which function to use. + Each value corresponds to a different implementation of certain basic + operations. More details are given in the configcore.h + source file. On platforms where integer ('int') and single-precision + floating-point ('float') numbers are not 32-bit, configure will try to + determine automatically which function to use. ================= diff --git a/unix/povconfig/syspovconfig.h b/unix/povconfig/syspovconfig.h index 079453b21..550bda809 100644 --- a/unix/povconfig/syspovconfig.h +++ b/unix/povconfig/syspovconfig.h @@ -11,7 +11,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 @@ -39,25 +39,6 @@ #ifndef POVRAY_UNIX_SYSPOVCONFIG_H #define POVRAY_UNIX_SYSPOVCONFIG_H -#define _FILE_OFFSET_BITS 64 // Required for some Unix flavors to get a 64-bit off_t type on 32-bit systems. - -// C++ variants of C standard headers -#include -#include - -// C++ standard headers -#include -#include -#include -#include -#include -#include -#include -#include - -// boost headers -#include - #ifdef HAVE_CONFIG_H // from directory "." (generated by ./configure) # include "config.h" @@ -65,49 +46,15 @@ # error "!!!!! config.h is required !!!!!" #endif -#ifdef HAVE_STDINT_H -#include "stdint.h" -#endif - -using std::max; -using std::min; - -#ifndef STD_TYPES_DECLARED -#define STD_TYPES_DECLARED - -// the following types are used extensively throughout the POV source and hence are -// included and named here for reasons of clarity and convenience. - -// when we say 'string' we mean std::string -using std::string; - -// and vector is a std::vector -using std::vector; - -// yup, list too -using std::list; - -// runtime_error is the base of our Exception class, plus is referred -// to in a few other places. -using std::runtime_error; - -// we use the C++11 standard shared pointers -using std::shared_ptr; -using std::weak_ptr; -using std::dynamic_pointer_cast; -using std::static_pointer_cast; -using std::const_pointer_cast; - -using boost::intrusive_ptr; - -#endif // STD_POV_TYPES_DECLARED +#define _FILE_OFFSET_BITS 64 // Required for some Unix flavors to get a 64-bit off_t type on 32-bit systems. -// After Stroustrup in _The C++ Programming Language, 3rd Ed_ p. 88 -#ifndef NULL -const int NULL=0; -#endif +// C++ variants of C standard headers +#include // TODO - Required for `PATH_MAX`, `_POSIX_PATH_MAX`, and `POV_ISINF()` emulated implementation. +#include // TODO - Required for `POV_ISNAN()` and `POV_ISINF()` default implementations. +#include // TODO - Required for `POV_INTn` and `POV_UINTn` default types. -#define POV_DELETE_FILE(name) unlink(name) +// C++ standard headers +#include // required for `POV_ISNAN` and `POV_ISINF` default implementations #if defined (PATH_MAX) // Use the system's actual limit if known. diff --git a/unix/povconfig/syspovconfig_bsd.h b/unix/povconfig/syspovconfig_bsd.h index df7379e22..d76ba3597 100644 --- a/unix/povconfig/syspovconfig_bsd.h +++ b/unix/povconfig/syspovconfig_bsd.h @@ -11,7 +11,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 @@ -39,29 +39,13 @@ #ifndef POVRAY_UNIX_SYSPOVCONFIG_BSD_H #define POVRAY_UNIX_SYSPOVCONFIG_BSD_H -#include +#include // Pulled in for `off_t`. +#include // Pulled in for `_POSIX_V6_xxx`. -#if defined(_POSIX_V6_LPBIG_OFFBIG) || defined(_POSIX_V6_LP64_OFF64) || defined(_POSIX_V6_ILP32_OFFBIG) - // `off_t` is at least 64 bits. - // This variant of BSD provides large file support via the `lseek` function, - // with file offsets having type `off_t`. - #define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) - #define POV_OFF_T off_t -#elif defined(_POSIX_V6_ILP32_OFF32) - // `off_t` is at least 32 bits. - // This variant of BSD does _not_ provide large file support via the `lseek` function. - // Comment-out the following line to proceed anyway. - #error "Image size will be limited to approx. 100 Megapixels. Proceed at your own risk." - #define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) - #define POV_OFF_T off_t -#else - // Unable to detect `off_t` size at compile-time. - // This variant of BSD _may or may not_ provide large file support via the `lseek` function. - // Comment-out the following line to proceed anyway - #error "Image size may be limited to approx. 100 Megapixels. Proceed at your own risk." - #define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) - #define POV_OFF_T off_t -#endif +// BSD does not seem to provide an explicit 64-bit `lseek`, so we're stuck with +// whatever size `off_t` happens to have. +#define POVUNIX_LSEEK64(h,o,w) lseek(h,o,w) +#define POV_OFF_T off_t /// @file /// @todo The POV_LONG stuff is just copied from the Posix settings; someone needs to verify universal BSD compatibility. diff --git a/unix/povconfig/syspovconfig_gnu.h b/unix/povconfig/syspovconfig_gnu.h index bd7629510..d118c1cfd 100644 --- a/unix/povconfig/syspovconfig_gnu.h +++ b/unix/povconfig/syspovconfig_gnu.h @@ -11,7 +11,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 @@ -39,11 +39,12 @@ #ifndef POVRAY_UNIX_SYSPOVCONFIG_GNU_H #define POVRAY_UNIX_SYSPOVCONFIG_GNU_H -#include +#include // Pulled in for `off64_t`. +#include // Pulled in for `_POSIX_V6_xxx`. -// GNU/Linux provides large file support via the `lseek64` function, -// with file offsets having type `off64_t`. -#define POV_LSEEK(handle,offset,whence) lseek64(handle,offset,whence) +// GNU/Linux provides large file support on all machines, via the `lseek64` +// function and `off64_t` type. (Requires `#define _FILE_OFFSET_BITS 64`.) +#define POVUNIX_LSEEK64(h,o,w) lseek64(h,o,w) #define POV_OFF_T off64_t #if defined(_POSIX_V6_LPBIG_OFFBIG) || defined(_POSIX_V6_LP64_OFF64) diff --git a/unix/povconfig/syspovconfig_osx.h b/unix/povconfig/syspovconfig_osx.h index 06500dfcc..62ac1c707 100644 --- a/unix/povconfig/syspovconfig_osx.h +++ b/unix/povconfig/syspovconfig_osx.h @@ -11,7 +11,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 @@ -39,13 +39,14 @@ #ifndef POVRAY_UNIX_SYSPOVCONFIG_OSX_H #define POVRAY_UNIX_SYSPOVCONFIG_OSX_H -#include +#include // Pulled in for `off_t`. +#include // Pulled in for `_POSIX_V6_xxx`. /// @file /// @todo Someone needs to verify that off_t is indeed always 64 bit on Mac OS X // OS X appears to provide large file support via the `lseek` function, // with file offsets having type `off_t`. -#define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) +#define POVUNIX_LSEEK64(h,o,w) lseek(h,o,w) #define POV_OFF_T off_t /// @file diff --git a/unix/povconfig/syspovconfig_posix.h b/unix/povconfig/syspovconfig_posix.h index db0b39380..be5a98a3b 100644 --- a/unix/povconfig/syspovconfig_posix.h +++ b/unix/povconfig/syspovconfig_posix.h @@ -11,7 +11,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 @@ -39,29 +39,13 @@ #ifndef POVRAY_UNIX_SYSPOVCONFIG_POSIX_H #define POVRAY_UNIX_SYSPOVCONFIG_POSIX_H -#include +#include // Pulled in for `off_t`. +#include // Pulled in for `_POSIX_V6_xxx`. -#if defined(_POSIX_V6_LPBIG_OFFBIG) || defined(_POSIX_V6_LP64_OFF64) || defined(_POSIX_V6_ILP32_OFFBIG) - // `off_t` is at least 64 bits. - // This variant of Unix provides large file support via the `lseek` function, - // with file offsets having type `off_t`. - #define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) - #define POV_OFF_T off_t -#elif defined(_POSIX_V6_ILP32_OFF32) - // `off_t` is at least 32 bits. - // This variant of Unix does _not_ provide large file support via the `lseek` function. - // Comment-out the following line to proceed anyway. - #error "Image size will be limited to approx. 100 Megapixels. Proceed at your own risk." - #define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) - #define POV_OFF_T off_t -#else - // Unable to detect `off_t` size at compile-time. - // This variant of Unix _may or may not_ provide large file support via the `lseek` function. - // Comment-out the following line to proceed anyway - #error "Image size may be limited to approx. 100 Megapixels. Proceed at your own risk." - #define POV_LSEEK(handle,offset,whence) lseek(handle,offset,whence) - #define POV_OFF_T off_t -#endif +// POSIX does not provide an explicit 64-bit `lseek`, so we're stuck with +// whatever size `off_t` happens to have. +#define POVUNIX_LSEEK64(h,o,w) lseek(h,o,w) +#define POV_OFF_T off_t #if defined(_POSIX_V6_LPBIG_OFFBIG) || defined(_POSIX_V6_LP64_OFF64) // long is at least 64 bits. diff --git a/unix/povconfig/syspovconfigbase.h b/unix/povconfig/syspovconfigbase.h index 2605730d2..30ad78f2b 100644 --- a/unix/povconfig/syspovconfigbase.h +++ b/unix/povconfig/syspovconfigbase.h @@ -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 @@ -42,7 +42,6 @@ #include "syspovconfig.h" #define POV_PATH_SEPARATOR '/' -#define IFF_SWITCH_CAST (long) // Our Unix-specific implementation of the Delay() function currently relies on the presence of // the nanosleep() or usleep() functions. If we have neither of those, we're falling back to @@ -68,4 +67,10 @@ // The default Path::ParsePathString() suits our needs perfectly. #define POV_USE_DEFAULT_PATH_PARSER 1 +// We want to implement a specialized Filesystem::DeleteFile. +#define POV_USE_DEFAULT_DELETEFILE 0 + +// We want to implement a specialized Filesystem::LargeFile. +#define POV_USE_DEFAULT_LARGEFILE 0 + #endif // POVRAY_UNIX_SYSPOVCONFIGBASE_H diff --git a/vfe/unix/unixconsole.cpp b/vfe/unix/unixconsole.cpp index 7d821f5a3..8acb6c37f 100644 --- a/vfe/unix/unixconsole.cpp +++ b/vfe/unix/unixconsole.cpp @@ -37,6 +37,10 @@ #include #include +// C++ standard header files +#include +#include + // Other library header files #include #include @@ -56,8 +60,9 @@ namespace pov_frontend { - shared_ptr gDisplay; + std::shared_ptr gDisplay; } +// end of namespace pov_frontend using namespace vfe; using namespace vfePlatform; @@ -174,7 +179,7 @@ static void PrintStatus (vfeSession *session) // TODO -- when invoked while processing "--help" command-line switch, // GNU/Linux customs would be to print to stdout (among other differences). - string str; + std::string str; vfeSession::MessageType type; static vfeSession::MessageType lastType = vfeSession::mUnclassified; @@ -303,12 +308,12 @@ static void PauseWhenDone(vfeSession *session) GetRenderWindow()->PauseWhenDoneNotifyEnd(); } -static ReturnValue PrepareBenchmark(vfeSession *session, vfeRenderOptions& opts, string& ini, string& pov, int argc, char **argv) +static ReturnValue PrepareBenchmark(vfeSession *session, vfeRenderOptions& opts, std::string& ini, std::string& pov, int argc, char **argv) { // parse command-line options while (*++argv) { - string s = string(*argv); + std::string s = std::string(*argv); boost::to_lower(s); // set number of threads to run the benchmark if (boost::starts_with(s, "+wt") || boost::starts_with(s, "-wt")) @@ -372,7 +377,7 @@ Press to continue or to abort.\n\ Delay(20); } - string basename = UCS2toSysString(session->CreateTemporaryFile()); + std::string basename = UCS2toSysString(session->CreateTemporaryFile()); ini = basename + ".ini"; pov = basename + ".pov"; if (pov::Write_Benchmark_File(pov.c_str(), ini.c_str())) @@ -390,7 +395,7 @@ Press to continue or to abort.\n\ return RETURN_OK; } -static void CleanupBenchmark(vfeUnixSession *session, string& ini, string& pov) +static void CleanupBenchmark(vfeUnixSession *session, std::string& ini, std::string& pov) { fprintf(stderr, "%s: removing %s\n", PACKAGE, ini.c_str()); session->DeleteTemporaryFile(SysToUCS2String(ini.c_str())); @@ -405,8 +410,8 @@ int main (int argc, char **argv) vfeRenderOptions opts; ReturnValue retval = RETURN_OK; bool running_benchmark = false; - string bench_ini_name; - string bench_pov_name; + std::string bench_ini_name; + std::string bench_pov_name; sigset_t sigset; boost::thread *sigthread; char ** argv_copy=argv; /* because argv is updated later */ @@ -512,7 +517,7 @@ int main (int argc, char **argv) if (running_benchmark) { // read only the provided INI file and set minimal lib paths - opts.AddLibraryPath(string(POVLIBDIR "/include")); + opts.AddLibraryPath(std::string(POVLIBDIR "/include")); opts.AddINI(bench_ini_name.c_str()); opts.SetSourceFile(bench_pov_name.c_str()); } diff --git a/vfe/unix/unixoptions.cpp b/vfe/unix/unixoptions.cpp index 7cec5d485..5a73b65b6 100644 --- a/vfe/unix/unixoptions.cpp +++ b/vfe/unix/unixoptions.cpp @@ -12,7 +12,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 @@ -44,6 +44,7 @@ // C++ standard header files #include +#include // Boost header files #include @@ -56,6 +57,8 @@ namespace vfePlatform { using std::cerr; using std::endl; + using std::string; + using std::list; extern bool gShelloutsPermittedFixThis; @@ -332,10 +335,10 @@ namespace vfePlatform nargv[nargc] = nullptr; - vector CmdVariations; + std::vector CmdVariations; boost::split(CmdVariations, (*iter).CmdOption, boost::is_any_of("|")); - for (vector::iterator iter_c = CmdVariations.begin(); iter_c != CmdVariations.end(); iter_c++) + for (std::vector::iterator iter_c = CmdVariations.begin(); iter_c != CmdVariations.end(); iter_c++) { for (int i = 1; i < nargc;) { @@ -513,7 +516,7 @@ namespace vfePlatform string UnixOptionsProcessor::CanonicalizePath(const string &path) { int i; - typedef struct { const char *match, *replace; } subst; + struct subst final { const char *match, *replace; }; const subst strings[] = { // beware: order does matter { "%INSTALLDIR%", POVLIBDIR }, { "%HOME%", m_home.c_str() }, @@ -720,7 +723,7 @@ namespace vfePlatform typedef enum { NONE, FILE_IO, SHELLOUT, PERMITTED_PATHS, UNKNOWN } SectionVal; SectionVal section; - typedef struct Section { const char *label; const SectionVal value; } Section; + struct Section final { const char *label; const SectionVal value; }; const Section sections[] = { { "" , NONE }, // init @@ -730,7 +733,7 @@ namespace vfePlatform { nullptr , UNKNOWN } // sentinel }; - typedef struct IOSettings { const char *label; const FileIO value; } IOSettings; + struct IOSettings final { const char *label; const FileIO value; }; const IOSettings io_settings[] = { { "" , IO_UNSET }, @@ -740,7 +743,7 @@ namespace vfePlatform { nullptr , IO_UNKNOWN } }; - typedef struct SHLSettings { const char *label; const ShellOut value; } SHLSettings; + struct SHLSettings final { const char *label; const ShellOut value; }; const SHLSettings shl_settings[] = { { "" , SHL_UNSET }, @@ -1227,3 +1230,4 @@ namespace vfePlatform } } +// end of namespace vfePlatform diff --git a/vfe/unix/unixoptions.h b/vfe/unix/unixoptions.h index 28099df4d..452c1a9b9 100644 --- a/vfe/unix/unixoptions.h +++ b/vfe/unix/unixoptions.h @@ -12,7 +12,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,6 @@ #include "vfe.h" #include -#include #include #include #include @@ -142,10 +141,10 @@ namespace vfePlatform /// permission path for IO restrictions settings struct UnixPath { - string str; + std::string str; bool descend, writable; - UnixPath(const string &s, bool desc = false, bool wrt = false) : str(s), descend(desc), writable(wrt) { } + UnixPath(const std::string &s, bool desc = false, bool wrt = false) : str(s), descend(desc), writable(wrt) { } }; /** @@ -155,11 +154,11 @@ namespace vfePlatform */ struct Conf_Option { - string Section; - string Name; - string Value; + std::string Section; + std::string Name; + std::string Value; - Conf_Option(const string &Sect, const string &Nm, const string &Val = "") : Section(Sect), Name(Nm), Value(Val) { } + Conf_Option(const std::string &Sect, const std::string &Nm, const std::string &Val = "") : Section(Sect), Name(Nm), Value(Val) { } }; /** @@ -174,21 +173,21 @@ namespace vfePlatform */ struct Option_Info { - string Section; - string Name; - string Value; - string CmdOption; - string EnvVariable; - string Comment; + std::string Section; + std::string Name; + std::string Value; + std::string CmdOption; + std::string EnvVariable; + std::string Comment; bool has_param; - Option_Info(const string &Sect , - const string &Nm, - const string &Val = "", - bool par = false, - const string &Cmd = "", - const string &Env = "", - const string &Comm = "") + Option_Info(const std::string &Sect , + const std::string &Nm, + const std::string &Val = "", + bool par = false, + const std::string &Cmd = "", + const std::string &Env = "", + const std::string &Comm = "") : Section(Sect), Name(Nm), Value(Val), has_param(par), CmdOption(Cmd), EnvVariable(Env), Comment(Comm) { } /// only checks identity of the option, not of the selected value. @@ -223,7 +222,7 @@ namespace vfePlatform Converts a file path to standard form replacing relative notations. */ - string CanonicalizePath(const string &path); + std::string CanonicalizePath(const std::string &path); /** Finds out the default location for temporary files. @@ -231,7 +230,7 @@ namespace vfePlatform @returns temporary path including a trailing slash */ - string GetTemporaryPath(void); + std::string GetTemporaryPath(void); /** Finds the value of a certain option from @@ -249,7 +248,7 @@ namespace vfePlatform section and option name and returns it as a string. */ - string QueryOptionString(const string §ion, const string &name); + std::string QueryOptionString(const std::string §ion, const std::string &name); /** Finds the value of a certain option via @@ -257,7 +256,7 @@ namespace vfePlatform an int. If the options value is not convertible to int dflt is returned instead. */ - int QueryOptionInt(const string §ion, const string &name, const int dflt = 0); + int QueryOptionInt(const std::string §ion, const std::string &name, const int dflt = 0); /** Finds the value of a certain option via @@ -265,7 +264,7 @@ namespace vfePlatform a float If the options value is not convertible to float dflt is returned instead. */ - float QueryOptionFloat(const string §ion, const string &name, const float dflt = 0.0); + float QueryOptionFloat(const std::string §ion, const std::string &name, const float dflt = 0.0); /** Check if a certain option has been set @@ -275,7 +274,7 @@ namespace vfePlatform @returns true if set, false otherwise */ bool isOptionSet(const Option_Info &option); - bool isOptionSet(const string §ion, const string &name); + bool isOptionSet(const std::string §ion, const std::string &name); /** Adds the custom povray.conf options with their values @@ -315,39 +314,40 @@ namespace vfePlatform @param write If write acccess was requested @param is_user_setting if denial was due to user setting */ - void IORestrictionsError(const string &fnm, bool write, bool is_user_setting); + void IORestrictionsError(const std::string &fnm, bool write, bool is_user_setting); - bool ShelloutPermitted(const string& command, const string& parameters) const { return m_shellout == SHL_ALLOWED; } + bool ShelloutPermitted(const std::string& command, const std::string& parameters) const { return m_shellout == SHL_ALLOWED; } protected: /// list of standard options static const Option_Info Standard_Options[]; - string unix_getcwd(void); - string basename(const string &path); - string dirname(const string &path); - string unix_readlink(const string &path); - string pre_process_conf_line(const string &input); - void add_permitted_path(list &paths, const string &input, const string &conf_name, unsigned long line_number); - void parse_conf_file(std::istream &Stream, const string &conf_name, bool user_mode); + std::string unix_getcwd(void); + std::string basename(const std::string &path); + std::string dirname(const std::string &path); + std::string unix_readlink(const std::string &path); + std::string pre_process_conf_line(const std::string &input); + void add_permitted_path(std::list &paths, const std::string &input, const std::string &conf_name, unsigned long line_number); + void parse_conf_file(std::istream &Stream, const std::string &conf_name, bool user_mode); void process_povray_conf(void); void remove_arg(int *argc, char *argv[], int index); - bool file_exist(const string &name); + bool file_exist(const std::string &name); vfeSession *m_Session; - string m_home; - string m_user_dir; - string m_sysconf; // system conf filename - string m_userconf; // user conf filename - string m_conf; // selected conf file - string m_sysini, m_sysini_old; // system ini filename - string m_userini, m_userini_old; // user ini filename + std::string m_home; + std::string m_user_dir; + std::string m_sysconf; // system conf filename + std::string m_userconf; // user conf filename + std::string m_conf; // selected conf file + std::string m_sysini, m_sysini_old; // system ini filename + std::string m_userini, m_userini_old; // user ini filename FileIO m_file_io; ShellOut m_shellout; - list m_permitted_paths; - list m_custom_conf_options; - list m_user_options; + std::list m_permitted_paths; + std::list m_custom_conf_options; + std::list m_user_options; }; } +// end of namespace vfePlatform #endif // POVRAY_VFE_UNIX_UNIXOPTIONS_H diff --git a/vfe/unix/vfeplatform.cpp b/vfe/unix/vfeplatform.cpp index 828270c58..daf1382d9 100644 --- a/vfe/unix/vfeplatform.cpp +++ b/vfe/unix/vfeplatform.cpp @@ -38,7 +38,7 @@ // must come first, will pull in "config.h" for HAVE_* macros #include "syspovconfig.h" -// C++ variants of C standard headers +// C++ variants of C standard header files #include #include #include @@ -46,7 +46,11 @@ # include #endif -// other library headers +// C++ standard header files +#include +#include + +// other library header files #include #ifdef HAVE_SYS_TIME_H # include @@ -59,6 +63,9 @@ #include "vfe.h" #include "unix/unixoptions.h" +#include "base/filesystem.h" +#include "syspovfilesystem.h" + namespace vfePlatform { using namespace vfe; @@ -80,7 +87,8 @@ namespace vfePlatform vfeUnixSession::vfeUnixSession(int id) : m_LastTimestamp(0), m_TimestampOffset(0), vfeSession(id) { - m_OptionsProc = shared_ptr(new UnixOptionsProcessor(this)); + m_OptionsProc = std::shared_ptr(new UnixOptionsProcessor(this)); + pov_base::Filesystem::SetTempFilePath(SysToUCS2String(m_OptionsProc->GetTemporaryPath())); } ///////////////////////////////////////////////////////////////////////// @@ -122,7 +130,7 @@ namespace vfePlatform // error will occur again (e.g. invalid output path or something), then // you may want to call the render cancel API so the user isn't bombarded // with an error message for each frame of the render. - int vfeUnixSession::RequestNewOutputPath(int CallCount, const string& Reason, const UCS2String& OldPath, UCS2String& NewPath) + int vfeUnixSession::RequestNewOutputPath(int CallCount, const std::string& Reason, const UCS2String& OldPath, UCS2String& NewPath) { // TODO: print warning and cancel? return 0; @@ -146,12 +154,9 @@ namespace vfePlatform // name to one that it can use. UCS2String vfeUnixSession::CreateTemporaryFile(void) const { - // TODO FIXME - This allows only one temporary file per process! - char str [POV_FILENAME_BUFFER_CHARS+1] = ""; - std::snprintf(str, sizeof(str), "%spov%d", m_OptionsProc->GetTemporaryPath().c_str(), getpid ()); - POV_DELETE_FILE (str); - - return SysToUCS2String(str); + pov_base::Filesystem::TemporaryFilePtr tempFile(new pov_base::Filesystem::TemporaryFile); + m_TempFiles.push_back(tempFile); + return tempFile->GetFileName(); } ///////////////////////////////////////////////////////////////////////// @@ -160,7 +165,7 @@ namespace vfePlatform // example doesn't do that but it's not a bad idea to add. void vfeUnixSession::DeleteTemporaryFile(const UCS2String& filename) const { - POV_DELETE_FILE (UCS2toSysString (filename).c_str()); + pov_base::Filesystem::DeleteFile(filename); } ////////////////////////////////////////////////////////////// @@ -268,8 +273,8 @@ namespace vfePlatform if (StrCompare(path.GetVolume(), file.GetVolume()) == false) return (false); - vector pc = path.GetAllFolders(); - vector fc = file.GetAllFolders(); + std::vector pc = path.GetAllFolders(); + std::vector fc = file.GetAllFolders(); if (fc.size() < pc.size()) return (false) ; for (int i = 0 ; i < pc.size(); i++) @@ -289,7 +294,7 @@ namespace vfePlatform if (!m_OptionsProc->isIORestrictionsEnabled(isWrite)) return true; - string FullFnm = m_OptionsProc->CanonicalizePath(UCS2toSysString(file())); + std::string FullFnm = m_OptionsProc->CanonicalizePath(UCS2toSysString(file())); if(FullFnm.length() == 0) return false; @@ -333,7 +338,7 @@ namespace vfePlatform // on the requirements for these methods. ///////////////////////////////////////////////////////////////////////////// - UnixShelloutProcessing::UnixShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height): ShelloutProcessing(opts, scene, width, height) + UnixShelloutProcessing::UnixShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height): ShelloutProcessing(opts, scene, width, height) { m_ProcessRunning = false; m_ProcessId = m_LastError = m_ExitCode = 0; @@ -346,7 +351,7 @@ namespace vfePlatform CollectCommand(); } - bool UnixShelloutProcessing::ExecuteCommand(const string& cmd, const string& params) + bool UnixShelloutProcessing::ExecuteCommand(const std::string& cmd, const std::string& params) { #if 0 if (UnixShelloutProcessing::CommandRunning()) @@ -365,7 +370,7 @@ namespace vfePlatform m_Params = params; m_ProcessId = m_LastError = m_ExitCode = 0; - string command = cmd + " " + params; + std::string command = cmd + " " + params; boost::trim(command); if (command.empty()) throw POV_EXCEPTION(kParamErr, "Empty shellout command"); @@ -420,19 +425,20 @@ namespace vfePlatform return m_ExitCode; } - int UnixShelloutProcessing::CollectCommand(string& output) + int UnixShelloutProcessing::CollectCommand(std::string& output) { // TODO: IMPLEMENT IF OUTPUT COLLECTION TO BE SUPPORTED return CollectCommand(); } - bool UnixShelloutProcessing::CommandPermitted(const string& command, const string& parameters) + bool UnixShelloutProcessing::CommandPermitted(const std::string& command, const std::string& parameters) { // until we get a unix support guy, this is just a hack: use a global - string cmd = command + " " + parameters; + std::string cmd = command + " " + parameters; boost::trim(cmd); if (command.empty() || *command.rbegin() == '&') return false; return gShelloutsPermittedFixThis; } } +// end of namespace vfePlatform diff --git a/vfe/unix/vfeplatform.h b/vfe/unix/vfeplatform.h index 866370dd7..0be3da362 100644 --- a/vfe/unix/vfeplatform.h +++ b/vfe/unix/vfeplatform.h @@ -38,10 +38,13 @@ #ifndef POVRAY_VFE_UNIX_VFEPLATFORM_H #define POVRAY_VFE_UNIX_VFEPLATFORM_H +#include + #include -#include "base/path.h" -#include "base/stringutilities.h" +#include "base/path_fwd.h" +#include "base/stringtypes.h" +#include "base/filesystem_fwd.h" #include "frontend/shelloutprocessing.h" @@ -57,29 +60,30 @@ namespace vfePlatform class UnixShelloutProcessing: public pov_frontend::ShelloutProcessing { public: - UnixShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height); - virtual ~UnixShelloutProcessing(); + UnixShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height); + virtual ~UnixShelloutProcessing() override; - virtual int ProcessID(void); - virtual bool ShelloutsSupported(void) { return true; } + virtual int ProcessID(void) override; + virtual bool ShelloutsSupported(void) override { 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); + virtual bool ExecuteCommand(const std::string& cmd, const std::string& params) override; + virtual bool KillCommand(int timeout, bool force = false) override; + virtual bool CommandRunning(void) override; + virtual int CollectCommand(std::string& output) override; + virtual int CollectCommand(void) override; + virtual bool CommandPermitted(const std::string& command, const std::string& parameters) override; bool m_ProcessRunning; - string m_Command; - string m_Params; + std::string m_Command; + std::string m_Params; unsigned long m_ExitCode; unsigned long m_LastError; unsigned long m_ProcessId; private: - UnixShelloutProcessing(); + + UnixShelloutProcessing() = delete; }; /////////////////////////////////////////////////////////////////////// @@ -89,23 +93,23 @@ namespace vfePlatform { 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) + virtual ~vfeUnixSession() override {} + + virtual UCS2String GetTemporaryPath(void) const override; + virtual UCS2String CreateTemporaryFile(void) const override; + virtual void DeleteTemporaryFile(const UCS2String& filename) const override; + virtual POV_LONG GetTimestamp(void) const override; + virtual void NotifyCriticalError(const char *message, const char *file, int line) override; + virtual int RequestNewOutputPath(int CallCount, const std::string& Reason, const UCS2String& OldPath, UCS2String& NewPath) override; + virtual bool TestAccessAllowed(const Path& file, bool isWrite) const override; + virtual ShelloutProcessing *CreateShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height) override { return new UnixShelloutProcessing(opts, scene, width, height); } - shared_ptr GetUnixOptions(void) { return m_OptionsProc; } + std::shared_ptr GetUnixOptions(void) { return m_OptionsProc; } protected: - virtual void WorkerThreadStartup(); - virtual void WorkerThreadShutdown(); + virtual void WorkerThreadStartup() override; + virtual void WorkerThreadShutdown() override; /////////////////////////////////////////////////////////////////////// // return true if the path component of file is equal to the path component @@ -127,7 +131,10 @@ namespace vfePlatform mutable POV_LONG m_TimestampOffset; // platform specific configuration options - shared_ptr m_OptionsProc; + std::shared_ptr m_OptionsProc; + + // Temporary files to be deleted when session closes. + mutable std::vector m_TempFiles; } ; /////////////////////////////////////////////////////////////////////// @@ -135,5 +142,6 @@ namespace vfePlatform // all other running threads in the process (and preferably in the OS). POVMS_Sys_Thread_Type GetThreadId(); } +// end of namespace vfePlatform #endif // POVRAY_VFE_UNIX_VFEPLATFORM_H diff --git a/vfe/vfe.cpp b/vfe/vfe.cpp index 5c3811d28..ab97f6336 100644 --- a/vfe/vfe.cpp +++ b/vfe/vfe.cpp @@ -45,6 +45,10 @@ #include #include +#include "base/filesystem.h" +#include "base/povassert.h" +#include "base/textstream.h" + #include "frontend/animationprocessing.h" #include "frontend/imageprocessing.h" @@ -57,11 +61,12 @@ namespace vfe using namespace pov_base; using namespace pov_frontend; using boost::format; +using std::shared_ptr; +using std::string; static int Allow_File_Read(const UCS2 *Filename, const unsigned int FileType); static int Allow_File_Write(const UCS2 *Filename, const unsigned int FileType); static FILE *vfeFOpen(const UCS2String& name, const char *mode); -static bool vfeRemove(const UCS2String& name); //////////////////////////////////////////////////////////////////////////////////////// // @@ -132,7 +137,7 @@ class ParseWarningDetails : public POVMSMessageDetails { public: ParseWarningDetails (POVMS_Object &Obj) : POVMSMessageDetails (Obj) {} ; - virtual ~ParseWarningDetails () {} ; + virtual ~ParseWarningDetails () override {} ; public: using POVMSMessageDetails::File ; @@ -147,7 +152,7 @@ class ParseErrorDetails : public POVMSMessageDetails { public: ParseErrorDetails (POVMS_Object &Obj) : POVMSMessageDetails (Obj) {} ; - virtual ~ParseErrorDetails () {} ; + virtual ~ParseErrorDetails () override {} ; public: using POVMSMessageDetails::File ; @@ -264,11 +269,6 @@ FILE* vfePlatformBase::OpenLocalFile (const UCS2String& name, const char *mode) return vfeFOpen (name, mode); } -void vfePlatformBase::DeleteLocalFile (const UCS2String& name) -{ - vfeRemove (name); -} - bool vfePlatformBase::AllowLocalFileAccess (const UCS2String& name, const unsigned int fileType, bool write) { if (write) @@ -1412,10 +1412,5 @@ FILE *vfeFOpen (const UCS2String& name, const char *mode) return (fopen (UCS2toSysString (name).c_str(), mode)) ; } -bool vfeRemove(const UCS2String& Filename) -{ - return (POV_DELETE_FILE (UCS2toSysString (Filename).c_str()) == 0); -} - } - +// end of namespace vfe diff --git a/vfe/vfe.h b/vfe/vfe.h index f3ca10708..92602a650 100644 --- a/vfe/vfe.h +++ b/vfe/vfe.h @@ -10,7 +10,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 @@ -38,18 +38,20 @@ #ifndef POVRAY_VFE_VFE_H #define POVRAY_VFE_VFE_H -#include +#include +#include #include #include #include -#include "povms/povmscpp.h" -#include "povms/povmsid.h" - #include "base/platformbase.h" +#include "base/stringtypes.h" #include "base/timer.h" +#include "povms/povmscpp.h" +#include "povms/povmsid.h" + #include "frontend/console.h" #include "frontend/display.h" #include "frontend/filemessagehandler.h" @@ -68,46 +70,46 @@ namespace vfe { using namespace pov_frontend; - class vfeException : public runtime_error + class vfeException : public std::runtime_error { public: - vfeException() : runtime_error("") {} - vfeException(const string str) : runtime_error(str) {} - virtual ~vfeException() throw() {} + vfeException() : std::runtime_error("") {} + vfeException(const std::string str) : std::runtime_error(str) {} + virtual ~vfeException() throw() override {} } ; class vfeCriticalError : public vfeException { public: vfeCriticalError() : m_Line(0), vfeException() {} - vfeCriticalError(const string str) : m_Line(0), vfeException(str) {} - vfeCriticalError(const string str, const string filename, int line) : + vfeCriticalError(const std::string str) : m_Line(0), vfeException(str) {} + vfeCriticalError(const std::string str, const std::string filename, int line) : vfeException(str), m_Filename(filename), m_Line(line) {} - virtual ~vfeCriticalError() throw() {} + virtual ~vfeCriticalError() throw() override {} - const string Filename() { return m_Filename; } + const std::string Filename() { return m_Filename; } int Line() { return m_Line; } - const string m_Filename; + const std::string m_Filename; const int m_Line; }; class vfeInvalidDataError : public vfeCriticalError { public: - vfeInvalidDataError(const string str) : vfeCriticalError(str) {} - virtual ~vfeInvalidDataError() throw() {} + vfeInvalidDataError(const std::string str) : vfeCriticalError(str) {} + virtual ~vfeInvalidDataError() throw() override {} }; class vfeConsole : public Console { public: vfeConsole(vfeSession *session, int width = -1); - virtual ~vfeConsole(); + virtual ~vfeConsole() override; - virtual void Initialise(); - virtual void Output(const string&); - virtual void Output(const string&, vfeSession::MessageType mType); + virtual void Initialise() override; + virtual void Output(const std::string&) override; + virtual void Output(const std::string&, vfeSession::MessageType mType); virtual void Output(const char *str, vfeSession::MessageType mType = vfeSession::mUnclassified); virtual void BufferOutput(const char *str, unsigned int chars = 0, vfeSession::MessageType mType = vfeSession::mUnclassified); @@ -123,15 +125,14 @@ namespace vfe public: vfePlatformBase(); vfePlatformBase(vfeSession& session); - virtual ~vfePlatformBase(); + virtual ~vfePlatformBase() override; - virtual UCS2String GetTemporaryPath(void); - virtual UCS2String CreateTemporaryFile(void); - virtual void DeleteTemporaryFile(const UCS2String& filename); - virtual bool ReadFileFromURL(OStream *file, const UCS2String& url, const UCS2String& referrer = UCS2String()); - virtual FILE* OpenLocalFile (const UCS2String& name, const char *mode); - virtual void DeleteLocalFile (const UCS2String& name); - virtual bool AllowLocalFileAccess (const UCS2String& name, const unsigned int fileType, bool write); + virtual UCS2String GetTemporaryPath() override; + virtual UCS2String CreateTemporaryFile() override; + virtual void DeleteTemporaryFile(const UCS2String& name) override; + virtual bool ReadFileFromURL(OStream *file, const UCS2String& url, const UCS2String& referrer = UCS2String()) override; + virtual FILE* OpenLocalFile (const UCS2String& name, const char *mode) override; + virtual bool AllowLocalFileAccess (const UCS2String& name, const unsigned int fileType, bool write) override; protected: vfeSession* m_Session; @@ -141,16 +142,16 @@ namespace vfe { public: vfeParserMessageHandler(); - virtual ~vfeParserMessageHandler(); + virtual ~vfeParserMessageHandler() override; protected: - virtual void Options(Console *, POVMS_Object&, bool); - virtual void Statistics(Console *, POVMS_Object&, bool); - virtual void Progress(Console *, POVMS_Object&, bool); - virtual void Warning(Console *, POVMS_Object&, bool); - virtual void Error(Console *, POVMS_Object&, bool); - virtual void FatalError(Console *, POVMS_Object&, bool); - virtual void DebugInfo(Console *, POVMS_Object&, bool); + virtual void Options(Console *, POVMS_Object&, bool) override; + virtual void Statistics(Console *, POVMS_Object&, bool) override; + virtual void Progress(Console *, POVMS_Object&, bool) override; + virtual void Warning(Console *, POVMS_Object&, bool) override; + virtual void Error(Console *, POVMS_Object&, bool) override; + virtual void FatalError(Console *, POVMS_Object&, bool) override; + virtual void DebugInfo(Console *, POVMS_Object&, bool) override; vfeSession* m_Session; }; @@ -159,15 +160,15 @@ namespace vfe { public: vfeRenderMessageHandler(); - virtual ~vfeRenderMessageHandler(); + virtual ~vfeRenderMessageHandler() override; protected: - virtual void Options(Console *, POVMS_Object&, bool); - virtual void Statistics(Console *, POVMS_Object&, bool); - virtual void Progress(Console *, POVMS_Object&, bool); - virtual void Warning(Console *, POVMS_Object&, bool); - virtual void Error(Console *, POVMS_Object&, bool); - virtual void FatalError(Console *, POVMS_Object&, bool); + virtual void Options(Console *, POVMS_Object&, bool) override; + virtual void Statistics(Console *, POVMS_Object&, bool) override; + virtual void Progress(Console *, POVMS_Object&, bool) override; + virtual void Warning(Console *, POVMS_Object&, bool) override; + virtual void Error(Console *, POVMS_Object&, bool) override; + virtual void FatalError(Console *, POVMS_Object&, bool) override; vfeSession *m_Session; }; @@ -176,18 +177,18 @@ namespace vfe { public: vfeProcessRenderOptions(vfeSession *); - virtual ~vfeProcessRenderOptions(); + virtual ~vfeProcessRenderOptions() override; protected: - virtual int ReadSpecialOptionHandler(INI_Parser_Table *, char *, POVMSObjectPtr); - virtual int ReadSpecialSwitchHandler(Cmd_Parser_Table *, char *, POVMSObjectPtr, bool); - virtual int WriteSpecialOptionHandler(INI_Parser_Table *, POVMSObjectPtr, OTextStream *); - virtual int ProcessUnknownString(char *, POVMSObjectPtr); - virtual ITextStream *OpenFileForRead(const char *, POVMSObjectPtr); - virtual OTextStream *OpenFileForWrite(const char *, POVMSObjectPtr); - virtual void ParseError (const char *, ...); - virtual void ParseErrorAt (ITextStream *, const char *, ...); - virtual void WriteError (const char *, ...); + virtual int ReadSpecialOptionHandler(INI_Parser_Table *, char *, POVMSObjectPtr) override; + virtual int ReadSpecialSwitchHandler(Cmd_Parser_Table *, char *, POVMSObjectPtr, bool) override; + virtual int WriteSpecialOptionHandler(INI_Parser_Table *, POVMSObjectPtr, OTextStream *) override; + virtual int ProcessUnknownString(char *, POVMSObjectPtr) override; + virtual ITextStream *OpenFileForRead(const char *, POVMSObjectPtr) override; + virtual OTextStream *OpenFileForWrite(const char *, POVMSObjectPtr) override; + virtual void ParseError (const char *, ...) override; + virtual void ParseErrorAt (ITextStream *, const char *, ...) override; + virtual void WriteError (const char *, ...) override; protected: vfeSession* m_Session; @@ -197,41 +198,41 @@ namespace vfe { public: vfeDisplay(unsigned int width, unsigned int height, vfeSession *session, bool visible = false); - virtual ~vfeDisplay(); + virtual ~vfeDisplay() override; - virtual void Initialise(); + virtual void Initialise() override; virtual void Close(); virtual void Show(); virtual void Hide(); - virtual void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour); - virtual void DrawRectangleFrame(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour); - virtual void DrawFilledRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour); - virtual void DrawPixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8 *colour); - virtual void Clear(); + virtual void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour) override; + virtual void DrawRectangleFrame(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour) override; + virtual void DrawFilledRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour) override; + virtual void DrawPixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8 *colour) override; + virtual void Clear() override; protected: vfeSession *m_Session; - vector m_Pixels; + std::vector m_Pixels; bool m_VisibleOnCreation; }; class VirtualFrontEnd { public: - VirtualFrontEnd(vfeSession& session, POVMSContext ctx, POVMSAddress addr, POVMS_Object& msg, POVMS_Object *result, shared_ptr& console) ; - virtual ~VirtualFrontEnd() ; - - virtual bool Start(POVMS_Object& opts) ; - virtual bool Stop() ; - virtual bool Pause() ; - virtual bool Resume() ; - virtual State Process() ; + VirtualFrontEnd(vfeSession& session, POVMSContext ctx, POVMSAddress addr, POVMS_Object& msg, POVMS_Object *result, std::shared_ptr& console) ; + virtual ~VirtualFrontEnd(); + + virtual bool Start(POVMS_Object& opts); + virtual bool Stop(); + virtual bool Pause(); + virtual bool Resume(); + virtual State Process(); virtual State GetState() const { return state; } - virtual void SetResultPointers(Console **cr, Image **ir, Display **dr) ; - virtual bool IsPausable() ; - virtual bool Paused() ; + virtual void SetResultPointers(Console **cr, Image **ir, Display **dr); + virtual bool IsPausable(); + virtual bool Paused(); virtual bool PausePending() { return m_PauseRequested; } - virtual shared_ptr GetDisplay() { return renderFrontend.GetDisplay(viewId); } + virtual std::shared_ptr GetDisplay() { return renderFrontend.GetDisplay(viewId); } // TODO: take care of any pending messages (e.g. a thread waiting on a blocking send) virtual void InvalidateBackend() { backendAddress = POVMSInvalidAddress; } @@ -249,9 +250,9 @@ namespace vfe POVMS_Object options; RenderFrontendBase::SceneId sceneId; RenderFrontendBase::ViewId viewId; - shared_ptr animationProcessing ; - shared_ptr imageProcessing ; - shared_ptr shelloutProcessing; + std::shared_ptr animationProcessing ; + std::shared_ptr imageProcessing ; + std::shared_ptr shelloutProcessing; Console **consoleResult; Display **displayResult; vfeSession* m_Session; @@ -261,5 +262,6 @@ namespace vfe State m_PostPauseState; }; } +// end of namespace vfe #endif // POVRAY_VFE_VFE_H diff --git a/vfe/vfeconf.h b/vfe/vfeconf.h index 5f6641691..fbb906130 100644 --- a/vfe/vfeconf.h +++ b/vfe/vfeconf.h @@ -10,7 +10,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,25 +44,22 @@ #define POVMS_Sys_Thread_Type unsigned long -#include -#include - namespace vfe { - typedef class SysQNode POVMS_Sys_QueueNode ; - void* /*POVMSAddress*/ vfe_POVMS_Sys_QueueToAddress (POVMS_Sys_QueueNode *q) ; - POVMS_Sys_QueueNode *vfe_POVMS_Sys_AddressToQueue (void* /*POVMSAddress*/ a) ; - POVMS_Sys_QueueNode *vfe_POVMS_Sys_QueueOpen (void) ; - void vfe_POVMS_Sys_QueueClose (POVMS_Sys_QueueNode *q) ; - void *vfe_POVMS_Sys_QueueReceive (POVMS_Sys_QueueNode *q, int *l, bool, bool) ; - int vfe_POVMS_Sys_QueueSend(POVMS_Sys_QueueNode *q, void *p, int l) ; + class SysQNode; + void* /*POVMSAddress*/ vfe_POVMS_Sys_QueueToAddress (SysQNode *q) ; + SysQNode *vfe_POVMS_Sys_AddressToQueue (void* /*POVMSAddress*/ a) ; + SysQNode *vfe_POVMS_Sys_QueueOpen (void) ; + void vfe_POVMS_Sys_QueueClose (SysQNode *q) ; + void *vfe_POVMS_Sys_QueueReceive (SysQNode *q, int *l, bool, bool) ; + int vfe_POVMS_Sys_QueueSend(SysQNode *q, void *p, int l) ; POVMS_Sys_Thread_Type POVMS_GetCurrentThread(); void vfeAssert (const char *message, const char *filename, int line) ; } +// end of namespace vfe #define POVMS_ASSERT_OUTPUT vfe::vfeAssert -#define POVMS_Sys_Queue_Type vfe::POVMS_Sys_QueueNode * -#define POVMS_Sys_Queue_Type vfe::POVMS_Sys_QueueNode * +#define POVMS_Sys_Queue_Type vfe::SysQNode * #define POVMS_Sys_QueueToAddress vfe::vfe_POVMS_Sys_QueueToAddress #define POVMS_Sys_AddressToQueue vfe::vfe_POVMS_Sys_AddressToQueue #define POVMS_Sys_QueueOpen vfe::vfe_POVMS_Sys_QueueOpen diff --git a/vfe/vfecontrol.cpp b/vfe/vfecontrol.cpp index 91531aeae..3ce97a46f 100644 --- a/vfe/vfecontrol.cpp +++ b/vfe/vfecontrol.cpp @@ -37,6 +37,8 @@ #include +#include + #include "vfe.h" /***************************************************************************************/ @@ -49,6 +51,7 @@ namespace pov_frontend extern struct ProcessOptions::INI_Parser_Table RenderOptions_INI_Table[]; extern struct ProcessRenderOptions::Output_FileType_Table FileTypeTable[]; } +// end of namespace pov_frontend static struct pov_frontend::ProcessOptions::INI_Parser_Table *GetPT(const char *OptionName) { @@ -132,7 +135,7 @@ int vfeSession::CancelRender() return (m_LastError = vfeNoError); } -bool vfeSession::StopRender(const string& reason) +bool vfeSession::StopRender(const std::string& reason) { if (m_Frontend->GetState() <= kReady) return true; @@ -233,7 +236,7 @@ int vfeSession::SetOptions (vfeRenderOptions& opts) m_InputFilename = opts.m_SourceFile; // most likely povray.ini will be the first INI file processed here (as it's included by default) - for (vector::iterator i = opts.m_IniFiles.begin(); i != opts.m_IniFiles.end(); i++) + for (std::vector::iterator i = opts.m_IniFiles.begin(); i != opts.m_IniFiles.end(); i++) { // we call TestAccessAllowed() here, even though ParseFile() will do it also, since if // access is denied, the reason will not be obvious (ParseFile() just returns kCannotOpenFileErr). @@ -260,7 +263,7 @@ int vfeSession::SetOptions (vfeRenderOptions& opts) } // any source file set on the command-line overrides a source file set another way - for (vector::iterator i = opts.m_Commands.begin(); i != opts.m_Commands.end(); i++) + for (std::vector::iterator i = opts.m_Commands.begin(); i != opts.m_Commands.end(); i++) { if ((err = options.ParseString (i->c_str(), &obj)) != kNoErr) return (m_LastError = vfeFailedToParseCommand) ; @@ -311,7 +314,7 @@ int vfeSession::SetOptions (vfeRenderOptions& opts) if (opts.m_LibraryPaths.empty() == false) { - for (vector::const_iterator i = opts.m_LibraryPaths.begin(); i != opts.m_LibraryPaths.end(); i++) + for (std::vector::const_iterator i = opts.m_LibraryPaths.begin(); i != opts.m_LibraryPaths.end(); i++) { Path path(*i); @@ -323,7 +326,7 @@ int vfeSession::SetOptions (vfeRenderOptions& opts) if (libpaths.empty() == false) { POVMS_List pathlist; - for (list::iterator i = libpaths.begin(); i != libpaths.end(); i++) + for (std::list::iterator i = libpaths.begin(); i != libpaths.end(); i++) { POVMS_Attribute attr((*i)().c_str()); pathlist.Append(attr); @@ -532,3 +535,4 @@ int vfeSession::StartRender() } } +// end of namespace vfe diff --git a/vfe/vfedisplay.cpp b/vfe/vfedisplay.cpp index fdf59bc4d..4bdb74c24 100644 --- a/vfe/vfedisplay.cpp +++ b/vfe/vfedisplay.cpp @@ -10,7 +10,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 @@ -35,7 +35,6 @@ /// //****************************************************************************** -#include "backend/frame.h" #include "vfe.h" // this must be the last file included @@ -106,3 +105,4 @@ void vfeDisplay::Clear() } } +// end of namespace vfe diff --git a/vfe/vfepovms.cpp b/vfe/vfepovms.cpp index 18af608cc..00061106a 100644 --- a/vfe/vfepovms.cpp +++ b/vfe/vfepovms.cpp @@ -10,7 +10,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 @@ -57,12 +57,12 @@ class SysQNode void *Receive (int *pLen, bool Blocking) ; private: - typedef struct _DataNode + struct DataNode final { unsigned int Len; void *Data; - _DataNode *Next; - } DataNode ; + DataNode *Next; + }; unsigned int m_Sanity ; unsigned int m_Count ; @@ -253,3 +253,4 @@ POVMS_Sys_Thread_Type POVMS_GetCurrentThread (void) } } +// end of namespace vfe diff --git a/vfe/vfepovms.h b/vfe/vfepovms.h index f4d96f3a4..e46124863 100644 --- a/vfe/vfepovms.h +++ b/vfe/vfepovms.h @@ -10,7 +10,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,22 +38,26 @@ #ifndef POVRAY_VFE_VFEPOVMS_H #define POVRAY_VFE_VFEPOVMS_H +#include "base/stringtypes.h" +#include "povms/povmscpp.h" + namespace vfe { bool POVMS_Init (void); void POVMS_Shutdown (void); } +// end of namespace vfe //////////////////////////////////////////////////////////////////////////////////////// // templates to turn a type into a POVMS typeid. note not all POVMS types are supported. //////////////////////////////////////////////////////////////////////////////////////// -template struct GetPOVMSTypeID { enum { type_id = 0 } ; } ; -template<> struct GetPOVMSTypeID { enum { type_id = kPOVMSType_Bool } ; } ; -template<> struct GetPOVMSTypeID { enum { type_id = kPOVMSType_Int } ; } ; -template<> struct GetPOVMSTypeID { enum { type_id = kPOVMSType_Long } ; } ; -template<> struct GetPOVMSTypeID { enum { type_id = kPOVMSType_Float } ; } ; -template<> struct GetPOVMSTypeID { enum { type_id = kPOVMSType_CString } ; } ; -template<> struct GetPOVMSTypeID { enum { type_id = kPOVMSType_UCS2String } ; } ; +template struct GetPOVMSTypeID final { enum { type_id = 0 } ; } ; +template<> struct GetPOVMSTypeID final { enum { type_id = kPOVMSType_Bool } ; } ; +template<> struct GetPOVMSTypeID final { enum { type_id = kPOVMSType_Int } ; } ; +template<> struct GetPOVMSTypeID final { enum { type_id = kPOVMSType_Long } ; } ; +template<> struct GetPOVMSTypeID final { enum { type_id = kPOVMSType_Float } ; } ; +template<> struct GetPOVMSTypeID final { enum { type_id = kPOVMSType_CString } ; } ; +template<> struct GetPOVMSTypeID final { enum { type_id = kPOVMSType_UCS2String } ; } ; #endif // POVRAY_VFE_VFEPOVMS_H diff --git a/vfe/vfeprecomp.h b/vfe/vfeprecomp.h index 1c30d6001..6aa72d4eb 100644 --- a/vfe/vfeprecomp.h +++ b/vfe/vfeprecomp.h @@ -1,61 +1,79 @@ -//****************************************************************************** -/// -/// @file vfe/vfeprecomp.h -/// -/// Precompiled header for the user interface portions of POV-Ray. -/// -/// @copyright -/// @parblock -/// -/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2017 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 -/// -//****************************************************************************** - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +//****************************************************************************** +/// +/// @file vfe/vfeprecomp.h +/// +/// Precompiled header for the user interface portions of POV-Ray. +/// +/// @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 +/// +//****************************************************************************** + +/// @file +/// @note +/// @parblock +/// This header file is _not_ explicitly included in any source file (except @ref vfe/vfeprecomp.cpp +/// which is designed to allow for precompiling this header in the first place). To use +/// precompiled headers, you will therefore have to make your build environment automatically +/// inject this header at the start of every source file. +/// +/// The rationale behind this is to keep the set of headers included in each source file at an +/// absolute minimum when precompiled headers are _not_ used. +/// @endparblock + +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED + +// C++ variants of C standard header files +#include +#include +#include +#include +#include +#include +#include +#include + +// C++ standard header files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Boost header files +#include +#include +#include +#if POV_MULTITHREADED +#include +#endif \ No newline at end of file diff --git a/vfe/vfesession.cpp b/vfe/vfesession.cpp index 9d8f4a638..e857812dd 100644 --- a/vfe/vfesession.cpp +++ b/vfe/vfesession.cpp @@ -51,10 +51,15 @@ namespace pov static volatile POVMSAddress RenderThreadAddr = POVMSInvalidAddress ; static volatile POVMSAddress GUIThreadAddr = POVMSInvalidAddress ; } +// end of namespace pov namespace vfe { +using std::min; +using std::max; +using std::string; + bool vfeSession::m_Initialized = false; vfeSession *vfeSession::m_CurrentSessionTemporaryHack = nullptr; @@ -373,7 +378,7 @@ bool vfeSession::GetNextCombinedMessage (MessageType &Type, string& Message) // from the aforementioned queues; whichever is the earliest. Returns false // if there is no message to fetch, otherwise will set the message type, // filename, line, and column parameters supplied. If the message retrieved -// did not contain this information, the relevent entry is either set to 0 +// did not contain this information, the relevant entry is either set to 0 // (line and column) or the empty string (filename). The filename parameter // is a UCS2String. bool vfeSession::GetNextNonStatusMessage (MessageType &Type, string& Message, UCS2String& File, int& Line, int& Col) @@ -419,7 +424,7 @@ bool vfeSession::GetNextNonStatusMessage (MessageType &Type, string& Message, UC // from the aforementioned queues; whichever is the earliest. Returns false // if there is no message to fetch, otherwise will set the message type, // filename, line, and column parameters supplied. If the message retrieved -// did not contain this information, the relevent entry is either set to 0 +// did not contain this information, the relevant entry is either set to 0 // (line and column) or the empty string (filename). The filename parameter // is a std::string. bool vfeSession::GetNextNonStatusMessage (MessageType &Type, string& Message, string& File, int& Line, int& Col) @@ -544,10 +549,10 @@ const char *vfeSession::GetBackendStateName (void) const // Returns a copy of the shared pointer containing the current instance // of a pov_frontend::Display-derived render preview instance, which may // be `nullptr`. -shared_ptr vfeSession::GetDisplay() const +std::shared_ptr vfeSession::GetDisplay() const { if (m_Frontend == nullptr) - return (shared_ptr()); + return (std::shared_ptr()); return m_Frontend->GetDisplay(); } @@ -585,7 +590,7 @@ void vfeSession::WorkerThread() m_BackendThread = povray_init (boost::bind(&vfeSession::BackendThreadNotify, this), const_cast(&pov::RenderThreadAddr)) ; POVMS_Output_Context = pov::POVMS_GUI_Context ; - m_Console = shared_ptr (new vfeConsole(this, m_ConsoleWidth)) ; + m_Console = std::shared_ptr (new vfeConsole(this, m_ConsoleWidth)) ; POVMS_Object obj ; m_Frontend = new VirtualFrontEnd (*this, POVMS_Output_Context, (POVMSAddress) pov::RenderThreadAddr, obj, nullptr, m_Console); @@ -1101,3 +1106,4 @@ int vfeSession::Initialize(vfeDestInfo *Dest, vfeAuthInfo *Auth) } } +// end of namespace vfe diff --git a/vfe/vfesession.h b/vfe/vfesession.h index 023c33f9a..67edc574d 100644 --- a/vfe/vfesession.h +++ b/vfe/vfesession.h @@ -39,17 +39,22 @@ #ifndef POVRAY_VFE_VFESESSION_H #define POVRAY_VFE_VFESESSION_H +#include #include +#include #include #include +#include "base/stringutilities.h" + #include "frontend/simplefrontend.h" namespace pov_frontend { class Display; } +// end of namespace pov_frontend namespace vfe { @@ -71,7 +76,7 @@ namespace vfe IOPath(const Path& path, bool recursive) : m_Path(path), m_Recursive(recursive) {} // construct an IOPath given a std::string path and a recursion flag. - IOPath(const string& path, bool recursive) : m_Path(Path(SysToUCS2String(path))), m_Recursive(recursive) {} + IOPath(const std::string& path, bool recursive) : m_Path(Path(SysToUCS2String(path))), m_Recursive(recursive) {} // construct an IOPath given a UCS2String Path and a recursion flag. IOPath(const UCS2String& path, bool recursive) : m_Path(path), m_Recursive(recursive) {} @@ -90,9 +95,9 @@ namespace vfe } ; // convenience typedefs. - typedef vector StringVector; - typedef vector UCS2StringVector; - typedef vector IOPathVector; + typedef std::vector StringVector; + typedef std::vector UCS2StringVector; + typedef std::vector IOPathVector; class vfeDisplay; class VirtualFrontEnd; @@ -150,7 +155,7 @@ namespace vfe void ClearLibraryPaths() { m_LibraryPaths.clear(); } // Add a library path given a std::string. - void AddLibraryPath(const string& Path) { m_LibraryPaths.push_back(SysToUCS2String(Path)); } + void AddLibraryPath(const std::string& Path) { m_LibraryPaths.push_back(SysToUCS2String(Path)); } // Add a library path given a UCS2String. void AddLibraryPath(const UCS2String& Path) { m_LibraryPaths.push_back(Path); } @@ -171,7 +176,7 @@ namespace vfe // Set the source file to be parsed (must be an SDL file, INI not // permitted). The file is specified as a std::string full or relative // path, with optional extension. - void SetSourceFile(const string& File) { m_SourceFile = SysToUCS2String(File); } + void SetSourceFile(const std::string& File) { m_SourceFile = SysToUCS2String(File); } // Returns a const reference to the currently set source file (may be // an empty string). Return type is a const reference to a UCS2String. @@ -183,7 +188,7 @@ namespace vfe // Adds the supplied std::string to the list of INI files to be read // prior to the start of the render. The files are processed in the // order in which they are added to this list. - void AddINI(const string& File) { m_IniFiles.push_back(SysToUCS2String(File)); } + void AddINI(const std::string& File) { m_IniFiles.push_back(SysToUCS2String(File)); } // Adds the supplied UCS2String to the list of INI files to be read // prior to the start of the render. The files are processed in the @@ -201,7 +206,7 @@ namespace vfe // Sets the number of threads to be used for rendering (and potentially // for bounding and similar tasks, if this is supported in the future). // Clipped to the range 1..512. - void SetThreadCount(int Count) { m_ThreadCount = max(1, min(Count, 512)); } + void SetThreadCount(int Count) { m_ThreadCount = std::max(1, std::min(Count, 512)); } // Gets the number of threads currently set to be used for renders. // Defaults to 2. @@ -215,14 +220,14 @@ namespace vfe // order in which they appear in this list. A 'command' in this context // is basically anything that could normally appear on the command-line // of a POV-Ray console compile. - void AddCommand(const string& Command) { m_Commands.push_back(Command); } + void AddCommand(const std::string& Command) { m_Commands.push_back(Command); } - // Returns a const reference to a vector containing the + // Returns a const reference to a std::vector containing the // current list of commands as added by AddCommand(), in order first // to last. const StringVector& GetCommands() const { return m_Commands; } - // Returns a copy of the vector which holds the current + // Returns a copy of the std::vector which holds the current // list of commands as added by AddCommand(), in order first to last. StringVector GetCommands() { return m_Commands; } @@ -383,13 +388,13 @@ namespace vfe public: MessageBase(const vfeSession& session) : m_Id(session.GetID()), m_TimeStamp (session.GetTimestamp()), m_Type(mUnclassified) {} - MessageBase(const vfeSession& session, MessageType type, string msg = "") : + MessageBase(const vfeSession& session, MessageType type, std::string msg = "") : m_Id(session.GetID()), m_TimeStamp (session.GetTimestamp()), m_Type(type), m_Message(msg) {} virtual ~MessageBase() {} POV_LONG m_TimeStamp; MessageType m_Type; - string m_Message; + std::string m_Message; int m_Id; } ; @@ -403,9 +408,9 @@ namespace vfe public: GenericMessage(const vfeSession& session) : MessageBase(session), m_Line(0), m_Col(0) {} - GenericMessage(const vfeSession& session, MessageType type, string msg, const UCS2String file = UCS2String(), int line = 0, int col = 0) : + GenericMessage(const vfeSession& session, MessageType type, std::string msg, const UCS2String file = UCS2String(), int line = 0, int col = 0) : MessageBase (session, type, msg), m_Filename(file), m_Line(line), m_Col(col) {} - virtual ~GenericMessage() {} + virtual ~GenericMessage() override {} int m_Line; int m_Col; @@ -429,11 +434,11 @@ namespace vfe public: StatusMessage(const vfeSession& session) : MessageBase(session), m_Delay(0), m_Frame(0), m_TotalFrames(0), m_FrameId(0) {} - StatusMessage(const vfeSession& session, string msg, int m_Delay) : + StatusMessage(const vfeSession& session, std::string msg, int m_Delay) : MessageBase(session, mGenericStatus, msg), m_Delay(m_Delay), m_Frame(0), m_TotalFrames(0), m_FrameId(0) {} StatusMessage(const vfeSession& session, const UCS2String& file, int frame, int totalframes, int frameId) : MessageBase(session, mAnimationStatus), m_Delay(0), m_Filename(file), m_Frame(frame), m_TotalFrames(totalframes), m_FrameId(frameId) {} - virtual ~StatusMessage() {} + virtual ~StatusMessage() override {} int m_Delay; int m_Frame; @@ -528,7 +533,7 @@ namespace vfe // Returns a copy of the shared pointer containing the current instance // of a pov_frontend::Display-derived render preview instance, which may // be `nullptr`. - virtual shared_ptr GetDisplay() const; + virtual std::shared_ptr GetDisplay() const; // If a VFE implementation has provided a display creator functor via // vfeSession::SetDisplayCreator(), this method will call it with the @@ -912,7 +917,7 @@ namespace vfe // any additional meta-information the message may have had, such as the // line number of an error. (Note that this does not mean the line number // cannot be in the message string; it may very well be). - virtual bool GetNextCombinedMessage (MessageType &Type, string& Message); + virtual bool GetNextCombinedMessage (MessageType &Type, std::string& Message); // Gets the next non-status message (meaning generic or console messages) // from the aforementioned queues; whichever is the earliest. Returns false @@ -921,7 +926,7 @@ namespace vfe // did not contain this information, the relevent entry is either set to 0 // (line and column) or the empty string (filename). The filename parameter // is a UCS2String. - virtual bool GetNextNonStatusMessage (MessageType &Type, string& Message, UCS2String& File, int& Line, int& Col); + virtual bool GetNextNonStatusMessage (MessageType &Type, std::string& Message, UCS2String& File, int& Line, int& Col); // Gets the next non-status message (meaning generic or console messages) // from the aforementioned queues; whichever is the earliest. Returns false @@ -930,14 +935,14 @@ namespace vfe // did not contain this information, the relevent entry is either set to 0 // (line and column) or the empty string (filename). The filename parameter // is a std::string. - virtual bool GetNextNonStatusMessage (MessageType &Type, string& Message, string& File, int& Line, int& Col); + virtual bool GetNextNonStatusMessage (MessageType &Type, std::string& Message, std::string& File, int& Line, int& Col); // Gets the next non-status message (meaning generic or console messages) // from the aforementioned queues; whichever is the earliest. Returns false // if there is no message to fetch, otherwise will set the message type // and text content parameters supplied. Any additional meta-information // that may have been contained in the message is discarded. - virtual bool GetNextNonStatusMessage (MessageType &Type, string& Message); + virtual bool GetNextNonStatusMessage (MessageType &Type, std::string& Message); // Returns false if there are no messages in the status message // queue, otherwise removes the oldest status message from the @@ -964,7 +969,7 @@ namespace vfe // event notification, as appropriate. Upon receiving either of the above // events therefore you may like to simply call this method and place the // returned value wherever suitable, overwriting the previous value.2 - virtual string GetStatusLineMessage() { return m_StatusLineMessage; } + virtual std::string GetStatusLineMessage() { return m_StatusLineMessage; } // Sets the maximum number of status messages that will be stored in the // status queue. If this limit is reached, the oldest message will be @@ -999,7 +1004,7 @@ namespace vfe // Allows you to manually set the console wrap width. // The supplied value is clipped to the range 80-999. - virtual void SetConsoleWidth(int width) { m_ConsoleWidth = max(min(999,width),80); } + virtual void SetConsoleWidth(int width) { m_ConsoleWidth = std::max(std::min(999,width),80); } // Return the current console wrap width. virtual int GetConsoleWidth(void) { return m_ConsoleWidth; } @@ -1020,7 +1025,7 @@ namespace vfe // Adds the supplied path to the list of allowed read paths, along with // the recursive flag (meaning paths under that path are also allowed). // The supplied path is a std::string. - virtual void AddReadPath(const string& path, bool recursive = true) { m_ReadPaths.push_back(IOPath(path, recursive)); } + virtual void AddReadPath(const std::string& path, bool recursive = true) { m_ReadPaths.push_back(IOPath(path, recursive)); } // Adds the supplied path to the list of allowed read paths. // The supplied path is a pre-constructed IOPath instance. @@ -1039,7 +1044,7 @@ namespace vfe // Adds the supplied path to the list of allowed write paths, along with // the recursive flag (meaning paths under that path are also allowed). // The supplied path is a std::string. - virtual void AddWritePath(const string& path, bool recursive = true) { m_WritePaths.push_back(IOPath(path, recursive)); } + virtual void AddWritePath(const std::string& path, bool recursive = true) { m_WritePaths.push_back(IOPath(path, recursive)); } // Adds the supplied path to the list of allowed write paths. // The supplied path is a pre-constructed IOPath instance. @@ -1062,7 +1067,7 @@ namespace vfe // Adds the supplied path to the list of excluded paths, along with the // recursion flag. The supplied path is a std::string. - virtual void AddExcludedPath(const string& path, bool recursive = true) { m_ExcludedPaths.push_back(IOPath(path, recursive)); } + virtual void AddExcludedPath(const std::string& path, bool recursive = true) { m_ExcludedPaths.push_back(IOPath(path, recursive)); } // Adds the supplied path to the list of excluded paths, along with the // recursion flag. The supplied path is a pre-constructed IOPath instance. @@ -1102,12 +1107,12 @@ namespace vfe // state changs to rendering. virtual POV_LONG GetElapsedTime() { return GetTimestamp() - m_StartTime; } - virtual void AppendErrorMessage (const string& Msg); - virtual void AppendWarningMessage (const string& Msg); - virtual void AppendStatusMessage (const string& Msg, int RecommendedPause = 0); + virtual void AppendErrorMessage (const std::string& Msg); + virtual void AppendWarningMessage (const std::string& Msg); + virtual void AppendStatusMessage (const std::string& Msg, int RecommendedPause = 0); virtual void AppendStatusMessage (const boost::format& fmt, int RecommendedPause = 0); - virtual void AppendWarningAndStatusMessage (const string& Msg, int RecommendedPause = 0) { AppendWarningMessage(Msg); AppendStatusMessage(Msg, RecommendedPause); } - virtual void AppendErrorAndStatusMessage (const string& Msg, int RecommendedPause = 0) { AppendErrorMessage(Msg); AppendStatusMessage(Msg, RecommendedPause); } + virtual void AppendWarningAndStatusMessage (const std::string& Msg, int RecommendedPause = 0) { AppendWarningMessage(Msg); AppendStatusMessage(Msg, RecommendedPause); } + virtual void AppendErrorAndStatusMessage (const std::string& Msg, int RecommendedPause = 0) { AppendErrorMessage(Msg); AppendStatusMessage(Msg, RecommendedPause); } // returns true if a render cancel was requested at some point since the render started. virtual bool GetCancelRequested() { return m_RenderCancelRequested | m_RenderCancelled ; } @@ -1127,8 +1132,8 @@ namespace vfe virtual void AppendStreamMessage (MessageType type, const char *message, bool chompLF = false); virtual void AppendStreamMessage (MessageType type, const boost::format& fmt, bool chompLF = false); - virtual void AppendErrorMessage (const string& Msg, const UCS2String& File, int Line = 0, int Col = 0); - virtual void AppendWarningMessage (const string& Msg, const UCS2String& File, int Line = 0, int Col = 0); + virtual void AppendErrorMessage (const std::string& Msg, const UCS2String& File, int Line = 0, int Col = 0); + virtual void AppendWarningMessage (const std::string& Msg, const UCS2String& File, int Line = 0, int Col = 0); virtual void AppendAnimationStatus (int FrameId, int SubsetFrame, int SubsetTotal, const UCS2String& Filename); virtual void SetUsingAlpha() { m_UsingAlpha = true ; } @@ -1143,7 +1148,7 @@ namespace vfe virtual bool ProcessFrontend (void); virtual bool ProcessCancelRender(void); - virtual bool StopRender(const string& reason); + virtual bool StopRender(const std::string& reason); // This method allows your platform code to perform platform-specific actions // when a render stops (whether it succeeds or fails). A good example would @@ -1205,11 +1210,11 @@ namespace vfe // NB this method is pure virtual. // // NOTE: The code to call this method isn't implemented in vfe yet. - virtual int RequestNewOutputPath(int CallCount, const string& Reason, const UCS2String& OldPath, UCS2String& NewPath) = 0; + virtual int RequestNewOutputPath(int CallCount, const std::string& Reason, const UCS2String& OldPath, UCS2String& NewPath) = 0; // Create an instance of the frontend ShelloutProcessing class. this handles creating and // managing render shellout commands, and typically will need platform-specific implementation. - virtual ShelloutProcessing *CreateShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height) { return new ShelloutProcessing(opts, scene, width, height); } + virtual ShelloutProcessing *CreateShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height) { return new ShelloutProcessing(opts, scene, width, height); } struct vfeSessionWorker { @@ -1254,7 +1259,7 @@ namespace vfe static bool m_Initialized; static vfeSession *m_CurrentSessionTemporaryHack; - shared_ptr m_Console; + std::shared_ptr m_Console; virtual vfeDisplay *DefaultDisplayCreator (unsigned int width, unsigned int height, vfeSession *session, bool visible); DisplayCreator m_DisplayCreator; @@ -1265,7 +1270,7 @@ namespace vfe GenericQueue m_MessageQueue; StatusQueue m_StatusQueue; ConsoleQueue m_ConsoleQueue; - string m_StatusLineMessage; + std::string m_StatusLineMessage; UCS2String m_OutputFilename; UCS2String m_InputFilename; IOPathVector m_ReadPaths; @@ -1293,5 +1298,6 @@ namespace vfe volatile int m_RequestResult; } ; } +// end of namespace vfe #endif // POVRAY_VFE_VFESESSION_H diff --git a/vfe/win/console/winconsole.cpp b/vfe/win/console/winconsole.cpp index 59c4b8269..5546828bf 100644 --- a/vfe/win/console/winconsole.cpp +++ b/vfe/win/console/winconsole.cpp @@ -10,7 +10,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 @@ -56,6 +56,7 @@ namespace pov_frontend bool MinimizeShellouts(void) { return false; } // TODO bool ShelloutsPermitted(void) { return false; } // TODO } +// end of namespace pov_frontend void PrintStatus (vfeSession *session) diff --git a/vfe/win/syspovimage.h b/vfe/win/syspovimage.h index 7f2d568ed..a81cb1794 100644 --- a/vfe/win/syspovimage.h +++ b/vfe/win/syspovimage.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,6 +36,8 @@ #ifndef POVRAY_VFE_WIN_SYSPOVIMAGE_H #define POVRAY_VFE_WIN_SYSPOVIMAGE_H +#include "base/image/image_fwd.h" + #ifdef POV_VIDCAP_IMPL namespace pov { @@ -45,7 +47,7 @@ public: VideoCaptureImpl(); ~VideoCaptureImpl(); - Image *Init(const char *params, Image::ReadOptions& options, bool doubleBuffer); + pov_base::Image *Init(const char *params, pov_base::ImageReadOptions& options, bool doubleBuffer); void UpdateImage(); bool WaitFrame(int count, unsigned int timeout); @@ -54,6 +56,7 @@ int m_WaitFrames; }; } + // end of namespace pov #endif // POV_VIDCAP_IMPL #endif // POVRAY_VFE_WIN_SYSPOVIMAGE_H diff --git a/vfe/win/vfeplatform.cpp b/vfe/win/vfeplatform.cpp index d81569554..38ba09b2f 100644 --- a/vfe/win/vfeplatform.cpp +++ b/vfe/win/vfeplatform.cpp @@ -35,9 +35,14 @@ /// //****************************************************************************** +#include + +#include #include #include "vfe.h" +#include "base/filesystem.h" +#include "base/stringtypes.h" #include @@ -46,6 +51,7 @@ namespace pov_frontend bool MinimizeShellouts(void); bool ShelloutsPermitted(void); } +// end of namespace pov_frontend namespace vfePlatform { @@ -72,16 +78,9 @@ namespace vfePlatform // if we fail to creat our temp dir, just use the default one if ((CreateDirectory(str, nullptr) == 0) && (GetLastError() != ERROR_ALREADY_EXISTS)) GetTempPath (sizeof (str), str); - m_TempPath = Path(str); m_TempPathString = str; } - vfeWinSession::~vfeWinSession() - { - for (vector::const_iterator it = m_TempFilenames.begin(); it != m_TempFilenames.end(); it++) - DeleteFile(it->c_str()); - } - void vfeWinSession::Clear(bool Notify) { m_ReadFiles.clear(); @@ -132,7 +131,7 @@ namespace vfePlatform // error will occur again (e.g. invalid output path or something), then // you may want to call the render cancel API so the user isn't bombarded // with an error message for each frame of the render. - int vfeWinSession::RequestNewOutputPath(int CallCount, const string& Reason, const UCS2String& OldPath, UCS2String& NewPath) + int vfeWinSession::RequestNewOutputPath(int CallCount, const std::string& Reason, const UCS2String& OldPath, UCS2String& NewPath) { // TODO return 0; @@ -145,8 +144,10 @@ namespace vfePlatform ///////////////////////////////////////////////////////////////////////// // return an absolute path including trailing path separator. // *nix platforms might want to just return "/tmp/" here. + // (NB This implementation actually returns UTF-16.) UCS2String vfeWinSession::GetTemporaryPath(void) const { +// return m_TempPathString; return SysToUCS2String(m_TempPathString); } @@ -156,12 +157,9 @@ namespace vfePlatform // name to one that it can use. UCS2String vfeWinSession::CreateTemporaryFile(void) const { - char str [MAX_PATH] = "" ; - - GetTempFileName (m_TempPathString.c_str(), "pv", 0, str) ; - remove (str) ; - m_TempFilenames.push_back(str); - return SysToUCS2String(str); + pov_base::Filesystem::TemporaryFilePtr tempFile(new pov_base::Filesystem::TemporaryFile); + m_TempFiles.push_back(tempFile); + return tempFile->GetFileName(); } ///////////////////////////////////////////////////////////////////////// @@ -170,7 +168,7 @@ namespace vfePlatform // example doesn't do that but it's not a bad idea to add. void vfeWinSession::DeleteTemporaryFile(const UCS2String& filename) const { - remove (UCS2toSysString (filename).c_str()); + pov_base::Filesystem::DeleteFile(filename); } ////////////////////////////////////////////////////////////// @@ -274,8 +272,8 @@ namespace vfePlatform if (StrCompareIC(path.GetVolume(), file.GetVolume()) == false) return (false); - vector pc = path.GetAllFolders(); - vector fc = file.GetAllFolders(); + std::vector pc = path.GetAllFolders(); + std::vector fc = file.GetAllFolders(); if (fc.size() < pc.size()) return (false) ; for (int i = 0 ; i < pc.size(); i++) @@ -307,7 +305,7 @@ namespace vfePlatform if (isWrite == false && GetReadPaths().empty() == true) returnOK = true; - int n = GetFullPathName (UCS2toSysString(file()).c_str(), sizeof (buf), buf, &s); + int n = GetFullPathName (UCS2toSysString(file()).c_str(), _MAX_PATH, buf, &s); if ((n == 0) || (n > sizeof(buf)) || (s == nullptr) || (s == buf)) { if (returnOK == true) @@ -318,8 +316,8 @@ namespace vfePlatform } // GetLongPathName is available on win95 due to the inclusion of newapis.h - n = GetLongPathName (buf, longbuf, sizeof (longbuf)) ; - if ((n > 0) && (n < sizeof(longbuf))) + n = GetLongPathName(buf, longbuf, _MAX_PATH) ; + if ((n > 0) && (n < _MAX_PATH)) { // we store the filename before doing anything else, since this may be used elsewhere // note that we convert it to lower case first @@ -342,8 +340,8 @@ namespace vfePlatform if (_stricmp(m_TempPathString.c_str(), buf) == 0) return (true); - n = GetLongPathName (buf, buf, sizeof (buf)) ; - if ((n == 0) || (n > sizeof(buf))) + n = GetLongPathName(buf, buf, _MAX_PATH); + if ((n == 0) || (n > _MAX_PATH)) { if (GetLastError() != ERROR_PATH_NOT_FOUND) { @@ -386,15 +384,15 @@ namespace vfePlatform // is not yet known, use the current working directory. if (m_InputFilename.empty() == true) { - if (_getcwd (buf, sizeof (buf) - 2) == nullptr) + if (_getcwd(buf, _MAX_PATH - 2) == nullptr) { // TODO: issue appropriate error message return (false) ; } } else - n = GetFullPathName (UCS2toSysString(m_InputFilename).c_str(), sizeof (buf), buf, &s); - if ((n == 0) || (n > sizeof(buf)) || (s == nullptr) || (s == buf)) + n = GetFullPathName (UCS2toSysString(m_InputFilename).c_str(), _MAX_PATH, buf, &s); + if ((n == 0) || (n > _MAX_PATH) || (s == nullptr) || (s == buf)) { // TODO: issue appropriate error message return (false) ; @@ -404,11 +402,11 @@ namespace vfePlatform // as the source filename may be incomplete (e.g. 'c:\temp\test' for c:\temp\test.pov). _splitpath(buf, drive, dir, nullptr, nullptr); sprintf(buf, "%s%s", drive, dir); - n = GetLongPathName (buf, buf, sizeof (buf)) ; - if ((n == 0) || (n > sizeof(buf))) + n = GetLongPathName(buf, buf, _MAX_PATH) ; + if ((n == 0) || (n > _MAX_PATH)) { if (GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_FILE_NOT_FOUND) - throw POV_EXCEPTION(kCannotOpenFileErr, string ("Input folder '") + buf + "' not found; cannot determine I/O permission for write."); + throw POV_EXCEPTION(kCannotOpenFileErr, std::string("Input folder '") + buf + "' not found; cannot determine I/O permission for write."); // TODO: issue appropriate error message return (false) ; @@ -424,7 +422,7 @@ namespace vfePlatform ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// - WinShelloutProcessing::WinShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height): ShelloutProcessing(opts, scene, width, height) + WinShelloutProcessing::WinShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height): ShelloutProcessing(opts, scene, width, height) { m_ProcessRunning = false; m_ProcessId = m_LastError = m_ExitCode = 0; @@ -450,7 +448,7 @@ namespace vfePlatform } // in the windows version of ExtractCommand, we don't treat backslashes in the command itself specially - bool WinShelloutProcessing::ExtractCommand(const string& src, string& command, string& parameters) const + bool WinShelloutProcessing::ExtractCommand(const std::string& src, std::string& command, std::string& parameters) const { bool inSQ = false; bool inDQ = false; @@ -459,8 +457,8 @@ namespace vfePlatform command.clear(); parameters.clear(); - string str = boost::trim_copy(src); - string tmp = boost::to_lower_copy(str); + std::string str = boost::trim_copy(src); + std::string tmp = boost::to_lower_copy(str); for (s = str.c_str(); *s != '\0'; s++) { @@ -489,11 +487,11 @@ namespace vfePlatform } } - parameters = boost::trim_copy(string(s)); + parameters = boost::trim_copy(std::string(s)); return true; } - bool WinShelloutProcessing::ExecuteCommand(const string& cmd, const string& params) + bool WinShelloutProcessing::ExecuteCommand(const std::string& cmd, const std::string& params) { STARTUPINFO startupInfo; PROCESS_INFORMATION procInfo; @@ -513,7 +511,7 @@ namespace vfePlatform startupInfo.dwFlags = pov_frontend::MinimizeShellouts() ? STARTF_USESHOWWINDOW : 0; startupInfo.wShowWindow = SW_SHOWMINNOACTIVE; - shared_ptr buf(new char[params.size() + 1]); + std::shared_ptr buf(new char[params.size() + 1]); strcpy(buf.get(), params.c_str()); if ((m_ProcessRunning = CreateProcess(cmd.c_str(), buf.get(), nullptr, nullptr, false, 0, nullptr, nullptr, &startupInfo, &procInfo))) { @@ -561,7 +559,7 @@ namespace vfePlatform return m_ExitCode; } - int WinShelloutProcessing::CollectCommand(string& output) + int WinShelloutProcessing::CollectCommand(std::string& output) { if (m_ProcessRunning == false && m_LastError != 0) { @@ -582,9 +580,10 @@ namespace vfePlatform return CollectCommand(); } - bool WinShelloutProcessing::CommandPermitted(const string& command, const string& parameters) + bool WinShelloutProcessing::CommandPermitted(const std::string& command, const std::string& parameters) { // this may change during a render, so we check it in real time return pov_frontend::ShelloutsPermitted(); } } +// end of namespace vfePlatform diff --git a/vfe/win/vfeplatform.h b/vfe/win/vfeplatform.h index cbf76b89c..84df777fb 100644 --- a/vfe/win/vfeplatform.h +++ b/vfe/win/vfeplatform.h @@ -38,6 +38,11 @@ #ifndef POVRAY_VFE_WIN_VFEPLATFORM_H #define POVRAY_VFE_WIN_VFEPLATFORM_H +#include + +#include "base/stringtypes.h" +#include "base/filesystem_fwd.h" + #include "frontend/shelloutprocessing.h" #include "vfesession.h" @@ -45,27 +50,27 @@ namespace vfePlatform { using namespace vfe; - class WinShelloutProcessing: public pov_frontend::ShelloutProcessing + class WinShelloutProcessing final : public pov_frontend::ShelloutProcessing { public: - WinShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height); - virtual ~WinShelloutProcessing(); + WinShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height); + virtual ~WinShelloutProcessing() override; - virtual int ProcessID(void); - virtual bool ShelloutsSupported(void) { return true; } + virtual int ProcessID(void) override; + virtual bool ShelloutsSupported(void) override { 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); - virtual bool ExtractCommand(const string& src, string& command, string& parameters) const; + virtual bool ExecuteCommand(const std::string& cmd, const std::string& params) override; + virtual bool KillCommand(int timeout, bool force = false) override; + virtual bool CommandRunning(void) override; + virtual int CollectCommand(std::string& output) override; + virtual int CollectCommand(void) override; + virtual bool CommandPermitted(const std::string& command, const std::string& parameters) override; + virtual bool ExtractCommand(const std::string& src, std::string& command, std::string& parameters) const override; bool m_ProcessRunning; - string m_Command; - string m_Params; + std::string m_Command; + std::string m_Params; void *m_ProcessHandle; void *m_ThreadHandle; unsigned long m_ExitCode; @@ -73,51 +78,51 @@ namespace vfePlatform unsigned long m_ProcessId; private: - WinShelloutProcessing(); + + WinShelloutProcessing() = delete; }; /////////////////////////////////////////////////////////////////////// // most of the methods in vfeWinSession are derived from vfeSession. // see vfeSession for documentation for those cases. - class vfeWinSession : public vfeSession + class vfeWinSession final : public vfeSession { public: - typedef std::set FilenameSet; + typedef std::set FilenameSet; vfeWinSession(int id = 0); - virtual ~vfeWinSession(); - 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 bool ImageOutputToStdoutSupported(void) const { return m_OptimizeForConsoleOutput; } - virtual ShelloutProcessing *CreateShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height) { return new WinShelloutProcessing(opts, scene, width, height); } + virtual UCS2String GetTemporaryPath(void) const override; + virtual UCS2String CreateTemporaryFile(void) const override; + virtual void DeleteTemporaryFile(const UCS2String& filename) const override; + virtual POV_LONG GetTimestamp(void) const override; + virtual void NotifyCriticalError(const char *message, const char *file, int line) override; + virtual int RequestNewOutputPath(int CallCount, const std::string& Reason, const UCS2String& OldPath, UCS2String& NewPath) override; + virtual bool TestAccessAllowed(const Path& file, bool isWrite) const override; + virtual bool ImageOutputToStdoutSupported(void) const override { return m_OptimizeForConsoleOutput; } + virtual ShelloutProcessing *CreateShelloutProcessing(POVMS_Object& opts, const std::string& scene, unsigned int width, unsigned int height) override { return new WinShelloutProcessing(opts, scene, width, height); } - virtual void Clear(bool Notify = true); + virtual void Clear(bool Notify = true) override; const FilenameSet& GetReadFiles(void) const { return m_ReadFiles; } const FilenameSet& GetWriteFiles(void) const { return m_WriteFiles; } protected: - virtual void WorkerThreadStartup(); - virtual void WorkerThreadShutdown(); + virtual void WorkerThreadStartup() override; + virtual void WorkerThreadShutdown() override; /////////////////////////////////////////////////////////////////////// // 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 // Latin-1 and perform case-insensitive comparisons. - virtual bool TestPath(const Path& path, const Path& file, bool recursive) const; + bool TestPath(const Path& path, const Path& file, bool recursive) const; /////////////////////////////////////////////////////////////////////// // perform case-insensitive UCS2 string comparison. does not take code- // page into account. - virtual bool StrCompareIC (const UCS2String& lhs, const UCS2String& rhs) const; + bool StrCompareIC (const UCS2String& lhs, const UCS2String& rhs) const; /////////////////////////////////////////////////////////////////////// // used to detect wall clock changes to prevent GetTimeStamp() @@ -129,9 +134,8 @@ namespace vfePlatform //////////////////////////////////////////////////////////////////// // used to store the location of the temp path. this is used by both // GetTemporaryPath() and TestAccessAllowed(). - Path m_TempPath; - string m_TempPathString; - mutable vector m_TempFilenames; + std::string m_TempPathString; + mutable std::vector m_TempFiles; mutable FilenameSet m_ReadFiles; mutable FilenameSet m_WriteFiles; } ; @@ -141,5 +145,6 @@ namespace vfePlatform // all other running threads in the process (and preferably in the OS). POVMS_Sys_Thread_Type GetThreadId(); } +// end of namespace vfePlatform #endif // POVRAY_VFE_WIN_VFEPLATFORM_H diff --git a/windows/povconfig/syspovconfig.h b/windows/povconfig/syspovconfig.h index 9c8e04971..fc8ac415a 100644 --- a/windows/povconfig/syspovconfig.h +++ b/windows/povconfig/syspovconfig.h @@ -13,7 +13,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 @@ -55,54 +55,13 @@ // failure to do so will lead to link errors. // #define _CONSOLE -// C++ variants of C standard headers -#include -#include -#include +// C++ variants of C standard header files +#include // TODO - Required for `_isnan()`, `_finite()`. +#include // TODO - required for `_MAX_PATH`, `std::memcpy()`[1], `std::malloc()`, `std::realloc()`, `std::free()`. +#include // TODO - Required for `std::memmove() `std::memcpy()`[1], `std::strdup()`. -// C++ standard headers -#include -#include -#include -#include -#include -#include - -// boost headers -#include - -#include -#include - -#ifndef STD_TYPES_DECLARED -#define STD_TYPES_DECLARED - -// the following types are used extensively throughout the POV source and hence are -// included and named here for reasons of clarity and convenience. - -// when we say 'string' we mean std::string -using std::string; - -// and vector is a std::vector -using std::vector; - -// yup, list too -using std::list; - -// runtime_error is the base of our Exception class, plus is referred -// to in a few other places. -using std::runtime_error; - -// we use the C++11 standard shared pointers -using std::shared_ptr; -using std::weak_ptr; -using std::dynamic_pointer_cast; -using std::static_pointer_cast; -using std::const_pointer_cast; - -using boost::intrusive_ptr; - -#endif // STD_POV_TYPES_DECLARED +// C++ standard header files +// (none at the moment) // the build command-line is expected to declare WIN32_LEAN_AND_MEAN, which will // prevent Window's objidl.h from being pulled in (which dupes IStream) @@ -186,6 +145,7 @@ namespace povwin #endif #ifndef _WIN64 + // TODO FIXME - The following will obviously only work on x86 machines. inline void DebugBreak() { _asm _emit 0cch } // rather than use the windows one inline POV_LONG RDTSC(){ _asm _emit 0Fh _asm _emit 31h } #define READ_PROFILE_TIMER RDTSC() @@ -194,27 +154,11 @@ namespace povwin #define READ_PROFILE_TIMER 0 #endif } +// end of namespace povwin #ifdef __INTEL_COMPILER #pragma warning(pop) #endif -// MS Windows provides large file support via the `_lseeki64` function, -// with file offsets having type `__int64`. -#define POV_LSEEK(handle,offset,whence) _lseeki64(handle,offset,whence) -#define POV_OFF_T __int64 - -namespace pov_base -{ - // declare these to avoid warnings in image.cpp, rather than turn off the deprecation warnings. - static inline int open(const char *name, int flags, int mode) { return _open(name, flags|_O_BINARY, mode); } - static inline int close(int handle) { return _close(handle); } - static inline int write(int handle, const void *data, int count) { return _write(handle, data, count); } - static inline int read(int handle, void *data, int count) { return _read(handle, data, count); } -} - -#define S_IRUSR _S_IREAD -#define S_IWUSR _S_IWRITE - #define ALTMAIN #define LITTLE_ENDIAN #define POV_PATH_SEPARATOR '\\' @@ -225,13 +169,10 @@ namespace pov_base #define POV_IS2 ".BMP" #define DEFAULT_DISPLAY_GAMMA_TYPE kPOVList_GammaType_SRGB #define DEFAULT_DISPLAY_GAMMA 2.2 -#define RENAME_FILE(orig,new) rename(orig,new) -#define POV_DELETE_FILE(name) _unlink(name) #define POV_NEW_LINE_STRING "\r\n" #define POV_SYS_IMAGE_EXTENSION ".bmp" #define POV_SYS_IMAGE_TYPE BMP #define POV_FILENAME_BUFFER_CHARS (_MAX_PATH-1) // (NB: _MAX_PATH includes terminating NUL character) -#define IFF_SWITCH_CAST (long) #define USE_OFFICIAL_BOOST 1 #define POV_MEMMOVE(dst,src,len) std::memmove((dst),(src),(len)) @@ -239,10 +180,10 @@ namespace pov_base #ifdef _CONSOLE -#define POV_MALLOC(size,msg) malloc (size) -#define POV_REALLOC(ptr,size,msg) realloc ((ptr), (size)) -#define POV_FREE(ptr) do { free (static_cast(ptr)); (ptr) = NULL; } while(false) -#define POV_STRDUP(str) strdup(str) +#define POV_MALLOC(size,msg) std::malloc (size) +#define POV_REALLOC(ptr,size,msg) std::realloc ((ptr), (size)) +#define POV_FREE(ptr) do { std::free (static_cast(ptr)); (ptr) = NULL; } while(false) +#define POV_STRDUP(str) std::strdup(str) #define NO_RTR 1 #define MEM_STATS 0 @@ -277,6 +218,7 @@ namespace pov { class VideoCaptureImpl; } +// end of namespace pov #endif // end of not _CONSOLE // see RLP comment in v3.6 windows config.h @@ -290,11 +232,6 @@ namespace pov #define OBJECT_DEBUG_HELPER #endif -// TODO REVIEW - Is this actually required for any Windows platform? -#ifndef MAX_PATH - #define MAX_PATH _MAX_PATH -#endif - #ifndef NO_RTR #define RTR_HACK #define RTR_SUPPORT diff --git a/windows/povconfig/syspovconfig_msvc.h b/windows/povconfig/syspovconfig_msvc.h index ab414b0bb..e7dc82676 100644 --- a/windows/povconfig/syspovconfig_msvc.h +++ b/windows/povconfig/syspovconfig_msvc.h @@ -11,7 +11,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 @@ -46,11 +46,10 @@ #endif // C++ variants of C standard header files -#include -#include +// (none at the moment) // Other library header files -#include +#include // TODO - Required for `_ReturnAddress()`. #pragma auto_inline(on) @@ -100,6 +99,7 @@ #define METADATA_COMPILER_STRING "msvc 8" #define NEED_INVHYP #define POV_CPP11_SUPPORTED 0 + #define POV_CPP14_SUPPORTED 0 #elif _MSC_VER >= 1400 && _MSC_VER < 1500 && defined (_WIN64) // MS Visual C++ 2005 (aka 8.0), compiling for 64 bit target #define POV_COMPILER_VER "msvc8" @@ -115,12 +115,14 @@ inline const unsigned long& min(const unsigned long& _X, const unsigned long& _Y) {return (_Y < _X ? _Y : _X); } #define NEED_INVHYP #define POV_CPP11_SUPPORTED 0 + #define POV_CPP14_SUPPORTED 0 #elif _MSC_VER >= 1500 && _MSC_VER < 1600 // MS Visual C++ 2008 (aka 9.0) #define POV_COMPILER_VER "msvc9" #define METADATA_COMPILER_STRING "msvc 9" #define NEED_INVHYP #define POV_CPP11_SUPPORTED 0 + #define POV_CPP14_SUPPORTED 0 #elif _MSC_VER >= 1600 && _MSC_VER < 1700 // MS Visual C++ 2010 (aka 10.0) #define POV_COMPILER_VER "msvc10" @@ -130,6 +132,7 @@ #pragma warning(disable : 4099) #define NEED_INVHYP #define POV_CPP11_SUPPORTED 0 + #define POV_CPP14_SUPPORTED 0 #elif _MSC_VER >= 1700 && _MSC_VER < 1800 // MS Visual C++ 2012 (aka 11.0) #define POV_COMPILER_VER "msvc11" @@ -138,6 +141,7 @@ // The following settings are just guesswork, and have never been tested: #define NEED_INVHYP #define POV_CPP11_SUPPORTED 0 + #define POV_CPP14_SUPPORTED 0 #elif _MSC_VER >= 1800 && _MSC_VER < 1900 // MS Visual C++ 2013 (aka 12.0) #define POV_COMPILER_VER "msvc12" @@ -145,12 +149,14 @@ #error "Please update syspovconfig_msvc.h to include this version of MSVC" // The following settings are just guesswork, and have never been tested: #define POV_CPP11_SUPPORTED 0 + #define POV_CPP14_SUPPORTED 0 // NB: The Microsoft Visual Studio developers seem to have skipped internal version number 13 entirely. #elif _MSC_VER >= 1900 && _MSC_VER < 2000 // MS Visual C++ 2015 (aka 14.0) #define POV_COMPILER_VER "msvc14" #define METADATA_COMPILER_STRING "msvc 14" #define POV_CPP11_SUPPORTED 1 + #define POV_CPP14_SUPPORTED 1 #ifndef DEBUG // Suppress erroneous warning about `string` having different alignment in base and parser. #pragma warning(disable : 4742) // 'var' has different alignment in 'file1' and 'file2': number and number @@ -204,7 +210,6 @@ #endif #endif -#define QSORT(a,b,c,d) std::qsort(reinterpret_cast(a), (size_t) b, (size_t) c, d) #define POV_LONG signed __int64 #define POV_ULONG unsigned __int64 #define FORCEINLINE __forceinline diff --git a/windows/povconfig/syspovconfigbase.h b/windows/povconfig/syspovconfigbase.h index c9b4152ee..b2f90dabe 100644 --- a/windows/povconfig/syspovconfigbase.h +++ b/windows/povconfig/syspovconfigbase.h @@ -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 @@ -57,4 +57,10 @@ // Windows requires platform-specific parsing of path name strings. #define POV_USE_DEFAULT_PATH_PARSER 0 +// Windows requires a platform-specific function to delete a file. +#define POV_USE_DEFAULT_DELETEFILE 0 + +// Windows gets a platform-specific implementation of large file handling. +#define POV_USE_DEFAULT_LARGEFILE 0 + #endif // POVRAY_WINDOWS_SYSPOVCONFIGBASE_H diff --git a/windows/pvbitmap.cpp b/windows/pvbitmap.cpp index c215e0519..102280af1 100644 --- a/windows/pvbitmap.cpp +++ b/windows/pvbitmap.cpp @@ -10,7 +10,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 @@ -1831,3 +1831,4 @@ DWORD PASCAL MyWrite(int iFileHandle, VOID *lpBuffer, DWORD dwBytes) } } +// end of namespace povwin diff --git a/windows/pvbitmap.h b/windows/pvbitmap.h index d76fba550..1f576ca68 100644 --- a/windows/pvbitmap.h +++ b/windows/pvbitmap.h @@ -10,7 +10,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 @@ -95,3 +95,4 @@ enum { #define RECTHEIGHT(lpRect) ((lpRect)->bottom - (lpRect)->top) } +// end of namespace povwin diff --git a/windows/pvdemo.h b/windows/pvdemo.h index f420e1ac2..7e7b1aa39 100644 --- a/windows/pvdemo.h +++ b/windows/pvdemo.h @@ -12,7 +12,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 @@ -426,3 +426,4 @@ char *povdemo_ini [] = } ; } +// end of namespace povwin diff --git a/windows/pvdialog.cpp b/windows/pvdialog.cpp index 3b13d44d8..eed60ecdb 100644 --- a/windows/pvdialog.cpp +++ b/windows/pvdialog.cpp @@ -10,7 +10,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 @@ -979,3 +979,4 @@ void FeatureNotify (const char *labelStr, const char *titleStr, const char *text } } +// end of namespace povwin diff --git a/windows/pvdialog.h b/windows/pvdialog.h index b999bf3bd..52ffe3f70 100644 --- a/windows/pvdialog.h +++ b/windows/pvdialog.h @@ -10,7 +10,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 @@ -53,5 +53,6 @@ INT_PTR CALLBACK RenderAlternativeFileDialogProc (HWND hDlg, UINT message, WPARA void FeatureNotify (const char *labelStr, const char *titleStr, const char *textStr, const char *helpStr, bool checked) ; } +// end of namespace povwin #endif // PVDIALOG_H_INCLUDED diff --git a/windows/pvdisplay.cpp b/windows/pvdisplay.cpp index 99fe17f52..3c58f7598 100644 --- a/windows/pvdisplay.cpp +++ b/windows/pvdisplay.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 @@ -100,6 +100,7 @@ extern HPALETTE hPalBitmap ; extern WINDOWPLACEMENT mainwin_placement ; } +// end of namespace povwin //////////////////////////////////////////////////////////////////////////////////////// // @@ -112,7 +113,7 @@ namespace pov_frontend using namespace povwin; -shared_ptr gDisplay; +std::shared_ptr gDisplay; BitmapInfo WinLegacyDisplay::m_BitmapTemplate; @@ -1251,3 +1252,4 @@ HPALETTE WinLegacyDisplay::CreatePalette (RGBQUAD *rgb, int entries, bool use8bp } } +// end of namespace pov_frontend diff --git a/windows/pvdisplay.h b/windows/pvdisplay.h index 1caf990c1..d38f73d42 100644 --- a/windows/pvdisplay.h +++ b/windows/pvdisplay.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,6 +36,8 @@ #ifndef __PVDISPLAY_H__ #define __PVDISPLAY_H__ +#include + #include #include "vfe.h" @@ -46,18 +48,18 @@ namespace pov_frontend using namespace vfe; using namespace povwin; - extern shared_ptr gDisplay; + extern std::shared_ptr gDisplay; class WinDisplay : public vfeDisplay { public: WinDisplay(unsigned int w, unsigned int h, vfeSession *session, bool visible) : vfeDisplay(w, h, session, visible), m_Handle (NULL) {}; - virtual ~WinDisplay() {} ; + virtual ~WinDisplay() override {} ; virtual bool CreateRenderWindow (void) = 0; - virtual void Close() = 0; - virtual void Show() = 0; - virtual void Hide() = 0; + virtual void Close() override = 0; + virtual void Show() override = 0; + virtual void Hide() override = 0; virtual bool TakeOver(WinDisplay *display) = 0; virtual bool IsVisible() { return (m_Handle != NULL) && (IsWindowVisible (m_Handle)) ; } virtual HWND GetHandle() { return m_Handle; } @@ -70,33 +72,33 @@ namespace pov_frontend HWND m_AuxHandle; }; - class WinLegacyDisplay : public WinDisplay + class WinLegacyDisplay final : public WinDisplay { public: WinLegacyDisplay(unsigned int w, unsigned int h, vfeSession *session, bool visible); - virtual ~WinLegacyDisplay(); + virtual ~WinLegacyDisplay() override; - void Initialise(); - void Close(); - void Show(); - void Hide(); - bool TakeOver(WinDisplay *display); - void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour); - void DrawRectangleFrame(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour); - void DrawFilledRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour); - void DrawPixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8 *colour); - void Clear(); - void SetRenderState(bool IsRendering); - bool CreateRenderWindow (void); + void Initialise() override; + void Close() override; + void Show() override; + void Hide() override; + bool TakeOver(WinDisplay *display) override; + void DrawPixel(unsigned int x, unsigned int y, const RGBA8& colour) override; + void DrawRectangleFrame(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour) override; + void DrawFilledRectangle(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8& colour) override; + void DrawPixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8 *colour) override; + void Clear() override; + void SetRenderState(bool IsRendering) override; + bool CreateRenderWindow (void) override; static LRESULT CALLBACK StaticWindowProc (HWND handle, UINT message, WPARAM wParam, LPARAM lParam); static HPALETTE CreatePalette (RGBQUAD *rgb, int entries, bool use8bpp); BITMAPINFOHEADER& GetBMIH(void) { return m_Bitmap.header; } unsigned char *GetBitmapSurface() { return m_BitmapSurface; } protected: - LRESULT WindowProc (UINT message, WPARAM wParam, LPARAM lParam); + virtual LRESULT WindowProc (UINT message, WPARAM wParam, LPARAM lParam) override; void InvalidatePixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2); - inline void SetPixel (unsigned int x, unsigned int y, uchar colour); + inline void SetPixel (unsigned int x, unsigned int y, unsigned char colour); inline void SetPixel (unsigned int x, unsigned int y, const RGBA8 *colour); unsigned char *m_BitmapSurface ; BitmapInfo m_Bitmap ; @@ -135,5 +137,6 @@ namespace pov_frontend return dynamic_cast(p) ; } } +// end of namespace pov_frontend #endif diff --git a/windows/pvedit.cpp b/windows/pvedit.cpp index f719c9140..20f434388 100644 --- a/windows/pvedit.cpp +++ b/windows/pvedit.cpp @@ -53,6 +53,7 @@ namespace pov_frontend { extern struct ProcessOptions::INI_Parser_Table RenderOptions_INI_Table[]; } +// end of namespace pov_frontend namespace povwin { @@ -311,7 +312,7 @@ char *Get_User_Keywords(const char *DocumentsPath) char str[_MAX_PATH]; char *s; FILE *f; - string result; + std::string result; sprintf(str, "%sini\\user-keywords.txt", DocumentsPath); if ((f = fopen(str, "rt")) == NULL) @@ -570,3 +571,4 @@ const char **EditGetWindowList (void) } } +// end of namespace povwin diff --git a/windows/pvedit.h b/windows/pvedit.h index 31c90d9f8..366dd3796 100644 --- a/windows/pvedit.h +++ b/windows/pvedit.h @@ -10,7 +10,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 @@ -146,6 +146,7 @@ void EditSetKeywords (LPCSTR SDLKeywords, LPCSTR INIKeywords) ; const char **EditGetWindowList(void); } +// end of namespace povwin #endif // PVEDIT_H_INCLUDED diff --git a/windows/pvengine.cpp b/windows/pvengine.cpp index 174425856..ad589877a 100644 --- a/windows/pvengine.cpp +++ b/windows/pvengine.cpp @@ -70,14 +70,16 @@ #include #include #include +#include // #define DEVELOPMENT +#include #include #include #include -#include +#include #include "pvengine.h" #include "resource.h" @@ -131,8 +133,9 @@ char *WriteDump(struct _EXCEPTION_POINTERS *pExceptionInfo, bool full, long time namespace pov_frontend { - extern shared_ptr gDisplay; + extern std::shared_ptr gDisplay; } +// end of namespace pov_frontend using namespace pov; using namespace pov_frontend; @@ -166,8 +169,8 @@ bool IsExpired; bool BackendFailedFlag = false; bool PreventSleep = true; char DumpMeta[65536]; -string ErrorMessage ; -string ErrorFilename ; +std::string ErrorMessage ; +std::string ErrorFilename ; unsigned ErrorLine ; unsigned ErrorCol ; unsigned render_priority = CM_RENDERPRIORITY_NORMAL ; @@ -318,7 +321,7 @@ HICON ourIcon ; HICON renderIcon ; HFONT about_font ; HANDLE hMainThread ; -string InputFileName ; +std::string InputFileName ; time_t SecondCountStart ; time_t quit ; HBITMAP hBmpBackground ; @@ -370,8 +373,8 @@ CRITICAL_SECTION critical_section ; // key is the name of an included file (all lower case). // content is the name of the most recent rendered file that caused it to be included. -map IncludeToSourceMap; -map IncludeAlternateDecisionMap; +map IncludeToSourceMap; +map IncludeAlternateDecisionMap; char queued_files [MAX_QUEUE] [_MAX_PATH] ; char dir [_MAX_PATH] ; @@ -497,12 +500,12 @@ SCROLLKEYS key2scroll [] = { -1, -1, -1 } } ; -string StripFilePath (const string& str) +std::string StripFilePath (const std::string& str) { - string::size_type pos = str.find_last_of ("\\/") ; - if (pos == string::npos) + std::string::size_type pos = str.find_last_of ("\\/") ; + if (pos == std::string::npos) return (str) ; - return string (str, pos + 1) ; + return std::string(str, pos + 1); } bool StripPathComponent (char *path, int number) @@ -611,7 +614,7 @@ void SetCaption (LPCSTR str) #ifndef DEVELOPMENT if (Session.GetBackendState() == kRendering && InputFileName.size () > 0) { - string filename = StripFilePath (InputFileName) ; + std::string filename = StripFilePath (InputFileName) ; if (strstr (str, filename.c_str ()) != NULL) { // if the filename is in the caption already, we're probably rendering @@ -632,7 +635,7 @@ void SetCaption (LPCSTR str) #else if (Session.GetBackendState() == kRendering && InputFileName.size () > 0) { - string filename = StripFilePath (InputFileName) ; + std::string filename = StripFilePath (InputFileName) ; if (strstr (str, filename.c_str ()) != NULL) { // if the filename is in the caption already, we're probably rendering @@ -1371,7 +1374,7 @@ bool inferHome (void) return (true) ; } -string getHome(const char* ver) +std::string getHome(const char* ver) { char str[_MAX_PATH]; HKEY key ; @@ -1385,7 +1388,7 @@ string getHome(const char* ver) { RegCloseKey (key) ; appendPathSeparator(str); - return string(str); + return std::string(str); } RegCloseKey (key) ; } @@ -1395,11 +1398,11 @@ string getHome(const char* ver) { RegCloseKey (key) ; appendPathSeparator(str); - return string(str); + return std::string(str); } RegCloseKey (key) ; } - return string(); + return std::string(); } bool copyEditSettings(const char* ver) @@ -2417,7 +2420,7 @@ void render_stopped (void) } if (!running_demo && !demo_mode && !benchmark_mode && !rendering_insert_menu && !running_benchmark && !was_insert_render) { - string ofn = UCS2toSysString (Session.GetOutputFilename()); + std::string ofn = UCS2toSysString (Session.GetOutputFilename()); if (output_to_file && ofn.size () != 0) { sprintf (str, "Output -> '%s'", ofn.c_str ()) ; @@ -2494,7 +2497,7 @@ void render_stopped (void) FileType ft = get_file_type(it->c_str()); if (ft < fileFirstImageType || ft > fileLastImageType) { - pair::iterator, bool> result = IncludeToSourceMap.insert(pair (*it, InputFileName)); + pair::iterator, bool> result = IncludeToSourceMap.insert(pair (*it, InputFileName)); if (result.second == false) result.first->second = InputFileName; } @@ -3869,12 +3872,12 @@ LRESULT CALLBACK PovMainWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM _strlwr(fn); // see if we have a previous decision recorded for this file. - map::const_iterator altit = IncludeAlternateDecisionMap.find(fn); + map::const_iterator altit = IncludeAlternateDecisionMap.find(fn); if (altit == IncludeAlternateDecisionMap.end() || altit->second == true) { // either there is no decision recorded, or the decision was 'yes' // in either case we need to find the alternate filename - map::const_iterator it = IncludeToSourceMap.find(fn); + map::const_iterator it = IncludeToSourceMap.find(fn); if (it != IncludeToSourceMap.end()) { // we've found the alternate filename. do we need to ask the user about it? @@ -3885,7 +3888,7 @@ LRESULT CALLBACK PovMainWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM { case IDYES: // record the decision - IncludeAlternateDecisionMap.insert(pair(fn, true)); + IncludeAlternateDecisionMap.insert(pair(fn, true)); strcpy(source_file_name, it->second.c_str()); break; @@ -3896,7 +3899,7 @@ LRESULT CALLBACK PovMainWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM case IDNO: // record the decision - IncludeAlternateDecisionMap.insert(pair(fn, false)); + IncludeAlternateDecisionMap.insert(pair(fn, false)); break; case IDCANCEL: @@ -5080,6 +5083,7 @@ __int64 LZTimerRawCount (void) #endif // #ifdef _MSC_VER } +// end of namespace povwin static void __cdecl newhandler (void) { @@ -5529,10 +5533,10 @@ int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) if (debugging) debug_output("no pvengine.ini: seeing if there is a %s ini\n", *oldVer) ; - string str(getHome(*oldVer)); + std::string str(getHome(*oldVer)); if (str.empty() == false) { - string oldINIpath = str + "ini\\pvengine.ini"; + std::string oldINIpath = str + "ini\\pvengine.ini"; if (!fileExists(oldINIpath.c_str())) continue; diff --git a/windows/pvengine.h b/windows/pvengine.h index a246847bf..b68c21985 100644 --- a/windows/pvengine.h +++ b/windows/pvengine.h @@ -10,7 +10,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 @@ -63,8 +63,9 @@ #include #include +#include + #include "pvfrontend.h" -#include "backend/frame.h" #include "backend/povray.h" #include @@ -258,7 +259,7 @@ typedef struct ushort menuBarBorder ; } pvncStruct ; -class AutoLock +class AutoLock final { public: inline AutoLock (CRITICAL_SECTION& CriticalSection) { m_CriticalSection = &CriticalSection ; EnterCriticalSection (m_CriticalSection) ; } @@ -327,7 +328,7 @@ FileType get_file_type (const char *filename) ; bool is_non_primary_file(const char *filename) ; void read_INI_settings (void) ; void write_INI_settings (bool noreset = false) ; -void cloneOldIni(const std::string oldPath, const std::string newPath); +void cloneOldIni(const std::string& oldPath, const std::string& newPath); void update_menu_for_render (bool rendering) ; void update_queue_status (bool write_files) ; void draw_ordinary_listbox (DRAWITEMSTRUCT *d, bool fitpath) ; @@ -594,6 +595,6 @@ uchar dither8x8 [64] = #endif // #if DECLARE_TABLES } +// end of namespace povwin #endif // PVENGINE_H_INCLUDED - diff --git a/windows/pvfiles.cpp b/windows/pvfiles.cpp index 9b223c4d5..90a86d5b0 100644 --- a/windows/pvfiles.cpp +++ b/windows/pvfiles.cpp @@ -10,7 +10,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 @@ -42,6 +42,7 @@ #include #include +#include #include "pvengine.h" #include "resource.h" @@ -210,3 +211,4 @@ char *save_demo_file (char *s1, char *s2) } } +// end of namespace povwin diff --git a/windows/pvfrontend.cpp b/windows/pvfrontend.cpp index 115d8c44a..befe74e70 100644 --- a/windows/pvfrontend.cpp +++ b/windows/pvfrontend.cpp @@ -10,7 +10,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 @@ -61,11 +61,12 @@ namespace povwin extern bool ErrorNotified; extern bool no_shell_outs; extern bool system_noactive; - extern string ErrorMessage ; - extern string ErrorFilename ; + extern std::string ErrorMessage ; + extern std::string ErrorFilename ; extern unsigned ErrorLine ; extern unsigned ErrorCol ; } +// end of namespace povwin namespace pov_frontend { @@ -138,7 +139,7 @@ void CreateFrontend (void) if (gSession->Initialize(NULL, NULL) != vfeNoError) { gSession->Shutdown(); - string str = gSession->GetErrorString(); + std::string str = gSession->GetErrorString(); delete gSession; gSession = NULL; throw POV_EXCEPTION_STRING (str.c_str()); @@ -162,17 +163,17 @@ void SetupFrontend (void) if (io_restrictions != 0) { for (char **dirspec = WriteDirSpecs ; *dirspec != NULL ; dirspec++) - gSession->AddWritePath (string (*dirspec), true); + gSession->AddWritePath (std::string(*dirspec), true); if (io_restrictions > 1) { - gSession->AddReadPath(string(DocumentsPath), true); - gSession->AddReadPath(string(FontPath) + "\\", false); + gSession->AddReadPath(std::string(DocumentsPath), true); + gSession->AddReadPath(std::string(FontPath) + "\\", false); for (char **dirspec = ReadDirSpecs ; *dirspec != NULL ; dirspec++) - gSession->AddReadPath (string (*dirspec), true); + gSession->AddReadPath (std::string(*dirspec), true); } // allow write to the insert menu directory - string str(DocumentsPath); + std::string str(DocumentsPath); str += "Insert Menu\\"; gSession->AddWritePath (str, true); @@ -308,9 +309,9 @@ bool ProcessSession (int delay) int line; int col; char str[32]; - string errormsg; - string message; - string filename; + std::string errormsg; + std::string message; + std::string filename; vfeSession::MessageType type; while (gSession->GetNextNonStatusMessage (type, message, filename, line, col)) @@ -414,3 +415,4 @@ bool ShelloutsPermitted(void) } } +// end of namespace pov_frontend diff --git a/windows/pvfrontend.h b/windows/pvfrontend.h index 7ccf6bfc0..fa5e90f2e 100644 --- a/windows/pvfrontend.h +++ b/windows/pvfrontend.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 @@ -52,5 +52,6 @@ namespace pov_frontend bool MinimizeShellouts(void); bool ShelloutsPermitted(void); } +// end of namespace pov_frontend #endif diff --git a/windows/pvguiext.cpp b/windows/pvguiext.cpp index 76e531c09..a965a71b8 100644 --- a/windows/pvguiext.cpp +++ b/windows/pvguiext.cpp @@ -10,7 +10,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 @@ -710,3 +710,4 @@ BOOL CheckGUIExtLoaded (const char *Name) } } +// end of namespace povwin diff --git a/windows/pvguiext.h b/windows/pvguiext.h index afceb95b5..bea765e94 100644 --- a/windows/pvguiext.h +++ b/windows/pvguiext.h @@ -10,7 +10,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 @@ -282,6 +282,6 @@ char *ExternalMenuTip (WPARAM wParam) ; BOOL CheckGUIExtLoaded (const char *Name) ; } +// end of namespace povwin #endif // PVGUIEXT_H_INCLUDED - diff --git a/windows/pvlegal.h b/windows/pvlegal.h index d29acfdc0..fe81efca4 100644 --- a/windows/pvlegal.h +++ b/windows/pvlegal.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 @@ -702,3 +702,4 @@ char povlegal_text [] = } ; } +// end of namespace povwin diff --git a/windows/pvmem.cpp b/windows/pvmem.cpp index 304fdb094..baed99699 100644 --- a/windows/pvmem.cpp +++ b/windows/pvmem.cpp @@ -10,7 +10,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 @@ -349,7 +349,8 @@ char *win_strdup(const char *s) #endif // else portion of '#ifdef _DEBUG' #endif // else portion of '#if POV_MEM_STATS == 0 && WIN_MEM_TRACKING == 0' -} // end of namespace povwin +} +// end of namespace povwin #if WIN_MEM_TRACKING diff --git a/windows/pvmem.h b/windows/pvmem.h index 80b0a3a99..90dab19e1 100644 --- a/windows/pvmem.h +++ b/windows/pvmem.h @@ -10,7 +10,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 povwin { -class WinMemStats +class WinMemStats final { public: WinMemStats() { Clear(); } @@ -140,7 +140,7 @@ class WinMemStats typedef WinMemStats PovMemStats; -class WinHeap +class WinHeap final { public: WinHeap() @@ -227,7 +227,7 @@ class WinHeap CRITICAL_SECTION m_CritSec; }; -class HeapLock +class HeapLock final { public: HeapLock(WinHeap *wh) : m_WinHeap(wh) { m_WinHeap->Lock(); } @@ -236,7 +236,7 @@ class HeapLock WinHeap *m_WinHeap; }; -class WinMemBlock +class WinMemBlock final { public: __declspec(nothrow) WinMemBlock(const void *data, int line) @@ -353,10 +353,11 @@ class WinMemBlock static const size_t BlockPadding = 0; # endif - WinMemBlock() {} // not available - void *operator new (size_t len) {} // not available + WinMemBlock() = delete; + void *operator new (size_t len) = delete; }; } +// end of namespace povwin #endif // POVRAY_WINDOWS_PVMEM_H diff --git a/windows/pvmenu.cpp b/windows/pvmenu.cpp index bd1252cf7..fd159d4f6 100644 --- a/windows/pvmenu.cpp +++ b/windows/pvmenu.cpp @@ -10,7 +10,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 @@ -279,3 +279,4 @@ void build_editor_menu (HMENU hMenu) } } +// end of namespace povwin diff --git a/windows/pvmisc.cpp b/windows/pvmisc.cpp index b59a43e82..455fd454a 100644 --- a/windows/pvmisc.cpp +++ b/windows/pvmisc.cpp @@ -10,7 +10,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 @@ -72,6 +72,7 @@ namespace povwin using std::map; using std::endl; +using std::string; extern int alert_sound ; extern int message_xchar ; @@ -658,7 +659,7 @@ void write_INI_settings (bool noreset) // and never use it. // // TODO: add replace regex to alter paths from old to new where appropriate -void cloneOldIni(string oldPath, string newPath) +void cloneOldIni(const string& oldPath, const string& newPath) { bool keep = false; smatch what; @@ -717,7 +718,7 @@ void cloneOldIni(string oldPath, string newPath) #else -void cloneOldIni(string oldPath, string newPath) +void cloneOldIni(const string& oldPath, const string& newPath) { bool keep = false; size_t pos; @@ -1543,5 +1544,4 @@ bool ShowRestrictionMessage (char *Message, char *Dir) } } - - +// end of namespace povwin diff --git a/windows/pvtext.cpp b/windows/pvtext.cpp index bbcb7e697..e6d973885 100644 --- a/windows/pvtext.cpp +++ b/windows/pvtext.cpp @@ -10,7 +10,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 @@ -2016,3 +2016,4 @@ void say_status_message (int section, const char *message) } } +// end of namespace povwin diff --git a/windows/pvupdate.cpp b/windows/pvupdate.cpp index dec135ad1..ad2af3dbc 100644 --- a/windows/pvupdate.cpp +++ b/windows/pvupdate.cpp @@ -10,7 +10,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 @@ -67,8 +67,6 @@ #define SCRIPTPATH "/updates/checkv2" -using std::string; - namespace povwin { @@ -102,7 +100,7 @@ bool InternetConnected (void) } // -1 == error, 0 == no update, 1 == update -int IsUpdateAvailable (bool SendSysinfo, char *CurrentVersion, string& NewVersion, string& Info) +int IsUpdateAvailable (bool SendSysinfo, char *CurrentVersion, std::string& NewVersion, std::string& Info) { int result = -1 ; char poststr [2048] ; @@ -231,8 +229,8 @@ int IsUpdateAvailable (bool SendSysinfo, char *CurrentVersion, string& NewVersio result = 1 ; Info.clear(); NewVersion = reply + 4; - string::size_type pos = NewVersion.find(' '); - if (pos != string::npos) + std::string::size_type pos = NewVersion.find(' '); + if (pos != std::string::npos) { Info = NewVersion.substr(pos); NewVersion.resize(pos); @@ -257,4 +255,5 @@ int IsUpdateAvailable (bool SendSysinfo, char *CurrentVersion, string& NewVersio return (result) ; } -} // end of namespace povwin +} +// end of namespace povwin diff --git a/windows/rtrsupport/rtrsupport.cpp b/windows/rtrsupport/rtrsupport.cpp index acb44170a..9b5b14bae 100644 --- a/windows/rtrsupport/rtrsupport.cpp +++ b/windows/rtrsupport/rtrsupport.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 @@ -54,11 +54,9 @@ std::string VideoSourceName; namespace povwin { -using namespace pov; - // this code has been stubbed out: need to re-implement -size_t GetVideoSourceNames(vector& result) +size_t GetVideoSourceNames(std::vector& result) { return 0; } @@ -77,5 +75,6 @@ void NextFrame(void) } } +// end of namespace povwin #endif diff --git a/windows/rtrsupport/rtrsupport.h b/windows/rtrsupport/rtrsupport.h index 966871c8f..de833c788 100644 --- a/windows/rtrsupport/rtrsupport.h +++ b/windows/rtrsupport/rtrsupport.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,6 +36,9 @@ #ifndef __RTRSUPPORT_H__ #define __RTRSUPPORT_H__ +#include +#include + namespace povwin { size_t GetVideoSourceNames(std::vector& result); @@ -43,5 +46,6 @@ namespace povwin const std::string& GetVideoSourceName(void); void NextFrame(void); } +// end of namespace povwin #endif diff --git a/windows/rtrsupport/vidcapimpl.cpp b/windows/rtrsupport/vidcapimpl.cpp index dd27ceb0c..d4fd75917 100644 --- a/windows/rtrsupport/vidcapimpl.cpp +++ b/windows/rtrsupport/vidcapimpl.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 @@ -66,7 +66,7 @@ VideoCaptureImpl::~VideoCaptureImpl() { } -Image *VideoCaptureImpl::Init(const char *params, Image::ReadOptions& options, bool doubleBuffer) +Image *VideoCaptureImpl::Init(const char *params, ImageReadOptions& options, bool doubleBuffer) { return NULL; } @@ -80,6 +80,7 @@ bool VideoCaptureImpl::WaitFrame(int count, unsigned int timeout) return false; } -} // end of namespace pov +} +// end of namespace pov #endif diff --git a/windows/vs2015/povbackend.vcxproj b/windows/vs2015/povbackend.vcxproj index f257b4955..8707cf355 100644 --- a/windows/vs2015/povbackend.vcxproj +++ b/windows/vs2015/povbackend.vcxproj @@ -433,10 +433,13 @@ + + + + - @@ -447,6 +450,8 @@ + + diff --git a/windows/vs2015/povbackend.vcxproj.filters b/windows/vs2015/povbackend.vcxproj.filters index 546e738b2..abbf2109b 100644 --- a/windows/vs2015/povbackend.vcxproj.filters +++ b/windows/vs2015/povbackend.vcxproj.filters @@ -119,9 +119,6 @@ Backend Headers - - Backend Headers - Backend Headers @@ -194,5 +191,23 @@ Backend Headers\Control + + Backend Headers\Scene + + + Backend Headers\Scene + + + Backend Headers\Control + + + Backend Headers\Scene + + + Backend Headers\Lighting + + + Backend Headers\Control + \ No newline at end of file diff --git a/windows/vs2015/povbase.vcxproj b/windows/vs2015/povbase.vcxproj index a33b03591..2cb007a33 100644 --- a/windows/vs2015/povbase.vcxproj +++ b/windows/vs2015/povbase.vcxproj @@ -388,6 +388,7 @@ + @@ -445,28 +446,41 @@ + + + + + + + + + + + + + diff --git a/windows/vs2015/povbase.vcxproj.filters b/windows/vs2015/povbase.vcxproj.filters index 1f241f597..21ff34f0c 100644 --- a/windows/vs2015/povbase.vcxproj.filters +++ b/windows/vs2015/povbase.vcxproj.filters @@ -144,6 +144,9 @@ Base source\Image + + Base source + @@ -284,5 +287,44 @@ Base Headers\Image + + Base Headers + + + Base Headers + + + Base Headers + + + Base Headers\Image + + + Base Headers + + + Base Headers + + + Base Headers\Image + + + Base Headers + + + Base Headers\Image + + + Base Headers + + + Base Headers + + + Base Headers + + + Base Headers + \ No newline at end of file diff --git a/windows/vs2015/povcore.vcxproj b/windows/vs2015/povcore.vcxproj index 4949cd7e4..56aaed906 100644 --- a/windows/vs2015/povcore.vcxproj +++ b/windows/vs2015/povcore.vcxproj @@ -429,6 +429,7 @@ + @@ -479,15 +480,19 @@ + + + + @@ -495,6 +500,7 @@ + @@ -511,9 +517,11 @@ + + @@ -523,6 +531,7 @@ + @@ -546,6 +555,7 @@ + diff --git a/windows/vs2015/povcore.vcxproj.filters b/windows/vs2015/povcore.vcxproj.filters index ca4c0396f..3e9736386 100644 --- a/windows/vs2015/povcore.vcxproj.filters +++ b/windows/vs2015/povcore.vcxproj.filters @@ -272,6 +272,9 @@ Core Source\Material + + Core Source\Math + @@ -496,5 +499,32 @@ Core Headers\Material + + Core Headers + + + Core Headers\Scene + + + Core Headers\Bounding + + + Core Headers\Bounding + + + Core Headers\Render + + + Core Headers\Shape + + + Core Headers\Lighting + + + Core Headers\Material + + + Core Headers\Support + \ No newline at end of file diff --git a/windows/vs2015/povfrontend.vcxproj b/windows/vs2015/povfrontend.vcxproj index 59357a4b8..e5293756c 100644 --- a/windows/vs2015/povfrontend.vcxproj +++ b/windows/vs2015/povfrontend.vcxproj @@ -411,6 +411,7 @@ + @@ -419,6 +420,7 @@ + diff --git a/windows/vs2015/povfrontend.vcxproj.filters b/windows/vs2015/povfrontend.vcxproj.filters index 72873eeec..fa7db9b7d 100644 --- a/windows/vs2015/povfrontend.vcxproj.filters +++ b/windows/vs2015/povfrontend.vcxproj.filters @@ -101,5 +101,11 @@ Frontend Headers + + Frontend Headers + + + Frontend Headers + \ No newline at end of file diff --git a/windows/vs2015/povparser.vcxproj b/windows/vs2015/povparser.vcxproj index ef1d47491..e90289687 100644 --- a/windows/vs2015/povparser.vcxproj +++ b/windows/vs2015/povparser.vcxproj @@ -426,6 +426,7 @@ + diff --git a/windows/vs2015/povparser.vcxproj.filters b/windows/vs2015/povparser.vcxproj.filters index 0a7230375..d050cbe31 100644 --- a/windows/vs2015/povparser.vcxproj.filters +++ b/windows/vs2015/povparser.vcxproj.filters @@ -43,6 +43,9 @@ Parser Headers + + Parser Headers + diff --git a/windows/vs2015/povplatform.vcxproj b/windows/vs2015/povplatform.vcxproj index 3deeba43f..b95f78ef0 100644 --- a/windows/vs2015/povplatform.vcxproj +++ b/windows/vs2015/povplatform.vcxproj @@ -376,6 +376,7 @@ + diff --git a/windows/vs2015/povvm.vcxproj b/windows/vs2015/povvm.vcxproj index 4cc830d31..96717ec7c 100644 --- a/windows/vs2015/povvm.vcxproj +++ b/windows/vs2015/povvm.vcxproj @@ -414,6 +414,7 @@ + diff --git a/windows/vs2015/povvm.vcxproj.filters b/windows/vs2015/povvm.vcxproj.filters index 48132ac4a..a5e77b9fc 100644 --- a/windows/vs2015/povvm.vcxproj.filters +++ b/windows/vs2015/povvm.vcxproj.filters @@ -27,6 +27,9 @@ VM Headers + + VM Headers + diff --git a/windows/winprecomp.h b/windows/winprecomp.h index c6286bd90..81224aa06 100644 --- a/windows/winprecomp.h +++ b/windows/winprecomp.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 @@ -45,17 +45,23 @@ /// absolute minimum when precompiled headers are _not_ used. /// @endparblock +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED + #define POVWIN_FILE #define _CRT_RAND_S #define _WIN32_IE COMMONCTRL_VERSION +// C++ variants of C standard header files #include #include #include #include + +// C++ standard header files #include #include #include +#include #include #include #include @@ -80,14 +86,14 @@ #include #include +// Boost header files #include #include #include #include -#include -#include +#if POV_MULTITHREADED #include #include +#endif #include -#include From f0c664838a4f8cc67d07f65faefd9416ce1100e6 Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Mon, 11 Feb 2019 08:43:42 +0100 Subject: [PATCH 08/13] Fix broken clang build. --- source/base/image/jpeg.cpp | 16 ++++++++++++++++ source/base/stringutilities.cpp | 12 ++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/source/base/image/jpeg.cpp b/source/base/image/jpeg.cpp index 22f343372..1d9d74812 100644 --- a/source/base/image/jpeg.cpp +++ b/source/base/image/jpeg.cpp @@ -51,12 +51,21 @@ #include #include +// Make sure we can later identify whether JPEGlib wants `TRUE` and `FALSE` to be macros. +#undef TRUE +#undef FALSE + // Other 3rd party header files extern "C" { #include } +// Check whether JPEGlib wants `TRUE` and `FALSE` to be macros. +#ifdef TRUE +#define POV_KEEP_BOOLEAN_MACROS +#endif + // POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/image/colourspace.h" @@ -68,6 +77,13 @@ extern "C" // this must be the last file included #include "base/povdebug.h" +// Work around an issue on Mac OS X, where `TRUE` and `FALSE` are defined +// _somewhere_, in a manner that is incompatible with JPEGlib. +#ifndef POV_KEEP_BOOLEAN_MACROS +#undef TRUE +#undef FALSE +#endif + namespace pov_base { diff --git a/source/base/stringutilities.cpp b/source/base/stringutilities.cpp index 003ac0931..f597e5680 100644 --- a/source/base/stringutilities.cpp +++ b/source/base/stringutilities.cpp @@ -438,7 +438,7 @@ struct CharsetUCS4 final : public CharsetUCS4Subset } }; -static const CharsetUCS4 kCharsetUCS4; +static const auto kCharsetUCS4 = CharsetUCS4(); //------------------------------------------------------------------------------ @@ -459,7 +459,7 @@ struct CharsetUCS2 final : public CharsetUCS4Subset } }; -static const CharsetUCS2 kCharsetUCS2; +static const auto kCharsetUCS2 = CharsetUCS2(); //------------------------------------------------------------------------------ @@ -480,7 +480,7 @@ struct CharsetLatin1 final : public CharsetUCS4Subset } }; -static const CharsetLatin1 kCharsetLatin1; +static const auto kCharsetLatin1 = CharsetLatin1(); //------------------------------------------------------------------------------ @@ -501,7 +501,7 @@ struct CharsetASCII final : public CharsetUCS4Subset } }; -static const CharsetASCII kCharsetASCII; +static const auto kCharsetASCII = CharsetASCII(); //------------------------------------------------------------------------------ @@ -512,8 +512,8 @@ struct CharsetExtendedASCII final : public Charset int i = 0; for (UCS4 c : highCharacters) mHighCharacters[i++] = c; - while (i < kNumNonASCIICharacters) - mHighCharacters[i++] = kFirstNonASCIICharacter + i; + for (; i < kNumNonASCIICharacters; ++i) + mHighCharacters[i] = kFirstNonASCIICharacter + i; } virtual bool Encode(POV_UINT32& result, UCS4 character) const override From 55c04883a1a8a6a15fe3b0e43cb40de32fc7f8f6 Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Mon, 11 Feb 2019 20:59:42 +0100 Subject: [PATCH 09/13] [doc] Minor update to coding style guide. --- source-doc/styleguide.md | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/source-doc/styleguide.md b/source-doc/styleguide.md index d2c21687e..80763460b 100644 --- a/source-doc/styleguide.md +++ b/source-doc/styleguide.md @@ -41,26 +41,14 @@ 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 - fair game though, as they are thought to provide significant benefit, and support by all major - compiler brands seems to be mature by now: - - Features "borrowed" from ISO/IEC 9899:1990 (aka C90, aka C89). - - Features "borrowed" from ISO/IEC TR 19768:2007 (aka C++ Technical Report 1, aka TR1). - - `decltype(v)`, with `v` being a simple variable or class member (as opposed to a more complex expression) - - Range-based for loops (most notably the `for (auto&& i : v)` idiom to iterate over a vector). - @note - Other C++11 features will be added to the above list at the discretion of the dev team, or - upon request if a reasonable case can be made in their favour. Note however that at present - we will only consider features that have been properly supported by GCC as early as version - 4.8, by Clang as early as version 4.2, and by MSVC as early as internal version 19.0 - (Visual Studio 2015). + - _Math Library Float Functions_: The `f`-suffixed variants of `` library functions + (e.g. `std::fabsf(float)`) _must not_ be used. The float overloads of the non-suffixed + variants (e.g. `std::fabs(float)`) should be used instead. [GCC, all versions as of + 2019-02-11]. - Source code should avoid potential conflicts with later standard extensions to the C++ language, - most notably ISO/IEC 14882:2014 (aka C++14) and the upcoming successor (aka C++17). + most notably ISO/IEC 14882:2014 (aka C++14), ISO/IEC 14882:2017 (aka C++17) and the upcoming + successor (aka C++20). - While POV-Ray does require boost, we want to keep dependency on it to a minimum. The following are currently considered fair game: From 77d267d2031d5f0ac4087cda69cd082729a6e75f Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Tue, 12 Feb 2019 03:51:26 +0100 Subject: [PATCH 10/13] More miscellaneous code cleanup / modernization. - Change include hierarchy, using more dedicated forward declaration headers. - Make use of C++11 standard library for threads and timing. - Start work on tearing down `TraceThreadData`. - Some odds and ends. --- .travis.yml | 1 - changes.txt | 3 +- platform/unix/syspovtimer.cpp | 73 ++++++-- platform/unix/syspovtimer.h | 28 ++- platform/windows/syspovtimer.cpp | 13 ++ platform/windows/syspovtimer.h | 4 +- platform/x86/avx/avxnoise.cpp | 4 +- platform/x86/avx2fma3/avx2fma3noise.cpp | 2 +- source-doc/styleguide.md | 3 +- source/backend/bounding/boundingtask.cpp | 1 - source/backend/configbackend.h | 38 ---- source/backend/control/messagefactory.cpp | 4 - source/backend/control/parsertask.cpp | 3 +- source/backend/control/parsertask.h | 1 - source/backend/control/scene.cpp | 14 +- source/backend/control/scene.h | 8 +- .../lighting/photonshootingstrategy.cpp | 2 +- .../backend/lighting/photonshootingstrategy.h | 6 +- .../backend/lighting/photonshootingtask.cpp | 1 + source/backend/povray.cpp | 18 +- source/backend/povray.h | 8 +- source/backend/precomp.h | 13 +- source/backend/render/radiositytask.cpp | 6 +- source/backend/render/rendertask.cpp | 1 - source/backend/render/tracetask.cpp | 4 +- source/backend/scene/backendscenedata.cpp | 4 - source/backend/scene/view.cpp | 38 ++-- source/backend/scene/view.h | 16 +- source/backend/support/task.cpp | 20 ++- source/backend/support/task.h | 39 +--- source/backend/support/taskqueue.cpp | 27 ++- source/backend/support/taskqueue.h | 9 +- source/base/base_fwd.h | 8 + source/base/configbase.h | 70 +++----- source/base/filesystem_fwd.h | 9 +- source/base/image/colourspace.cpp | 14 +- source/base/image/colourspace.h | 12 +- source/base/image/colourspace_fwd.h | 9 +- source/base/image/dither_fwd.h | 9 +- source/base/image/metadata.h | 1 - source/base/image/tiff.cpp | 3 - source/base/pov_mem.cpp | 6 +- source/base/pov_mem.h | 1 + source/base/precomp.h | 13 +- source/base/stringutilities.h | 6 +- source/base/timer.cpp | 44 ++--- source/base/timer.h | 108 +++++++---- source/core/bounding/boundingbox.cpp | 4 +- source/core/configcore.h | 2 +- source/core/core_fwd.h | 3 + source/core/coretypes.h | 2 - source/core/lighting/photons.cpp | 2 + source/core/lighting/radiosity.cpp | 19 +- source/core/lighting/radiosity.h | 14 +- source/core/material/media.cpp | 2 + source/core/material/noise.cpp | 4 +- source/core/material/noise.h | 4 +- source/core/material/normal.cpp | 1 + source/core/material/pattern.cpp | 60 +++---- source/core/material/pattern.h | 75 -------- source/core/material/pattern_fwd.h | 3 +- source/core/math/jitter.h | 2 +- source/core/math/randomsequence.cpp | 14 +- source/core/math/randomsequence.h | 1 + source/core/math/randomsequence_fwd.h | 74 ++++++++ source/core/math/vector.h | 1 + source/core/math/vector_fwd.h | 60 +++++++ source/core/precomp.h | 12 +- source/core/render/trace.cpp | 4 +- source/core/render/tracepixel.cpp | 6 +- source/core/scene/object.cpp | 1 + source/core/scene/scenedata.cpp | 3 - source/core/scene/scenedata.h | 1 + source/core/scene/scenedata_fwd.h | 51 ++++++ source/core/scene/tracethreaddata.cpp | 49 +---- source/core/scene/tracethreaddata.h | 22 +-- source/core/shape/bezier.cpp | 6 +- source/core/shape/blob.cpp | 10 +- source/core/shape/box.cpp | 1 + source/core/shape/cone.cpp | 1 + source/core/shape/csg.cpp | 1 + source/core/shape/disc.cpp | 1 + source/core/shape/fractal.cpp | 1 + source/core/shape/heightfield.cpp | 1 + source/core/shape/isosurface.cpp | 1 + source/core/shape/lathe.cpp | 1 + source/core/shape/lemon.cpp | 1 + source/core/shape/mesh.cpp | 23 +-- source/core/shape/mesh.h | 15 +- source/core/shape/ovus.cpp | 1 + source/core/shape/parametric.cpp | 1 + source/core/shape/plane.cpp | 1 + source/core/shape/polygon.cpp | 1 + source/core/shape/polynomial.cpp | 1 + source/core/shape/prism.cpp | 1 + source/core/shape/quadric.cpp | 1 + source/core/shape/sor.cpp | 1 + source/core/shape/sphere.cpp | 1 + source/core/shape/spheresweep.cpp | 1 + source/core/shape/superellipsoid.cpp | 1 + source/core/shape/torus.cpp | 1 + source/core/shape/triangle.cpp | 1 + source/core/shape/truetype.cpp | 1 + source/core/support/cracklecache.cpp | 151 ++++++++++++++++ source/core/support/cracklecache.h | 169 ++++++++++++++++++ source/core/support/cracklecache_fwd.h | 55 ++++++ source/core/support/octree.cpp | 9 +- source/core/support/octree_fwd.h | 9 +- source/core/support/statistics.h | 1 + source/core/support/statistics_fwd.h | 51 ++++++ source/frontend/imagemessagehandler.cpp | 1 - source/frontend/parsermessagehandler.cpp | 1 + source/frontend/precomp.h | 10 -- source/frontend/processrenderoptions.cpp | 1 - source/frontend/renderfrontend.cpp | 2 +- source/frontend/renderfrontend.h | 3 + source/frontend/rendermessagehandler.cpp | 4 +- source/frontend/shelloutprocessing.cpp | 1 - source/frontend/simplefrontend.h | 3 + source/parser/fncode.cpp | 2 +- source/parser/parser.cpp | 17 +- source/parser/parser.h | 3 + source/parser/parser_expressions.cpp | 13 +- source/parser/parser_strings.cpp | 5 +- source/parser/parsertypes.cpp | 2 - source/parser/parsertypes.h | 3 - source/parser/precomp.h | 13 +- source/parser/rawtokenizer.cpp | 2 - source/parser/rawtokenizer.h | 3 - source/parser/scanner.cpp | 3 - source/parser/scanner.h | 3 - source/parser/symboltable.cpp | 5 +- source/parser/symboltable.h | 3 - source/povmain.cpp | 1 - source/povms/precomp.h | 12 -- source/vm/fnintern.cpp | 1 + source/vm/fnpovfpu.cpp | 1 + source/vm/precomp.h | 11 -- tests/source/tests.h | 4 +- tools/doxygen/doxygen.cfg | 4 +- tools/doxygen/source-doc.cfg | 3 +- unix/README.md | 1 - unix/configure.ac | 39 ---- unix/disp_sdl.cpp | 2 + unix/install.txt | 6 - unix/povconfig/syspovconfig_gnu.h | 1 - unix/povconfig/syspovconfigbackend.h | 8 +- unix/povconfig/syspovconfigbase.h | 18 +- vfe/unix/unixconsole.cpp | 50 ++++-- vfe/unix/vfeplatform.cpp | 3 + vfe/unix/vfeplatform.h | 2 - vfe/vfe.cpp | 3 + vfe/vfe.h | 4 - vfe/vfepovms.cpp | 19 +- vfe/vfeprecomp.h | 153 ++++++++-------- vfe/vfesession.cpp | 76 ++++---- vfe/vfesession.h | 28 +-- windows/povconfig/syspovconfig.h | 18 +- windows/povconfig/syspovconfig_msvc.h | 2 - windows/povconfig/syspovconfigbase.h | 3 +- windows/pvdisplay.cpp | 9 +- windows/pvengine.cpp | 13 +- windows/pvengine.h | 106 +---------- windows/pvmem.cpp | 6 +- windows/pvmem.h | 15 +- windows/pvtext.cpp | 4 +- windows/vs2015/console.vcxproj | 9 - windows/vs2015/povcore.vcxproj | 7 + windows/vs2015/povcore.vcxproj.filters | 21 +++ windows/vs2015/povray.sln | 6 - windows/vs2015/povray.vcxproj | 6 - windows/winprecomp.h | 11 +- 172 files changed, 1433 insertions(+), 1099 deletions(-) create mode 100644 source/core/math/randomsequence_fwd.h create mode 100644 source/core/math/vector_fwd.h create mode 100644 source/core/scene/scenedata_fwd.h create mode 100644 source/core/support/cracklecache.cpp create mode 100644 source/core/support/cracklecache.h create mode 100644 source/core/support/cracklecache_fwd.h create mode 100644 source/core/support/statistics_fwd.h diff --git a/.travis.yml b/.travis.yml index 46701f4f2..cb2a719fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,6 @@ addons: packages: - libboost-dev - libboost-date-time-dev - - libboost-thread-dev - libjpeg8-dev - libopenexr-dev - libpng12-dev diff --git a/changes.txt b/changes.txt index 990b1da88..0c4fc70b8 100644 --- a/changes.txt +++ b/changes.txt @@ -155,7 +155,7 @@ Reported by Coverity static code analysis: Miscellaneous: - - Fix `interior_texture` for text objects (as mentioned in GitHub issue #65) + - Fix `interior_texture` for text objects (as mentioned in GitHub issue #65). - Eliminated use of deprecated C++ `register` keyword (except in 3rd party libraries bundled with the POV-Ray source code). - Fix long-standing bug in Julia fractal primitive using hypercomplex numbers. @@ -195,6 +195,7 @@ Other Noteworthy - The `./configure` script can now be run without the `COMPILED_BY=...` option. In this case it defaults to `$USER `, where `$USER` is your login name. + - The `boost_thread` and `boost_system` libraries are no longer required. Changes between 3.7.1-beta.9 and 3.7.1-rc.1 diff --git a/platform/unix/syspovtimer.cpp b/platform/unix/syspovtimer.cpp index 239a59316..226f3518b 100644 --- a/platform/unix/syspovtimer.cpp +++ b/platform/unix/syspovtimer.cpp @@ -36,6 +36,7 @@ #include "syspovtimer.h" +#include #include #ifdef HAVE_UNISTD_H @@ -69,24 +70,47 @@ namespace pov_base //****************************************************************************** -#if !POV_USE_DEFAULT_DELAY +#if (POV_USE_PLATFORM_DELAY == 1) +// NOTE: Even if we decide to discontinue the use of this implementation, +// we may want to keep it around in case it may turn out to be superior on some +// exotic systems. void Delay(unsigned int msec) { -#if defined(HAVE_NANOSLEEP) - timespec ts; + timespec ts, remain; ts.tv_sec = msec / 1000; ts.tv_nsec = (POV_ULONG) (1000000) * (msec % 1000); - nanosleep(&ts, nullptr); -#elif defined(HAVE_USLEEP) - POV_ASSERT(msec < 1000); // On some systems, usleep() does not support sleeping for 1 second or more. - usleep (msec * (useconds_t)1000); -#else -#error "Bad compile-time configuration." -#endif + errno = 0; + while ((nanosleep(&ts, &remain) != 0) && (errno == EINTR)) + { + ts = remain; + errno = 0; + } +} + +#elif (POV_USE_PLATFORM_DELAY == 2) + +// ATTENTION: According to the POSIX standard, `usleep()` need not be +// thread-safe! + +// NOTE: Although we're currently not using this implementation, we may want to +// keep it around in case we find the default implementation wanting on some +// systems. +void Delay(unsigned int msec) +{ + // According to the POSIX standard, `usleep()` may not support parameter + // values of 1 million or higher (corresponding to 1s). We work around this + // by simply calling `usleep()` repeatedly until we're good. + for (unsigned int sec = 0; sec < (msec/1000); ++sec) + usleep((useconds_t)999999); // not exactly 1s, but close enough. + usleep ((msec % 1000) * (useconds_t)1000); } -#endif // !POV_USE_DEFAULT_DELAY +#else // POV_USE_PLATFORM_DELAY + +#error "Bad compile-time configuration." + +#endif // POV_USE_PLATFORM_DELAY //****************************************************************************** @@ -138,9 +162,11 @@ static inline bool GettimeofdayMillisec(POV_ULONG& result) } Timer::Timer () : +#if !POVUNIX_USE_DEFAULT_REAL_TIMER mWallTimeUseClockGettimeMonotonic (false), mWallTimeUseClockGettimeRealtime (false), mWallTimeUseGettimeofday (false), +#endif mProcessTimeUseGetrusageSelf (false), mProcessTimeUseClockGettimeProcess (false), mProcessTimeUseFallback (false), @@ -149,6 +175,7 @@ Timer::Timer () : mThreadTimeUseClockGettimeThread (false), mThreadTimeUseFallback (false) { +#if !POVUNIX_USE_DEFAULT_REAL_TIMER // Figure out which timer source to use for wall clock time. bool haveWallTime = false; #if defined(HAVE_DECL_CLOCK_MONOTONIC) && HAVE_DECL_CLOCK_MONOTONIC @@ -165,12 +192,13 @@ Timer::Timer () : // gettimeofday(), and document it here. if (!haveWallTime) haveWallTime = mWallTimeUseGettimeofday = GettimeofdayMillisec(mWallTimeStart); - // FIXME: add fallback, using ftime(), or time() + a counter for ms, or maybe boost::date_time + // FIXME: add fallback, using ftime(), or time() + a counter for ms, or maybe std::chrono if (!haveWallTime) { POV_ASSERT(false); mWallTimeStart = 0; } +#endif // Figure out which timer source to use for per-process CPU time. bool haveProcessTime = false; @@ -186,8 +214,12 @@ Timer::Timer () : #endif if (!haveProcessTime) { +#if POVUNIX_USE_DEFAULT_REAL_TIMER + haveProcessTime = mProcessTimeUseFallback = true; +#else haveProcessTime = mProcessTimeUseFallback = haveWallTime; mProcessTimeStart = mWallTimeStart; +#endif } // Figure out which timer source to use for per-thread CPU time. @@ -212,11 +244,7 @@ Timer::Timer () : } } -Timer::~Timer () -{ - // nothing to do -} - +#if !POVUNIX_USE_DEFAULT_REAL_TIMER POV_ULONG Timer::GetWallTime () const { POV_ULONG result; @@ -232,6 +260,7 @@ POV_ULONG Timer::GetWallTime () const return (GettimeofdayMillisec(result) ? result : 0); return 0; } +#endif POV_ULONG Timer::GetProcessTime () const { @@ -245,7 +274,11 @@ POV_ULONG Timer::GetProcessTime () const return (ClockGettimeMillisec(result, CLOCK_PROCESS_CPUTIME_ID) ? result : 0); #endif if (mProcessTimeUseFallback) +#if POVUNIX_USE_DEFAULT_REAL_TIMER + return mRealTimer.ElapsedTime(); +#else return GetWallTime (); +#endif return 0; } @@ -269,10 +302,12 @@ POV_ULONG Timer::GetThreadTime () const return 0; } +#if !POVUNIX_USE_DEFAULT_REAL_TIMER POV_LONG Timer::ElapsedRealTime () const { return GetWallTime () - mWallTimeStart; } +#endif POV_LONG Timer::ElapsedProcessCPUTime () const { @@ -286,7 +321,11 @@ POV_LONG Timer::ElapsedThreadCPUTime () const void Timer::Reset () { +#if POVUNIX_USE_DEFAULT_REAL_TIMER + mRealTimer.Reset(); +#else mWallTimeStart = GetWallTime (); +#endif mProcessTimeStart = GetProcessTime (); mThreadTimeStart = GetThreadTime (); } diff --git a/platform/unix/syspovtimer.h b/platform/unix/syspovtimer.h index b70305ff4..9983ce405 100644 --- a/platform/unix/syspovtimer.h +++ b/platform/unix/syspovtimer.h @@ -39,17 +39,19 @@ #include "base/configbase.h" +#include "base/timer.h" + namespace pov_base { -#if !POV_USE_DEFAULT_DELAY - -void Delay(unsigned int msec); - -#endif // !POV_USE_DEFAULT_DELAY +#if !POV_USE_DEFAULT_TIMER +// NOTE: Although we're currently not using platform-specific implementations +// of the wall clock timer, we may want to keep them around in case we find the +// default implementation wanting on particular flavours of Unix. +#define POVUNIX_USE_DEFAULT_REAL_TIMER 1 -#if !POV_USE_DEFAULT_TIMER +class DefaultRealTimer; /// Millisecond-precision timer. /// @@ -67,9 +69,13 @@ class Timer final public: Timer(); - ~Timer(); + ~Timer() = default; +#if POVUNIX_USE_DEFAULT_REAL_TIMER + inline POV_LONG ElapsedRealTime() const { return mRealTimer.ElapsedTime(); } +#else POV_LONG ElapsedRealTime() const; +#endif POV_LONG ElapsedProcessCPUTime() const; POV_LONG ElapsedThreadCPUTime() const; @@ -80,13 +86,19 @@ class Timer final private: +#if POVUNIX_USE_DEFAULT_REAL_TIMER + DefaultRealTimer mRealTimer; +#else POV_ULONG mWallTimeStart; +#endif POV_ULONG mProcessTimeStart; POV_ULONG mThreadTimeStart; +#if !POVUNIX_USE_DEFAULT_REAL_TIMER bool mWallTimeUseClockGettimeMonotonic : 1; ///< Whether we'll measure elapsed wall-clock time using `clock_gettime(CLOCK_MONOTONIC)`. bool mWallTimeUseClockGettimeRealtime : 1; ///< Whether we'll measure elapsed wall-clock time using `clock_gettime(CLOCK_REALTIME)`. bool mWallTimeUseGettimeofday : 1; ///< Whether we'll measure elapsed wall-clock time using `gettimeofday()`. +#endif bool mProcessTimeUseGetrusageSelf : 1; ///< Whether we'll measure per-process CPU time using `getrusage(RUSAGE_SELF)`. bool mProcessTimeUseClockGettimeProcess : 1; ///< Whether we'll measure per-process CPU time using `clock_gettime(CLOCK_PROCESS_CPUTIME_ID)`. @@ -97,7 +109,9 @@ class Timer final bool mThreadTimeUseClockGettimeThread : 1; ///< Whether we'll measure per-thread CPU time `clock_gettime(CLOCK_THREAD_CPUTIME_ID)`. bool mThreadTimeUseFallback : 1; ///< Whether we'll fall back to per-process CPU time (or wall-clock time) instead of per-thread CPU time. +#if !POVUNIX_USE_DEFAULT_REAL_TIMER POV_ULONG GetWallTime() const; +#endif POV_ULONG GetThreadTime() const; POV_ULONG GetProcessTime() const; }; diff --git a/platform/windows/syspovtimer.cpp b/platform/windows/syspovtimer.cpp index e4b793eb0..a00f7f482 100644 --- a/platform/windows/syspovtimer.cpp +++ b/platform/windows/syspovtimer.cpp @@ -53,13 +53,22 @@ namespace pov_base //****************************************************************************** +#if POV_USE_PLATFORM_DELAY + +// NOTE: Although we're currently not using this implementation, we may want to +// keep it around in case we find the default implementation wanting on Windows +// systems in general or some flavours in particular. void Delay(unsigned int msec) { Sleep (msec); } +#endif // POV_USE_PLATFORM_DELAY + //****************************************************************************** +#if !POV_USE_DEFAULT_TIMER + Timer::Timer () : // TODO - sources on the internet indicate that GetThreadTimes() and GetProcessTimes() have been // around as early as NT 3.1. Is there a reason we're only making use of it in NT 4.0 and @@ -175,5 +184,9 @@ bool Timer::HasValidProcessCPUTime () const return mCPUTimeSupported; } +#endif // POV_USE_DEFAULT_TIMER + +//****************************************************************************** + } // end of namespace pov_base diff --git a/platform/windows/syspovtimer.h b/platform/windows/syspovtimer.h index d6610fdd4..d43986549 100644 --- a/platform/windows/syspovtimer.h +++ b/platform/windows/syspovtimer.h @@ -42,7 +42,7 @@ namespace pov_base { -void Delay(unsigned int msec); +#if !POV_USE_DEFAULT_TIMER class Timer final { @@ -72,6 +72,8 @@ class Timer final POV_ULONG GetProcessTime () const; }; +#endif // POV_USE_DEFAULT_TIMER + } // end of namespace pov_base diff --git a/platform/x86/avx/avxnoise.cpp b/platform/x86/avx/avxnoise.cpp index 047b28bfb..1bd6da533 100644 --- a/platform/x86/avx/avxnoise.cpp +++ b/platform/x86/avx/avxnoise.cpp @@ -79,7 +79,7 @@ static inline __m256d permute4x64_functional(const __m256d& x, int i) const int idx1 = ((i >> 2) & 0x3); const int idx2 = ((i >> 4) & 0x3); const int idx3 = ((i >> 6) & 0x3); - ALIGN32 double p[4]; + alignas(32) double p[4]; _mm256_store_pd(p,x); if (idx0 == idx1 && idx1 == idx2 && idx2 == idx3) @@ -134,7 +134,7 @@ static inline __m256d permute4x64_functional(const __m256d& x, int i) extern DBL RTable[]; -ALIGN32 static AVXTABLETYPE AVXRTable[267]; +alignas(32) static AVXTABLETYPE AVXRTable[267]; void AVXNoiseInit() { diff --git a/platform/x86/avx2fma3/avx2fma3noise.cpp b/platform/x86/avx2fma3/avx2fma3noise.cpp index ba4b5827d..616527956 100644 --- a/platform/x86/avx2fma3/avx2fma3noise.cpp +++ b/platform/x86/avx2fma3/avx2fma3noise.cpp @@ -121,7 +121,7 @@ const bool kAVX2FMA3NoiseEnabled = true; extern DBL RTable[]; -ALIGN32 static AVX2TABLETYPE AVX2RTable[267]; +alignas(32) static AVX2TABLETYPE AVX2RTable[267]; void AVX2FMA3NoiseInit() { diff --git a/source-doc/styleguide.md b/source-doc/styleguide.md index 80763460b..cef442af6 100644 --- a/source-doc/styleguide.md +++ b/source-doc/styleguide.md @@ -53,7 +53,6 @@ POV-Ray is being developed with portability high in mind. In practice and at pre - While POV-Ray does require boost, we want to keep dependency on it to a minimum. The following are currently considered fair game: - Flyweights. - - Threads. - DateTime **except** features that may require linking with the lib (mostly conversions to/from string). - SmartPtr intrusive pointers. . @@ -171,6 +170,8 @@ Parameter and variable names might carry one or more additional prefixes. These . - Protected or private member variable names should begin with a (possibly additional) `m` prefix. - Global variable names should begin with a (possibly additional) `g` prefix. + - Global variables with thread-local storage should begin with a (possibly additional) `gt` + - prefix. - Constants should begin with a `k` prefix. (Does not apply to const parameters.) . diff --git a/source/backend/bounding/boundingtask.cpp b/source/backend/bounding/boundingtask.cpp index f05ae93bd..f49e9b821 100644 --- a/source/backend/bounding/boundingtask.cpp +++ b/source/backend/bounding/boundingtask.cpp @@ -45,7 +45,6 @@ // Boost header files #include -#include // POV-Ray header files (base module) // (none at the moment) diff --git a/source/backend/configbackend.h b/source/backend/configbackend.h index 1a2c63212..cbed8b408 100644 --- a/source/backend/configbackend.h +++ b/source/backend/configbackend.h @@ -77,35 +77,6 @@ #define POV_USE_DEFAULT_TASK_CLEANUP 1 #endif -/// @def POV_THREAD_STACK_SIZE -/// Default thread stack size. -/// -#ifndef POV_THREAD_STACK_SIZE - #define POV_THREAD_STACK_SIZE (2 * 1024 * 1024) // 2 MiB -#endif - -static_assert( - POV_THREAD_STACK_SIZE >= 1024 * 1024, - "Unreasonably small thread stack size. Proceed at your own risk." -); - -/// @def POV_CONVERT_TEXT_TO_UCS2 -/// Convert text from system-specific format to UCS2. -/// -/// @note -/// The macro is responsible for creating a sufficiently large result buffer, using @ref POV_MALLOC(). -/// @note -/// The result must be a genuine UCS2 string. UCS4/Unicode characters outside the Basic Multilingual Plane -/// are not supported. -/// -/// @param[in] ts Null-terminated byte sequence to convert. -/// @param[out] as Number of UCS2 characters in result. -/// @return Converted null-terminated UCS2 character sequence, or `nullptr` if conversion is not supported. -/// -#ifndef POV_CONVERT_TEXT_TO_UCS2 - #define POV_CONVERT_TEXT_TO_UCS2(ts, as) (nullptr) -#endif - //****************************************************************************** /// /// @name Debug Settings. @@ -165,15 +136,6 @@ static_assert( #define POV_TASK_ASSERT(expr) POV_ASSERT_DISABLE(expr) #endif -/// @def HAVE_BOOST_THREAD_ATTRIBUTES -/// Whether boost::thread::attributes is available (and can be used to set a thread's stack size). -/// -#if BOOST_VERSION >= 105000 - #define HAVE_BOOST_THREAD_ATTRIBUTES 1 -#else - #define HAVE_BOOST_THREAD_ATTRIBUTES 0 -#endif - /// @} /// //****************************************************************************** diff --git a/source/backend/control/messagefactory.cpp b/source/backend/control/messagefactory.cpp index 48c8bc6b1..adde3762d 100644 --- a/source/backend/control/messagefactory.cpp +++ b/source/backend/control/messagefactory.cpp @@ -40,10 +40,6 @@ // C++ standard header files // (none at the moment) -// Boost header files -#include -#include - // POV-Ray header files (base module) #include "base/povassert.h" diff --git a/source/backend/control/parsertask.cpp b/source/backend/control/parsertask.cpp index a07d44946..52157a320 100644 --- a/source/backend/control/parsertask.cpp +++ b/source/backend/control/parsertask.cpp @@ -38,8 +38,9 @@ // C++ variants of C standard header files // C++ standard header files + // Boost header files -// (none at the moment) +#include // POV-Ray header files (base module) #include "base/types.h" diff --git a/source/backend/control/parsertask.h b/source/backend/control/parsertask.h index bc8d786d0..75a6cdc9a 100644 --- a/source/backend/control/parsertask.h +++ b/source/backend/control/parsertask.h @@ -45,7 +45,6 @@ // C++ standard header files #include -// Boost header files // POV-Ray header files (base module) // POV-Ray header files (core module) // (none at the moment) diff --git a/source/backend/control/scene.cpp b/source/backend/control/scene.cpp index f4dc518b9..c8376f9c4 100644 --- a/source/backend/control/scene.cpp +++ b/source/backend/control/scene.cpp @@ -42,9 +42,9 @@ // C++ standard header files #include #include +#include // Boost header files -#include #include // POV-Ray header files (base module) @@ -106,7 +106,7 @@ void Scene::StartParser(POVMS_Object& parseOptions) // A scene can only be parsed once if (parserControlThread == nullptr) - parserControlThread = Task::NewBoostThread(boost::bind(&Scene::ParserControlThread, this), POV_THREAD_STACK_SIZE); + parserControlThread = new std::thread(boost::bind(&Scene::ParserControlThread, this)); else return; @@ -274,7 +274,10 @@ void Scene::GetStatistics(POVMS_Object& parserStats) for(std::vector::iterator i(sceneThreadData.begin()); i != sceneThreadData.end(); i++) { timeData[(*i)->timeType].realTime = max(timeData[(*i)->timeType].realTime, (*i)->realTime); - timeData[(*i)->timeType].cpuTime += (*i)->cpuTime; + if ((*i)->cpuTime >= 0) + timeData[(*i)->timeType].cpuTime += (*i)->cpuTime; + else + timeData[(*i)->timeType].cpuTime = -1; timeData[(*i)->timeType].samples++; } @@ -285,7 +288,8 @@ void Scene::GetStatistics(POVMS_Object& parserStats) POVMS_Object elapsedTime(kPOVObjectClass_ElapsedTime); elapsedTime.SetLong(kPOVAttrib_RealTime, timeData[i].realTime); - elapsedTime.SetLong(kPOVAttrib_CPUTime, timeData[i].cpuTime); + if (timeData[i].cpuTime >= 0) + elapsedTime.SetLong(kPOVAttrib_CPUTime, timeData[i].cpuTime); elapsedTime.SetInt(kPOVAttrib_TimeSamples, POVMSInt(timeData[i].samples)); switch(i) @@ -369,7 +373,7 @@ void Scene::ParserControlThread() if(stopRequsted == false) { - boost::thread::yield(); + std::this_thread::yield(); Delay(10); } } diff --git a/source/backend/control/scene.h b/source/backend/control/scene.h index f5c5f7826..6288c2c3a 100644 --- a/source/backend/control/scene.h +++ b/source/backend/control/scene.h @@ -45,13 +45,11 @@ // C++ standard header files #include +// not required for `std::thread` because we forward-declare it in `base/base_fwd.h` #include -// Boost header files -#include - // POV-Ray header files (base module) -// (none at the moment) +#include "base/base_fwd.h" // POV-Ray header files (core module) #include "core/core_fwd.h" @@ -190,7 +188,7 @@ class Scene final /// stop request flag bool stopRequsted; /// parser control thread - boost::thread *parserControlThread; + std::thread *parserControlThread; /** * Send the parser statistics upon completion of a parsing. diff --git a/source/backend/lighting/photonshootingstrategy.cpp b/source/backend/lighting/photonshootingstrategy.cpp index 3c808c241..3db547533 100644 --- a/source/backend/lighting/photonshootingstrategy.cpp +++ b/source/backend/lighting/photonshootingstrategy.cpp @@ -75,7 +75,7 @@ void PhotonShootingStrategy::start() PhotonShootingUnit* PhotonShootingStrategy::getNextUnit() { - boost::mutex::scoped_lock lock(nextUnitMutex); + std::lock_guard lock(nextUnitMutex); if (iter == units.end()) return nullptr; PhotonShootingUnit* unit = *iter; diff --git a/source/backend/lighting/photonshootingstrategy.h b/source/backend/lighting/photonshootingstrategy.h index 6774b979a..6f7c5ddd9 100644 --- a/source/backend/lighting/photonshootingstrategy.h +++ b/source/backend/lighting/photonshootingstrategy.h @@ -45,11 +45,9 @@ // C++ standard header files #include +#include #include -// Boost header files -#include - // POV-Ray header files (base module) // (none at the moment) @@ -78,7 +76,7 @@ class PhotonShootingStrategy final private: std::vector::iterator iter; - boost::mutex nextUnitMutex; + std::mutex nextUnitMutex; }; diff --git a/source/backend/lighting/photonshootingtask.cpp b/source/backend/lighting/photonshootingtask.cpp index ce593ebb0..860943fb5 100644 --- a/source/backend/lighting/photonshootingtask.cpp +++ b/source/backend/lighting/photonshootingtask.cpp @@ -54,6 +54,7 @@ #include "core/scene/object.h" #include "core/shape/csg.h" #include "core/support/octree.h" +#include "core/support/statistics.h" // POV-Ray header files (POVMS module) #include "povms/povmscpp.h" diff --git a/source/backend/povray.cpp b/source/backend/povray.cpp index 7b7690db7..dc0e1a299 100644 --- a/source/backend/povray.cpp +++ b/source/backend/povray.cpp @@ -41,9 +41,9 @@ // C++ standard header files #include +#include // Boost header files -#include #include // POV-Ray header files (base module) @@ -216,7 +216,7 @@ volatile POVMSContext POV_RenderContext = nullptr; volatile POVMSAddress POV_FrontendAddress = POVMSInvalidAddress; /// Main POV-Ray thread that waits for messages from the frontend -boost::thread *POV_MainThread = nullptr; +std::thread *POV_MainThread = nullptr; /// Flag to mark main POV-Ray thread for termination volatile bool POV_TerminateMainThread = false; @@ -610,7 +610,7 @@ void MainThreadFunction(const boost::function0& threadExit) (void)POVMS_ASSERT_OUTPUT("Unhandled exception in POVMS receive handler in main POV-Ray backend thread.", __FILE__, __LINE__); } - boost::thread::yield(); + std::this_thread::yield(); } // close_all(); // TODO FIXME - Remove this call! [trf] @@ -642,7 +642,7 @@ void MainThreadFunction(const boost::function0& threadExit) } // namespace -boost::thread *povray_init(const boost::function0& threadExit, POVMSAddress *addr) +std::thread *povray_init(const boost::function0& threadExit, POVMSAddress *addr) { using namespace pov; @@ -654,13 +654,13 @@ boost::thread *povray_init(const boost::function0& threadExit, POVMSAddres Initialize_Noise(); pov::InitializePatternGenerators(); - POV_MainThread = Task::NewBoostThread(boost::bind(&MainThreadFunction, threadExit), POV_THREAD_STACK_SIZE); + POV_MainThread = new std::thread(boost::bind(&MainThreadFunction, threadExit)); - // we can't depend on boost::thread::yield here since under windows it is not - // guaranteed to give up a time slice [see API docs for Sleep(0)] + // We can't depend on `std::this_thread::yield()` here since it is not + // guaranteed to give up a time slice. while (POV_RenderContext == nullptr) { - boost::thread::yield(); + std::this_thread::yield(); pov_base::Delay(50); } } @@ -688,7 +688,7 @@ void povray_terminate() while (POV_RenderContext != nullptr) { - boost::thread::yield(); + std::this_thread::yield(); pov_base::Delay(100); } diff --git a/source/backend/povray.h b/source/backend/povray.h index eb53108da..f60fb43b0 100644 --- a/source/backend/povray.h +++ b/source/backend/povray.h @@ -46,14 +46,16 @@ #include "backend/configbackend.h" // C++ variants of C standard header files -// C++ standard header files // (none at the moment) +// C++ standard header files +// not required for `std::thread` because we forward-declare it in `base/base_fwd.h` + // Boost header files -#include #include // POV-Ray header files (base module) +#include "base/base_fwd.h" #include "base/version_info.h" // POV-Ray header files (backend module) @@ -66,7 +68,7 @@ * @param addr If not `nullptr`, backend address on return. * @return Pointer to the thread resource created. */ -boost::thread *povray_init(const boost::function0& threadExit, POVMSAddress *addr = nullptr); +std::thread *povray_init(const boost::function0& threadExit, POVMSAddress *addr = nullptr); /** * This function shuts down the main render thread and after it has diff --git a/source/backend/precomp.h b/source/backend/precomp.h index f9397f771..0976c7677 100644 --- a/source/backend/precomp.h +++ b/source/backend/precomp.h @@ -59,25 +59,20 @@ // C++ standard header files #include -#include +#include +#include #include #include #include +#include #include #include #include #include #include +#include #include // Boost header files #include -#include #include -#include -#if POV_MULTITHREADED -#include -#include -#endif -#include - diff --git a/source/backend/render/radiositytask.cpp b/source/backend/render/radiositytask.cpp index fc706957e..a6d8262a2 100644 --- a/source/backend/render/radiositytask.cpp +++ b/source/backend/render/radiositytask.cpp @@ -43,15 +43,13 @@ #include #include -// Boost header files -#include -#include - // POV-Ray header files (base module) #include "base/timer.h" #include "base/types.h" // POV-Ray header files (core module) +#include "core/support/statistics.h" + // POV-Ray header files (POVMS module) // (none at the moment) diff --git a/source/backend/render/rendertask.cpp b/source/backend/render/rendertask.cpp index 9219624bc..dcc9da4b7 100644 --- a/source/backend/render/rendertask.cpp +++ b/source/backend/render/rendertask.cpp @@ -41,7 +41,6 @@ // (none at the moment) // Boost header files -#include #include // POV-Ray header files (base module) diff --git a/source/backend/render/tracetask.cpp b/source/backend/render/tracetask.cpp index 063404981..b73119de4 100644 --- a/source/backend/render/tracetask.cpp +++ b/source/backend/render/tracetask.cpp @@ -43,9 +43,6 @@ #include #include -// Boost header files -#include - // POV-Ray header files (base module) #include "base/image/colourspace.h" #ifdef PROFILE_INTERSECTIONS @@ -58,6 +55,7 @@ #include "core/math/jitter.h" #include "core/math/matrix.h" #include "core/render/trace.h" +#include "core/support/statistics.h" // POV-Ray header files (POVMS module) // (none at the moment) diff --git a/source/backend/scene/backendscenedata.cpp b/source/backend/scene/backendscenedata.cpp index e2829156a..b0c7a54af 100644 --- a/source/backend/scene/backendscenedata.cpp +++ b/source/backend/scene/backendscenedata.cpp @@ -43,10 +43,6 @@ #include #include -// Boost header files -#include -#include - // POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/fileutil.h" diff --git a/source/backend/scene/view.cpp b/source/backend/scene/view.cpp index f1b693085..8500f8a23 100644 --- a/source/backend/scene/view.cpp +++ b/source/backend/scene/view.cpp @@ -41,12 +41,11 @@ // C++ standard header files #include +#include +#include // Boost header files -#include #include -#include -#include #include // POV-Ray header files (base module) @@ -237,7 +236,7 @@ void ViewData::getBlockXY(const unsigned int nb, unsigned int &x, unsigned int & bool ViewData::GetNextRectangle(POVRect& rect, unsigned int& serial) { - boost::mutex::scoped_lock lock(nextBlockMutex); + std::lock_guard lock(nextBlockMutex); while(true) { @@ -274,7 +273,7 @@ bool ViewData::GetNextRectangle(POVRect& rect, unsigned int& serial) bool ViewData::GetNextRectangle(POVRect& rect, unsigned int& serial, BlockInfo*& blockInfo, unsigned int stride) { - boost::mutex::scoped_lock lock(nextBlockMutex); + std::lock_guard lock(nextBlockMutex); BlockIdSet newPostponedList; @@ -535,7 +534,7 @@ void ViewData::CompletedRectangle(const POVRect& rect, unsigned int serial, cons void ViewData::CompletedRectangle(const POVRect& rect, unsigned int serial, float completion, BlockInfo* blockInfo) { { - boost::mutex::scoped_lock lock(nextBlockMutex); + std::lock_guard lock(nextBlockMutex); blockBusyList.erase(serial); blockInfoList[serial] = blockInfo; } @@ -578,7 +577,7 @@ void ViewData::SetNextRectangle(const BlockIdSet& bsl, unsigned int fs) void ViewData::SetHighestTraceLevel(unsigned int htl) { - boost::mutex::scoped_lock lock(setDataMutex); + std::lock_guard lock(setDataMutex); highestTraceLevel = max(highestTraceLevel, htl); } @@ -709,7 +708,7 @@ void View::StartRender(POVMS_Object& renderOptions) shared_ptr blockskiplist(new ViewData::BlockIdSet()); if (renderControlThread == nullptr) - renderControlThread = Task::NewBoostThread(boost::bind(&View::RenderControlThread, this), POV_THREAD_STACK_SIZE); + renderControlThread = new std::thread(boost::bind(&View::RenderControlThread, this)); viewData.qualityFlags = QualityFlags(clip(renderOptions.TryGetInt(kPOVAttrib_Quality, 9), 0, 9)); @@ -738,11 +737,11 @@ void View::StartRender(POVMS_Object& renderOptions) seed = renderOptions.TryGetInt(kPOVAttrib_StochasticSeed, 0); if (seed == 0) - { - boost::posix_time::ptime now = boost::posix_time::second_clock::universal_time(); - boost::posix_time::ptime base = boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1)); - seed = (now - base).total_seconds(); - } + // The following expression returns the number of _ticks_ elapsed since + // the system clock's _epoch_, where a _tick_ is the platform-dependent + // shortest time interval the system clock can measure, and _epoch_ is a + // platform-dependent point in time (usually 1970-01-01 00:00:00). + seed = std::chrono::system_clock::now().time_since_epoch().count(); // TODO FIXME - [CLi] handle loading, storing (and later optionally deleting) of radiosity cache file for trace abort & continue feature // TODO FIXME - [CLi] if high reproducibility is a demand, timing of writing samples to disk is an issue regarding abort & continue @@ -1462,7 +1461,7 @@ void View::RenderControlThread() if(stopRequsted == false) { - boost::thread::yield(); + std::this_thread::yield(); Delay(50); } } @@ -1495,14 +1494,14 @@ RTRData::~RTRData() // lead to all threads ending up waiting on the condition). const Camera *RTRData::CompletedFrame() { - boost::mutex::scoped_lock lock (counterMutex); + std::unique_lock lock (counterMutex); vector& cameras = viewData.GetSceneData()->cameras; bool ca = viewData.GetSceneData()->clocklessAnimation; if(true) // yes I know it's not needed, but I prefer this over headless code blocks { - // test >= in case of weirdness due to the timed wait we use with the boost::condition + // test >= in case of weirdness due to the timed wait we use with the std::condition_variable if (++numRenderThreadsCompleted >= numRenderThreads) { viewData.SetNextRectangle(ViewData::BlockIdSet(), 0); @@ -1549,16 +1548,11 @@ const Camera *RTRData::CompletedFrame() } } - // TODO FIXME - boost::xtime has been deprecated since boost 1.34. - boost::xtime t; - boost::xtime_get (&t, POV_TIME_UTC); - t.sec += 3; - // this will cause us to wait until the other threads are done. // we use a timed lock so that we eventually pick up a render cancel request. // if we do exit as a result of a timeout, and there is not a cancel pending, // things could get out of whack. - if (!event.timed_wait(lock, t)) + if (event.wait_for(lock, std::chrono::seconds(3)) == std::cv_status::timeout) numRenderThreadsCompleted--; return (ca ? &cameras[numRTRframes % cameras.size()] : nullptr); diff --git a/source/backend/scene/view.h b/source/backend/scene/view.h index c5fb4164c..a2b5931cc 100644 --- a/source/backend/scene/view.h +++ b/source/backend/scene/view.h @@ -44,10 +44,14 @@ // (none at the moment) // C++ standard header files +#include #include +#include +// not required for `std::thread` because we forward-declare it in `base/base_fwd.h` #include // POV-Ray header files (base module) +#include "base/base_fwd.h" #include "base/types.h" // TODO - only appears to be pulled in for POVRect - can we avoid this? // POV-Ray header files (core module) @@ -85,9 +89,9 @@ class RTRData final private: ViewData& viewData; - boost::mutex counterMutex; - boost::mutex eventMutex; - boost::condition event; + std::mutex counterMutex; + std::mutex eventMutex; + std::condition_variable event; int width; int height; unsigned int numPixelsCompleted; @@ -304,9 +308,9 @@ class ViewData final /// repeating the process until a value is reached that is not found in @ref blockSkipList. volatile unsigned int nextBlock; /// next block counter mutex - boost::mutex nextBlockMutex; + std::mutex nextBlockMutex; /// set data mutex - boost::mutex setDataMutex; + std::mutex setDataMutex; /// Whether all blocks have been dispatched at least once. bool completedFirstPass; /// highest reached trace level @@ -459,7 +463,7 @@ class View final /// stop request flag bool stopRequsted; /// render control thread - boost::thread *renderControlThread; + std::thread *renderControlThread; /// BSP tree mailbox BSPTree::Mailbox mailbox; diff --git a/source/backend/support/task.cpp b/source/backend/support/task.cpp index f6732d71a..72c3065a3 100644 --- a/source/backend/support/task.cpp +++ b/source/backend/support/task.cpp @@ -41,10 +41,10 @@ // C++ standard header files #include +#include // Boost header files #include -#include // POV-Ray header files (base module) #include "base/povassert.h" @@ -113,7 +113,7 @@ POV_LONG Task::ConsumedCPUTime() const void Task::Start(const boost::function0& completion) { if ((done == false) && (taskThread == nullptr)) - taskThread = NewBoostThread(boost::bind(&Task::TaskThread, this, completion), POV_THREAD_STACK_SIZE); + taskThread = new std::thread(boost::bind(&Task::TaskThread, this, completion)); } void Task::RequestStop() @@ -143,6 +143,22 @@ void Task::Resume() paused = false; } +void Task::Cooperate() +{ + if (stopRequested == true) + throw StopThreadException(); + else if (paused == true) + { + while (paused == true) + { + std::this_thread::yield(); + Delay(100); + if (stopRequested == true) + throw StopThreadException(); + } + } +} + POV_LONG Task::ElapsedRealTime() const { POV_TASK_ASSERT(timer != nullptr); diff --git a/source/backend/support/task.h b/source/backend/support/task.h index 14a2f6904..6fec0194b 100644 --- a/source/backend/support/task.h +++ b/source/backend/support/task.h @@ -45,9 +45,9 @@ // C++ standard header files #include #include +// not required for `std::thread` because we forward-declare it in `base/base_fwd.h` // Boost header files -#include #include // POV-Ray header files (base module) @@ -86,45 +86,12 @@ class Task void Stop(); void Pause(); void Resume(); - - inline void Cooperate() - { - if(stopRequested == true) - throw StopThreadException(); - else if(paused == true) - { - while(paused == true) - { - boost::thread::yield(); - Delay(100); - if(stopRequested == true) - throw StopThreadException(); - } - } - } + void Cooperate(); inline ThreadData *GetDataPtr() { return taskData; } inline POVMSContext GetPOVMSContext() { return povmsContext; } - /// Start a new thread with a given stack size. - template - inline static boost::thread* NewBoostThread(CALLABLE_T func, int stackSize) - { -#if HAVE_BOOST_THREAD_ATTRIBUTES - // boost 1.50 and later provide an official mechanism to set the stack size. - boost::thread::attributes attr; - attr.set_stack_size (stackSize); - return new boost::thread(attr, func); -#elif !defined(USE_OFFICIAL_BOOST) - // Prior to boost 1.50, for some platforms we used an unofficial hacked version of boost to set the stack size. - return new boost::thread(func, stackSize); -#else - // For some platforms the default stack size of older boost versions may suffice. - return new boost::thread(func); -#endif - } - protected: struct StopThreadException final {}; // TODO - consider subclassing from std::exception hierarchy. @@ -157,7 +124,7 @@ class Task // CPU time spend in task POV_LONG cpuTime; /// task thread - boost::thread *taskThread; + std::thread *taskThread; /// POVMS message receiving context POVMSContext povmsContext; diff --git a/source/backend/support/taskqueue.cpp b/source/backend/support/taskqueue.cpp index 9db706040..80db09b93 100644 --- a/source/backend/support/taskqueue.cpp +++ b/source/backend/support/taskqueue.cpp @@ -40,7 +40,6 @@ // C++ standard header files // Boost header files -#include #include // POV-Ray header files (base module) @@ -71,7 +70,7 @@ TaskQueue::~TaskQueue() void TaskQueue::Stop() { - boost::recursive_mutex::scoped_lock lock(queueMutex); + std::lock_guard lock(queueMutex); // we pass through this list twice; the first time through only sets the cancel // flag, and the second time through waits for the threads to exit. if we only @@ -93,7 +92,7 @@ void TaskQueue::Stop() void TaskQueue::Pause() { - boost::recursive_mutex::scoped_lock lock(queueMutex); + std::lock_guard lock(queueMutex); for(list::iterator i(activeTasks.begin()); i != activeTasks.end(); i++) i->GetTask()->Pause(); @@ -101,7 +100,7 @@ void TaskQueue::Pause() void TaskQueue::Resume() { - boost::recursive_mutex::scoped_lock lock(queueMutex); + std::lock_guard lock(queueMutex); for(list::iterator i(activeTasks.begin()); i != activeTasks.end(); i++) i->GetTask()->Resume(); @@ -109,7 +108,7 @@ void TaskQueue::Resume() bool TaskQueue::IsPaused() { - boost::recursive_mutex::scoped_lock lock(queueMutex); + std::lock_guard lock(queueMutex); bool paused = false; @@ -121,7 +120,7 @@ bool TaskQueue::IsPaused() bool TaskQueue::IsRunning() { - boost::recursive_mutex::scoped_lock lock(queueMutex); + std::lock_guard lock(queueMutex); bool running = !queuedTasks.empty(); @@ -133,7 +132,7 @@ bool TaskQueue::IsRunning() bool TaskQueue::IsDone() { - boost::recursive_mutex::scoped_lock lock(queueMutex); + std::lock_guard lock(queueMutex); bool done = queuedTasks.empty(); @@ -145,14 +144,14 @@ bool TaskQueue::IsDone() bool TaskQueue::Failed() { - boost::recursive_mutex::scoped_lock lock(queueMutex); + std::lock_guard lock(queueMutex); return (failed != kNoError); } int TaskQueue::FailureCode(int defval) { - boost::recursive_mutex::scoped_lock lock(queueMutex); + std::lock_guard lock(queueMutex); if(failed == kNoError) return defval; @@ -162,7 +161,7 @@ int TaskQueue::FailureCode(int defval) ThreadData *TaskQueue::AppendTask(Task *task) { - boost::recursive_mutex::scoped_lock lock(queueMutex); + std::lock_guard lock(queueMutex); failed = false; @@ -175,7 +174,7 @@ ThreadData *TaskQueue::AppendTask(Task *task) void TaskQueue::AppendSync() { - boost::recursive_mutex::scoped_lock lock(queueMutex); + std::lock_guard lock(queueMutex); queuedTasks.push(TaskEntry::kSync); @@ -184,7 +183,7 @@ void TaskQueue::AppendSync() void TaskQueue::AppendMessage(POVMS_Message& msg) { - boost::recursive_mutex::scoped_lock lock(queueMutex); + std::lock_guard lock(queueMutex); queuedTasks.push(TaskEntry(msg)); @@ -193,7 +192,7 @@ void TaskQueue::AppendMessage(POVMS_Message& msg) void TaskQueue::AppendFunction(const boost::function1& fn) { - boost::recursive_mutex::scoped_lock lock(queueMutex); + std::lock_guard lock(queueMutex); queuedTasks.push(TaskEntry(fn)); @@ -202,7 +201,7 @@ void TaskQueue::AppendFunction(const boost::function1& fn) bool TaskQueue::Process() { - boost::recursive_mutex::scoped_lock lock(queueMutex); + std::unique_lock lock(queueMutex); for(list::iterator i(activeTasks.begin()); i != activeTasks.end();) { diff --git a/source/backend/support/taskqueue.h b/source/backend/support/taskqueue.h index ba482a311..a5a0ae457 100644 --- a/source/backend/support/taskqueue.h +++ b/source/backend/support/taskqueue.h @@ -43,13 +43,14 @@ // (none at the moment) // C++ standard header files +#include #include #include +#include #include // Boost header files -#include -#include +#include // POV-Ray header files (base module) // (none at the moment) @@ -122,11 +123,11 @@ class TaskQueue final /// active task list std::list activeTasks; /// queue mutex - boost::recursive_mutex queueMutex; + std::recursive_mutex queueMutex; /// failed code int failed; /// wait for data in queue or related operation to be processed - boost::condition processCondition; + std::condition_variable_any processCondition; TaskQueue(const TaskQueue&) = delete; TaskQueue& operator=(const TaskQueue&) = delete; diff --git a/source/base/base_fwd.h b/source/base/base_fwd.h index c71b98949..37622eea9 100644 --- a/source/base/base_fwd.h +++ b/source/base/base_fwd.h @@ -40,6 +40,14 @@ /// @note /// This file should not pull in any POV-Ray header whatsoever. +// Forward-declare the standard library's thread type, rather than pulling in +// ``, and all the other headers it might want in turn. +namespace std +{ +class thread; +} +// end of namespace std + namespace pov_base { diff --git a/source/base/configbase.h b/source/base/configbase.h index 18b9bae02..d83b18e06 100644 --- a/source/base/configbase.h +++ b/source/base/configbase.h @@ -45,9 +45,6 @@ // C++ standard header files // (none at the moment) -// Boost header files -#include - //############################################################################## /// /// @defgroup PovBaseConfig Base Compile-Time Configuration @@ -67,7 +64,6 @@ /// - `POV_MALLOC` /// - `POV_REALLOC` /// - `POV_FREE` -/// - `POV_MEMMOVE` /// /// @{ @@ -87,6 +83,7 @@ #define POV_CPP11_SUPPORTED (__cplusplus >= 201103L) #endif + /// @} /// //****************************************************************************** @@ -510,15 +507,6 @@ #define POV_STRDUP(str) pov_base::pov_strdup(str) #endif -// For those systems that don't have memmove, this can also be pov_memmove -#ifndef POV_MEMMOVE - #define POV_MEMMOVE(dst,src,len) pov_base::pov_memmove((dst),(src),(len)) -#endif - -#ifndef POV_MEMCPY - #define POV_MEMCPY(dst,src,len) std::memcpy((dst),(src),(len)) -#endif - #ifndef POV_MEM_STATS #define POV_MEM_STATS 0 #define POV_GLOBAL_MEM_STATS(a,f,c,p,s,l) (false) @@ -708,17 +696,6 @@ #define CDECL #endif -#ifndef ALIGN16 - #define ALIGN16 -#endif - -#ifndef ALIGN32 - // leave undefined, allowing code to detect that forced 32-bit alignment isn't supported - // The following two lines work around doxygen being unable to document undefined macros. - #define ALIGN32 (undefined) - #undef ALIGN32 -#endif - #ifndef FORCEINLINE #define FORCEINLINE inline #endif @@ -733,18 +710,29 @@ #define POV_MULTITHREADED 1 #endif -/// @def POV_USE_DEFAULT_DELAY -/// Whether to use a default implementation for the millisecond-precision delay function. +/// @def POV_USE_PLATFORM_DELAY +/// Whether to use a platform-specific implementation for the millisecond-precision delay function. /// -/// Define as non-zero to use a default implementation for the @ref pov_base::Delay() function, or zero if +/// Define as zero to use a portable default implementation for the @ref pov_base::Delay() function, or non-zero if /// the platform provides its own implementation. /// -/// @note -/// The default implementation is only provided as a last-ditch resort. Wherever possible, -/// implementations should provide their own implementation. +/// The actual value may carry additional semantics based on the platform +/// family. The following are currently known (but see the respective platform +/// specific code for authoritative information): +/// +/// | Value | Windows | Unix | +/// | ----: | :------------ | :---------------- | +/// | 0 | `std::this_thread::sleep_for()` | +/// | 1 | `Sleep()` | `nanosleep()` | +/// | 2 | ^ | `usleep()` | +/// | other | ^ | undefined | /// -#ifndef POV_USE_DEFAULT_DELAY - #define POV_USE_DEFAULT_DELAY 1 +#ifndef POV_USE_PLATFORM_DELAY + #define POV_USE_PLATFORM_DELAY 0 +#endif + +#ifdef POV_USE_DEFAULT_DELAY +#error "POV_USE_DEFAULT_DELAY has been superseded by POV_USE_PLATFORM_DELAY. Note that the new setting has inverse semantics." #endif /// @def POV_USE_DEFAULT_TIMER @@ -926,24 +914,6 @@ /// /// @{ -/// @def POV_TIME_UTC -/// Alias for `boost::TIME_UTC` or `boost::TIME_UTC_`, whichever is applicable. -/// -/// Boost 1.50 changed TIME_UTC to TIME_UTC_ to avoid a clash with C++11, which has -/// TIME_UTC as a define (in boost it's an enum). To allow compilation with earlier -/// versions of boost we now use POV_TIME_UTC in the code and define that here. -/// -#if BOOST_VERSION >= 105000 - #define POV_TIME_UTC boost::TIME_UTC_ -#else - #ifdef TIME_UTC - // clash between C++11 and boost detected, need to hard-code - #define POV_TIME_UTC 1 - #else - #define POV_TIME_UTC boost::TIME_UTC - #endif -#endif - /// @def POV_BACKSLASH_IS_PATH_SEPARATOR /// Whether the system supports the backslash as a separator character. /// diff --git a/source/base/filesystem_fwd.h b/source/base/filesystem_fwd.h index 08ac0a636..0a6053ae1 100644 --- a/source/base/filesystem_fwd.h +++ b/source/base/filesystem_fwd.h @@ -36,12 +36,13 @@ #ifndef POVRAY_BASE_FILESYSTEM_FWD_H #define POVRAY_BASE_FILESYSTEM_FWD_H -// C++ standard header files -#include - /// @file /// @note -/// This file should not pull in any POV-Ray header whatsoever. +/// This file should not pull in any headers whatsoever (except other +/// forward declaration headers or certain select standard headers). + +// C++ standard header files +#include namespace pov_base { diff --git a/source/base/image/colourspace.cpp b/source/base/image/colourspace.cpp index eadbb7d32..6d12c48d7 100644 --- a/source/base/image/colourspace.cpp +++ b/source/base/image/colourspace.cpp @@ -57,9 +57,7 @@ using std::max; // definitions of static GammaCurve member variables to satisfy the linker std::list> GammaCurve::cache; -#if POV_MULTITHREADED -boost::mutex GammaCurve::cacheMutex; -#endif +std::mutex GammaCurve::cacheMutex; // definitions of static GammaCurve-derivatives' member variables to satisfy the linker SimpleGammaCurvePtr NeutralGammaCurve::instance; @@ -77,10 +75,8 @@ float* GammaCurve::GetLookupTable(unsigned int max) // Get a reference to the lookup table pointer we're dealing with, so we don't need to duplicate all the remaining code. float*& lookupTable = (max == 255 ? lookupTable8 : lookupTable16); -#if POV_MULTITHREADED // Make sure we're not racing any other thread that might currently be busy creating the LUT. - boost::mutex::scoped_lock lock(lutMutex); -#endif + std::lock_guard lock(lutMutex); // Create the LUT if it doesn't exist yet. if (!lookupTable) @@ -102,12 +98,10 @@ GammaCurvePtr GammaCurve::GetMatching(const GammaCurvePtr& newInstance) GammaCurvePtr oldInstance; bool cached = false; - // See if we have a matching gamma curve in our chache already + // See if we have a matching gamma curve in our cache already -#if POV_MULTITHREADED // make sure the cache doesn't get tampered with while we're working on it - boost::mutex::scoped_lock lock(cacheMutex); -#endif + std::lock_guard lock(cacheMutex); // Check if we already have created a matching gamma curve object; if so, return that object instead. // Also, make sure we get the new object stored (as we're using weak pointers, we may have stale entries; diff --git a/source/base/image/colourspace.h b/source/base/image/colourspace.h index 21a2d16e8..b7f46c2b0 100644 --- a/source/base/image/colourspace.h +++ b/source/base/image/colourspace.h @@ -46,11 +46,7 @@ // C++ standard header files #include #include - -// Boost header files -#if POV_MULTITHREADED -#include -#endif +#include // POV-Ray header files (base module) #include "base/colour.h" @@ -306,7 +302,7 @@ class GammaCurve #if POV_MULTITHREADED /// Mutex to guard access to @ref lookupTable8 and @ref lookupTable16. - boost::mutex lutMutex; + std::mutex lutMutex; #endif /// Constructor. @@ -341,7 +337,7 @@ class GammaCurve #if POV_MULTITHREADED /// Mutex to guard access to `cache`. - static boost::mutex cacheMutex; + static std::mutex cacheMutex; #endif /// Function to manage the gamma curve cache. @@ -570,7 +566,7 @@ class TranscodingGammaCurve final : public GammaCurve protected: GammaCurvePtr workGamma; GammaCurvePtr encGamma; - TranscodingGammaCurve(); + TranscodingGammaCurve() = delete; TranscodingGammaCurve(const GammaCurvePtr&, const GammaCurvePtr&); virtual bool Matches(const GammaCurvePtr&) const override; }; diff --git a/source/base/image/colourspace_fwd.h b/source/base/image/colourspace_fwd.h index 55ee33371..efde5724c 100644 --- a/source/base/image/colourspace_fwd.h +++ b/source/base/image/colourspace_fwd.h @@ -36,12 +36,13 @@ #ifndef POVRAY_BASE_COLOURSPACE_FWD_H #define POVRAY_BASE_COLOURSPACE_FWD_H -// C++ standard header files -#include - /// @file /// @note -/// This file should not pull in any POV-Ray header whatsoever. +/// This file should not pull in any headers whatsoever (except other +/// forward declaration headers or certain select standard headers). + +// C++ standard header files +#include namespace pov_base { diff --git a/source/base/image/dither_fwd.h b/source/base/image/dither_fwd.h index 5e568b37a..d953b5d0e 100644 --- a/source/base/image/dither_fwd.h +++ b/source/base/image/dither_fwd.h @@ -36,12 +36,13 @@ #ifndef POVRAY_BASE_DITHER_FWD_H #define POVRAY_BASE_DITHER_FWD_H -// C++ standard header files -#include - /// @file /// @note -/// This file should not pull in any POV-Ray header whatsoever. +/// This file should not pull in any headers whatsoever (except other +/// forward declaration headers or certain select standard headers). + +// C++ standard header files +#include namespace pov_base { diff --git a/source/base/image/metadata.h b/source/base/image/metadata.h index 6520c8fed..8cbc482d7 100644 --- a/source/base/image/metadata.h +++ b/source/base/image/metadata.h @@ -46,7 +46,6 @@ #include // Boost header files -#include #include // POV-Ray header files (base module) diff --git a/source/base/image/tiff.cpp b/source/base/image/tiff.cpp index 5f6b26e61..59a2ea5ae 100644 --- a/source/base/image/tiff.cpp +++ b/source/base/image/tiff.cpp @@ -45,9 +45,6 @@ #include #include -// Boost header files -#include - // Other 3rd party header files extern "C" { diff --git a/source/base/pov_mem.cpp b/source/base/pov_mem.cpp index 838eea34e..6ef58371f 100644 --- a/source/base/pov_mem.cpp +++ b/source/base/pov_mem.cpp @@ -739,7 +739,7 @@ void *pov_memmove (void *dest, const void *src, size_t length) while (length > 0) { - POV_MEMCPY(cdest + length - size, csrc + length - size, size); + std::memcpy(cdest + length - size, csrc + length - size, size); length -= size; @@ -758,7 +758,7 @@ void *pov_memmove (void *dest, const void *src, size_t length) while (length > 0) { - POV_MEMCPY(new_dest, csrc, length); + std::memcpy(new_dest, csrc, length); new_dest += size; csrc += size; @@ -770,7 +770,7 @@ void *pov_memmove (void *dest, const void *src, size_t length) } else { - POV_MEMCPY(cdest, csrc, length); + std::memcpy(cdest, csrc, length); } return cdest; diff --git a/source/base/pov_mem.h b/source/base/pov_mem.h index 6b3fa5267..8d9a5ee16 100644 --- a/source/base/pov_mem.h +++ b/source/base/pov_mem.h @@ -46,6 +46,7 @@ // C++ variants of C standard header files #include +#include // C++ standard header files // (none at the moment) diff --git a/source/base/precomp.h b/source/base/precomp.h index 9c8636a86..fbd0b30bf 100644 --- a/source/base/precomp.h +++ b/source/base/precomp.h @@ -59,10 +59,9 @@ // C++ standard header files #include -#include #include -#include #include +#include #include #include #include @@ -71,12 +70,4 @@ #include // Boost header files -#include -#include -#include -#include -#if POV_MULTITHREADED -#include -#include -#endif -#include +#include diff --git a/source/base/stringutilities.h b/source/base/stringutilities.h index d0b20f8c1..33f38baa0 100644 --- a/source/base/stringutilities.h +++ b/source/base/stringutilities.h @@ -45,9 +45,6 @@ // C++ standard header files #include -// Boost header files -// (none at the moment) - // POV-Ray header files (base module) #include "base/base_fwd.h" #include "base/povassert.h" @@ -250,7 +247,8 @@ bool IsUCSLowSurrogate(UCS4 character); /// @return `true` if the code point qualifies as a UCS scalar value. bool IsUCSScalarValue(UCS4 character); -} // end of namespace UCS +} +// end of namespace UCS //****************************************************************************** diff --git a/source/base/timer.cpp b/source/base/timer.cpp index 2ffe0270b..812fba7fc 100644 --- a/source/base/timer.cpp +++ b/source/base/timer.cpp @@ -37,12 +37,12 @@ #include "base/timer.h" // C++ variants of C standard header files -// C++ standard header files // (none at the moment) -// Boost header files -#if POV_MULTITHREADED -#include +// C++ standard header files +#if !POV_USE_PLATFORM_DELAY +#include +#include #endif // POV-Ray header files (base module) @@ -54,46 +54,36 @@ namespace pov_base { -#if POV_MULTITHREADED && POV_USE_DEFAULT_DELAY +//****************************************************************************** + +#if !POV_USE_PLATFORM_DELAY void Delay(unsigned int msec) { - boost::xtime t; - boost::xtime_get(&t, POV_TIME_UTC); - POV_ULONG ns = (POV_ULONG)(t.sec) * (POV_ULONG)(1000000000) + (POV_ULONG)(t.nsec) + (POV_ULONG)(msec) * (POV_ULONG)(1000000); - t.sec = (boost::xtime::xtime_sec_t)(ns / (POV_ULONG)(1000000000)); - t.nsec = (boost::xtime::xtime_nsec_t)(ns % (POV_ULONG)(1000000000)); - boost::thread::sleep(t); + std::this_thread::sleep_for(std::chrono::milliseconds(msec)); } -#endif // POV_MULTITHREADED && POV_USE_DEFAULT_DELAY +#endif // POV_USE_PLATFORM_DELAY -#if POV_USE_DEFAULT_TIMER +//****************************************************************************** -Timer::Timer() +DefaultRealTimer::DefaultRealTimer() { Reset(); } -Timer::~Timer() +POV_LONG DefaultRealTimer::ElapsedTime() const { + auto elapsed = std::chrono::steady_clock::now() - mRealTimeStart; + return std::chrono::duration_cast(elapsed).count(); } -POV_LONG Timer::ElapsedRealTime() const +void DefaultRealTimer::Reset() { - boost::xtime t; - boost::xtime_get(&t, POV_TIME_UTC); - POV_LONG tt = (POV_LONG)(t.sec) * (POV_LONG)(1000000000) + (POV_LONG)(t.nsec); - POV_LONG st = (POV_LONG)(mRealTimeStart.sec) * (POV_LONG)(1000000000) + (POV_LONG)(mRealTimeStart.nsec); - return ((tt - st) / (POV_LONG)(1000000)); + mRealTimeStart = std::chrono::steady_clock::now(); } -void Timer::Reset() -{ - boost::xtime_get(&mRealTimeStart, POV_TIME_UTC); -} - -#endif // POV_USE_DEFAULT_TIMER +//****************************************************************************** } // end of namespace pov_base diff --git a/source/base/timer.h b/source/base/timer.h index 6c0204349..7f6f8df2d 100644 --- a/source/base/timer.h +++ b/source/base/timer.h @@ -40,17 +40,13 @@ #include "base/configbase.h" // C++ variants of C standard header files -// C++ standard header files // (none at the moment) -// Boost header files -#if POV_USE_DEFAULT_TIMER -#include -#endif +// C++ standard header files +#include -#if !POV_USE_DEFAULT_TIMER || (POV_MULTITHREADED && !POV_USE_DEFAULT_DELAY) -#include "syspovtimer.h" -#endif +// NOTE: +// Another file is included at the end of this file. // POV-Ray header files (base module) // (none at the moment) @@ -65,47 +61,78 @@ namespace pov_base /// /// @{ -#if POV_MULTITHREADED && POV_USE_DEFAULT_DELAY - /// Wait for the specified time. /// -/// This function puts the current thread into idle mode for the specified time. +/// This function puts the current thread into idle mode for the specified time, +/// give or take. +/// +/// The default implementation is based on `std::this_thread::sleep_for`, which +/// should be good enough on most platforms. However, platforms can still +/// provide their own implementations, by setting @ref POV_USE_PLATFORM_DELAY to +/// non-zero and providing their own definition. /// /// @note -/// This is a default implementation, provided only as a last-ditch resort for platforms that -/// cannot provide a better implementation. +/// For low values (e.g. below 10 ms, but depending on implementation and +/// platform) this function may effectively be a no-op. /// -/// @todo -/// The current implementation is based on boost::xtime, which has been deprecated since -/// boost 1.34. +/// @param[in] msec Time to wait in milliseconds (0..999). /// -/// @attention -/// Due to possible limitations of platform-specific implementations, this function may only be -/// called to wait for less than 1 second. +void Delay(unsigned int msec); + +/// Default Millisecond-precision wall clock timer. /// -/// @attention -/// Due to possible limitations of platform-specific implementations, callers must not rely on -/// the duration to be exact, or even anywhere close. Most notably, the function may return -/// prematurely in case the thread receives a signal. +/// This class provides facilities to measure the elapsed wall clock time +/// since the object was created or last reset. /// -/// @param[in] msec Time to wait in milliseconds (0..999). +/// @note +/// This class should not be used directly. Instead, it is intended as a +/// building block for implementations of the @ref Timer class. /// -void Delay(unsigned int msec); +/// @impl +/// The current implementation is based on `std::chrono::steady_clock`. +/// +class DefaultRealTimer final +{ +public: + + /// Create and start a new timer. + DefaultRealTimer(); + + /// Report elapsed wall-clock time. + /// + /// This method reports the actual time in milliseconds that has elapsed + /// since the timer's creation or last call to @ref Reset(). + /// + /// @return Elapsed real time in milliseconds. + /// + POV_LONG ElapsedTime() const; + + /// Reset the timer. + void Reset(); + +private: -#endif // POV_MULTITHREADED && POV_USE_DEFAULT_DELAY + /// Point in time of construction or last reset. + std::chrono::steady_clock::time_point mRealTimeStart; +}; #if POV_USE_DEFAULT_TIMER /// Millisecond-precision timer. /// +/// This class provides facilities to measure the elapsed wall clock time, CPU +/// time used by the current process, and CPU time used by the current thread, +/// since the object was created or last reset. +/// +/// It is intended that platforms provide their own implementations, by setting +/// @ref POV_USE_DEFAULT_TIMER to non-zero, providing their own declaration in +/// `syspovtimer.h`, and providing their own definition. +/// /// @note -/// This is a default implementation, provided only as a last-ditch resort for platforms that +/// The default implementation is provided only as a last-ditch resort for platforms that /// cannot provide a better implementation. It can neither guarantee millisecond precision, nor /// does it support measurement of CPU time. /// -/// @todo -/// This implementation is based on boost::xtime, which has been deprecated since 1.34. -/// /// @impl /// Note that to measure per-process CPU time we're not resorting to `clock()` as a default /// implementation, as depending on the platform it may incorrectly report elapsed wall-clock @@ -119,11 +146,11 @@ class Timer final /// Create and start a new timer. /// - Timer(); + Timer() = default; /// Destroy the timer. /// - ~Timer(); + ~Timer() = default; /// Report elapsed wall-clock time. /// @@ -132,7 +159,7 @@ class Timer final /// /// @return Elapsed real time in milliseconds. /// - POV_LONG ElapsedRealTime() const; + inline POV_LONG ElapsedRealTime() const { return mRealTimer.ElapsedTime(); } /// Report CPU time consumed by current process. /// @@ -145,7 +172,7 @@ class Timer final /// /// @return Elapsed CPU time in milliseconds. /// - inline POV_LONG ElapsedProcessCPUTime() const { return ElapsedRealTime(); } + inline POV_LONG ElapsedProcessCPUTime() const { return mRealTimer.ElapsedTime(); } /// Report CPU time consumed by current thread. /// @@ -162,11 +189,11 @@ class Timer final /// /// @return Elapsed CPU time in milliseconds. /// - inline POV_LONG ElapsedThreadCPUTime() const { return ElapsedProcessCPUTime(); } + inline POV_LONG ElapsedThreadCPUTime() const { return mRealTimer.ElapsedTime(); } /// Reset the timer. /// - void Reset(); + inline void Reset() { mRealTimer.Reset(); } /// Report whether per-process measurement of CPU time is supported. /// @@ -190,8 +217,8 @@ class Timer final private: - /// real time at last reset - boost::xtime mRealTimeStart; + /// Point in time of construction or last reset. + DefaultRealTimer mRealTimer; }; #endif // POV_USE_DEFAULT_TIMER @@ -203,4 +230,9 @@ class Timer final } // end of namespace pov_base +// Need to include this last because it may require definitions from this file. +#if !POV_USE_DEFAULT_TIMER +#include "syspovtimer.h" +#endif + #endif // POVRAY_BASE_TIMER_H diff --git a/source/core/bounding/boundingbox.cpp b/source/core/bounding/boundingbox.cpp index d02901029..8152e17c5 100644 --- a/source/core/bounding/boundingbox.cpp +++ b/source/core/bounding/boundingbox.cpp @@ -42,6 +42,7 @@ // C++ variants of C standard header files #include +#include // C++ standard header files // (none at the moment) @@ -54,6 +55,7 @@ #include "core/render/ray.h" #include "core/scene/object.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" @@ -288,7 +290,7 @@ void Build_BBox_Tree(BBOX_TREE **Root, size_t numOfFiniteObjects, BBOX_TREE **&F { root = *Root; root->Node = reinterpret_cast(POV_REALLOC(root->Node, (root->Entries + 1) * sizeof(BBOX_TREE *), "composite")); - POV_MEMMOVE(&(root->Node[1]), &(root->Node[0]), root->Entries * sizeof(BBOX_TREE *)); + std::memmove(&(root->Node[1]), &(root->Node[0]), root->Entries * sizeof(BBOX_TREE *)); root->Entries++; cd = create_bbox_node(numOfInfiniteObjects); for(size_t i = 0; i < numOfInfiniteObjects; i++) diff --git a/source/core/configcore.h b/source/core/configcore.h index 284b0f3bb..ef3ef3bf4 100644 --- a/source/core/configcore.h +++ b/source/core/configcore.h @@ -243,7 +243,7 @@ /// /// The available implementations are based on the following primitives: /// -/// | Value | `Pow2Floor` | `BiasedIntLog2` | `BiasedIntPow2` | Bias | Prerequisites | +/// | Value | Pow2Floor | BiasedIntLog2 | BiasedIntPow2 | Bias | Prerequisites | /// | ----: | :---------------------------- | :-------- | :-------------------- | ----: | :------------------------------------ | /// | 0 | `float` bit bashing ||| +127 | `float` must be IEEE 754 "binary32" | /// | 1 | `logbf`, `pow` | `logbf` | `int` bit shifting | 0 | `float` must be radix-2 | diff --git a/source/core/core_fwd.h b/source/core/core_fwd.h index 28fe8da7f..d924029ea 100644 --- a/source/core/core_fwd.h +++ b/source/core/core_fwd.h @@ -43,6 +43,9 @@ namespace pov { +class GenericFunctionContext; +typedef GenericFunctionContext* GenericFunctionContextPtr; + class Interior; class Intersection; diff --git a/source/core/coretypes.h b/source/core/coretypes.h index f075ee7b0..3ba5cb219 100644 --- a/source/core/coretypes.h +++ b/source/core/coretypes.h @@ -599,8 +599,6 @@ class GenericFunctionContext virtual ~GenericFunctionContext() {} }; -typedef GenericFunctionContext* GenericFunctionContextPtr; - class GenericFunctionContextFactory { public: diff --git a/source/core/lighting/photons.cpp b/source/core/lighting/photons.cpp index b54dfe633..230858418 100644 --- a/source/core/lighting/photons.cpp +++ b/source/core/lighting/photons.cpp @@ -52,6 +52,7 @@ #include "core/lighting/lightsource.h" #include "core/material/interior.h" #include "core/material/normal.h" +#include "core/material/pattern.h" #include "core/material/pigment.h" #include "core/material/texture.h" #include "core/material/warp.h" @@ -62,6 +63,7 @@ #include "core/scene/tracethreaddata.h" #include "core/shape/csg.h" #include "core/support/octree.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/lighting/radiosity.cpp b/source/core/lighting/radiosity.cpp index f90aa086f..2063e24b3 100644 --- a/source/core/lighting/radiosity.cpp +++ b/source/core/lighting/radiosity.cpp @@ -79,6 +79,7 @@ #include "core/scene/scenedata.h" #include "core/scene/tracethreaddata.h" #include "core/support/octree.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" @@ -1045,7 +1046,7 @@ RadiosityCache::~RadiosityCache() { // mutex scope #if POV_MULTITHREADED - boost::mutex::scoped_lock lock(fileMutex); + std::lock_guard lock(fileMutex); #endif // finish up cache file if (ot_fd != nullptr) @@ -1058,8 +1059,8 @@ RadiosityCache::~RadiosityCache() { // mutex scope #if POV_MULTITHREADED - boost::mutex::scoped_lock lockTree(octree.treeMutex); - boost::mutex::scoped_lock lockBlock(octree.blockMutex); + std::lock_guard lockTree(octree.treeMutex); + std::lock_guard lockBlock(octree.blockMutex); #endif if (octree.root != nullptr) ot_free_tree(&octree.root); @@ -1067,7 +1068,7 @@ RadiosityCache::~RadiosityCache() { // mutex scope #if POV_MULTITHREADED - boost::mutex::scoped_lock lock(blockPoolsMutex); + std::lock_guard lock(blockPoolsMutex); #endif while (!blockPools.empty()) { @@ -1083,7 +1084,7 @@ RadiosityCache::~RadiosityCache() RadiosityCache::BlockPool* RadiosityCache::AcquireBlockPool() { #if POV_MULTITHREADED - boost::mutex::scoped_lock lock(blockPoolsMutex); + std::lock_guard lock(blockPoolsMutex); #endif if (blockPools.empty()) return new BlockPool(); @@ -1099,14 +1100,14 @@ void RadiosityCache::ReleaseBlockPool(RadiosityCache::BlockPool* pool) { { // mutex scope #if POV_MULTITHREADED - boost::mutex::scoped_lock lock(fileMutex); + std::lock_guard lock(fileMutex); #endif pool->Save(ot_fd); } { // mutex scope #if POV_MULTITHREADED - boost::mutex::scoped_lock lock(blockPoolsMutex); + std::lock_guard lock(blockPoolsMutex); #endif blockPools.push_back(pool); } @@ -1238,7 +1239,7 @@ ot_node_struct *RadiosityCache::GetNode(RenderStatistics* stats, const ot_id_str ot_id_struct temp_id; #if POV_MULTITHREADED - boost::mutex::scoped_lock treeLock(octree.treeMutex, boost::defer_lock_t()); // we may need to lock this mutex - but not now. + std::unique_lock treeLock(octree.treeMutex, std::defer_lock); // we may need to lock this mutex - but not now. #endif #ifdef RADSTATS @@ -1420,7 +1421,7 @@ ot_node_struct *RadiosityCache::GetNode(RenderStatistics* stats, const ot_id_str void RadiosityCache::InsertBlock(ot_node_struct *node, ot_block_struct *block) { #if POV_MULTITHREADED - boost::mutex::scoped_lock lock(octree.blockMutex); + std::lock_guard lock(octree.blockMutex); #endif block->next = node->Values; diff --git a/source/core/lighting/radiosity.h b/source/core/lighting/radiosity.h index 8689fcef0..64832c9e1 100644 --- a/source/core/lighting/radiosity.h +++ b/source/core/lighting/radiosity.h @@ -44,13 +44,9 @@ // C++ standard header files #include +#include #include -// Boost header files -#if POV_MULTITHREADED -#include -#endif - // POV-Ray header files (base module) #include "base/fileinputoutput_fwd.h" #include "base/path_fwd.h" @@ -231,8 +227,8 @@ class RadiosityCache final { ot_node_struct *root; #if POV_MULTITHREADED - boost::mutex treeMutex; // lock this when adding nodes to the tree - boost::mutex blockMutex; // lock this when adding blocks to any node of the tree + std::mutex treeMutex; // lock this when adding nodes to the tree + std::mutex blockMutex; // lock this when adding blocks to any node of the tree #endif Octree() : root(nullptr) {} @@ -240,14 +236,14 @@ class RadiosityCache final std::vector blockPools; // block pools ready to be re-used #if POV_MULTITHREADED - boost::mutex blockPoolsMutex; // lock this when accessing blockPools + std::mutex blockPoolsMutex; // lock this when accessing blockPools #endif Octree octree; OStream *ot_fd; #if POV_MULTITHREADED - boost::mutex fileMutex; // lock this when accessing ot_fd + std::mutex fileMutex; // lock this when accessing ot_fd #endif RadiosityRecursionSettings* recursionSettings; // dynamically allocated array; use recursion depth as index diff --git a/source/core/material/media.cpp b/source/core/material/media.cpp index c8572f7ad..9132565e2 100644 --- a/source/core/material/media.cpp +++ b/source/core/material/media.cpp @@ -52,7 +52,9 @@ #include "core/material/pigment.h" #include "core/math/chi2.h" #include "core/render/ray.h" +#include "core/scene/object.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/material/noise.cpp b/source/core/material/noise.cpp index 3b67f01bc..ff71e5c3c 100644 --- a/source/core/material/noise.cpp +++ b/source/core/material/noise.cpp @@ -92,10 +92,10 @@ static DBL *sintab; // GLOBAL VARIABLE #ifdef DYNAMIC_HASHTABLE unsigned short *hashTable; // GLOBAL VARIABLE #else -ALIGN16 unsigned short hashTable[8192]; // GLOBAL VARIABLE +alignas(16) unsigned short hashTable[8192]; // GLOBAL VARIABLE #endif -ALIGN16 DBL RTable[267*2] = +alignas(16) DBL RTable[267*2] = { -1, 0.0, 0.604974, 0.0, -0.937102, 0.0, 0.414115, 0.0, 0.576226, 0.0, -0.0161593, 0.0, 0.432334, 0.0, 0.103685, 0.0, 0.590539, 0.0, 0.0286412, 0.0, 0.46981, 0.0, -0.84622, 0.0, diff --git a/source/core/material/noise.h b/source/core/material/noise.h index 4a3f94e80..13dec5af9 100644 --- a/source/core/material/noise.h +++ b/source/core/material/noise.h @@ -97,10 +97,10 @@ const int NOISE_MINZ = NOISE_MINX; #ifdef DYNAMIC_HASHTABLE extern unsigned short *hashTable; #else -extern ALIGN16 unsigned short hashTable[8192]; +alignas(16) extern unsigned short hashTable[8192]; #endif -extern ALIGN16 DBL RTable[]; +alignas(16) extern DBL RTable[]; /***************************************************************************** diff --git a/source/core/material/normal.cpp b/source/core/material/normal.cpp index d39bad426..25bd58e1b 100644 --- a/source/core/material/normal.cpp +++ b/source/core/material/normal.cpp @@ -56,6 +56,7 @@ // POV-Ray header files (core module) #include "core/material/blendmap.h" #include "core/material/noise.h" +#include "core/material/pattern.h" #include "core/material/pigment.h" #include "core/material/warp.h" #include "core/scene/object.h" diff --git a/source/core/material/pattern.cpp b/source/core/material/pattern.cpp index fb55df1a1..5a2219715 100644 --- a/source/core/material/pattern.cpp +++ b/source/core/material/pattern.cpp @@ -65,7 +65,9 @@ #include "core/scene/object.h" #include "core/scene/scenedata.h" #include "core/scene/tracethreaddata.h" +#include "core/support/cracklecache.h" #include "core/support/imageutil.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" @@ -5746,7 +5748,7 @@ DBL CheckerPattern::Evaluate(const Vector3d& EPoint, const Intersection *pIsecti * neighbours from a set of disjoint points, like the membranes in suds are * to the centres of the bubbles). * -* All "crackle" specific source code and examples are in the public domain. +* The original "crackle" specific source code and examples are in the public domain. * * CHANGES * Oct 1994 : adapted from pigment by [CY] @@ -5795,36 +5797,30 @@ DBL CracklePattern::EvaluateRaw(const Vector3d& EPoint, const Intersection *pIse CrackleCacheEntry dummy_entry; CrackleCacheEntry* entry = &dummy_entry; - // search for this hash value in the cache - CrackleCache::iterator iter = pThread->mCrackleCache.find(ccoord); - if (iter == pThread->mCrackleCache.end()) - { - /* - * No, not same unit cube. Calculate the random points for this new - * cube and its 80 neighbours which differ in any axis by 1 or 2. - * Why distance of 2? If there is 1 point in each cube, located - * randomly, it is possible for the closest random point to be in the - * cube 2 over, or the one two over and one up. It is NOT possible - * for it to be two over and two up. Picture a 3x3x3 cube with 9 more - * cubes glued onto each face. - */ + if (pThread->mpCrackleCache->Lookup(entry, ccoord)) + { + // Cache hit. `entry` now points to the cached entry. + pThread->Stats()[CrackleCache_Tests_Succeeded]++; + } + else + { + // Cache miss. `entry` now points to a pristine entry set up in the + // cache, or to `dummy_entry` if the cache is too crowded already. + // In either case we need to fill in the blanks. - // generate a new cache entry, but only if the size of the cache is reasonable. - // having to re-calculate entries that would have been cache hits had we not - // skipped on adding an entry is less expensive than chewing up immense amounts - // of RAM and finally hitting the swapfile. unfortunately there's no good way - // to tell how much memory is 'too much' for the cache, so we just use a hard- - // coded number for now (ideally we should allow the user to configure this). - // keep in mind that the cache memory usage is per-thread, so the more threads, - // the more RAM. if we don't do the insert, entry will point at a local variable. - if (pThread->mCrackleCache.size() * sizeof(CrackleCache::value_type) < 30 * 1024 * 1024) - { - iter = pThread->mCrackleCache.insert(pThread->mCrackleCache.end(), CrackleCache::value_type(ccoord, CrackleCacheEntry())); - entry = &iter->second; - entry->lastUsed = pThread->ProgressIndex(); - } + // Calculate the random points for this new + // cube and its 80 neighbours which differ in any axis by 1 or 2. + // Why distance of 2? If there is 1 point in each cube, located + // randomly, it is possible for the closest random point to be in the + // cube 2 over, or the one two over and one up. It is NOT possible + // for it to be two over and two up. Picture a 3x3x3 cube with 9 more + // cubes glued onto each face. + + // TODO - Note that we're currently re-computing each cell up to 81 + // times - once as a main cell and 80 times as a neighbor - + // even in the best case scenario. Wouldn't it be more efficient + // to just cache the individual cells? - // see InitializeCrackleCubes() below. int *pc = gaCrackleCubeTable; for (int i = 0; i < 81; i++, pc += 3) { @@ -5854,11 +5850,6 @@ DBL CracklePattern::EvaluateRaw(const Vector3d& EPoint, const Intersection *pIse entry->aCellNuclei[i] += wrappingOffset; } } - else - { - pThread->Stats()[CrackleCache_Tests_Succeeded]++; - entry = &iter->second; - } // Find the 3 points with the 3 shortest distances from the input point. // Set up the loop so the invariant is true: minsum <= minsum2 <= minsum3 @@ -8915,6 +8906,7 @@ int PickInCube(const Vector3d& tv, Vector3d& p1) ******************************************************************************/ #ifndef HAVE_BOOST_HASH +// NOTE: Keep this around - we may need it when we get rid of boost::hash. static unsigned long int NewHash(long int tvx, long int tvy, long int tvz) { unsigned long int seed; diff --git a/source/core/material/pattern.h b/source/core/material/pattern.h index 95159fd93..72b708fba 100644 --- a/source/core/material/pattern.h +++ b/source/core/material/pattern.h @@ -44,10 +44,6 @@ // C++ standard header files // (none at the moment) -// Boost header files -#include // required for crackle -#include - // POV-Ray header files (base module) #include "base/fileinputoutput_fwd.h" @@ -1108,77 +1104,6 @@ struct ColourImagePattern final : public ColourPattern, public ImagePatternImpl }; -//****************************************************************************** -// Crackle Pattern Support Types - -/// Helper class to implement the crackle cache. -class CrackleCellCoord final -{ -public: - - CrackleCellCoord() : mX(0), mY(0), mZ(0), mRepeatX(0), mRepeatY(0), mRepeatZ(0) {} - CrackleCellCoord(int x, int y, int z, int rx, int ry, int rz) : mX(x), mY(y), mZ(z), mRepeatX(rx), mRepeatY(ry), mRepeatZ(rz) - { - WrapCellCoordinate(mX, mRepeatX); - WrapCellCoordinate(mY, mRepeatY); - WrapCellCoordinate(mZ, mRepeatZ); - } - - bool operator==(CrackleCellCoord const& other) const - { - return mX == other.mX && mY == other.mY && mZ == other.mZ; - } - - /// Function to compute a hash value from the coordinates. - /// - /// @note This function's name, as well as it being a global function rather than a member, is mandated by - /// boost::unordered_map. - /// - /// @param[in] coord The coordinate. - /// @return The hash. - /// - friend std::size_t hash_value(CrackleCellCoord const& coord) - { - std::size_t seed = 0; - boost::hash_combine(seed, coord.mX); - boost::hash_combine(seed, coord.mY); - boost::hash_combine(seed, coord.mZ); - - return seed; - } - -protected: - - int mX; - int mY; - int mZ; - int mRepeatX; - int mRepeatY; - int mRepeatZ; - - static inline void WrapCellCoordinate(int& v, int& repeat) - { - if (!repeat) - return; - v = wrapInt(v, repeat); - if ((v >= 2) && (v < repeat - 2)) - repeat = 0; - } -}; - -/// Helper class to implement the crackle cache. -struct CrackleCacheEntry final -{ - /// A kind of timestamp specifying when this particular entry was last used. - size_t lastUsed; - - /// The pseudo-random points defining the pattern in this particular subset of 3D space. - Vector3d aCellNuclei[81]; -}; - -typedef boost::unordered_map> CrackleCache; - - //****************************************************************************** // Legacy Global Functions diff --git a/source/core/material/pattern_fwd.h b/source/core/material/pattern_fwd.h index 17c99923e..befb79841 100644 --- a/source/core/material/pattern_fwd.h +++ b/source/core/material/pattern_fwd.h @@ -38,7 +38,8 @@ /// @file /// @note -/// This file should not pull in any POV-Ray header whatsoever. +/// This file should not pull in any headers whatsoever (except other +/// forward declaration headers or certain select standard headers). namespace pov { diff --git a/source/core/math/jitter.h b/source/core/math/jitter.h index e02db55e7..3d0b8a1e0 100644 --- a/source/core/math/jitter.h +++ b/source/core/math/jitter.h @@ -60,7 +60,7 @@ namespace pov #ifdef DYNAMIC_HASHTABLE extern unsigned short *hashTable; // GLOBAL VARIABLE #else -extern ALIGN16 unsigned short hashTable[]; // GLOBAL VARIABLE +alignas(16) extern unsigned short hashTable[]; // GLOBAL VARIABLE #endif extern const float JitterTable[]; // GLOBAL VARIABLE diff --git a/source/core/math/randomsequence.cpp b/source/core/math/randomsequence.cpp index 512ab8aae..681587e87 100644 --- a/source/core/math/randomsequence.cpp +++ b/source/core/math/randomsequence.cpp @@ -42,6 +42,7 @@ // C++ standard header files #include #include +#include #include // Boost header files @@ -49,9 +50,6 @@ #include #include #include -#if POV_MULTITHREADED -#include -#endif // POV-Ray header files (base module) #include "base/povassert.h" @@ -499,7 +497,7 @@ class NumberSequenceFactory GeneratorPtr master; SequenceConstPtr masterSequence; #if POV_MULTITHREADED - boost::mutex masterMutex; + std::mutex masterMutex; #endif }; @@ -527,7 +525,7 @@ class NumberSequenceMetaFactory static FactoryTable* lookupTable; #if POV_MULTITHREADED - static boost::mutex lookupMutex; + static std::mutex lookupMutex; #endif }; @@ -774,7 +772,7 @@ template shared_ptr const> NumberSequenceFactory::operator()(size_t count) { #if POV_MULTITHREADED - boost::mutex::scoped_lock lock(masterMutex); + std::lock_guard lock(masterMutex); #endif if (!masterSequence) { @@ -817,14 +815,14 @@ std::map -boost::mutex NumberSequenceMetaFactory::lookupMutex; +std::mutex NumberSequenceMetaFactory::lookupMutex; #endif template shared_ptr> NumberSequenceMetaFactory::GetFactory(const typename GeneratorType::ParameterStruct& param) { #if POV_MULTITHREADED - boost::mutex::scoped_lock lock(lookupMutex); + std::lock_guard lock(lookupMutex); #endif if (!lookupTable) lookupTable = new FactoryTable(); diff --git a/source/core/math/randomsequence.h b/source/core/math/randomsequence.h index 65af6da16..593725a17 100644 --- a/source/core/math/randomsequence.h +++ b/source/core/math/randomsequence.h @@ -38,6 +38,7 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/math/randomsequence_fwd.h" // C++ variants of C standard header files // (none at the moment) diff --git a/source/core/math/randomsequence_fwd.h b/source/core/math/randomsequence_fwd.h new file mode 100644 index 000000000..7f7302a25 --- /dev/null +++ b/source/core/math/randomsequence_fwd.h @@ -0,0 +1,74 @@ +//****************************************************************************** +/// +/// @file core/math/randomsequence_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_CORE_RANDOMSEQUENCE_FWD_H +#define POVRAY_CORE_RANDOMSEQUENCE_FWD_H + +/// @file +/// @note +/// This file should not pull in any headers whatsoever (except other +/// forward declaration headers or certain select standard headers). + +// C++ standard header files +#include + +// POV-Ray header files (core module) +#include "core/math/vector_fwd.h" + +namespace pov +{ + +template class SequentialNumberGenerator; +using SequentialIntGeneratorPtr = std::shared_ptr>; +using SequentialDoubleGeneratorPtr = std::shared_ptr>; +using SequentialVectorGeneratorPtr = std::shared_ptr>; +using SequentialVector2dGeneratorPtr = std::shared_ptr>; + +template class SeedableNumberGenerator; +using SeedableIntGeneratorPtr = std::shared_ptr>; +using SeedableDoubleGeneratorPtr = std::shared_ptr>; +using SeedableVectorGeneratorPtr = std::shared_ptr>; +using SeedableVector2dGeneratorPtr = std::shared_ptr>; + +template class IndexedNumberGenerator; +using IndexedIntGeneratorPtr = std::shared_ptr const>; +using IndexedDoubleGeneratorPtr = std::shared_ptr const>; +using IndexedVectorGeneratorPtr = std::shared_ptr const>; +using IndexedVector2dGeneratorPtr = std::shared_ptr const>; + +} +// end of namespace pov + +#endif // POVRAY_CORE_RANDOMSEQUENCE_FWD_H diff --git a/source/core/math/vector.h b/source/core/math/vector.h index 174868bf7..8fafee883 100644 --- a/source/core/math/vector.h +++ b/source/core/math/vector.h @@ -38,6 +38,7 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/math/vector_fwd.h" // C++ variants of C standard header files // (none at the moment) diff --git a/source/core/math/vector_fwd.h b/source/core/math/vector_fwd.h new file mode 100644 index 000000000..db65361c4 --- /dev/null +++ b/source/core/math/vector_fwd.h @@ -0,0 +1,60 @@ +//****************************************************************************** +/// +/// @file core/math/vector_fwd.h +/// +/// Forward declarations related to vector arithmetics. +/// +/// @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_CORE_VECTOR_FWD_H +#define POVRAY_CORE_VECTOR_FWD_H + +/// @file +/// @note +/// This file should not pull in any headers whatsoever (except other +/// forward declaration headers or certain select standard headers). + +namespace pov +{ + +template class GenericVector2d; +template class GenericVector3d; + +using Vector2d = GenericVector2d; ///< Double-precision 2D vector. +using SnglVector2d = GenericVector2d; ///< Single-precision 2D vector. + +using Vector3d = GenericVector3d; ///< Double-precision 3D vector. +using SnglVector3d = GenericVector3d; ///< Single-precision 3D vector. +using IntVector3d = GenericVector3d; ///< Integer 3D vector. + +} +// end of namespace pov + +#endif // POVRAY_CORE_VECTOR_FWD_H diff --git a/source/core/precomp.h b/source/core/precomp.h index 35f6028c6..08397dcce 100644 --- a/source/core/precomp.h +++ b/source/core/precomp.h @@ -59,7 +59,6 @@ // C++ standard header files #include -#include #include #include #include @@ -68,17 +67,8 @@ #include #include #include +#include #include // Boost header files -#include -#include -#include -#include #include -#if POV_MULTITHREADED -#include -#include -#endif -#include - diff --git a/source/core/render/trace.cpp b/source/core/render/trace.cpp index 468dd2c49..eb48d4f27 100644 --- a/source/core/render/trace.cpp +++ b/source/core/render/trace.cpp @@ -42,9 +42,6 @@ // C++ standard header files #include -// Boost header files -#include - // POV-Ray header files (base module) #include "base/povassert.h" @@ -69,6 +66,7 @@ #include "core/shape/box.h" #include "core/shape/csg.h" #include "core/support/imageutil.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/render/tracepixel.cpp b/source/core/render/tracepixel.cpp index 32a8abcba..cf8d64a88 100644 --- a/source/core/render/tracepixel.cpp +++ b/source/core/render/tracepixel.cpp @@ -42,7 +42,7 @@ #include "core/render/tracepixel.h" // C++ variants of C standard header files -// (none at the moment) +#include // C++ standard header files #include @@ -74,7 +74,7 @@ using std::max; #ifdef DYNAMIC_HASHTABLE extern unsigned short *hashTable; // GLOBAL VARIABLE #else -extern ALIGN16 unsigned short hashTable[]; // GLOBAL VARIABLE +alignas(16) extern unsigned short hashTable[]; // GLOBAL VARIABLE #endif const int Grid1Size = 4; @@ -1251,7 +1251,7 @@ TracePixel::FocalBlurData::FocalBlurData(const Camera& camera, TraceThreadData* // Allocate temporary grid. std::unique_ptr Grid_Data (new char [Grid_Size * Grid_Size]); char *p = Grid_Data.get(); - memset(p, 0, Grid_Size * Grid_Size); + std::memset(p, 0, Grid_Size * Grid_Size); std::vector Grid(Grid_Size); for(int i = 0; i < Grid_Size; i++, p += Grid_Size) Grid[i] = p; diff --git a/source/core/scene/object.cpp b/source/core/scene/object.cpp index 55a74be24..7cb81c84d 100644 --- a/source/core/scene/object.cpp +++ b/source/core/scene/object.cpp @@ -54,6 +54,7 @@ #include "core/shape/box.h" #include "core/shape/csg.h" #include "core/shape/sphere.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/scene/scenedata.cpp b/source/core/scene/scenedata.cpp index 2b93c3edf..13ae568cd 100644 --- a/source/core/scene/scenedata.cpp +++ b/source/core/scene/scenedata.cpp @@ -42,9 +42,6 @@ // C++ standard header files #include -// Boost header files -#include - // POV-Ray header files (base module) #include "base/types.h" #include "base/version_info.h" diff --git a/source/core/scene/scenedata.h b/source/core/scene/scenedata.h index b93f77fee..ab2da21a9 100644 --- a/source/core/scene/scenedata.h +++ b/source/core/scene/scenedata.h @@ -38,6 +38,7 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/scene/scenedata_fwd.h" // C++ variants of C standard header files // (none at the moment) diff --git a/source/core/scene/scenedata_fwd.h b/source/core/scene/scenedata_fwd.h new file mode 100644 index 000000000..a36cb1392 --- /dev/null +++ b/source/core/scene/scenedata_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file core/scene/scenedata_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_CORE_SCENEDATA_FWD_H +#define POVRAY_CORE_SCENEDATA_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class SceneData; + +} +// end of namespace pov + +#endif // POVRAY_CORE_SCENEDATA_FWD_H diff --git a/source/core/scene/tracethreaddata.cpp b/source/core/scene/tracethreaddata.cpp index 203d87b51..2a0dc567f 100644 --- a/source/core/scene/tracethreaddata.cpp +++ b/source/core/scene/tracethreaddata.cpp @@ -51,6 +51,7 @@ #include "core/shape/blob.h" #include "core/shape/fractal.h" #include "core/shape/isosurface.h" +#include "core/support/cracklecache.h" // this must be the last file included #include "base/povdebug.h" @@ -62,7 +63,9 @@ TraceThreadData::TraceThreadData(std::shared_ptr sd, size_t seed) : sceneData(sd), qualityFlags(9), stochasticRandomGenerator(GetRandomDoubleGenerator(0.0,1.0)), - stochasticRandomSeedBase(seed) + stochasticRandomSeedBase(seed), + mpCrackleCache(new CrackleCache), + mpRenderStats(new RenderStatistics) { for(int i = 0; i < 4; i++) Fractal_IStack[i] = nullptr; @@ -114,14 +117,6 @@ TraceThreadData::TraceThreadData(std::shared_ptr sd, size_t seed) : surfacePhotonMap = new PhotonMap(); mediaPhotonMap = new PhotonMap(); - // advise the crackle cache's unordered_map that we don't mind hash collisions - // while this is a very high load factor, the simple fact is that the cost of - // allocating memory at render time (each insert into the table requires an alloc - // as the container doesn't pre-emptively allocate, unlike e.g. std::vector) is - // quite high, particularly when we have multiple threads contending for the heap - // lock. - mCrackleCache.max_load_factor(50.0); - numberOfWaves = sd->numberOfWaves; Initialize_Waves(waveFrequencies, waveSources, numberOfWaves); } @@ -140,43 +135,13 @@ TraceThreadData::~TraceThreadData() delete[] Blob_Intervals; for(std::vector::iterator it = lightSources.begin(); it != lightSources.end(); it++) Destroy_Object(*it); + delete mpCrackleCache; + delete mpRenderStats; } void TraceThreadData::AfterTile() { - CrackleCache::iterator it; - - // this serves as a render block index - progress_index++; - - // probably we ought to have a means for the end-user to choose the preferred maximum bytes reserved for the cache - // for now, we have hard-coded values. we also do not discard any entries that are from the current block, even if - // the cache size is exceeded. also, note that the cache size is per-thread. finally, don't forget that erasing - // elements doesn't in and of itself return the freed memory to the heap. - if (mCrackleCache.size() * sizeof(CrackleCache::value_type) < 15 * 1024 * 1024) - return; - while (mCrackleCache.size() * sizeof(CrackleCache::value_type) > 10 * 1024 * 1024) - { - // search the cache for the oldest entries - int oldest = std::numeric_limits::max(); - for (it = mCrackleCache.begin(); it != mCrackleCache.end(); it++) - if (it->second.lastUsed < oldest) - oldest = (int) it->second.lastUsed; - - // don't remove any entries from the most recent block - if (oldest == progress_index - 1) - break; - - for (it = mCrackleCache.begin(); it != mCrackleCache.end(); ) - { - if (it->second.lastUsed == oldest) - { - it = mCrackleCache.erase(it); - continue; - } - it++; - } - } + mpCrackleCache->Prune(); } } diff --git a/source/core/scene/tracethreaddata.h b/source/core/scene/tracethreaddata.h index b7c0c76fd..e9d9714b4 100644 --- a/source/core/scene/tracethreaddata.h +++ b/source/core/scene/tracethreaddata.h @@ -49,15 +49,16 @@ // POV-Ray header files (base module) #include "base/types.h" +#include "base/colour.h" // POV-Ray header files (core module) #include "core/coretypes.h" #include "core/bounding/boundingcylinder.h" -#include "core/bounding/bsptree.h" -#include "core/material/pattern.h" -#include "core/math/randomsequence.h" -#include "core/shape/mesh.h" -#include "core/support/statistics.h" +#include "core/math/randomsequence_fwd.h" +#include "core/math/vector.h" +#include "core/scene/scenedata_fwd.h" +#include "core/support/cracklecache_fwd.h" +#include "core/support/statistics_fwd.h" namespace pov { @@ -78,10 +79,6 @@ struct Blob_Interval_Struct; /// Class holding parser thread specific data. class TraceThreadData : public ThreadData { - friend class Scene; - friend class Trace; - friend class View; // TODO FIXME - needed only to access TraceThreadData for CheckCameraHollowObject() - public: /// Create thread local data. @@ -95,10 +92,9 @@ class TraceThreadData : public ThreadData /// Get the statistics. /// @return Reference to statistic counters. - RenderStatistics& Stats(void) { return renderStats; } + RenderStatistics& Stats(void) { return *mpRenderStats; } DBL *Fractal_IStack[4]; - BBoxPriorityQueue Mesh_Queue; void **Blob_Queue; unsigned int Max_Blob_Queue_Size; DBL *Blob_Coefficients; @@ -141,7 +137,7 @@ class TraceThreadData : public ThreadData PhotonMap* surfacePhotonMap; PhotonMap* mediaPhotonMap; - CrackleCache mCrackleCache; + CrackleCache* mpCrackleCache; // data for waves and ripples pattern unsigned int numberOfWaves; @@ -178,7 +174,7 @@ class TraceThreadData : public ThreadData /// scene data std::shared_ptr sceneData; /// render statistics - RenderStatistics renderStats; + RenderStatistics* mpRenderStats; private: diff --git a/source/core/shape/bezier.cpp b/source/core/shape/bezier.cpp index a57f5ddf0..dbabce6fe 100644 --- a/source/core/shape/bezier.cpp +++ b/source/core/shape/bezier.cpp @@ -39,18 +39,20 @@ #include "core/shape/bezier.h" // C++ variants of C standard header files -// (none at the moment) +#include // C++ standard header files #include // POV-Ray header files (base module) #include "base/pov_err.h" +#include "base/pov_mem.h" // POV-Ray header files (core module) #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" @@ -1987,7 +1989,7 @@ ObjectPtr BicubicPatch::Copy() if (Weights != nullptr) { New->Weights = reinterpret_cast(POV_MALLOC( sizeof(BEZIER_WEIGHTS),"bicubic patch" )); - POV_MEMCPY( New->Weights, Weights, sizeof(BEZIER_WEIGHTS) ); + std::memcpy( New->Weights, Weights, sizeof(BEZIER_WEIGHTS) ); } for (i = 0; i < 4; i++) diff --git a/source/core/shape/blob.cpp b/source/core/shape/blob.cpp index 6c11a8490..5850ed575 100644 --- a/source/core/shape/blob.cpp +++ b/source/core/shape/blob.cpp @@ -98,7 +98,7 @@ #include "core/shape/blob.h" // C++ variants of C standard header files -// (none at the moment) +#include // C++ standard header files #include @@ -115,6 +115,7 @@ #include "core/math/polynomialsolver.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" @@ -600,7 +601,7 @@ bool Blob::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDat * * Store the points of intersection. Keep track of: whether this is * the start or end point of the hit, which component was pierced -* by the ray, and the point along the ray that the hit occured at. +* by the ray, and the point along the ray that the hit occurred at. * * CHANGES * @@ -608,6 +609,7 @@ bool Blob::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDat * Sep 1995 : Changed to allow use of memcpy if memmove isn't available. [AED] * Jul 1996 : Changed to use POV_MEMMOVE, which can be memmove or pov_memmove. * Oct 1996 : Changed to avoid unnecessary compares. [DB] +* Feb 2019 : Changed back to use std::memmove again. [CLi] * ******************************************************************************/ @@ -630,7 +632,7 @@ void Blob::insert_hit(const Blob_Element *Element, DBL t0, DBL t1, Blob_Interval * bump the rest and insert it here. */ - POV_MEMMOVE(&intervals[k+1], &intervals[k], (*cnt-k)*sizeof(Blob_Interval_Struct)); + std::memmove(&intervals[k+1], &intervals[k], (*cnt-k)*sizeof(Blob_Interval_Struct)); /* We are entering the component. */ @@ -650,7 +652,7 @@ void Blob::insert_hit(const Blob_Element *Element, DBL t0, DBL t1, Blob_Interval if (k < *cnt) { - POV_MEMMOVE(&intervals[k+1], &intervals[k], (*cnt-k)*sizeof(Blob_Interval_Struct)); + std::memmove(&intervals[k+1], &intervals[k], (*cnt-k)*sizeof(Blob_Interval_Struct)); /* We are exiting the component. */ diff --git a/source/core/shape/box.cpp b/source/core/shape/box.cpp index 6e4e96770..245b920d5 100644 --- a/source/core/shape/box.cpp +++ b/source/core/shape/box.cpp @@ -50,6 +50,7 @@ #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/cone.cpp b/source/core/shape/cone.cpp index f5acc49d0..b0b8b3bf4 100644 --- a/source/core/shape/cone.cpp +++ b/source/core/shape/cone.cpp @@ -50,6 +50,7 @@ #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/csg.cpp b/source/core/shape/csg.cpp index a6e3c15e1..ee75e996a 100644 --- a/source/core/shape/csg.cpp +++ b/source/core/shape/csg.cpp @@ -55,6 +55,7 @@ #include "core/shape/heightfield.h" #include "core/shape/plane.h" #include "core/shape/quadric.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/disc.cpp b/source/core/shape/disc.cpp index fd84c7fec..5fc369ed2 100644 --- a/source/core/shape/disc.cpp +++ b/source/core/shape/disc.cpp @@ -50,6 +50,7 @@ #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/fractal.cpp b/source/core/shape/fractal.cpp index 9601f3ca1..c62602882 100644 --- a/source/core/shape/fractal.cpp +++ b/source/core/shape/fractal.cpp @@ -53,6 +53,7 @@ #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" #include "core/shape/sphere.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/heightfield.cpp b/source/core/shape/heightfield.cpp index a91ec7236..6c3500241 100644 --- a/source/core/shape/heightfield.cpp +++ b/source/core/shape/heightfield.cpp @@ -73,6 +73,7 @@ #include "core/scene/tracethreaddata.h" #include "core/shape/box.h" #include "core/support/imageutil.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/isosurface.cpp b/source/core/shape/isosurface.cpp index 5bd9bc9e0..d0aedb96c 100644 --- a/source/core/shape/isosurface.cpp +++ b/source/core/shape/isosurface.cpp @@ -53,6 +53,7 @@ #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/lathe.cpp b/source/core/shape/lathe.cpp index 9b009ae8b..6f1f2ba56 100644 --- a/source/core/shape/lathe.cpp +++ b/source/core/shape/lathe.cpp @@ -139,6 +139,7 @@ #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" #include "core/shape/torus.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/lemon.cpp b/source/core/shape/lemon.cpp index e3355399b..712fbaadd 100644 --- a/source/core/shape/lemon.cpp +++ b/source/core/shape/lemon.cpp @@ -50,6 +50,7 @@ #include "core/math/polynomialsolver.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/mesh.cpp b/source/core/shape/mesh.cpp index b8b7540d6..34641e831 100644 --- a/source/core/shape/mesh.cpp +++ b/source/core/shape/mesh.cpp @@ -77,6 +77,7 @@ #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" #include "core/shape/triangle.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" @@ -106,6 +107,8 @@ HASH_TABLE **Mesh::Vertex_Hash_Table; HASH_TABLE **Mesh::Normal_Hash_Table; UV_HASH_TABLE **Mesh::UV_Hash_Table; +thread_local std::unique_ptr Mesh::mtpQueue(new BBoxPriorityQueue()); + /***************************************************************************** * * FUNCTION @@ -1458,7 +1461,7 @@ bool Mesh::intersect_bbox_tree(const BasicRay &ray, const BasicRay &Orig_Ray, DB Rayinfo rayinfo(ray); /* Start with an empty priority queue. */ - Thread->Mesh_Queue.Clear(); + mtpQueue->Clear(); found = false; Best = BOUND_HUGE; @@ -1473,13 +1476,13 @@ bool Mesh::intersect_bbox_tree(const BasicRay &ray, const BasicRay &Orig_Ray, DB /* Set the root object infinite to avoid a test. */ - Check_And_Enqueue(Thread->Mesh_Queue, Root, &Root->BBox, &rayinfo, Thread->Stats()); + Check_And_Enqueue(*mtpQueue, Root, &Root->BBox, &rayinfo, Thread->Stats()); /* Check elements in the priority queue. */ - while (!Thread->Mesh_Queue.IsEmpty()) + while (!mtpQueue->IsEmpty()) { - Thread->Mesh_Queue.RemoveMin(Depth, Node); + mtpQueue->RemoveMin(Depth, Node); /* * If current intersection is larger than the best intersection found @@ -1503,7 +1506,7 @@ bool Mesh::intersect_bbox_tree(const BasicRay &ray, const BasicRay &Orig_Ray, DB /* This is a node containing leaves to be checked. */ for (i = 0; i < Node->Entries; i++) - Check_And_Enqueue(Thread->Mesh_Queue, Node->Node[i], &Node->Node[i]->BBox, &rayinfo, Thread->Stats()); + Check_And_Enqueue(*mtpQueue, Node->Node[i], &Node->Node[i]->BBox, &rayinfo, Thread->Stats()); } else { @@ -2370,7 +2373,7 @@ bool Mesh::inside_bbox_tree(const BasicRay &ray, TraceThreadData *Thread) const Rayinfo rayinfo(ray); /* Start with an empty priority queue. */ - Thread->Mesh_Queue.Clear(); + mtpQueue->Clear(); found = 0; Best = BOUND_HUGE; @@ -2383,19 +2386,19 @@ bool Mesh::inside_bbox_tree(const BasicRay &ray, TraceThreadData *Thread) const Root = Data->Tree; /* Set the root object infinite to avoid a test. */ - Check_And_Enqueue(Thread->Mesh_Queue, Root, &Root->BBox, &rayinfo, Thread->Stats()); + Check_And_Enqueue(*mtpQueue, Root, &Root->BBox, &rayinfo, Thread->Stats()); /* Check elements in the priority queue. */ - while (!Thread->Mesh_Queue.IsEmpty()) + while (!mtpQueue->IsEmpty()) { - Thread->Mesh_Queue.RemoveMin(Depth, Node); + mtpQueue->RemoveMin(Depth, Node); /* Check current node. */ if (Node->Entries) { /* This is a node containing leaves to be checked. */ for (i = 0; i < Node->Entries; i++) - Check_And_Enqueue(Thread->Mesh_Queue, Node->Node[i], &Node->Node[i]->BBox, &rayinfo, Thread->Stats()); + Check_And_Enqueue(*mtpQueue, Node->Node[i], &Node->Node[i]->BBox, &rayinfo, Thread->Stats()); } else { diff --git a/source/core/shape/mesh.h b/source/core/shape/mesh.h index f6493e138..4a75843f0 100644 --- a/source/core/shape/mesh.h +++ b/source/core/shape/mesh.h @@ -40,9 +40,11 @@ #include "core/configcore.h" // C++ variants of C standard header files -// C++ standard header files // (none at the moment) +// C++ standard header files +#include + // POV-Ray header files (base module) // (none at the moment) @@ -194,6 +196,17 @@ class Mesh final : public ObjectBase static HASH_TABLE **Vertex_Hash_Table; static HASH_TABLE **Normal_Hash_Table; static UV_HASH_TABLE **UV_Hash_Table; + + /// Priority queue object. + /// + /// This object is for temporary use in the intersection and insideness tests; + /// the only reason it is not simply a local variable there is that we want to + /// avoid the overhead of repeated construction and destruction on the stack. + /// Technically we could get the same performance by keeping it local to the + /// functions and making it thread-local, but this would mean having one such + /// object per function, when it's perfectly safe for them to share one object. + /// + static thread_local std::unique_ptr mtpQueue; }; /// @} diff --git a/source/core/shape/ovus.cpp b/source/core/shape/ovus.cpp index f42e461b5..ffec245a4 100644 --- a/source/core/shape/ovus.cpp +++ b/source/core/shape/ovus.cpp @@ -81,6 +81,7 @@ #include "core/math/polynomialsolver.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/parametric.cpp b/source/core/shape/parametric.cpp index 065dd5c82..f815d7a07 100644 --- a/source/core/shape/parametric.cpp +++ b/source/core/shape/parametric.cpp @@ -50,6 +50,7 @@ #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/plane.cpp b/source/core/shape/plane.cpp index f1f3c2f03..376d92c27 100644 --- a/source/core/shape/plane.cpp +++ b/source/core/shape/plane.cpp @@ -47,6 +47,7 @@ #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/polygon.cpp b/source/core/shape/polygon.cpp index 5aef6ba8e..5964bc52b 100644 --- a/source/core/shape/polygon.cpp +++ b/source/core/shape/polygon.cpp @@ -74,6 +74,7 @@ #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/polynomial.cpp b/source/core/shape/polynomial.cpp index de466ca24..2f82214e3 100644 --- a/source/core/shape/polynomial.cpp +++ b/source/core/shape/polynomial.cpp @@ -51,6 +51,7 @@ #include "core/math/polynomialsolver.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/prism.cpp b/source/core/shape/prism.cpp index 381a83200..274c4a2bb 100644 --- a/source/core/shape/prism.cpp +++ b/source/core/shape/prism.cpp @@ -130,6 +130,7 @@ #include "core/math/polynomialsolver.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/quadric.cpp b/source/core/shape/quadric.cpp index a2f1146e6..48898f88d 100644 --- a/source/core/shape/quadric.cpp +++ b/source/core/shape/quadric.cpp @@ -52,6 +52,7 @@ #include "core/render/ray.h" #include "core/shape/plane.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/sor.cpp b/source/core/shape/sor.cpp index 3342ee951..04fc53ccd 100644 --- a/source/core/shape/sor.cpp +++ b/source/core/shape/sor.cpp @@ -115,6 +115,7 @@ #include "core/math/polynomialsolver.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/sphere.cpp b/source/core/shape/sphere.cpp index e79e01fdb..788cd3a33 100644 --- a/source/core/shape/sphere.cpp +++ b/source/core/shape/sphere.cpp @@ -48,6 +48,7 @@ #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/spheresweep.cpp b/source/core/shape/spheresweep.cpp index 13d6d1412..03c8f929f 100644 --- a/source/core/shape/spheresweep.cpp +++ b/source/core/shape/spheresweep.cpp @@ -96,6 +96,7 @@ #include "core/math/polynomialsolver.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/superellipsoid.cpp b/source/core/shape/superellipsoid.cpp index d1d94ddc2..f2afc5eb2 100644 --- a/source/core/shape/superellipsoid.cpp +++ b/source/core/shape/superellipsoid.cpp @@ -80,6 +80,7 @@ #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/torus.cpp b/source/core/shape/torus.cpp index 4a084ee88..e881d2bd8 100644 --- a/source/core/shape/torus.cpp +++ b/source/core/shape/torus.cpp @@ -61,6 +61,7 @@ #include "core/math/polynomialsolver.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/triangle.cpp b/source/core/shape/triangle.cpp index be771c7a2..c5a801a0f 100644 --- a/source/core/shape/triangle.cpp +++ b/source/core/shape/triangle.cpp @@ -47,6 +47,7 @@ #include "core/math/matrix.h" #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/shape/truetype.cpp b/source/core/shape/truetype.cpp index bd225c33c..50dd3218e 100644 --- a/source/core/shape/truetype.cpp +++ b/source/core/shape/truetype.cpp @@ -56,6 +56,7 @@ #include "core/render/ray.h" #include "core/scene/tracethreaddata.h" #include "core/shape/csg.h" +#include "core/support/statistics.h" // this must be the last file included #include "base/povdebug.h" diff --git a/source/core/support/cracklecache.cpp b/source/core/support/cracklecache.cpp new file mode 100644 index 000000000..4f897d18a --- /dev/null +++ b/source/core/support/cracklecache.cpp @@ -0,0 +1,151 @@ +//****************************************************************************** +/// +/// @file core/support/cracklecache.cpp +/// +/// Implementation of the crackle pattern cache. +/// +/// @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 "core/support/cracklecache.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 (core module) +// POV-Ray header files (parser module) +// (none at the moment) + +// this must be the last file included +#include "base/povdebug.h" + +namespace pov +{ + +CrackleCache::CrackleCache() : + mPruneCounter(0) +{ + // Advise the unordered_map that we don't mind hash collisions. + // While this is a very high load factor, the simple fact is that the cost of + // allocating memory at render time (each insert into the table requires an alloc + // as the container doesn't pre-emptively allocate, unlike e.g. std::vector) is + // quite high, particularly when we have multiple threads contending for the heap + // lock. + mData.max_load_factor(50.0); +} + +bool CrackleCache::Lookup(CrackleCacheEntryPtr& entry, const CrackleCellCoord& coord) +{ + // search for this hash value in the cache + CrackleCacheData::iterator iter = mData.find(coord); + bool found = (iter != mData.end()); + + if (!found) + { + // Not in cache. + + // If cache is already excessively large; refrain from creating a new entry. + // Having to re-calculate entries that would have been cache hits had we not + // skipped on adding an entry is less expensive than chewing up immense amounts + // of RAM and finally hitting the swapfile. unfortunately there's no good way + // to tell how much memory is 'too much' for the cache, so we just use a hard- + // coded number for now (ideally we should allow the user to configure this). + // keep in mind that the cache memory usage is per-thread, so the more threads, + // the more RAM. If we don't do the insert, `entry` will remain unchanged. + if (mData.size() * sizeof(CrackleCacheData::value_type) >= 30 * 1024 * 1024) + return false; + + // Generate a new cache entry. + iter = mData.insert(mData.end(), CrackleCacheData::value_type(coord, CrackleCacheEntry())); + entry = &iter->second; + entry->lastUsed = mPruneCounter; + return false; + } + else + { + entry = &iter->second; + // NB: We're deliberately _not_ updating `entry->lastUsed` here, as that + // seems to be counter-productive to performance. + return true; + } +} + +void CrackleCache::Prune() +{ + CrackleCacheData::iterator it; + + // This serves as a kind of "clock" to track age of cache entries. + ++mPruneCounter; + + // Probably we ought to have a means for the end-user to choose the preferred maximum bytes reserved for the cache. + // For now, we have hard-coded values. we also do not discard any entries that are from the current block, even if + // the cache size is exceeded. also, note that the cache size is per-thread. finally, don't forget that erasing + // elements doesn't in and of itself return the freed memory to the heap. + + // Don't go through the hassle of pruning unless the cache has reached a certain size. + if (mData.size() * sizeof(CrackleCacheData::value_type) < 15 * 1024 * 1024 / 64) + return; + + // If we're pruning, aim for a somewhat lower size. + // Traverse the map to determine the oldest age, then traverse it again to + // throw away all entries with that age. Rinse, repeat. + // TODO - This salami approach - cutting away one slice at a time - seems + // inefficient; instead, from the oldest age we should probably be + // able to guesstimate a cut-off age that will get us close to the + // desired cache size, and then throw away everything older than + // that in a single pass. + while (mData.size() * sizeof(CrackleCacheData::value_type) > 10 * 1024 * 1024 / 64) + { + // search the cache for the oldest entries + int oldest = std::numeric_limits::max(); + for (it = mData.begin(); it != mData.end(); it++) + if (it->second.lastUsed < oldest) + oldest = (int)it->second.lastUsed; + + // don't remove any entries from the most recent block + if (oldest == mPruneCounter) + break; + + for (it = mData.begin(); it != mData.end(); ) + { + if (it->second.lastUsed == oldest) + { + it = mData.erase(it); + continue; + } + it++; + } + } +} + +} +// end of namespace pov diff --git a/source/core/support/cracklecache.h b/source/core/support/cracklecache.h new file mode 100644 index 000000000..ac424fcd4 --- /dev/null +++ b/source/core/support/cracklecache.h @@ -0,0 +1,169 @@ +//****************************************************************************** +/// +/// @file core/support/cracklecache.h +/// +/// Declarations related to crackle pattern cache. +/// +/// @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_CORE_CRACKLECACHE_H +#define POVRAY_CORE_CRACKLECACHE_H + +// Module config header file must be the first file included within POV-Ray unit header files +#include "core/configcore.h" +#include "core/support/cracklecache_fwd.h" + +// C++ variants of C standard header files +// (none at the moment) + +// C++ standard header files +#include + +// Boost header files +#include + +// POV-Ray header files (base module) +#include "base/mathutil.h" + +// POV-Ray header files (core module) +#include "core/math/vector.h" + +namespace pov +{ + +//****************************************************************************** + +/// Helper class to implement the crackle cache. +class CrackleCellCoord final +{ +public: + + CrackleCellCoord() : mX(0), mY(0), mZ(0), mRepeatX(0), mRepeatY(0), mRepeatZ(0) {} + CrackleCellCoord(int x, int y, int z, int rx, int ry, int rz) : mX(x), mY(y), mZ(z), mRepeatX(rx), mRepeatY(ry), mRepeatZ(rz) + { + WrapCellCoordinate(mX, mRepeatX); + WrapCellCoordinate(mY, mRepeatY); + WrapCellCoordinate(mZ, mRepeatZ); + } + + bool operator==(CrackleCellCoord const& other) const + { + return mX == other.mX && mY == other.mY && mZ == other.mZ; + } + + /// Function to compute a hash value from the coordinates. + /// + /// @note This function's name, as well as it being a global function rather than a member, is mandated by + /// std::unordered_map. + /// + /// @param[in] coord The coordinate. + /// @return The hash. + /// + friend std::size_t hash_value(CrackleCellCoord const& coord) + { + std::size_t seed = 0; + boost::hash_combine(seed, coord.mX); + boost::hash_combine(seed, coord.mY); + boost::hash_combine(seed, coord.mZ); + + return seed; + } + +protected: + + int mX; + int mY; + int mZ; + int mRepeatX; + int mRepeatY; + int mRepeatZ; + + static inline void WrapCellCoordinate(int& v, int& repeat) + { + if (!repeat) + return; + v = pov_base::wrapInt(v, repeat); + if ((v >= 2) && (v < repeat - 2)) + repeat = 0; + } +}; + +//****************************************************************************** + +/// Helper class to implement the crackle cache. +struct CrackleCacheEntry final +{ + /// A kind of timestamp specifying when this particular entry was last used. + size_t lastUsed; + + /// The pseudo-random points defining the pattern in this particular subset of 3D space. + Vector3d aCellNuclei[81]; +}; +using CrackleCacheEntryPtr = CrackleCacheEntry*; + +//****************************************************************************** + +/// Crackle cache. +/// +/// This class buffers the pseudorandom "seeds points" for the Voronoi-based +/// crackle pattern. +/// +class CrackleCache final +{ +public: + + /// Construct a new crackle cache. + CrackleCache(); + + /// Look up cache entry. + /// If the queried entry is not currently in the cache, an empty entry is + /// automatically created, unless the cache has reached an excessive size. + /// @param[out] entry Pointer to cache entry, or unchanged if not in cache. + /// @param[in] coord Crackle cell coordinates. + /// @return `true` if entry already existed, `false` otherwise. + bool Lookup(CrackleCacheEntryPtr& entry, const CrackleCellCoord& coord); + + /// Prune the crackle cache. + /// This function is intended to be called at regular intervals to remove + /// the least recently used entries from the cache to keep it reasonably + /// lean and fast. + void Prune(); + +private: + + using CrackleCacheData = std::unordered_map>; + CrackleCacheData mData; + std::size_t mPruneCounter; +}; + +} +// end of namespace pov + +#endif // POVRAY_CORE_CRACKLECACHE_H diff --git a/source/core/support/cracklecache_fwd.h b/source/core/support/cracklecache_fwd.h new file mode 100644 index 000000000..154405028 --- /dev/null +++ b/source/core/support/cracklecache_fwd.h @@ -0,0 +1,55 @@ +//****************************************************************************** +/// +/// @file core/support/cracklecache_fwd.h +/// +/// Forward declarations related to the crackle pattern cache. +/// +/// @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_CORE_CRACKLECACHE_FWD_H +#define POVRAY_CORE_CRACKLECACHE_FWD_H + +/// @file +/// @note +/// This file should not pull in any headers whatsoever (except other +/// forward declaration headers or certain select standard headers). + +// C++ standard header files +// (none at the moment) + +namespace pov +{ + +class CrackleCache; + +} +// end of namespace pov + +#endif // POVRAY_CORE_CRACKLECACHE_FWD_H diff --git a/source/core/support/octree.cpp b/source/core/support/octree.cpp index c78cd673c..aa7695e12 100644 --- a/source/core/support/octree.cpp +++ b/source/core/support/octree.cpp @@ -61,6 +61,7 @@ #include #include #include +#include // C++ standard header files #include @@ -204,7 +205,7 @@ static inline float Pow2Floor(float a) /// @f] /// /// The value of the bias _b_ depends on @ref POV_PORTABLE_RADIOSITY, bit is -/// the same value as used by @BiasedIntPow2(). +/// the same value as used by @ref BiasedIntPow2(). /// /// @note /// The function signature may differ depending on @@ -231,11 +232,11 @@ static inline int BiasedIntLog2(float a) /// @f] /// /// The value of the bias _b_ depends on @ref POV_PORTABLE_RADIOSITY, bit is -/// the same value as used by @BiasedIntLog2(). +/// the same value as used by @ref BiasedIntLog2(). /// /// @note /// The function signature may differ depending on -/// @ref POV_PORTABLE_BIASEDINTPOW2. +/// @ref POV_PORTABLE_RADIOSITY. /// static inline float BiasedIntPow2(int a) { @@ -1580,7 +1581,7 @@ bool ot_read_file(OT_NODE **root, IStream *fd, const OT_READ_PARAM* param, OT_RE new_block = reinterpret_cast(POV_MALLOC(sizeof (OT_BLOCK), "octree node from file")); if (new_block != nullptr) { - POV_MEMCPY(new_block, &bl, sizeof (OT_BLOCK)); + std::memcpy(new_block, &bl, sizeof (OT_BLOCK)); ot_index_sphere(bl.Point, bl.Harmonic_Mean_Distance * param->RealErrorBound, &id); ot_ins(root, new_block, &id); diff --git a/source/core/support/octree_fwd.h b/source/core/support/octree_fwd.h index 5020b9c14..d85e06c4b 100644 --- a/source/core/support/octree_fwd.h +++ b/source/core/support/octree_fwd.h @@ -36,12 +36,13 @@ #ifndef POVRAY_CORE_OCTREE_FWD_H #define POVRAY_CORE_OCTREE_FWD_H -// C++ standard header files -#include - /// @file /// @note -/// This file should not pull in any POV-Ray header whatsoever. +/// This file should not pull in any headers whatsoever (except other +/// forward declaration headers or certain select standard headers). + +// C++ standard header files +#include namespace pov { diff --git a/source/core/support/statistics.h b/source/core/support/statistics.h index dd076f6f1..4c18cd2fe 100644 --- a/source/core/support/statistics.h +++ b/source/core/support/statistics.h @@ -38,6 +38,7 @@ // Module config header file must be the first file included within POV-Ray unit header files #include "core/configcore.h" +#include "core/support/statistics_fwd.h" // C++ variants of C standard header files #include diff --git a/source/core/support/statistics_fwd.h b/source/core/support/statistics_fwd.h new file mode 100644 index 000000000..dfa278ee6 --- /dev/null +++ b/source/core/support/statistics_fwd.h @@ -0,0 +1,51 @@ +//****************************************************************************** +/// +/// @file core/support/statistics_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_CORE_STATISTICS_FWD_H +#define POVRAY_CORE_STATISTICS_FWD_H + +/// @file +/// @note +/// This file should not pull in any POV-Ray header whatsoever. + +namespace pov +{ + +class RenderStatistics; + +} +// end of namespace pov + +#endif // POVRAY_CORE_STATISTICS_FWD_H diff --git a/source/frontend/imagemessagehandler.cpp b/source/frontend/imagemessagehandler.cpp index d99357fee..c260f802f 100644 --- a/source/frontend/imagemessagehandler.cpp +++ b/source/frontend/imagemessagehandler.cpp @@ -45,7 +45,6 @@ // POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/types.h" -#include "base/image/colourspace.h" #include "base/image/dither.h" #include "base/image/encoding.h" #include "base/image/image.h" diff --git a/source/frontend/parsermessagehandler.cpp b/source/frontend/parsermessagehandler.cpp index 5cdcdf304..322a589e5 100644 --- a/source/frontend/parsermessagehandler.cpp +++ b/source/frontend/parsermessagehandler.cpp @@ -40,6 +40,7 @@ // (none at the moment) // C++ standard header files +#include #include // POV-Ray header files (base module) diff --git a/source/frontend/precomp.h b/source/frontend/precomp.h index 70db91f1e..74acf21ca 100644 --- a/source/frontend/precomp.h +++ b/source/frontend/precomp.h @@ -59,7 +59,6 @@ // C++ standard header files #include -#include #include #include #include @@ -71,13 +70,4 @@ #include // Boost header files -#include #include -#include -#include -#if POV_MULTITHREADED -#include -#include -#endif -#include - diff --git a/source/frontend/processrenderoptions.cpp b/source/frontend/processrenderoptions.cpp index 818633d54..e257dbc90 100644 --- a/source/frontend/processrenderoptions.cpp +++ b/source/frontend/processrenderoptions.cpp @@ -48,7 +48,6 @@ #include "base/stringutilities.h" #include "base/image/colourspace.h" #include "base/image/dither.h" -#include "base/image/encoding.h" // POV-Ray header files (core module) #include "base/fileinputoutput.h" diff --git a/source/frontend/renderfrontend.cpp b/source/frontend/renderfrontend.cpp index f0cb9c2d2..6827d9219 100644 --- a/source/frontend/renderfrontend.cpp +++ b/source/frontend/renderfrontend.cpp @@ -44,13 +44,13 @@ // POV-Ray header files (base module) #include "base/fileinputoutput.h" +#include "base/mathutil.h" #include "base/platformbase.h" #include "base/textstream.h" #include "base/textstreambuffer.h" #include "base/types.h" #include "base/image/colourspace.h" #include "base/image/dither.h" -#include "base/image/encoding.h" // POV-Ray header files (POVMS module) #include "povms/povmsid.h" diff --git a/source/frontend/renderfrontend.h b/source/frontend/renderfrontend.h index efcabd6cb..fb83956e1 100644 --- a/source/frontend/renderfrontend.h +++ b/source/frontend/renderfrontend.h @@ -51,6 +51,9 @@ #include #include +// Boost header files +#include + // POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/filesystem.h" diff --git a/source/frontend/rendermessagehandler.cpp b/source/frontend/rendermessagehandler.cpp index 3437853b2..374823dab 100644 --- a/source/frontend/rendermessagehandler.cpp +++ b/source/frontend/rendermessagehandler.cpp @@ -37,9 +37,11 @@ #include "frontend/rendermessagehandler.h" // C++ variants of C standard header files -// C++ standard header files // (none at the moment) +// C++ standard header files +#include + // POV-Ray header files (base module) // POV-Ray header files (POVMS module) // (none at the moment) diff --git a/source/frontend/shelloutprocessing.cpp b/source/frontend/shelloutprocessing.cpp index 5e11f9076..c5b2aa0b9 100644 --- a/source/frontend/shelloutprocessing.cpp +++ b/source/frontend/shelloutprocessing.cpp @@ -41,7 +41,6 @@ // (none at the moment) // Boost header files -#include #include // POV-Ray header files (base module) diff --git a/source/frontend/simplefrontend.h b/source/frontend/simplefrontend.h index e6fc7a3f8..9cdbfc82e 100644 --- a/source/frontend/simplefrontend.h +++ b/source/frontend/simplefrontend.h @@ -45,6 +45,9 @@ // C++ standard header files #include +// Boost header files +#include + // POV-Ray header files (base module) #include "base/povassert.h" #include "base/stringutilities.h" diff --git a/source/parser/fncode.cpp b/source/parser/fncode.cpp index 41fe13e26..0fddf587b 100644 --- a/source/parser/fncode.cpp +++ b/source/parser/fncode.cpp @@ -393,7 +393,7 @@ void FNCode_Copy(FunctionCode *f, FunctionCode *fnew) if (f->program != nullptr) { fnew->program = reinterpret_cast(POV_MALLOC(sizeof(Instruction) * f->program_size, "fn: program")); - POV_MEMCPY(fnew->program, f->program, sizeof(Instruction) * f->program_size); + std::memcpy(fnew->program, f->program, sizeof(Instruction) * f->program_size); } if (f->name != nullptr) { diff --git a/source/parser/parser.cpp b/source/parser/parser.cpp index 27e4c0c36..5ecd39536 100644 --- a/source/parser/parser.cpp +++ b/source/parser/parser.cpp @@ -42,13 +42,11 @@ #include #include #include +#include // C++ standard header files #include -// Boost header files -#include - // POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/fileutil.h" @@ -71,6 +69,7 @@ #include "core/material/interior.h" #include "core/material/noise.h" #include "core/material/normal.h" +#include "core/material/pattern.h" #include "core/material/pigment.h" #include "core/material/texture.h" #include "core/math/matrix.h" @@ -157,6 +156,18 @@ Parser::Parser(shared_ptr sd, const Options& opts, mTokensSinceLastProgressReport(0), next_rand(nullptr) { + std::tm tmY2K; + // Field = Value - Base + tmY2K.tm_year = 2000 - 1900; + tmY2K.tm_mon = 1 - 1; + tmY2K.tm_mday = 1 - 0; + tmY2K.tm_hour = 0; + tmY2K.tm_min = 0; + tmY2K.tm_sec = 0; + tmY2K.tm_isdst = false; + // `std::mktime()` doesn't need `tmY2K.tm_wday` nor `tmY2K.yday` to be set. + mY2K = std::chrono::system_clock::from_time_t(std::mktime(&tmY2K)); + pre_init_tokenizer(); if (sceneData->realTimeRaytracing) mBetaFeatureFlags.realTimeRaytracing = true; diff --git a/source/parser/parser.h b/source/parser/parser.h index 1353e9ff6..aa0b62f74 100644 --- a/source/parser/parser.h +++ b/source/parser/parser.h @@ -46,6 +46,7 @@ // (none at the moment) // C++ standard header files +#include #include #include #include @@ -734,6 +735,8 @@ class Parser final size_t MaxCachedMacroSize; + std::chrono::system_clock::time_point mY2K; + // parse.h/parse.cpp void Frame_Init(void); void InitDefaults(int version); diff --git a/source/parser/parser_expressions.cpp b/source/parser/parser_expressions.cpp index 357c7e3f6..cce741027 100644 --- a/source/parser/parser_expressions.cpp +++ b/source/parser/parser_expressions.cpp @@ -40,12 +40,11 @@ #include #include #include +#include // C++ standard header files #include - -// Boost header files -#include +#include // POV-Ray header files (base module) #include "base/fileinputoutput.h" @@ -975,9 +974,9 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms) case NOW_TOKEN: { - static boost::posix_time::ptime y2k(boost::gregorian::date(2000,1,1)); - boost::posix_time::ptime now(boost::posix_time::microsec_clock::universal_time()); - Val = (now-y2k).total_microseconds() * (1.0e-6) / (24*60*60); + auto now = std::chrono::system_clock::now(); + using FractionalDays = std::chrono::duration>; + Val = std::chrono::duration_cast (now - mY2K).count(); } break; } @@ -1723,7 +1722,7 @@ void Parser::Parse_Express (EXPRESS& Express,int *Terms) Chosen = &Local_Express2; *Terms = Local_Terms2; } - POV_MEMCPY(Express, Chosen, sizeof(EXPRESS)); + std::memcpy(Express, Chosen, sizeof(EXPRESS)); } else { diff --git a/source/parser/parser_strings.cpp b/source/parser/parser_strings.cpp index 89c128421..33508ee62 100644 --- a/source/parser/parser_strings.cpp +++ b/source/parser/parser_strings.cpp @@ -40,6 +40,7 @@ #include #include #include +#include // C++ standard header files // (none at the moment) @@ -145,7 +146,7 @@ UCS2 *Parser::Parse_String(bool pathname, bool require) len = pString->size() + 1; New = reinterpret_cast(POV_MALLOC(len * sizeof(UCS2), "UCS2 String")); - POV_MEMCPY(reinterpret_cast(New), + std::memcpy(reinterpret_cast(New), reinterpret_cast(pString->c_str()), len * sizeof(UCS2)); EXIT @@ -194,7 +195,7 @@ UCS2 *Parser::Parse_String(bool pathname, bool require) CASE(STRING_ID_TOKEN) len = UCS2_strlen(CurrentTokenDataPtr()) + 1; New = reinterpret_cast(POV_MALLOC(len * sizeof(UCS2), "UCS2 String")); - POV_MEMCPY(reinterpret_cast(New), CurrentTokenDataPtr(), len * sizeof(UCS2)); + std::memcpy(reinterpret_cast(New), CurrentTokenDataPtr(), len * sizeof(UCS2)); EXIT END_CASE diff --git a/source/parser/parsertypes.cpp b/source/parser/parsertypes.cpp index 5bdc6aa18..c870a8f29 100644 --- a/source/parser/parsertypes.cpp +++ b/source/parser/parsertypes.cpp @@ -38,8 +38,6 @@ // C++ variants of C standard header files // C++ standard header files -// Boost header files -// (none at the moment) // POV-Ray header files (base module) #include "base/fileinputoutput.h" diff --git a/source/parser/parsertypes.h b/source/parser/parsertypes.h index 4fcf84a17..8f0f7cf58 100644 --- a/source/parser/parsertypes.h +++ b/source/parser/parsertypes.h @@ -45,9 +45,6 @@ // C++ standard header files #include -// Boost header files -// (none at the moment) - // POV-Ray header files (base module) #include "base/fileinputoutput_fwd.h" #include "base/messenger.h" diff --git a/source/parser/precomp.h b/source/parser/precomp.h index a8f5d0853..308d36038 100644 --- a/source/parser/precomp.h +++ b/source/parser/precomp.h @@ -59,7 +59,7 @@ // C++ standard header files #include -#include +#include #include #include #include @@ -68,17 +68,8 @@ #include #include #include +#include #include // Boost header files -#include -#include -#include -#include #include -#if POV_MULTITHREADED -#include -#include -#endif -#include - diff --git a/source/parser/rawtokenizer.cpp b/source/parser/rawtokenizer.cpp index 64040782f..d1336d9be 100644 --- a/source/parser/rawtokenizer.cpp +++ b/source/parser/rawtokenizer.cpp @@ -38,8 +38,6 @@ // C++ variants of C standard header files // C++ standard header files -// Boost header files -// (none at the moment) // POV-Ray header files (base module) #include "base/fileinputoutput.h" diff --git a/source/parser/rawtokenizer.h b/source/parser/rawtokenizer.h index 80bece576..92be183c2 100644 --- a/source/parser/rawtokenizer.h +++ b/source/parser/rawtokenizer.h @@ -46,9 +46,6 @@ #include #include -// Boost header files -// (none at the moment) - // POV-Ray header files (base module) #include "base/stringtypes.h" diff --git a/source/parser/scanner.cpp b/source/parser/scanner.cpp index 885c55fb9..9f5d6e4a4 100644 --- a/source/parser/scanner.cpp +++ b/source/parser/scanner.cpp @@ -45,9 +45,6 @@ #include #include -// Boost header files -// (none at the moment) - // POV-Ray header files (base module) #include "base/fileinputoutput.h" #include "base/povassert.h" diff --git a/source/parser/scanner.h b/source/parser/scanner.h index 68365cd32..67df35d25 100644 --- a/source/parser/scanner.h +++ b/source/parser/scanner.h @@ -46,9 +46,6 @@ #include #include -// Boost header files -// (none at the moment) - // POV-Ray header files (base module) #include "base/messenger_fwd.h" #include "base/stringtypes.h" diff --git a/source/parser/symboltable.cpp b/source/parser/symboltable.cpp index 071c7acf3..d028a54ff 100644 --- a/source/parser/symboltable.cpp +++ b/source/parser/symboltable.cpp @@ -37,8 +37,9 @@ #include "parser/symboltable.h" // C++ variants of C standard header files +#include + // C++ standard header files -// Boost header files // (none at the moment) // POV-Ray header files (base module) @@ -265,7 +266,7 @@ void* SymbolTable::Copy_Identifier(void* Data, int Type) case STRING_ID_TOKEN: len = UCS2_strlen(reinterpret_cast(Data)) + 1; New = reinterpret_cast(POV_MALLOC(len * sizeof(UCS2), "UCS2 String")); - POV_MEMCPY(reinterpret_cast(New), reinterpret_cast(Data), len * sizeof(UCS2)); + std::memcpy(reinterpret_cast(New), reinterpret_cast(Data), len * sizeof(UCS2)); break; case ARRAY_ID_TOKEN: New = CloneData(Data); diff --git a/source/parser/symboltable.h b/source/parser/symboltable.h index de34cbb23..52da82502 100644 --- a/source/parser/symboltable.h +++ b/source/parser/symboltable.h @@ -45,9 +45,6 @@ // C++ standard header files #include -// Boost header files -// (none at the moment) - // POV-Ray header files (base module) #include "base/stringtypes.h" diff --git a/source/povmain.cpp b/source/povmain.cpp index 3f296b697..e90e5080f 100644 --- a/source/povmain.cpp +++ b/source/povmain.cpp @@ -33,7 +33,6 @@ /// //****************************************************************************** -#include #include #include diff --git a/source/povms/precomp.h b/source/povms/precomp.h index 9ad2a0b3e..0f82796d8 100644 --- a/source/povms/precomp.h +++ b/source/povms/precomp.h @@ -59,7 +59,6 @@ // C++ standard header files #include -#include #include #include #include @@ -69,14 +68,3 @@ #include #include #include - -// Boost header files -#include -#include -#include -#include -#if POV_MULTITHREADED -#include -#include -#endif -#include diff --git a/source/vm/fnintern.cpp b/source/vm/fnintern.cpp index c09c84cc2..94bd28f3f 100644 --- a/source/vm/fnintern.cpp +++ b/source/vm/fnintern.cpp @@ -51,6 +51,7 @@ // POV-Ray header files (core module) #include "core/material/noise.h" +#include "core/material/pattern.h" #include "core/material/pigment.h" #include "core/material/warp.h" #include "core/math/matrix.h" diff --git a/source/vm/fnpovfpu.cpp b/source/vm/fnpovfpu.cpp index 3cfd68789..c302558d4 100644 --- a/source/vm/fnpovfpu.cpp +++ b/source/vm/fnpovfpu.cpp @@ -246,6 +246,7 @@ Density of instruction set: 916 / 1024 = 0.8945 // POV-Ray header files (core module) #include "core/scene/tracethreaddata.h" +#include "core/support/statistics.h" // POV-Ray header files (VM module) #include "vm/fnintern.h" diff --git a/source/vm/precomp.h b/source/vm/precomp.h index 46e5b0738..1f1a046ee 100644 --- a/source/vm/precomp.h +++ b/source/vm/precomp.h @@ -59,7 +59,6 @@ // C++ standard header files #include -#include #include #include #include @@ -71,14 +70,4 @@ #include // Boost header files -#include -#include -#include -#include #include -#if POV_MULTITHREADED -#include -#include -#endif -#include - diff --git a/tests/source/tests.h b/tests/source/tests.h index 873d4c7a0..a13c9a5c2 100644 --- a/tests/source/tests.h +++ b/tests/source/tests.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 @@ -38,4 +38,6 @@ #include +#include "base/povassert.h" + #endif // POVRAY_TESTS_H diff --git a/tools/doxygen/doxygen.cfg b/tools/doxygen/doxygen.cfg index e881467ae..36dfb74cb 100644 --- a/tools/doxygen/doxygen.cfg +++ b/tools/doxygen/doxygen.cfg @@ -426,7 +426,7 @@ EXTRACT_ALL = NO # be included in the documentation. # The default value is: NO. -EXTRACT_PRIVATE = NO +EXTRACT_PRIVATE = YES # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. @@ -438,7 +438,7 @@ EXTRACT_PACKAGE = NO # included in the documentation. # The default value is: NO. -EXTRACT_STATIC = NO +EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, diff --git a/tools/doxygen/source-doc.cfg b/tools/doxygen/source-doc.cfg index 89a280be7..dad835fd4 100644 --- a/tools/doxygen/source-doc.cfg +++ b/tools/doxygen/source-doc.cfg @@ -50,7 +50,8 @@ FILE_PATTERNS += */source-doc/*.dox \ */dirinfo.dox # make sure we don't accidently pick up documentation of 3rd party libraries -EXCLUDE_PATTERNS = */libraries/dirinfo.dox +EXCLUDE_PATTERNS = */libraries/dirinfo.dox \ + */windows/vs2015/* EXAMPLE_PATH = source-doc/snippets diff --git a/unix/README.md b/unix/README.md index be5f24f92..79e1b9138 100644 --- a/unix/README.md +++ b/unix/README.md @@ -17,7 +17,6 @@ following packages pre-installed: libboost-dev libboost-date-time-dev - libboost-thread-dev libz-dev libpng-dev libjpeg-dev diff --git a/unix/configure.ac b/unix/configure.ac index bf4d62fe8..c41671671 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -61,7 +61,6 @@ m4_include([unix/config/ax_pthread.m4]) m4_include([unix/config/ax_arg_enable.m4]) m4_include([unix/config/ax_arg_with.m4]) m4_include([unix/config/ax_boost_base.m4]) -m4_include([unix/config/ax_boost_thread.m4]) m4_include([unix/config/ax_test_compiler_flags.m4]) m4_include([unix/config/ax_check_compile_flag.m4]) m4_include([unix/config/ax_check_lib.m4]) @@ -300,44 +299,6 @@ LIBS="$LIBS $PTHREAD_CFLAGS $PTHREAD_LIBS" # append # Boost; required library # the following macro stops with error when boost is not found AX_BOOST_BASE([$required_libboost_version]) -AX_BOOST_THREAD -if test x"$ax_cv_boost_thread" != x"yes"; then - AC_MSG_ERROR([cannot find a suitable boost thread library]) -else - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" # append - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" # append - LIBS="$BOOST_THREAD_LIB $LIBS" -fi -AC_MSG_CHECKING([whether the boost thread library is usable]) -SAVED_LIBS=$LIBS -boost_thread_links=0 -for extralib in '' '-lboost_system' -do - LIBS=$SAVED_LIBS - LIBS="$LIBS $extralib" - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([[ - #include - ]],[[ - boost::mutex m; - boost::defer_lock_t(); - return 0; - ]]) - ],[ - AC_MSG_RESULT([yes]) - BOOST_THREAD_LIB="$BOOST_THREAD_LIB $extralib" - boost_thread_links=1 - ],,[ - AC_MSG_RESULT([cross-compiling]) # FIXME - ]) - if test $boost_thread_links = '1'; then - break - fi -done -if test $boost_thread_links != '1'; then - AC_MSG_RESULT([no]) - AC_MSG_FAILURE([cannot link with the boost thread library]) -fi AC_DEFINE([USE_OFFICIAL_BOOST], [], [Use the official Boost libraries.]) diff --git a/unix/disp_sdl.cpp b/unix/disp_sdl.cpp index 936ec5854..36ddf9e6e 100644 --- a/unix/disp_sdl.cpp +++ b/unix/disp_sdl.cpp @@ -43,6 +43,8 @@ #include +#include + // this must be the last file included #include "syspovdebug.h" diff --git a/unix/install.txt b/unix/install.txt index 4450db2eb..bc7f3ee62 100644 --- a/unix/install.txt +++ b/unix/install.txt @@ -352,12 +352,6 @@ Additional POV-Ray specific options are: requests to find the Boost library in the DIR directory. Boost 1.38 or above is mandatory to build POV-Ray. ---with-boost-thread=special-lib - requests to find the Boost thread library under the special-lib name, for - instance --with-boost-thread=boost_thread-gcc-mt if the thread library is - libboost_thread-gcc-mt.a (static form) or libboost_thread-gcc-mt.so* - (shared form) under the DIR directory specified by the option above. - --with-zlib=DIR or --without-zlib requests to find the ZLIB library in the DIR directory, where DIR is for instance /path/lib if ZLIB is /path/lib/libz.a (static form) or diff --git a/unix/povconfig/syspovconfig_gnu.h b/unix/povconfig/syspovconfig_gnu.h index d118c1cfd..b7320482d 100644 --- a/unix/povconfig/syspovconfig_gnu.h +++ b/unix/povconfig/syspovconfig_gnu.h @@ -61,6 +61,5 @@ #define POV_ULONG unsigned POV_LONG #define MACHINE_INTRINSICS_H -#define ALIGN32 __attribute__ ((aligned(32))) #endif // POVRAY_UNIX_SYSPOVCONFIG_GNU_H diff --git a/unix/povconfig/syspovconfigbackend.h b/unix/povconfig/syspovconfigbackend.h index a9c5f4497..7424d9e6d 100644 --- a/unix/povconfig/syspovconfigbackend.h +++ b/unix/povconfig/syspovconfigbackend.h @@ -11,7 +11,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,10 +50,4 @@ #define POV_USE_DEFAULT_TASK_INITIALIZE 1 #define POV_USE_DEFAULT_TASK_CLEANUP 1 -// Linux machines appear to need more stack storage than the default. -// Note that we leave this setting configurable via `-DPOV_THREAD_STACK_SIZE=...`. -#ifndef POV_THREAD_STACK_SIZE - #define POV_THREAD_STACK_SIZE (4 * 1024 * 1024) // 4 MiB -#endif - #endif // POVRAY_UNIX_SYSPOVCONFIGBACKEND_H diff --git a/unix/povconfig/syspovconfigbase.h b/unix/povconfig/syspovconfigbase.h index 30ad78f2b..7d1dc1b8f 100644 --- a/unix/povconfig/syspovconfigbase.h +++ b/unix/povconfig/syspovconfigbase.h @@ -46,10 +46,20 @@ // Our Unix-specific implementation of the Delay() function currently relies on the presence of // the nanosleep() or usleep() functions. If we have neither of those, we're falling back to // POV-Ray's platform-independent default implementation. -#if defined(HAVE_NANOSLEEP) || defined(HAVE_USLEEP) - #define POV_USE_DEFAULT_DELAY 0 -#else - #define POV_USE_DEFAULT_DELAY 1 +#ifndef POV_USE_PLATFORM_DELAY // allow for flavour-specific override in `syspovconfig.h`. + #if defined(HAVE_NANOSLEEP) + // While the default implementation _should_ do exactly what we want, + // for now we prefer `nanosleep()` because we presume to have a better + // understanding of its limitations and pitfalls. + #define POV_USE_PLATFORM_DELAY 1 + #elif defined(HAVE_USLEEP) + // `usleep()` definitely has some unwieldy quirks, so we presume we'll + // be better off with the default. + #define POV_USE_PLATFORM_DELAY 0 // use 2 for `usleep()` + #else + // We have no other choice but the default. + #define POV_USE_PLATFORM_DELAY 0 + #endif #endif // Our Unix-specific implementation of the Timer class currently relies on the presence of the diff --git a/vfe/unix/unixconsole.cpp b/vfe/unix/unixconsole.cpp index 8acb6c37f..5b492d7e3 100644 --- a/vfe/unix/unixconsole.cpp +++ b/vfe/unix/unixconsole.cpp @@ -39,7 +39,12 @@ // C++ standard header files #include +#include #include +#include + +// Boost library files +#include // Other library header files #include @@ -87,19 +92,34 @@ static bool gCancelRender = false; // for handling asynchronous (external) signals static int gSignalNumber = 0; -static boost::mutex gSignalMutex; +static std::mutex gSignalMutex; +static bool gTerminateSignalHandler = false; + +// TODO FIXME - This way to handle signals seems rather wonky, as it is subject +// to a potential race condition on `gSignalNumber` between `ProcessSignal()` +// polling the signal and `SignalHandler()` processing the next signal. +// Wouldn't it be smarter to register proper signal handlers? static void SignalHandler (void) { - sigset_t sigset; - int signum; + sigset_t sigset; + timespec timeout; + int signum; - while(true) + sigfillset(&sigset); + timeout.tv_sec = 0; + timeout.tv_nsec = 10000000; // 10 ms + + while(!gTerminateSignalHandler) { - sigfillset(&sigset); - sigwait(&sigset, &signum); // wait till a signal is caught - boost::mutex::scoped_lock lock(gSignalMutex); + // Wait till a signal is caught. + signum = sigtimedwait(&sigset, nullptr, &timeout); + if (signum == -1) + continue; // Error. Presumably timed out; check whether to end the task. + + // Got a signal. + std::lock_guard lock(gSignalMutex); gSignalNumber = signum; } } @@ -107,7 +127,7 @@ static void SignalHandler (void) static void ProcessSignal (void) { - boost::mutex::scoped_lock lock(gSignalMutex); + std::lock_guard lock(gSignalMutex); switch (gSignalNumber) { @@ -413,7 +433,7 @@ int main (int argc, char **argv) std::string bench_ini_name; std::string bench_pov_name; sigset_t sigset; - boost::thread *sigthread; + std::thread* sigthread; char ** argv_copy=argv; /* because argv is updated later */ int argc_copy=argc; /* because it might also be updated */ @@ -441,7 +461,7 @@ int main (int argc, char **argv) pthread_sigmask(SIG_BLOCK, &sigset, nullptr); // create the signal handling thread - sigthread = new boost::thread(SignalHandler); + sigthread = new std::thread(SignalHandler); session = new vfeUnixSession(); if (session->Initialize(nullptr, nullptr) != vfeNoError) @@ -479,6 +499,8 @@ int main (int argc, char **argv) PrintStatus (session) ; // TODO: general usage display (not yet in core code) session->GetUnixOptions()->PrintOptions(); + gTerminateSignalHandler = true; + sigthread->join(); delete sigthread; delete session; return RETURN_OK; @@ -487,6 +509,8 @@ int main (int argc, char **argv) { session->Shutdown() ; PrintVersion(); + gTerminateSignalHandler = true; + sigthread->join(); delete sigthread; delete session; return RETURN_OK; @@ -495,6 +519,8 @@ int main (int argc, char **argv) { session->Shutdown(); PrintGeneration(); + gTerminateSignalHandler = true; + sigthread->join(); delete sigthread; delete session; return RETURN_OK; @@ -507,6 +533,8 @@ int main (int argc, char **argv) else { session->Shutdown(); + gTerminateSignalHandler = true; + sigthread->join(); delete sigthread; delete session; return retval; @@ -607,6 +635,8 @@ int main (int argc, char **argv) retval = gCancelRender ? RETURN_USER_ABORT : RETURN_ERROR; session->Shutdown(); PrintStatus (session); + gTerminateSignalHandler = true; + sigthread->join(); delete sigthread; delete session; diff --git a/vfe/unix/vfeplatform.cpp b/vfe/unix/vfeplatform.cpp index daf1382d9..903667afe 100644 --- a/vfe/unix/vfeplatform.cpp +++ b/vfe/unix/vfeplatform.cpp @@ -50,6 +50,9 @@ #include #include +// Boost header files +#include + // other library header files #include #ifdef HAVE_SYS_TIME_H diff --git a/vfe/unix/vfeplatform.h b/vfe/unix/vfeplatform.h index 0be3da362..c8810d076 100644 --- a/vfe/unix/vfeplatform.h +++ b/vfe/unix/vfeplatform.h @@ -40,8 +40,6 @@ #include -#include - #include "base/path_fwd.h" #include "base/stringtypes.h" #include "base/filesystem_fwd.h" diff --git a/vfe/vfe.cpp b/vfe/vfe.cpp index ab97f6336..d6901710c 100644 --- a/vfe/vfe.cpp +++ b/vfe/vfe.cpp @@ -45,6 +45,9 @@ #include #include +#include +#include + #include "base/filesystem.h" #include "base/povassert.h" #include "base/textstream.h" diff --git a/vfe/vfe.h b/vfe/vfe.h index 92602a650..d11eda13d 100644 --- a/vfe/vfe.h +++ b/vfe/vfe.h @@ -41,10 +41,6 @@ #include #include -#include -#include -#include - #include "base/platformbase.h" #include "base/stringtypes.h" #include "base/timer.h" diff --git a/vfe/vfepovms.cpp b/vfe/vfepovms.cpp index 00061106a..274c76862 100644 --- a/vfe/vfepovms.cpp +++ b/vfe/vfepovms.cpp @@ -37,6 +37,9 @@ #include "vfe.h" +#include +#include + #include "povms/povmscpp.h" // this must be the last file included @@ -69,8 +72,8 @@ class SysQNode unsigned int m_ID ; DataNode *m_First ; DataNode *m_Last ; - boost::mutex m_EventMutex ; - boost::condition m_Event ; + std::mutex m_EventMutex ; + std::condition_variable m_Event ; static unsigned int QueueID ; } ; @@ -109,7 +112,7 @@ SysQNode::~SysQNode () { assert (m_Sanity == 0xEDFEEFBE) ; m_Event.notify_all (); - boost::mutex::scoped_lock lock (m_EventMutex); + std::lock_guard lock (m_EventMutex); if (m_Count > 0) { DataNode *current = m_First ; @@ -137,7 +140,7 @@ int SysQNode::Send (void *pData, int Len) dNode->Len = Len ; dNode->Next = nullptr; - boost::mutex::scoped_lock lock (m_EventMutex) ; + std::lock_guard lock (m_EventMutex) ; if (m_Last != nullptr) m_Last->Next = dNode ; @@ -155,7 +158,7 @@ int SysQNode::Send (void *pData, int Len) void *SysQNode::Receive (int *pLen, bool Blocking) { - boost::mutex::scoped_lock lock (m_EventMutex); + std::unique_lock lock (m_EventMutex); assert (m_Sanity == 0xEDFEEFBE) ; if (m_Sanity != 0xEDFEEFBE) @@ -167,11 +170,7 @@ void *SysQNode::Receive (int *pLen, bool Blocking) return nullptr; // TODO: have a shorter wait but loop, and check for system shutdown - // TODO FIXME - boost::xtime has been deprecated since boost 1.34. - boost::xtime t; - boost::xtime_get (&t, POV_TIME_UTC); - t.nsec += 50000000 ; - m_Event.timed_wait (lock, t); + m_Event.wait_for (lock, std::chrono::milliseconds(50)); if (m_Count == 0) return nullptr; diff --git a/vfe/vfeprecomp.h b/vfe/vfeprecomp.h index 6aa72d4eb..d1f61db2e 100644 --- a/vfe/vfeprecomp.h +++ b/vfe/vfeprecomp.h @@ -1,79 +1,74 @@ -//****************************************************************************** -/// -/// @file vfe/vfeprecomp.h -/// -/// Precompiled header for the user interface portions of POV-Ray. -/// -/// @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 -/// -//****************************************************************************** - -/// @file -/// @note -/// @parblock -/// This header file is _not_ explicitly included in any source file (except @ref vfe/vfeprecomp.cpp -/// which is designed to allow for precompiling this header in the first place). To use -/// precompiled headers, you will therefore have to make your build environment automatically -/// inject this header at the start of every source file. -/// -/// The rationale behind this is to keep the set of headers included in each source file at an -/// absolute minimum when precompiled headers are _not_ used. -/// @endparblock - -#include "base/configbase.h" // only pulled in for POV_MULTITHREADED - -// C++ variants of C standard header files -#include -#include -#include -#include -#include -#include -#include -#include - -// C++ standard header files -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Boost header files -#include -#include -#include -#if POV_MULTITHREADED -#include -#endif \ No newline at end of file +//****************************************************************************** +/// +/// @file vfe/vfeprecomp.h +/// +/// Precompiled header for the user interface portions of POV-Ray. +/// +/// @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 +/// +//****************************************************************************** + +/// @file +/// @note +/// @parblock +/// This header file is _not_ explicitly included in any source file (except @ref vfe/vfeprecomp.cpp +/// which is designed to allow for precompiling this header in the first place). To use +/// precompiled headers, you will therefore have to make your build environment automatically +/// inject this header at the start of every source file. +/// +/// The rationale behind this is to keep the set of headers included in each source file at an +/// absolute minimum when precompiled headers are _not_ used. +/// @endparblock + +#include "base/configbase.h" // only pulled in for POV_MULTITHREADED + +// C++ variants of C standard header files +#include +#include +#include +#include +#include +#include +#include +#include + +// C++ standard header files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Boost header files +#include diff --git a/vfe/vfesession.cpp b/vfe/vfesession.cpp index e857812dd..8d8ccb72f 100644 --- a/vfe/vfesession.cpp +++ b/vfe/vfesession.cpp @@ -41,6 +41,11 @@ #endif #include "vfe.h" + +#include + +#include + #include "backend/povray.h" static POVMSContext POVMS_Output_Context = nullptr; @@ -165,7 +170,7 @@ void vfeSession::SetSucceeded (bool ok) // Clears all messages from the status message queue. void vfeSession::ClearStatusMessages() { - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); while (m_StatusQueue.empty() == false) m_StatusQueue.pop(); @@ -199,7 +204,7 @@ void vfeSession::AppendStreamMessage (MessageType type, const char *message, boo const char *begin = message ; const char *end = begin + strlen (message) - 1; - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); for (const char *s = begin ; s <= end ; s++) { @@ -226,7 +231,7 @@ void vfeSession::AppendStreamMessage (MessageType type, const boost::format& fmt void vfeSession::AppendErrorMessage (const string& Msg) { - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); bool possibleError = Msg.find("Possible ") == 0 ; // for the purpose of setting m_HadErrorMessage, we don't consider a @@ -242,7 +247,7 @@ void vfeSession::AppendErrorMessage (const string& Msg) void vfeSession::AppendErrorMessage (const string& Msg, const UCS2String& File, int Line, int Col) { - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); bool possibleError = Msg.find("Possible ") == 0 ; // for the purpose of setting m_HadErrorMessage, we don't consider a @@ -258,7 +263,7 @@ void vfeSession::AppendErrorMessage (const string& Msg, const UCS2String& File, void vfeSession::AppendWarningMessage (const string& Msg) { - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); m_MessageQueue.push (GenericMessage (*this, mWarning, Msg)); if (m_MaxGenericMessages != -1) @@ -269,7 +274,7 @@ void vfeSession::AppendWarningMessage (const string& Msg) void vfeSession::AppendWarningMessage (const string& Msg, const UCS2String& File, int Line, int Col) { - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); m_MessageQueue.push (GenericMessage (*this, mWarning, Msg, File, Line, Col)); if (m_MaxGenericMessages != -1) @@ -280,7 +285,7 @@ void vfeSession::AppendWarningMessage (const string& Msg, const UCS2String& File void vfeSession::AppendStatusMessage (const string& Msg, int RecommendedPause) { - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); m_StatusQueue.push (StatusMessage (*this, Msg, RecommendedPause)); m_StatusLineMessage = Msg; @@ -292,7 +297,7 @@ void vfeSession::AppendStatusMessage (const string& Msg, int RecommendedPause) void vfeSession::AppendStatusMessage (const boost::format& fmt, int RecommendedPause) { - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); m_StatusQueue.push (StatusMessage (*this, fmt.str(), RecommendedPause)); m_StatusLineMessage = fmt.str(); @@ -304,7 +309,7 @@ void vfeSession::AppendStatusMessage (const boost::format& fmt, int RecommendedP void vfeSession::AppendAnimationStatus (int FrameId, int SubsetFrame, int SubsetTotal, const UCS2String& Filename) { - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); m_CurrentFrameId = FrameId; m_CurrentFrame = SubsetFrame; @@ -339,7 +344,7 @@ bool vfeSession::GetNextCombinedMessage (MessageType &Type, string& Message) POV_LONG mqTime = 0x7fffffffffffffffLL ; POV_LONG sqTime = 0x7fffffffffffffffLL ; POV_LONG cqTime = 0x7fffffffffffffffLL ; - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); if (m_MessageQueue.empty() && m_StatusQueue.empty() && m_ConsoleQueue.empty()) return (false); @@ -385,7 +390,7 @@ bool vfeSession::GetNextNonStatusMessage (MessageType &Type, string& Message, UC { POV_LONG mqTime = 0x7fffffffffffffffLL ; POV_LONG cqTime = 0x7fffffffffffffffLL ; - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); if (m_MessageQueue.empty() && m_ConsoleQueue.empty()) return (false); @@ -455,7 +460,7 @@ bool vfeSession::GetNextNonStatusMessage (MessageType &Type, string& Message) // as a parameter, then returns true. bool vfeSession::GetNextStatusMessage (StatusMessage& Message) { - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); if (m_StatusQueue.empty()) return (false); @@ -470,7 +475,7 @@ bool vfeSession::GetNextStatusMessage (StatusMessage& Message) // parameter, then returns true. bool vfeSession::GetNextGenericMessage (GenericMessage& Message) { - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); if (m_MessageQueue.empty()) return (false); @@ -485,7 +490,7 @@ bool vfeSession::GetNextGenericMessage (GenericMessage& Message) // then returns true. bool vfeSession::GetNextConsoleMessage (MessageBase& Message) { - boost::mutex::scoped_lock lock(m_MessageMutex); + std::lock_guard lock(m_MessageMutex); if (m_ConsoleQueue.empty()) return (false); @@ -653,7 +658,7 @@ void vfeSession::WorkerThread() } m_RequestEvent.notify_all (); } - boost::thread::yield(); + std::this_thread::yield(); } catch (pov_base::Exception& e) { @@ -903,7 +908,7 @@ const char *vfeSession::GetErrorString(int code) const // provided for VFE does this). vfeStatusFlags vfeSession::GetStatus(bool Clear, int WaitTime) { - boost::mutex::scoped_lock lock (m_SessionMutex); + std::unique_lock lock (m_SessionMutex); if ((m_StatusFlags & m_EventMask) != 0) { @@ -916,12 +921,7 @@ vfeStatusFlags vfeSession::GetStatus(bool Clear, int WaitTime) if (WaitTime > 0) { - // TODO FIXME - boost::xtime has been deprecated since boost 1.34. - boost::xtime t; - boost::xtime_get (&t, POV_TIME_UTC); - t.sec += WaitTime / 1000 ; - t.nsec += (WaitTime % 1000) * 1000000 ; - m_SessionEvent.timed_wait (lock, t); + m_SessionEvent.wait_for (lock, std::chrono::milliseconds(WaitTime)); } else if (WaitTime == -1) m_SessionEvent.wait (lock); @@ -978,18 +978,14 @@ bool vfeSession::Paused() const // vfeSession::Initialize() hasn't been called or failed when called). bool vfeSession::Pause() { - boost::mutex::scoped_lock lock (m_RequestMutex); + std::unique_lock lock (m_RequestMutex); CheckFrontend(); // we can't call pause directly since it will result in a thread context // error. pause must be called from the context of the worker thread. - // TODO FIXME - boost::xtime has been deprecated since boost 1.34. - boost::xtime t; - boost::xtime_get (&t, POV_TIME_UTC); - t.sec += 3 ; m_RequestFlag = rqPauseRequest; - if (m_RequestEvent.timed_wait(lock, t) == false) + if (m_RequestEvent.wait_for(lock, std::chrono::seconds(3)) == std::cv_status::timeout) { m_RequestFlag = rqNoRequest; m_LastError = vfeRequestTimedOut; @@ -1002,18 +998,14 @@ bool vfeSession::Pause() // The converse of vfeSession::Pause(). All the same considerations apply. bool vfeSession::Resume() { - boost::mutex::scoped_lock lock (m_RequestMutex); + std::unique_lock lock (m_RequestMutex); CheckFrontend(); // we can't call resume directly since it will result in a thread context // error. it must be called from the context of the worker thread. - // TODO FIXME - boost::xtime has been deprecated since boost 1.34. - boost::xtime t; - boost::xtime_get (&t, POV_TIME_UTC); - t.sec += 3 ; m_RequestFlag = rqResumeRequest; - if (m_RequestEvent.timed_wait(lock, t) == false) + if (m_RequestEvent.wait_for(lock, std::chrono::seconds(3)) == std::cv_status::timeout) { m_RequestFlag = rqNoRequest; m_LastError = vfeRequestTimedOut; @@ -1026,7 +1018,7 @@ bool vfeSession::Resume() // Internal method used to generate an event notification. void vfeSession::NotifyEvent(vfeStatusFlags Status) { - boost::mutex::scoped_lock lock (m_SessionMutex); + std::lock_guard lock (m_SessionMutex); m_StatusFlags = vfeStatusFlags(m_StatusFlags | Status); if ((m_StatusFlags & m_EventMask) != 0) @@ -1055,7 +1047,7 @@ void vfeSession::NotifyEvent(vfeStatusFlags Status) // connection with the backend code. int vfeSession::Initialize(vfeDestInfo *Dest, vfeAuthInfo *Auth) { - boost::mutex::scoped_lock lock (m_InitializeMutex); + std::unique_lock lock (m_InitializeMutex); // params must be `nullptr` in this version if ((Dest != nullptr) || (Auth != nullptr)) @@ -1075,18 +1067,14 @@ int vfeSession::Initialize(vfeDestInfo *Dest, vfeAuthInfo *Auth) m_MessageCount = 0; m_LastError = vfeNoError; - // TODO FIXME - boost::xtime has been deprecated since boost 1.34. - boost::xtime t; - boost::xtime_get (&t, POV_TIME_UTC); - t.sec += 3 ; + auto timeout = 3; #ifdef _DEBUG - t.sec += 120; + timeout += 120; #endif - t.nsec = 0; - m_WorkerThread = new boost::thread(vfeSessionWorker(*this)); + m_WorkerThread = new std::thread(vfeSessionWorker(*this)); // TODO FIXME: see thread <47ca756c$1@news.povray.org> - if (m_BackendState == kUnknown && m_InitializeEvent.timed_wait(lock, t) == false) + if ((m_BackendState == kUnknown) && (m_InitializeEvent.wait_for(lock, std::chrono::seconds(timeout)) == std::cv_status::timeout)) { m_WorkerThreadShutdownRequest = true ; m_Initialized = false ; diff --git a/vfe/vfesession.h b/vfe/vfesession.h index 67edc574d..f46cfb672 100644 --- a/vfe/vfesession.h +++ b/vfe/vfesession.h @@ -39,13 +39,17 @@ #ifndef POVRAY_VFE_VFESESSION_H #define POVRAY_VFE_VFESESSION_H +#include #include +#include #include +// not required for `std::thread` because we forward-declare it in `base/base_fwd.h` #include -#include -#include +#include +#include +#include "base/base_fwd.h" #include "base/stringutilities.h" #include "frontend/simplefrontend.h" @@ -1280,20 +1284,20 @@ namespace vfe VirtualFrontEnd *m_Frontend; State m_BackendState; - boost::mutex m_MessageMutex; - boost::mutex m_SessionMutex; - boost::condition m_SessionEvent; - boost::mutex m_InitializeMutex; - boost::condition m_InitializeEvent; - boost::condition m_ShutdownEvent; - boost::thread *m_WorkerThread; - boost::thread *m_BackendThread; + std::mutex m_MessageMutex; + std::mutex m_SessionMutex; + std::condition_variable m_SessionEvent; + std::mutex m_InitializeMutex; + std::condition_variable m_InitializeEvent; + std::condition_variable m_ShutdownEvent; + std::thread *m_WorkerThread; + std::thread *m_BackendThread; volatile bool m_WorkerThreadExited; volatile bool m_BackendThreadExited; volatile bool m_WorkerThreadShutdownRequest; - boost::mutex m_RequestMutex; - boost::condition m_RequestEvent; + std::mutex m_RequestMutex; + std::condition_variable m_RequestEvent; volatile int m_RequestFlag; volatile int m_RequestResult; } ; diff --git a/windows/povconfig/syspovconfig.h b/windows/povconfig/syspovconfig.h index fc8ac415a..eb2ceed09 100644 --- a/windows/povconfig/syspovconfig.h +++ b/windows/povconfig/syspovconfig.h @@ -108,16 +108,6 @@ ///////////////////////////////////////////////////////////// -#ifndef __GENDEFS - #define __GENDEFS - typedef unsigned char uchar; - typedef unsigned short ushort; - typedef unsigned int uint; - typedef unsigned long ulong; - typedef unsigned __int64 uint64; - typedef __int64 int64; -#endif - #ifdef __INTEL_COMPILER // Intel C++ whines about the lack of a return on RDTSC() for each and every file // it is included in. VC++ is smarter (or dumber, depending on your point of view). @@ -140,7 +130,8 @@ namespace povwin void win_free(void *p, const void *ptr, int line); char *win_strdup(const char *s); char *win_strdup(const char *s, const void *ptr, int line); - bool WinMemReport(bool global, uint64& allocs, uint64& frees, int64& current, uint64& peak, uint64& smallest, uint64& largest); + bool WinMemReport(bool global, unsigned __int64& allocs, unsigned __int64& frees, __int64& current, + unsigned __int64& peak, unsigned __int64& smallest, unsigned __int64& largest); void WinMemStage(bool BeginRender, void *cookie = NULL); #endif @@ -160,7 +151,6 @@ namespace povwin #endif #define ALTMAIN -#define LITTLE_ENDIAN #define POV_PATH_SEPARATOR '\\' #define POV_IS_PATH_SEPARATOR(c) (((c) == POV_PATH_SEPARATOR) || ((c) == '/')) #define POV_SLASH_IS_SWITCH_CHARACTER 1 // allow forward slash as a switch character (even despite its use as a path separator!) @@ -173,10 +163,6 @@ namespace povwin #define POV_SYS_IMAGE_EXTENSION ".bmp" #define POV_SYS_IMAGE_TYPE BMP #define POV_FILENAME_BUFFER_CHARS (_MAX_PATH-1) // (NB: _MAX_PATH includes terminating NUL character) -#define USE_OFFICIAL_BOOST 1 - -#define POV_MEMMOVE(dst,src,len) std::memmove((dst),(src),(len)) -#define POV_MEMCPY(dst,src,len) std::memcpy((dst),(src),(len)) #ifdef _CONSOLE diff --git a/windows/povconfig/syspovconfig_msvc.h b/windows/povconfig/syspovconfig_msvc.h index e7dc82676..7f3e77998 100644 --- a/windows/povconfig/syspovconfig_msvc.h +++ b/windows/povconfig/syspovconfig_msvc.h @@ -104,7 +104,6 @@ // MS Visual C++ 2005 (aka 8.0), compiling for 64 bit target #define POV_COMPILER_VER "msvc8" #define METADATA_COMPILER_STRING "msvc 8" - #define ALIGN16 __declspec(align(16)) inline const int& max(const int& _X, const int& _Y) {return (_X < _Y ? _Y : _X); } inline const int& min(const int& _X, const int& _Y) {return (_Y < _X ? _Y : _X); } inline const unsigned int& max(const unsigned int& _X, const unsigned int& _Y) {return (_X < _Y ? _Y : _X); } @@ -226,7 +225,6 @@ #undef ReturnAddress #define ReturnAddress() _ReturnAddress() -#define ALIGN32 __declspec(align(32)) #define MACHINE_INTRINSICS_H #if _MSC_VER >= 1600 diff --git a/windows/povconfig/syspovconfigbase.h b/windows/povconfig/syspovconfigbase.h index b2f90dabe..e6646b8ec 100644 --- a/windows/povconfig/syspovconfigbase.h +++ b/windows/povconfig/syspovconfigbase.h @@ -49,7 +49,8 @@ #endif // Windows provides a platform-specific mechanism to let a task wait for a specified time. -#define POV_USE_DEFAULT_DELAY 0 +// However, the C++11 standard mechanism should be fine. +#define POV_USE_PLATFORM_DELAY 0 // Windows provides platform-specific mechanisms to measure both wall-clock and CPU time. #define POV_USE_DEFAULT_TIMER 0 diff --git a/windows/pvdisplay.cpp b/windows/pvdisplay.cpp index 3c58f7598..10a0ff024 100644 --- a/windows/pvdisplay.cpp +++ b/windows/pvdisplay.cpp @@ -369,10 +369,11 @@ inline void WinLegacyDisplay::SetPixel (unsigned int x, unsigned int y, const po unsigned char *p = m_BitmapSurface + (m_Bitmap.header.biHeight - 1 - y) * m_BytesPerLine + x * 3 ; if (pov_frontend::UseAlpha && colour->alpha < 255) { - uint backColor = (x & 8) == (y & 8) ? (uint) (255 - colour->alpha) * 0xff : (uint) (255 - colour->alpha) * 0xc0 ; - *p++ = (unsigned char) (((uint) colour->blue * colour->alpha + backColor) / 255) ; - *p++ = (unsigned char) (((uint) colour->green * colour->alpha + backColor) / 255) ; - *p++ = (unsigned char) (((uint) colour->red * colour->alpha + backColor) / 255) ; + unsigned int backColor = (x & 8) == (y & 8) ? (unsigned int) (255 - colour->alpha) * 0xff : + (unsigned int) (255 - colour->alpha) * 0xc0 ; + *p++ = (unsigned char) (((unsigned int) colour->blue * colour->alpha + backColor) / 255) ; + *p++ = (unsigned char) (((unsigned int) colour->green * colour->alpha + backColor) / 255) ; + *p++ = (unsigned char) (((unsigned int) colour->red * colour->alpha + backColor) / 255) ; } else { diff --git a/windows/pvengine.cpp b/windows/pvengine.cpp index ad589877a..2aa31190c 100644 --- a/windows/pvengine.cpp +++ b/windows/pvengine.cpp @@ -80,6 +80,7 @@ #include #include +#include #include "pvengine.h" #include "resource.h" @@ -567,7 +568,7 @@ void WIN32_DEBUG_FILE_OUTPUT (const char *format,...) { va_list arg_ptr ; static FILE *f ; - static boost::mutex mtx; + static std::mutex mtx; if (format == NULL) { @@ -586,7 +587,7 @@ void WIN32_DEBUG_FILE_OUTPUT (const char *format,...) return ; } - boost::mutex::scoped_lock l(mtx); + std::lock_guard l(mtx); fprintf (f, "%u [%d]: ", GetTickCount (), GetCurrentThreadId ()) ; va_start (arg_ptr, format) ; vfprintf (f, format, arg_ptr) ; @@ -1713,8 +1714,8 @@ LONG WINAPI ExceptionHandler(struct _EXCEPTION_POINTERS* ExceptionInfo) long timestamp = _time32(NULL); PCONTEXT c ; static char str[2048] ; - static boost::mutex mtx; - boost::mutex::scoped_lock l(mtx); + static std::mutex mtx; + std::lock_guard l(mtx); c = ExceptionInfo->ContextRecord ; const char *desc = GetExceptionDescription(ExceptionInfo->ExceptionRecord->ExceptionCode); @@ -5067,11 +5068,11 @@ void LZTimerOff (void) PerformanceCounter2 = 0 ; } -ulong LZTimerCount (void) +unsigned long LZTimerCount (void) { if (PerformanceCounter1 == 0 || PerformanceCounter2 < PerformanceCounter1) return (0) ; - return ((ulong) ((PerformanceCounter2 - PerformanceCounter1) / PerformanceScale)) ; + return ((unsigned long) ((PerformanceCounter2 - PerformanceCounter1) / PerformanceScale)) ; } __int64 LZTimerRawCount (void) diff --git a/windows/pvengine.h b/windows/pvengine.h index b68c21985..1d2db7272 100644 --- a/windows/pvengine.h +++ b/windows/pvengine.h @@ -72,23 +72,16 @@ #define MAX_MESSAGE 1024 #define MAX_ARGV 256 -#define TOOLFILENAME "PVTOOLS.INI" #define MAX_TOOLCMD 32 #define MAX_TOOLCMDTEXT 128 #define MAX_TOOLHELPTEXT 128 -#define MIN_EDITOR_VERSION 100 -#define MAX_EDITOR_VERSION 199 #define MAX_WINDOWS 16 #define MAX_EDIT_FILES 32 #define POV_INTERNAL_STREAM ((FILE *) 1L) -#define LEGACY_OPTION_FILE_SUPPORT - #define EDIT_FILE 1 #define RENDER_FILE 2 -#define CRASH_REPORTER_EXECUTABLE "SubmitMinidump.exe" - #if POV_RAY_IS_OFFICIAL #ifdef _WIN64 #define CLASSNAMEPREFIX "Pov" POV_RAY_MAJOR_VERSION POV_RAY_MINOR_VERSION "-Win64-" @@ -114,14 +107,12 @@ #endif #ifdef _WIN64 - #define BINDIRNAME "bin64" #define INSTALLTIMEKEY "InstallTime64" // NB: We're using the standard editor DLLs regardless of architecture optimization (e.g. AVX) #define EDITDLLNAME "cmedit64.dll" #define EDITDLLNAME_DEBUG "cmedit64d.dll" #define VERSIONVAL POVWIN_BETA_PREFIX "VersionNo64" #else - #define BINDIRNAME "bin32" #define INSTALLTIMEKEY "InstallTime32" // TODO - use the standard editor DLLs regardless of architecture optimization (e.g. SSE2) #ifdef BUILD_SSE2 @@ -137,32 +128,11 @@ // message definitions used to be here but have been moved to pvedit.h. // ---------------------------------------------------------------------- -#define NUM_BUTTONS 16 #define HDIB HANDLE #define SEPARATOR '\\' #define DRAWFASTRECT(hdc,lprc) ExtTextOut(hdc,0,0,ETO_OPAQUE,lprc,NULL,0,NULL) -#define RGBBLACK RGB(0,0,0) -#define RGBRED RGB(128,0,0) -#define RGBGREEN RGB(0,128,0) -#define RGBBLUE RGB(0,0,128) - -#define RGBBROWN RGB(128,128,0) -#define RGBMAGENTA RGB(128,0,128) -#define RGBCYAN RGB(0,128,128) -#define RGBLTGRAY RGB(192,192,192) - -#define RGBGRAY RGB(128,128,128) -#define RGBLTRED RGB(255,0,0) -#define RGBLTGREEN RGB(0,255,0) -#define RGBLTBLUE RGB(0,0,255) - -#define RGBYELLOW RGB(255,255,0) -#define RGBLTMAGENTA RGB(255,0,255) -#define RGBLTCYAN RGB(0,255,255) -#define RGBWHITE RGB(255,255,255) - namespace povwin { @@ -227,48 +197,6 @@ typedef struct PALETTEENTRY pe [256] ; } LogPal ; -typedef struct -{ - bool ncEnabled ; - bool menuWasUp ; - bool hasCaption ; - bool hasBorder ; - bool hasSizeableBorder ; - bool hasStatusBar ; - bool hasMenuBar ; - bool sysMenuOverride ; - bool isMaxiMinimized ; - HWND hWnd ; - HFONT hMenuBarFont ; - HFONT hStatusBarFont ; - HFONT hSystemFont ; - ushort captionTotal ; - ushort captionInternal ; - ushort captionBorderLeft ; - ushort captionBorderRight ; - ushort captionBorderTop ; - ushort captionBorderBottom ; - ushort borderWidth ; - ushort borderHeight ; - ushort buttonWidth ; - ushort buttonHeight ; - ushort sizing ; - ushort statusBarTotal ; - ushort statusBarBorder ; - ushort menuBarTotal ; - ushort menuBarBorder ; -} pvncStruct ; - -class AutoLock final -{ -public: - inline AutoLock (CRITICAL_SECTION& CriticalSection) { m_CriticalSection = &CriticalSection ; EnterCriticalSection (m_CriticalSection) ; } - inline ~AutoLock() { LeaveCriticalSection (m_CriticalSection) ; } - -private: - LPCRITICAL_SECTION m_CriticalSection ; -}; - inline int MulDivNoRound (int value, int mul_by, int div_by) { return ((int) ((__int64) value * mul_by / div_by)) ; @@ -297,7 +225,6 @@ void message_printf (const char *format, ...) ; void wrapped_printf (const char *format, ...) ; void dump_pane_to_clipboard (void) ; bool copy_text_to_clipboard(const char *text); -bool PutPrivateProfileInt (LPCSTR lpszSection, LPCSTR lpszEntry, UINT uiValue, LPCSTR lpszFilename) ; void get_logfont (HDC hdc, LOGFONT *lf) ; int create_message_font (HDC hdc, LOGFONT *lf) ; void status_printf (int nSection, const char *format, ...) ; @@ -309,10 +236,8 @@ bool hasTrailingPathSeparator (const char *s) ; void trimTrailingPathSeparator (char *s) ; void validatePath (char *s) ; int joinPath (char *out, const char *path, const char *name) ; -void UpdateTabbedWindow (int current, bool force) ; void CalculateClientWindows (bool redraw) ; bool start_rendering (bool ignore_source_file) ; -bool HaveWin95 (void) ; void render_stopped (void) ; void cancel_render (void) ; void SetStatusPanelItemText (int id, LPCSTR format, ...) ; @@ -332,7 +257,6 @@ void cloneOldIni(const std::string& oldPath, const std::string& newPath); void update_menu_for_render (bool rendering) ; void update_queue_status (bool write_files) ; void draw_ordinary_listbox (DRAWITEMSTRUCT *d, bool fitpath) ; -void fill_statistics_listbox (HWND hlb, int id) ; void resize_listbox_dialog (HWND hDlg, int idLb, int chars) ; void CenterWindowRelative (HWND hRelativeTo, HWND hTarget, bool bRepaint, bool checkBorders) ; void FitWindowInWindow (HWND hRelativeTo, HWND hTarget) ; @@ -343,20 +267,14 @@ void set_toggles (void) ; void load_tool_menu (char *iniFilename) ; char *parse_tool_command (char *command) ; char *get_elapsed_time (int seconds) ; -void initialise_statusbar (bool isMaxiMiniMode) ; -void calculate_statusbar (void) ; -void paint_statusbar (int nSection) ; void extract_ini_sections (char *filename, HWND hwnd) ; void extract_ini_sections_ex (char *filename, HWND hwnd) ; int select_combo_item_ex (HWND hwnd, char *s) ; -void paint_rendering_signal (int which_one) ; char *get_full_name (char *s) ; bool PovInvalidateRect (HWND hWnd, CONST RECT *lpRect, bool bErase) ; -int load_editors (char *iniFilename) ; bool TaskBarAddIcon (HWND hwnd, UINT uID, HICON hicon, LPSTR lpszTip) ; bool TaskBarModifyIcon (HWND hwnd, UINT uID, LPSTR lpszTip) ; bool TaskBarDeleteIcon (HWND hwnd, UINT uID) ; -bool TestAccessAllowed (const char *Filename, unsigned int FileType, bool IsWrite) ; char *clean (char *s) ; bool fileExists (const char *filename) ; bool dirExists (const char *filename) ; @@ -368,8 +286,6 @@ bool PutHKCU(const char *Section, const char *Name, const std::string& Value); bool PutHKCU(const char *Section, const char *Name, unsigned Value); unsigned GetHKCU(const char *Section, const char *Name, unsigned DefaultValue); size_t GetHKCU(const char *Section, const char *Name, const char *DefaultValue, char *Buffer, unsigned MaxLength); -bool read_legacy_INI_settings (const char *iniFilename, const char *oldHome, const char *newHome); -void clone_legacy_dir_restrictions (const char *iniFilename, const char *oldHome, const char *newHome); // file PVFILES.C @@ -390,23 +306,17 @@ void clear_menu (HMENU hMenu) ; void build_main_menu (HMENU hMenu, bool have_editor) ; void build_editor_menu (HMENU hMenu) ; void set_newuser_menus (bool hide) ; -void swap_renderwin_menu (void) ; int find_menuitem (HMENU hMenu, LPCSTR title) ; // file PVTEXT.C void write_wrapped_text (HDC hdc, RECT *rect, const char *text) ; void tip_of_the_day (HDC hdc, RECT *rect, char *text) ; -void paint_statusbar (int nSection) ; void say_status_message (int section, const char *message) ; void handle_menu_select (WPARAM wParam, LPARAM lParam) ; char *clean_str (const char *s) ; HWND create_toolbar (HWND hwndParent) ; -HWND create_tabbed_window (HWND hwndParent) ; -void initialise_tabbed_window (HWND hwnd) ; -unsigned add_window_to_tab (HWND hwnd, void *editor, char *s) ; void resize_windows (unsigned left, unsigned top, unsigned width, unsigned height) ; -unsigned get_tab_index (HWND hwnd, void *editor) ; char *preparse_commandline (char *s) ; char *preparse_instance_commandline (char *s) ; void add_edit_file (char *file); @@ -417,11 +327,6 @@ HWND CreateStatusbar (HWND hwndParent) ; void ResizeStatusBar (HWND hwnd) ; bool HandleStatusTooltip(NMHDR *nmh); -// file PVPOVMS.CPP - -bool WIN_POVMS_Init (void) ; -void WIN_POVMS_Shutdown (void) ; - // file PVBITMAP.CPP HDIB FAR BitmapToDIB (HBITMAP hBitmap, HPALETTE hPal); @@ -438,7 +343,6 @@ HDIB FAR CopyWindowToDIB (HWND, WORD); HPALETTE FAR CreateDIBPalette (HDIB hDIB); HDIB FAR CreateDIB(DWORD, DWORD, WORD); WORD FAR DestroyDIB (HDIB); -void FAR DIBError (int ErrNo); DWORD FAR DIBHeight (LPSTR lpDIB); WORD FAR DIBNumColors (LPSTR lpDIB); HBITMAP FAR DIBToBitmap (HDIB hDIB, HPALETTE hPal); @@ -540,7 +444,7 @@ RGBQUAD halftonePal [256] = // Division lookup tables. These tables compute 0-255 divided by 51 and // modulo 51. These tables could approximate gamma correction. -uchar div51 [256] = +unsigned char div51 [256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -555,7 +459,7 @@ uchar div51 [256] = 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5 } ; -uchar mod51 [256] = +unsigned char mod51 [256] = { 0, 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, @@ -575,12 +479,12 @@ uchar mod51 [256] = // Multiplication lookup tables. These compute 0-5 times 6 and 36. -uchar mul6 [6] = {0, 6, 12, 18, 24, 30} ; -uchar mul36 [6] = {0, 36, 72, 108, 144, 180} ; +unsigned char mul6 [6] = {0, 6, 12, 18, 24, 30} ; +unsigned char mul36 [6] = {0, 36, 72, 108, 144, 180} ; // Ordered 8x8 dither matrix for 8 bit to 2.6 bit halftones. -uchar dither8x8 [64] = +unsigned char dither8x8 [64] = { 0, 38, 9, 47, 2, 40, 11, 50, 25, 12, 35, 22, 27, 15, 37, 24, diff --git a/windows/pvmem.cpp b/windows/pvmem.cpp index baed99699..05827ca80 100644 --- a/windows/pvmem.cpp +++ b/windows/pvmem.cpp @@ -153,7 +153,8 @@ void WinMemStage(bool BeginRender, void *cookie) TrackMem = false; } -bool WinMemReport(bool global, uint64& allocs, uint64& frees, int64& current, uint64& peak, uint64 &smallest, uint64 &largest) +bool WinMemReport(bool global, unsigned __int64& allocs, unsigned __int64& frees, __int64& current, + unsigned __int64& peak, unsigned __int64& smallest, unsigned __int64& largest) { if (!global) return false; @@ -200,7 +201,8 @@ void WinMemThreadCleanup() delete lMemStats; } -bool WinMemReport(bool global, uint64& allocs, uint64& frees, int64& current, uint64& peak, uint64 &smallest, uint64 &largest) +bool WinMemReport(bool global, unsigned __int64& allocs, unsigned __int64& frees, __int64& current, + unsigned __int64& peak, unsigned __int64 &smallest, unsigned __int64 &largest) { HeapLock lock(gHeap); diff --git a/windows/pvmem.h b/windows/pvmem.h index 90dab19e1..82bc01dec 100644 --- a/windows/pvmem.h +++ b/windows/pvmem.h @@ -82,7 +82,8 @@ class WinMemStats final { } - void Report(uint64& allocs, uint64& frees, int64& current, uint64& peak, uint64 &smallest, uint64 &largest) + void Report(unsigned __int64& allocs, unsigned __int64& frees, __int64& current, + unsigned __int64& peak, unsigned __int64& smallest, unsigned __int64& largest) { allocs = callsToAlloc; frees = callsToFree; @@ -130,12 +131,12 @@ class WinMemStats final } private: - volatile int64 currentAllocated; - volatile uint64 peakAllocated; - volatile uint64 callsToAlloc; - volatile uint64 callsToFree; - volatile uint64 smallestAlloc; - volatile uint64 largestAlloc; + volatile __int64 currentAllocated; + volatile unsigned __int64 peakAllocated; + volatile unsigned __int64 callsToAlloc; + volatile unsigned __int64 callsToFree; + volatile unsigned __int64 smallestAlloc; + volatile unsigned __int64 largestAlloc; }; typedef WinMemStats PovMemStats; diff --git a/windows/pvtext.cpp b/windows/pvtext.cpp index e6d973885..50e68d77c 100644 --- a/windows/pvtext.cpp +++ b/windows/pvtext.cpp @@ -358,7 +358,7 @@ void buffer_message (msgtype message_type, const char *s, bool addLF) message_type = mHorzLine ; strcpy (s1 + 1, str_buffer) ; - *s1 = (uchar) message_type ; + *s1 = (unsigned char) message_type ; if (lf == CR) { @@ -432,7 +432,7 @@ void add_single_line (msgtype message_type, const char *str) } strcpy (s1 + 1, str) ; - *s1 = (uchar) message_type ; + *s1 = (unsigned char) message_type ; if (*next_message) { diff --git a/windows/vs2015/console.vcxproj b/windows/vs2015/console.vcxproj index 40687cf30..bfb56ab19 100644 --- a/windows/vs2015/console.vcxproj +++ b/windows/vs2015/console.vcxproj @@ -353,9 +353,6 @@ - - {d870a978-8130-4d1d-9fb2-3ee2028d2c50} - {39c65232-04fb-4622-8283-34829739887c} false @@ -369,12 +366,6 @@ {7df42126-d237-41d3-9abe-a3acc8bac56e} - - {35a2dc31-84bc-4f7a-9c93-1d072432ad79} - - - {10b193d4-e27b-4438-a825-bfb3d2b4c74d} - {9edb5c0f-bfd0-4a59-bb93-f06a52bb0128} diff --git a/windows/vs2015/povcore.vcxproj b/windows/vs2015/povcore.vcxproj index 56aaed906..9de155e14 100644 --- a/windows/vs2015/povcore.vcxproj +++ b/windows/vs2015/povcore.vcxproj @@ -464,6 +464,7 @@ + @@ -514,8 +515,10 @@ + + @@ -525,6 +528,7 @@ + @@ -553,6 +557,8 @@ + + @@ -560,6 +566,7 @@ + diff --git a/windows/vs2015/povcore.vcxproj.filters b/windows/vs2015/povcore.vcxproj.filters index 3e9736386..1f88c3857 100644 --- a/windows/vs2015/povcore.vcxproj.filters +++ b/windows/vs2015/povcore.vcxproj.filters @@ -275,6 +275,9 @@ Core Source\Math + + Core Source\Support + @@ -526,5 +529,23 @@ Core Headers\Support + + Core Headers\Scene + + + Core Headers\Support + + + Core Headers\Math + + + Core Headers\Math + + + Core Headers\Support + + + Core Headers\Support + \ No newline at end of file diff --git a/windows/vs2015/povray.sln b/windows/vs2015/povray.sln index d5f4371d4..9b3ecf49a 100644 --- a/windows/vs2015/povray.sln +++ b/windows/vs2015/povray.sln @@ -227,18 +227,12 @@ Global {C6D9B754-11EB-4FC3-8683-593BFD58C904}.Release-SSE2|Win32.Build.0 = Release-SSE2|Win32 {C6D9B754-11EB-4FC3-8683-593BFD58C904}.Release-SSE2|x64.ActiveCfg = Release|x64 {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Debug|Win32.ActiveCfg = Debug|Win32 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Debug|Win32.Build.0 = Debug|Win32 {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Debug|x64.ActiveCfg = Debug|x64 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Debug|x64.Build.0 = Debug|x64 {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release|Win32.ActiveCfg = Release|Win32 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release|Win32.Build.0 = Release|Win32 {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release|x64.ActiveCfg = Release|x64 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release|x64.Build.0 = Release|x64 {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release-AVX|Win32.ActiveCfg = Release|Win32 {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release-AVX|x64.ActiveCfg = Release-AVX|x64 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release-AVX|x64.Build.0 = Release-AVX|x64 {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release-SSE2|Win32.ActiveCfg = Release-SSE2|Win32 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release-SSE2|Win32.Build.0 = Release-SSE2|Win32 {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release-SSE2|x64.ActiveCfg = Release|x64 {35A2DC31-84BC-4F7A-9C93-1D072432AD79}.Debug|Win32.ActiveCfg = Debug|Win32 {35A2DC31-84BC-4F7A-9C93-1D072432AD79}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/windows/vs2015/povray.vcxproj b/windows/vs2015/povray.vcxproj index 80e1a0ea5..12f1769d3 100644 --- a/windows/vs2015/povray.vcxproj +++ b/windows/vs2015/povray.vcxproj @@ -587,9 +587,6 @@ - - {d870a978-8130-4d1d-9fb2-3ee2028d2c50} - {39c65232-04fb-4622-8283-34829739887c} false @@ -603,9 +600,6 @@ {7df42126-d237-41d3-9abe-a3acc8bac56e} - - {10b193d4-e27b-4438-a825-bfb3d2b4c74d} - {9edb5c0f-bfd0-4a59-bb93-f06a52bb0128} diff --git a/windows/winprecomp.h b/windows/winprecomp.h index 81224aa06..48b0537f7 100644 --- a/windows/winprecomp.h +++ b/windows/winprecomp.h @@ -58,7 +58,6 @@ #include // C++ standard header files -#include #include #include #include @@ -67,6 +66,7 @@ #include #include #include +#include #include #include @@ -87,13 +87,4 @@ #include // Boost header files -#include #include -#include -#include -#if POV_MULTITHREADED -#include -#include -#endif -#include - From 2d35fd4b36ad19e3c17273101f8f71a2ce7924aa Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Mon, 18 Feb 2019 23:43:42 +0100 Subject: [PATCH 11/13] Drop now-unused boost_thread and boost_system libraries from our repo and Windows solution. --- libraries/boost/boost/system/api_config.hpp | 42 - libraries/boost/boost/system/config.hpp | 70 - libraries/boost/boost/system/cygwin_error.hpp | 56 - .../boost/boost/system/detail/error_code.ipp | 467 -- .../detail/local_free_on_destruction.hpp | 40 - libraries/boost/boost/system/error_code.hpp | 520 -- libraries/boost/boost/system/linux_error.hpp | 110 - libraries/boost/boost/system/system_error.hpp | 84 - .../boost/boost/system/windows_error.hpp | 126 - libraries/boost/boost/thread/barrier.hpp | 255 - .../boost/boost/thread/caller_context.hpp | 59 - .../boost/boost/thread/completion_latch.hpp | 225 - .../concurrent_queues/deque_adaptor.hpp | 209 - .../thread/concurrent_queues/deque_base.hpp | 202 - .../thread/concurrent_queues/deque_views.hpp | 165 - .../detail/sync_deque_base.hpp | 223 - .../detail/sync_queue_base.hpp | 223 - .../concurrent_queues/queue_adaptor.hpp | 209 - .../thread/concurrent_queues/queue_base.hpp | 202 - .../concurrent_queues/queue_op_status.hpp | 46 - .../thread/concurrent_queues/queue_views.hpp | 144 - .../concurrent_queues/sync_bounded_queue.hpp | 725 --- .../thread/concurrent_queues/sync_deque.hpp | 327 - .../concurrent_queues/sync_priority_queue.hpp | 369 -- .../thread/concurrent_queues/sync_queue.hpp | 335 - .../concurrent_queues/sync_timed_queue.hpp | 468 -- libraries/boost/boost/thread/condition.hpp | 21 - .../boost/boost/thread/condition_variable.hpp | 21 - libraries/boost/boost/thread/csbl/deque.hpp | 45 - .../boost/boost/thread/csbl/devector.hpp | 102 - .../boost/boost/thread/csbl/functional.hpp | 49 - libraries/boost/boost/thread/csbl/list.hpp | 35 - libraries/boost/boost/thread/csbl/memory.hpp | 61 - .../thread/csbl/memory/allocator_arg.hpp | 41 - .../thread/csbl/memory/allocator_traits.hpp | 35 - .../boost/boost/thread/csbl/memory/config.hpp | 16 - .../thread/csbl/memory/default_delete.hpp | 41 - .../thread/csbl/memory/pointer_traits.hpp | 35 - .../thread/csbl/memory/scoped_allocator.hpp | 35 - .../boost/thread/csbl/memory/shared_ptr.hpp | 42 - .../boost/thread/csbl/memory/unique_ptr.hpp | 28 - libraries/boost/boost/thread/csbl/queue.hpp | 45 - libraries/boost/boost/thread/csbl/tuple.hpp | 49 - libraries/boost/boost/thread/csbl/vector.hpp | 35 - libraries/boost/boost/thread/cv_status.hpp | 26 - .../boost/boost/thread/detail/config.hpp | 472 -- .../boost/boost/thread/detail/counter.hpp | 106 - .../boost/boost/thread/detail/delete.hpp | 58 - .../boost/boost/thread/detail/force_cast.hpp | 39 - .../boost/thread/detail/function_wrapper.hpp | 93 - .../boost/boost/thread/detail/invoke.hpp | 1604 ----- .../boost/boost/thread/detail/invoker.hpp | 762 --- .../boost/thread/detail/is_convertible.hpp | 49 - .../boost/thread/detail/lockable_wrapper.hpp | 45 - libraries/boost/boost/thread/detail/log.hpp | 83 - .../thread/detail/make_tuple_indices.hpp | 224 - .../boost/boost/thread/detail/memory.hpp | 48 - libraries/boost/boost/thread/detail/move.hpp | 374 -- .../boost/thread/detail/nullary_function.hpp | 234 - .../boost/boost/thread/detail/platform.hpp | 73 - .../boost/boost/thread/detail/singleton.hpp | 59 - .../boost/boost/thread/detail/thread.hpp | 873 --- .../boost/thread/detail/thread_group.hpp | 155 - .../boost/thread/detail/thread_heap_alloc.hpp | 23 - .../thread/detail/thread_interruption.hpp | 39 - .../boost/boost/thread/detail/tss_hooks.hpp | 65 - .../boost/thread/detail/variadic_footer.hpp | 10 - .../boost/thread/detail/variadic_header.hpp | 19 - .../boost/boost/thread/exceptional_ptr.hpp | 44 - libraries/boost/boost/thread/exceptions.hpp | 225 - libraries/boost/boost/thread/executor.hpp | 15 - .../thread/executors/basic_thread_pool.hpp | 318 - .../detail/priority_executor_base.hpp | 77 - .../detail/scheduled_executor_base.hpp | 66 - .../boost/boost/thread/executors/executor.hpp | 148 - .../thread/executors/executor_adaptor.hpp | 136 - .../thread/executors/generic_executor_ref.hpp | 213 - .../thread/executors/inline_executor.hpp | 171 - .../boost/thread/executors/loop_executor.hpp | 205 - .../executors/scheduled_thread_pool.hpp | 48 - .../boost/thread/executors/scheduler.hpp | 271 - .../thread/executors/scheduling_adaptor.hpp | 51 - .../thread/executors/serial_executor.hpp | 216 - .../thread/executors/serial_executor_cont.hpp | 170 - .../thread/executors/thread_executor.hpp | 157 - .../boost/boost/thread/executors/work.hpp | 30 - .../experimental/config/inline_namespace.hpp | 23 - .../thread/experimental/exception_list.hpp | 16 - .../parallel/v1/exception_list.hpp | 70 - .../parallel/v1/inline_namespace.hpp | 28 - .../parallel/v2/inline_namespace.hpp | 29 - .../experimental/parallel/v2/task_region.hpp | 316 - .../boost/thread/experimental/task_region.hpp | 16 - .../boost/boost/thread/externally_locked.hpp | 351 - .../boost/thread/externally_locked_stream.hpp | 170 - libraries/boost/boost/thread/future.hpp | 5660 ----------------- .../boost/thread/futures/future_error.hpp | 98 - .../thread/futures/future_error_code.hpp | 61 - .../boost/thread/futures/future_status.hpp | 30 - .../boost/thread/futures/is_future_type.hpp | 21 - .../boost/boost/thread/futures/launch.hpp | 32 - .../boost/thread/futures/wait_for_all.hpp | 74 - .../boost/thread/futures/wait_for_any.hpp | 161 - .../boost/thread/is_locked_by_this_thread.hpp | 39 - libraries/boost/boost/thread/latch.hpp | 170 - .../boost/boost/thread/lock_algorithms.hpp | 468 -- .../boost/boost/thread/lock_concepts.hpp | 197 - .../boost/boost/thread/lock_factories.hpp | 78 - libraries/boost/boost/thread/lock_guard.hpp | 88 - libraries/boost/boost/thread/lock_options.hpp | 31 - libraries/boost/boost/thread/lock_traits.hpp | 45 - libraries/boost/boost/thread/lock_types.hpp | 1230 ---- .../boost/boost/thread/lockable_adapter.hpp | 226 - .../boost/boost/thread/lockable_concepts.hpp | 157 - .../boost/boost/thread/lockable_traits.hpp | 207 - libraries/boost/boost/thread/locks.hpp | 17 - libraries/boost/boost/thread/mutex.hpp | 53 - libraries/boost/boost/thread/null_mutex.hpp | 243 - libraries/boost/boost/thread/once.hpp | 44 - .../boost/boost/thread/ostream_buffer.hpp | 45 - .../boost/boost/thread/poly_lockable.hpp | 68 - .../boost/thread/poly_lockable_adapter.hpp | 89 - .../boost/thread/poly_shared_lockable.hpp | 135 - .../thread/poly_shared_lockable_adapter.hpp | 170 - .../thread/pthread/condition_variable.hpp | 429 -- .../thread/pthread/condition_variable_fwd.hpp | 361 -- .../boost/boost/thread/pthread/mutex.hpp | 361 -- libraries/boost/boost/thread/pthread/once.hpp | 540 -- .../boost/thread/pthread/once_atomic.hpp | 313 - .../pthread/pthread_mutex_scoped_lock.hpp | 64 - .../boost/thread/pthread/recursive_mutex.hpp | 404 -- .../boost/thread/pthread/shared_mutex.hpp | 716 --- .../thread/pthread/shared_mutex_assert.hpp | 724 --- .../boost/thread/pthread/thread_data.hpp | 292 - .../thread/pthread/thread_heap_alloc.hpp | 242 - .../boost/boost/thread/pthread/timespec.hpp | 120 - .../boost/boost/thread/recursive_mutex.hpp | 64 - libraries/boost/boost/thread/reverse_lock.hpp | 59 - .../boost/boost/thread/scoped_thread.hpp | 292 - .../boost/boost/thread/shared_lock_guard.hpp | 53 - libraries/boost/boost/thread/shared_mutex.hpp | 50 - libraries/boost/boost/thread/strict_lock.hpp | 235 - .../boost/boost/thread/sync_bounded_queue.hpp | 16 - libraries/boost/boost/thread/sync_queue.hpp | 16 - .../boost/boost/thread/synchronized_value.hpp | 1068 ---- .../boost/boost/thread/testable_mutex.hpp | 152 - libraries/boost/boost/thread/thread.hpp | 16 - .../boost/boost/thread/thread_functors.hpp | 57 - libraries/boost/boost/thread/thread_guard.hpp | 46 - libraries/boost/boost/thread/thread_only.hpp | 29 - libraries/boost/boost/thread/thread_pool.hpp | 15 - libraries/boost/boost/thread/thread_time.hpp | 55 - libraries/boost/boost/thread/tss.hpp | 113 - .../boost/boost/thread/user_scheduler.hpp | 202 - .../boost/boost/thread/v2/shared_mutex.hpp | 1062 ---- libraries/boost/boost/thread/v2/thread.hpp | 155 - .../thread/win32/basic_recursive_mutex.hpp | 164 - .../boost/thread/win32/basic_timed_mutex.hpp | 279 - .../boost/thread/win32/condition_variable.hpp | 567 -- .../boost/thread/win32/interlocked_read.hpp | 77 - .../boost/thread/win32/mfc_thread_init.hpp | 40 - libraries/boost/boost/thread/win32/mutex.hpp | 72 - libraries/boost/boost/thread/win32/once.hpp | 1087 ---- .../boost/thread/win32/recursive_mutex.hpp | 70 - .../boost/boost/thread/win32/shared_mutex.hpp | 903 --- .../boost/boost/thread/win32/thread_data.hpp | 328 - .../boost/thread/win32/thread_heap_alloc.hpp | 409 -- .../boost/thread/win32/thread_primitives.hpp | 670 -- .../boost/boost/thread/with_lock_guard.hpp | 234 - libraries/boost/boost/thread/xtime.hpp | 93 - .../boost/libs/system/src/error_code.cpp | 20 - libraries/boost/libs/thread/src/future.cpp | 64 - .../boost/libs/thread/src/pthread/once.cpp | 83 - .../libs/thread/src/pthread/once_atomic.cpp | 90 - .../boost/libs/thread/src/pthread/thread.cpp | 846 --- libraries/boost/libs/thread/src/tss_null.cpp | 38 - .../boost/libs/thread/src/win32/thread.cpp | 1043 --- .../boost/libs/thread/src/win32/tss_dll.cpp | 85 - .../boost/libs/thread/src/win32/tss_pe.cpp | 325 - unix/config/ax_boost_thread.m4 | 149 - windows/vs2015/boost_date_time.vcxproj | 288 - .../vs2015/boost_date_time.vcxproj.filters | 26 - windows/vs2015/boost_system.vcxproj | 286 - windows/vs2015/boost_system.vcxproj.filters | 20 - windows/vs2015/boost_thread.vcxproj | 295 - windows/vs2015/boost_thread.vcxproj.filters | 27 - windows/vs2015/povray.sln | 41 - windows/vs2015/tests.vcxproj | 3 - 188 files changed, 42730 deletions(-) delete mode 100644 libraries/boost/boost/system/api_config.hpp delete mode 100644 libraries/boost/boost/system/config.hpp delete mode 100644 libraries/boost/boost/system/cygwin_error.hpp delete mode 100644 libraries/boost/boost/system/detail/error_code.ipp delete mode 100644 libraries/boost/boost/system/detail/local_free_on_destruction.hpp delete mode 100644 libraries/boost/boost/system/error_code.hpp delete mode 100644 libraries/boost/boost/system/linux_error.hpp delete mode 100644 libraries/boost/boost/system/system_error.hpp delete mode 100644 libraries/boost/boost/system/windows_error.hpp delete mode 100644 libraries/boost/boost/thread/barrier.hpp delete mode 100644 libraries/boost/boost/thread/caller_context.hpp delete mode 100644 libraries/boost/boost/thread/completion_latch.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/deque_adaptor.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/deque_base.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/deque_views.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/detail/sync_deque_base.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/detail/sync_queue_base.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/queue_adaptor.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/queue_base.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/queue_op_status.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/queue_views.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/sync_bounded_queue.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/sync_deque.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/sync_priority_queue.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/sync_queue.hpp delete mode 100644 libraries/boost/boost/thread/concurrent_queues/sync_timed_queue.hpp delete mode 100644 libraries/boost/boost/thread/condition.hpp delete mode 100644 libraries/boost/boost/thread/condition_variable.hpp delete mode 100644 libraries/boost/boost/thread/csbl/deque.hpp delete mode 100644 libraries/boost/boost/thread/csbl/devector.hpp delete mode 100644 libraries/boost/boost/thread/csbl/functional.hpp delete mode 100644 libraries/boost/boost/thread/csbl/list.hpp delete mode 100644 libraries/boost/boost/thread/csbl/memory.hpp delete mode 100644 libraries/boost/boost/thread/csbl/memory/allocator_arg.hpp delete mode 100644 libraries/boost/boost/thread/csbl/memory/allocator_traits.hpp delete mode 100644 libraries/boost/boost/thread/csbl/memory/config.hpp delete mode 100644 libraries/boost/boost/thread/csbl/memory/default_delete.hpp delete mode 100644 libraries/boost/boost/thread/csbl/memory/pointer_traits.hpp delete mode 100644 libraries/boost/boost/thread/csbl/memory/scoped_allocator.hpp delete mode 100644 libraries/boost/boost/thread/csbl/memory/shared_ptr.hpp delete mode 100644 libraries/boost/boost/thread/csbl/memory/unique_ptr.hpp delete mode 100644 libraries/boost/boost/thread/csbl/queue.hpp delete mode 100644 libraries/boost/boost/thread/csbl/tuple.hpp delete mode 100644 libraries/boost/boost/thread/csbl/vector.hpp delete mode 100644 libraries/boost/boost/thread/cv_status.hpp delete mode 100644 libraries/boost/boost/thread/detail/config.hpp delete mode 100644 libraries/boost/boost/thread/detail/counter.hpp delete mode 100644 libraries/boost/boost/thread/detail/delete.hpp delete mode 100644 libraries/boost/boost/thread/detail/force_cast.hpp delete mode 100644 libraries/boost/boost/thread/detail/function_wrapper.hpp delete mode 100644 libraries/boost/boost/thread/detail/invoke.hpp delete mode 100644 libraries/boost/boost/thread/detail/invoker.hpp delete mode 100644 libraries/boost/boost/thread/detail/is_convertible.hpp delete mode 100644 libraries/boost/boost/thread/detail/lockable_wrapper.hpp delete mode 100644 libraries/boost/boost/thread/detail/log.hpp delete mode 100644 libraries/boost/boost/thread/detail/make_tuple_indices.hpp delete mode 100644 libraries/boost/boost/thread/detail/memory.hpp delete mode 100644 libraries/boost/boost/thread/detail/move.hpp delete mode 100644 libraries/boost/boost/thread/detail/nullary_function.hpp delete mode 100644 libraries/boost/boost/thread/detail/platform.hpp delete mode 100644 libraries/boost/boost/thread/detail/singleton.hpp delete mode 100644 libraries/boost/boost/thread/detail/thread.hpp delete mode 100644 libraries/boost/boost/thread/detail/thread_group.hpp delete mode 100644 libraries/boost/boost/thread/detail/thread_heap_alloc.hpp delete mode 100644 libraries/boost/boost/thread/detail/thread_interruption.hpp delete mode 100644 libraries/boost/boost/thread/detail/tss_hooks.hpp delete mode 100644 libraries/boost/boost/thread/detail/variadic_footer.hpp delete mode 100644 libraries/boost/boost/thread/detail/variadic_header.hpp delete mode 100644 libraries/boost/boost/thread/exceptional_ptr.hpp delete mode 100644 libraries/boost/boost/thread/exceptions.hpp delete mode 100644 libraries/boost/boost/thread/executor.hpp delete mode 100644 libraries/boost/boost/thread/executors/basic_thread_pool.hpp delete mode 100644 libraries/boost/boost/thread/executors/detail/priority_executor_base.hpp delete mode 100644 libraries/boost/boost/thread/executors/detail/scheduled_executor_base.hpp delete mode 100644 libraries/boost/boost/thread/executors/executor.hpp delete mode 100644 libraries/boost/boost/thread/executors/executor_adaptor.hpp delete mode 100644 libraries/boost/boost/thread/executors/generic_executor_ref.hpp delete mode 100644 libraries/boost/boost/thread/executors/inline_executor.hpp delete mode 100644 libraries/boost/boost/thread/executors/loop_executor.hpp delete mode 100644 libraries/boost/boost/thread/executors/scheduled_thread_pool.hpp delete mode 100644 libraries/boost/boost/thread/executors/scheduler.hpp delete mode 100644 libraries/boost/boost/thread/executors/scheduling_adaptor.hpp delete mode 100644 libraries/boost/boost/thread/executors/serial_executor.hpp delete mode 100644 libraries/boost/boost/thread/executors/serial_executor_cont.hpp delete mode 100644 libraries/boost/boost/thread/executors/thread_executor.hpp delete mode 100644 libraries/boost/boost/thread/executors/work.hpp delete mode 100644 libraries/boost/boost/thread/experimental/config/inline_namespace.hpp delete mode 100644 libraries/boost/boost/thread/experimental/exception_list.hpp delete mode 100644 libraries/boost/boost/thread/experimental/parallel/v1/exception_list.hpp delete mode 100644 libraries/boost/boost/thread/experimental/parallel/v1/inline_namespace.hpp delete mode 100644 libraries/boost/boost/thread/experimental/parallel/v2/inline_namespace.hpp delete mode 100644 libraries/boost/boost/thread/experimental/parallel/v2/task_region.hpp delete mode 100644 libraries/boost/boost/thread/experimental/task_region.hpp delete mode 100644 libraries/boost/boost/thread/externally_locked.hpp delete mode 100644 libraries/boost/boost/thread/externally_locked_stream.hpp delete mode 100644 libraries/boost/boost/thread/future.hpp delete mode 100644 libraries/boost/boost/thread/futures/future_error.hpp delete mode 100644 libraries/boost/boost/thread/futures/future_error_code.hpp delete mode 100644 libraries/boost/boost/thread/futures/future_status.hpp delete mode 100644 libraries/boost/boost/thread/futures/is_future_type.hpp delete mode 100644 libraries/boost/boost/thread/futures/launch.hpp delete mode 100644 libraries/boost/boost/thread/futures/wait_for_all.hpp delete mode 100644 libraries/boost/boost/thread/futures/wait_for_any.hpp delete mode 100644 libraries/boost/boost/thread/is_locked_by_this_thread.hpp delete mode 100644 libraries/boost/boost/thread/latch.hpp delete mode 100644 libraries/boost/boost/thread/lock_algorithms.hpp delete mode 100644 libraries/boost/boost/thread/lock_concepts.hpp delete mode 100644 libraries/boost/boost/thread/lock_factories.hpp delete mode 100644 libraries/boost/boost/thread/lock_guard.hpp delete mode 100644 libraries/boost/boost/thread/lock_options.hpp delete mode 100644 libraries/boost/boost/thread/lock_traits.hpp delete mode 100644 libraries/boost/boost/thread/lock_types.hpp delete mode 100644 libraries/boost/boost/thread/lockable_adapter.hpp delete mode 100644 libraries/boost/boost/thread/lockable_concepts.hpp delete mode 100644 libraries/boost/boost/thread/lockable_traits.hpp delete mode 100644 libraries/boost/boost/thread/locks.hpp delete mode 100644 libraries/boost/boost/thread/mutex.hpp delete mode 100644 libraries/boost/boost/thread/null_mutex.hpp delete mode 100644 libraries/boost/boost/thread/once.hpp delete mode 100644 libraries/boost/boost/thread/ostream_buffer.hpp delete mode 100644 libraries/boost/boost/thread/poly_lockable.hpp delete mode 100644 libraries/boost/boost/thread/poly_lockable_adapter.hpp delete mode 100644 libraries/boost/boost/thread/poly_shared_lockable.hpp delete mode 100644 libraries/boost/boost/thread/poly_shared_lockable_adapter.hpp delete mode 100644 libraries/boost/boost/thread/pthread/condition_variable.hpp delete mode 100644 libraries/boost/boost/thread/pthread/condition_variable_fwd.hpp delete mode 100644 libraries/boost/boost/thread/pthread/mutex.hpp delete mode 100644 libraries/boost/boost/thread/pthread/once.hpp delete mode 100644 libraries/boost/boost/thread/pthread/once_atomic.hpp delete mode 100644 libraries/boost/boost/thread/pthread/pthread_mutex_scoped_lock.hpp delete mode 100644 libraries/boost/boost/thread/pthread/recursive_mutex.hpp delete mode 100644 libraries/boost/boost/thread/pthread/shared_mutex.hpp delete mode 100644 libraries/boost/boost/thread/pthread/shared_mutex_assert.hpp delete mode 100644 libraries/boost/boost/thread/pthread/thread_data.hpp delete mode 100644 libraries/boost/boost/thread/pthread/thread_heap_alloc.hpp delete mode 100644 libraries/boost/boost/thread/pthread/timespec.hpp delete mode 100644 libraries/boost/boost/thread/recursive_mutex.hpp delete mode 100644 libraries/boost/boost/thread/reverse_lock.hpp delete mode 100644 libraries/boost/boost/thread/scoped_thread.hpp delete mode 100644 libraries/boost/boost/thread/shared_lock_guard.hpp delete mode 100644 libraries/boost/boost/thread/shared_mutex.hpp delete mode 100644 libraries/boost/boost/thread/strict_lock.hpp delete mode 100644 libraries/boost/boost/thread/sync_bounded_queue.hpp delete mode 100644 libraries/boost/boost/thread/sync_queue.hpp delete mode 100644 libraries/boost/boost/thread/synchronized_value.hpp delete mode 100644 libraries/boost/boost/thread/testable_mutex.hpp delete mode 100644 libraries/boost/boost/thread/thread.hpp delete mode 100644 libraries/boost/boost/thread/thread_functors.hpp delete mode 100644 libraries/boost/boost/thread/thread_guard.hpp delete mode 100644 libraries/boost/boost/thread/thread_only.hpp delete mode 100644 libraries/boost/boost/thread/thread_pool.hpp delete mode 100644 libraries/boost/boost/thread/thread_time.hpp delete mode 100644 libraries/boost/boost/thread/tss.hpp delete mode 100644 libraries/boost/boost/thread/user_scheduler.hpp delete mode 100644 libraries/boost/boost/thread/v2/shared_mutex.hpp delete mode 100644 libraries/boost/boost/thread/v2/thread.hpp delete mode 100644 libraries/boost/boost/thread/win32/basic_recursive_mutex.hpp delete mode 100644 libraries/boost/boost/thread/win32/basic_timed_mutex.hpp delete mode 100644 libraries/boost/boost/thread/win32/condition_variable.hpp delete mode 100644 libraries/boost/boost/thread/win32/interlocked_read.hpp delete mode 100644 libraries/boost/boost/thread/win32/mfc_thread_init.hpp delete mode 100644 libraries/boost/boost/thread/win32/mutex.hpp delete mode 100644 libraries/boost/boost/thread/win32/once.hpp delete mode 100644 libraries/boost/boost/thread/win32/recursive_mutex.hpp delete mode 100644 libraries/boost/boost/thread/win32/shared_mutex.hpp delete mode 100644 libraries/boost/boost/thread/win32/thread_data.hpp delete mode 100644 libraries/boost/boost/thread/win32/thread_heap_alloc.hpp delete mode 100644 libraries/boost/boost/thread/win32/thread_primitives.hpp delete mode 100644 libraries/boost/boost/thread/with_lock_guard.hpp delete mode 100644 libraries/boost/boost/thread/xtime.hpp delete mode 100644 libraries/boost/libs/system/src/error_code.cpp delete mode 100644 libraries/boost/libs/thread/src/future.cpp delete mode 100644 libraries/boost/libs/thread/src/pthread/once.cpp delete mode 100644 libraries/boost/libs/thread/src/pthread/once_atomic.cpp delete mode 100644 libraries/boost/libs/thread/src/pthread/thread.cpp delete mode 100644 libraries/boost/libs/thread/src/tss_null.cpp delete mode 100644 libraries/boost/libs/thread/src/win32/thread.cpp delete mode 100644 libraries/boost/libs/thread/src/win32/tss_dll.cpp delete mode 100644 libraries/boost/libs/thread/src/win32/tss_pe.cpp delete mode 100644 unix/config/ax_boost_thread.m4 delete mode 100644 windows/vs2015/boost_date_time.vcxproj delete mode 100644 windows/vs2015/boost_date_time.vcxproj.filters delete mode 100644 windows/vs2015/boost_system.vcxproj delete mode 100644 windows/vs2015/boost_system.vcxproj.filters delete mode 100644 windows/vs2015/boost_thread.vcxproj delete mode 100644 windows/vs2015/boost_thread.vcxproj.filters diff --git a/libraries/boost/boost/system/api_config.hpp b/libraries/boost/boost/system/api_config.hpp deleted file mode 100644 index 28b8bece4..000000000 --- a/libraries/boost/boost/system/api_config.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// boost/system/api_config.hpp -------------------------------------------------------// - -// Copyright Beman Dawes 2003, 2006, 2010 - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - -// See http://www.boost.org/libs/system for documentation. - -//--------------------------------------------------------------------------------------// - -// Boost.System calls operating system API functions to implement system error category -// functions. Usually there is no question as to which API is to be used. -// -// In the case of MinGW or Cygwin/MinGW, however, both POSIX and Windows API's are -// available. Chaos ensues if other code thinks one is in use when Boost.System was -// actually built with the other. This header centralizes the API choice and prevents -// user definition of API macros, thus elminating the possibility of mismatches and the -// need to test configurations with little or no practical value. -// - -//--------------------------------------------------------------------------------------// - -#ifndef BOOST_SYSTEM_API_CONFIG_HPP -#define BOOST_SYSTEM_API_CONFIG_HPP - -# if defined(BOOST_POSIX_API) || defined(BOOST_WINDOWS_API) -# error user defined BOOST_POSIX_API or BOOST_WINDOWS_API not supported -# endif - -// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use -// Cygwin/MinGW does not predefine _WIN32. -// Standalone MinGW and all other known Windows compilers do predefine _WIN32 -// Compilers that predefine _WIN32 or __MINGW32__ do so for Windows 64-bit builds too. - -# if defined(_WIN32) || defined(__CYGWIN__) // Windows default, including MinGW and Cygwin -# define BOOST_WINDOWS_API -# else -# define BOOST_POSIX_API -# endif - -#endif // BOOST_SYSTEM_API_CONFIG_HPP diff --git a/libraries/boost/boost/system/config.hpp b/libraries/boost/boost/system/config.hpp deleted file mode 100644 index 14faa6342..000000000 --- a/libraries/boost/boost/system/config.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// boost/system/config.hpp -----------------------------------------------------------// - -// Copyright Beman Dawes 2003, 2006 - -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/system for documentation. - -#ifndef BOOST_SYSTEM_CONFIG_HPP -#define BOOST_SYSTEM_CONFIG_HPP - -#include -#include -#include // for BOOST_POSIX_API or BOOST_WINDOWS_API - -// This header implements separate compilation features as described in -// http://www.boost.org/more/separate_compilation.html - -// normalize macros ------------------------------------------------------------------// - -#if !defined(BOOST_SYSTEM_DYN_LINK) && !defined(BOOST_SYSTEM_STATIC_LINK) \ - && !defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_ALL_STATIC_LINK) -# define BOOST_SYSTEM_STATIC_LINK -#endif - -#if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_SYSTEM_DYN_LINK) -# define BOOST_SYSTEM_DYN_LINK -#elif defined(BOOST_ALL_STATIC_LINK) && !defined(BOOST_SYSTEM_STATIC_LINK) -# define BOOST_SYSTEM_STATIC_LINK -#endif - -#if defined(BOOST_SYSTEM_DYN_LINK) && defined(BOOST_SYSTEM_STATIC_LINK) -# error Must not define both BOOST_SYSTEM_DYN_LINK and BOOST_SYSTEM_STATIC_LINK -#endif - -// enable dynamic or static linking as requested --------------------------------------// - -#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK) -# if defined(BOOST_SYSTEM_SOURCE) -# define BOOST_SYSTEM_DECL BOOST_SYMBOL_EXPORT -# else -# define BOOST_SYSTEM_DECL BOOST_SYMBOL_IMPORT -# endif -#else -# define BOOST_SYSTEM_DECL -#endif - -// enable automatic library variant selection ----------------------------------------// - -#if !defined(BOOST_SYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SYSTEM_NO_LIB) -// -// Set the name of our library, this will get undef'ed by auto_link.hpp -// once it's done with it: -// -#define BOOST_LIB_NAME boost_system -// -// If we're importing code from a dll, then tell auto_link.hpp about it: -// -#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SYSTEM_DYN_LINK) -# define BOOST_DYN_LINK -#endif -// -// And include the header that does the work: -// -#include -#endif // auto-linking disabled - -#endif // BOOST_SYSTEM_CONFIG_HPP - diff --git a/libraries/boost/boost/system/cygwin_error.hpp b/libraries/boost/boost/system/cygwin_error.hpp deleted file mode 100644 index ea3528b66..000000000 --- a/libraries/boost/boost/system/cygwin_error.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// boost/system/cygwin_error.hpp -------------------------------------------// - -// Copyright Beman Dawes 2007 - -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See library home page at http://www.boost.org/libs/system - -#ifndef BOOST_CYGWIN_ERROR_HPP -#define BOOST_CYGWIN_ERROR_HPP - -// This header is effectively empty for compiles on operating systems where -// it is not applicable. - -# ifdef __CYGWIN__ - -#include - -namespace boost -{ - namespace system - { - // To construct an error_code after a API error: - // - // error_code( errno, system_category() ) - - // User code should use the portable "posix" enums for POSIX errors; this - // allows such code to be portable to non-POSIX systems. For the non-POSIX - // errno values that POSIX-based systems typically provide in addition to - // POSIX values, use the system specific enums below. - - namespace cygwin_error - { - enum cygwin_errno - { - no_net = ENONET, - no_package = ENOPKG, - no_share = ENOSHARE - }; - } // namespace cygwin_error - - template<> struct is_error_code_enum - { static const bool value = true; }; - - namespace cygwin_error - { - inline error_code make_error_code( cygwin_errno e ) - { return error_code( e, system_category() ); } - } - } -} - -#endif // __CYGWIN__ - -#endif // BOOST_CYGWIN_ERROR_HPP diff --git a/libraries/boost/boost/system/detail/error_code.ipp b/libraries/boost/boost/system/detail/error_code.ipp deleted file mode 100644 index 71c60f61d..000000000 --- a/libraries/boost/boost/system/detail/error_code.ipp +++ /dev/null @@ -1,467 +0,0 @@ -// error_code support implementation file ----------------------------------// - -// Copyright Beman Dawes 2002, 2006 -// Copyright (c) Microsoft Corporation 2014 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See library home page at http://www.boost.org/libs/system - -//----------------------------------------------------------------------------// - -#include - -#include -#include -#include -#include -#include -#include - -#include // for strerror/strerror_r - -# if defined( BOOST_WINDOWS_API ) -# include -# if !BOOST_PLAT_WINDOWS_RUNTIME -# include -# endif -# ifndef ERROR_INCORRECT_SIZE -# define ERROR_INCORRECT_SIZE ERROR_BAD_ARGUMENTS -# endif -# endif - -//----------------------------------------------------------------------------// -namespace boost -{ - namespace system - { - -namespace -{ - - // standard error categories ---------------------------------------------// - - class generic_error_category : public error_category - { - public: - generic_error_category(){} - const char * name() const BOOST_SYSTEM_NOEXCEPT; - std::string message( int ev ) const; - }; - - class system_error_category : public error_category - { - public: - system_error_category(){} - const char * name() const BOOST_SYSTEM_NOEXCEPT; - std::string message( int ev ) const; - error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; - }; - - // generic_error_category implementation ---------------------------------// - - const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT - { - return "generic"; - } - - std::string generic_error_category::message( int ev ) const - { - using namespace boost::system::errc; -#if defined(__PGI) - using boost::system::errc::invalid_argument; -#endif - - static std::string unknown_err( "Unknown error" ); - // strerror_r is preferred because it is always thread safe, - // however, we fallback to strerror in certain cases because: - // -- Windows doesn't provide strerror_r. - // -- HP and Sun do provide strerror_r on newer systems, but there is - // no way to tell if is available at runtime and in any case their - // versions of strerror are thread safe anyhow. - // -- Linux only sometimes provides strerror_r. - // -- Tru64 provides strerror_r only when compiled -pthread. - // -- VMS doesn't provide strerror_r, but on this platform, strerror is - // thread safe. - # if defined(BOOST_WINDOWS_API) || defined(__hpux) || defined(__sun)\ - || (defined(__linux) && (!defined(__USE_XOPEN2K) || defined(BOOST_SYSTEM_USE_STRERROR)))\ - || (defined(__osf__) && !defined(_REENTRANT))\ - || (defined(__INTEGRITY))\ - || (defined(__vms))\ - || (defined(__QNXNTO__)) - const char * c_str = std::strerror( ev ); - return c_str - ? std::string( c_str ) - : unknown_err; - # else // use strerror_r - char buf[64]; - char * bp = buf; - std::size_t sz = sizeof(buf); - # if defined(__CYGWIN__) || defined(__USE_GNU) - // Oddball version of strerror_r - const char * c_str = strerror_r( ev, bp, sz ); - return c_str - ? std::string( c_str ) - : unknown_err; - # else - // POSIX version of strerror_r - int result; - for (;;) - { - // strerror_r returns 0 on success, otherwise ERANGE if buffer too small, - // invalid_argument if ev not a valid error number - # if defined (__sgi) - const char * c_str = strerror( ev ); - result = 0; - return c_str - ? std::string( c_str ) - : unknown_err; - # else - result = strerror_r( ev, bp, sz ); - # endif - if (result == 0 ) - break; - else - { - # if defined(__linux) - // Linux strerror_r returns -1 on error, with error number in errno - result = errno; - # endif - if ( result != ERANGE ) break; - if ( sz > sizeof(buf) ) std::free( bp ); - sz *= 2; - if ( (bp = static_cast(std::malloc( sz ))) == 0 ) - return std::string( "ENOMEM" ); - } - } - std::string msg; -# ifndef BOOST_NO_EXCEPTIONS - try -# endif - { - msg = ( ( result == invalid_argument ) ? "Unknown error" : bp ); - } - -# ifndef BOOST_NO_EXCEPTIONS - // See ticket #2098 - catch(...) - { - // just eat the exception - } -# endif - - if ( sz > sizeof(buf) ) std::free( bp ); - sz = 0; - return msg; - # endif // else POSIX version of strerror_r - # endif // else use strerror_r - } - // system_error_category implementation --------------------------------// - - const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT - { - return "system"; - } - - error_condition system_error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT - { - using namespace boost::system::errc; -#if defined(__PGI) - using boost::system::errc::invalid_argument; -#endif - -# if defined(BOOST_WINDOWS_API) -# if defined(WINAPI_FAMILY) && ((WINAPI_FAMILY & WINAPI_PARTITION_APP) != 0) - // When using the Windows Runtime, most system errors are reported as HRESULTs. - // We want to map the common Win32 errors to their equivalent error condition, - // whether or not they are reported via an HRESULT. - if ( ev < 0 ) // Check for failed HRESULTs only. - if ( HRESULT_FACILITY( ev ) == FACILITY_WIN32 ) - ev = HRESULT_CODE( ev ); -# endif -# endif - - switch ( ev ) - { - case 0: return make_error_condition( success ); -# if defined(BOOST_POSIX_API) - // POSIX-like O/S -> posix_errno decode table ---------------------------// - case E2BIG: return make_error_condition( argument_list_too_long ); - case EACCES: return make_error_condition( permission_denied ); - case EADDRINUSE: return make_error_condition( address_in_use ); - case EADDRNOTAVAIL: return make_error_condition( address_not_available ); - case EAFNOSUPPORT: return make_error_condition( address_family_not_supported ); - case EAGAIN: return make_error_condition( resource_unavailable_try_again ); -# if EALREADY != EBUSY // EALREADY and EBUSY are the same on QNX Neutrino - case EALREADY: return make_error_condition( connection_already_in_progress ); -# endif - case EBADF: return make_error_condition( bad_file_descriptor ); - case EBADMSG: return make_error_condition( bad_message ); - case EBUSY: return make_error_condition( device_or_resource_busy ); - case ECANCELED: return make_error_condition( operation_canceled ); - case ECHILD: return make_error_condition( no_child_process ); - case ECONNABORTED: return make_error_condition( connection_aborted ); - case ECONNREFUSED: return make_error_condition( connection_refused ); - case ECONNRESET: return make_error_condition( connection_reset ); - case EDEADLK: return make_error_condition( resource_deadlock_would_occur ); - case EDESTADDRREQ: return make_error_condition( destination_address_required ); - case EDOM: return make_error_condition( argument_out_of_domain ); - case EEXIST: return make_error_condition( file_exists ); - case EFAULT: return make_error_condition( bad_address ); - case EFBIG: return make_error_condition( file_too_large ); - case EHOSTUNREACH: return make_error_condition( host_unreachable ); - case EIDRM: return make_error_condition( identifier_removed ); - case EILSEQ: return make_error_condition( illegal_byte_sequence ); - case EINPROGRESS: return make_error_condition( operation_in_progress ); - case EINTR: return make_error_condition( interrupted ); - case EINVAL: return make_error_condition( invalid_argument ); - case EIO: return make_error_condition( io_error ); - case EISCONN: return make_error_condition( already_connected ); - case EISDIR: return make_error_condition( is_a_directory ); - case ELOOP: return make_error_condition( too_many_symbolic_link_levels ); - case EMFILE: return make_error_condition( too_many_files_open ); - case EMLINK: return make_error_condition( too_many_links ); - case EMSGSIZE: return make_error_condition( message_size ); - case ENAMETOOLONG: return make_error_condition( filename_too_long ); - case ENETDOWN: return make_error_condition( network_down ); - case ENETRESET: return make_error_condition( network_reset ); - case ENETUNREACH: return make_error_condition( network_unreachable ); - case ENFILE: return make_error_condition( too_many_files_open_in_system ); - case ENOBUFS: return make_error_condition( no_buffer_space ); - case ENODATA: return make_error_condition( no_message_available ); - case ENODEV: return make_error_condition( no_such_device ); - case ENOENT: return make_error_condition( no_such_file_or_directory ); - case ENOEXEC: return make_error_condition( executable_format_error ); - case ENOLCK: return make_error_condition( no_lock_available ); - case ENOLINK: return make_error_condition( no_link ); - case ENOMEM: return make_error_condition( not_enough_memory ); - case ENOMSG: return make_error_condition( no_message ); - case ENOPROTOOPT: return make_error_condition( no_protocol_option ); - case ENOSPC: return make_error_condition( no_space_on_device ); - case ENOSR: return make_error_condition( no_stream_resources ); - case ENOSTR: return make_error_condition( not_a_stream ); - case ENOSYS: return make_error_condition( function_not_supported ); - case ENOTCONN: return make_error_condition( not_connected ); - case ENOTDIR: return make_error_condition( not_a_directory ); - # if ENOTEMPTY != EEXIST // AIX treats ENOTEMPTY and EEXIST as the same value - case ENOTEMPTY: return make_error_condition( directory_not_empty ); - # endif // ENOTEMPTY != EEXIST - # if ENOTRECOVERABLE != ECONNRESET // the same on some Broadcom chips - case ENOTRECOVERABLE: return make_error_condition( state_not_recoverable ); - # endif // ENOTRECOVERABLE != ECONNRESET - case ENOTSOCK: return make_error_condition( not_a_socket ); - case ENOTSUP: return make_error_condition( not_supported ); - case ENOTTY: return make_error_condition( inappropriate_io_control_operation ); - case ENXIO: return make_error_condition( no_such_device_or_address ); - # if EOPNOTSUPP != ENOTSUP - case EOPNOTSUPP: return make_error_condition( operation_not_supported ); - # endif // EOPNOTSUPP != ENOTSUP - case EOVERFLOW: return make_error_condition( value_too_large ); - # if EOWNERDEAD != ECONNABORTED // the same on some Broadcom chips - case EOWNERDEAD: return make_error_condition( owner_dead ); - # endif // EOWNERDEAD != ECONNABORTED - case EPERM: return make_error_condition( operation_not_permitted ); - case EPIPE: return make_error_condition( broken_pipe ); - case EPROTO: return make_error_condition( protocol_error ); - case EPROTONOSUPPORT: return make_error_condition( protocol_not_supported ); - case EPROTOTYPE: return make_error_condition( wrong_protocol_type ); - case ERANGE: return make_error_condition( result_out_of_range ); - case EROFS: return make_error_condition( read_only_file_system ); - case ESPIPE: return make_error_condition( invalid_seek ); - case ESRCH: return make_error_condition( no_such_process ); - case ETIME: return make_error_condition( stream_timeout ); - case ETIMEDOUT: return make_error_condition( timed_out ); - case ETXTBSY: return make_error_condition( text_file_busy ); - # if EAGAIN != EWOULDBLOCK - case EWOULDBLOCK: return make_error_condition( operation_would_block ); - # endif // EAGAIN != EWOULDBLOCK - case EXDEV: return make_error_condition( cross_device_link ); - #else - // Windows system -> posix_errno decode table ---------------------------// - // see WinError.h comments for descriptions of errors - case ERROR_ACCESS_DENIED: return make_error_condition( permission_denied ); - case ERROR_ALREADY_EXISTS: return make_error_condition( file_exists ); - case ERROR_BAD_UNIT: return make_error_condition( no_such_device ); - case ERROR_BUFFER_OVERFLOW: return make_error_condition( filename_too_long ); - case ERROR_BUSY: return make_error_condition( device_or_resource_busy ); - case ERROR_BUSY_DRIVE: return make_error_condition( device_or_resource_busy ); - case ERROR_CANNOT_MAKE: return make_error_condition( permission_denied ); - case ERROR_CANTOPEN: return make_error_condition( io_error ); - case ERROR_CANTREAD: return make_error_condition( io_error ); - case ERROR_CANTWRITE: return make_error_condition( io_error ); - case ERROR_CURRENT_DIRECTORY: return make_error_condition( permission_denied ); - case ERROR_DEV_NOT_EXIST: return make_error_condition( no_such_device ); - case ERROR_DEVICE_IN_USE: return make_error_condition( device_or_resource_busy ); - case ERROR_DIR_NOT_EMPTY: return make_error_condition( directory_not_empty ); - case ERROR_DIRECTORY: return make_error_condition( invalid_argument ); // WinError.h: "The directory name is invalid" - case ERROR_DISK_FULL: return make_error_condition( no_space_on_device ); - case ERROR_FILE_EXISTS: return make_error_condition( file_exists ); - case ERROR_FILE_NOT_FOUND: return make_error_condition( no_such_file_or_directory ); - case ERROR_HANDLE_DISK_FULL: return make_error_condition( no_space_on_device ); - case ERROR_INVALID_ACCESS: return make_error_condition( permission_denied ); - case ERROR_INVALID_DRIVE: return make_error_condition( no_such_device ); - case ERROR_INVALID_FUNCTION: return make_error_condition( function_not_supported ); - case ERROR_INVALID_HANDLE: return make_error_condition( invalid_argument ); - case ERROR_INVALID_NAME: return make_error_condition( invalid_argument ); - case ERROR_LOCK_VIOLATION: return make_error_condition( no_lock_available ); - case ERROR_LOCKED: return make_error_condition( no_lock_available ); - case ERROR_NEGATIVE_SEEK: return make_error_condition( invalid_argument ); - case ERROR_NOACCESS: return make_error_condition( permission_denied ); - case ERROR_NOT_ENOUGH_MEMORY: return make_error_condition( not_enough_memory ); - case ERROR_NOT_READY: return make_error_condition( resource_unavailable_try_again ); - case ERROR_NOT_SAME_DEVICE: return make_error_condition( cross_device_link ); - case ERROR_OPEN_FAILED: return make_error_condition( io_error ); - case ERROR_OPEN_FILES: return make_error_condition( device_or_resource_busy ); - case ERROR_OPERATION_ABORTED: return make_error_condition( operation_canceled ); - case ERROR_OUTOFMEMORY: return make_error_condition( not_enough_memory ); - case ERROR_PATH_NOT_FOUND: return make_error_condition( no_such_file_or_directory ); - case ERROR_READ_FAULT: return make_error_condition( io_error ); - case ERROR_RETRY: return make_error_condition( resource_unavailable_try_again ); - case ERROR_SEEK: return make_error_condition( io_error ); - case ERROR_SHARING_VIOLATION: return make_error_condition( permission_denied ); - case ERROR_TOO_MANY_OPEN_FILES: return make_error_condition( too_many_files_open ); - case ERROR_WRITE_FAULT: return make_error_condition( io_error ); - case ERROR_WRITE_PROTECT: return make_error_condition( permission_denied ); - case WSAEACCES: return make_error_condition( permission_denied ); - case WSAEADDRINUSE: return make_error_condition( address_in_use ); - case WSAEADDRNOTAVAIL: return make_error_condition( address_not_available ); - case WSAEAFNOSUPPORT: return make_error_condition( address_family_not_supported ); - case WSAEALREADY: return make_error_condition( connection_already_in_progress ); - case WSAEBADF: return make_error_condition( bad_file_descriptor ); - case WSAECONNABORTED: return make_error_condition( connection_aborted ); - case WSAECONNREFUSED: return make_error_condition( connection_refused ); - case WSAECONNRESET: return make_error_condition( connection_reset ); - case WSAEDESTADDRREQ: return make_error_condition( destination_address_required ); - case WSAEFAULT: return make_error_condition( bad_address ); - case WSAEHOSTUNREACH: return make_error_condition( host_unreachable ); - case WSAEINPROGRESS: return make_error_condition( operation_in_progress ); - case WSAEINTR: return make_error_condition( interrupted ); - case WSAEINVAL: return make_error_condition( invalid_argument ); - case WSAEISCONN: return make_error_condition( already_connected ); - case WSAEMFILE: return make_error_condition( too_many_files_open ); - case WSAEMSGSIZE: return make_error_condition( message_size ); - case WSAENAMETOOLONG: return make_error_condition( filename_too_long ); - case WSAENETDOWN: return make_error_condition( network_down ); - case WSAENETRESET: return make_error_condition( network_reset ); - case WSAENETUNREACH: return make_error_condition( network_unreachable ); - case WSAENOBUFS: return make_error_condition( no_buffer_space ); - case WSAENOPROTOOPT: return make_error_condition( no_protocol_option ); - case WSAENOTCONN: return make_error_condition( not_connected ); - case WSAENOTSOCK: return make_error_condition( not_a_socket ); - case WSAEOPNOTSUPP: return make_error_condition( operation_not_supported ); - case WSAEPROTONOSUPPORT: return make_error_condition( protocol_not_supported ); - case WSAEPROTOTYPE: return make_error_condition( wrong_protocol_type ); - case WSAETIMEDOUT: return make_error_condition( timed_out ); - case WSAEWOULDBLOCK: return make_error_condition( operation_would_block ); - #endif - default: return error_condition( ev, system_category() ); - } - } - -# if !defined( BOOST_WINDOWS_API ) - - std::string system_error_category::message( int ev ) const - { - return generic_category().message( ev ); - } -# else - - std::string system_error_category::message( int ev ) const - { -#if defined(UNDER_CE) || BOOST_PLAT_WINDOWS_RUNTIME || defined(BOOST_NO_ANSI_APIS) - std::wstring buf(128, wchar_t()); - for (;;) - { - DWORD retval = ::FormatMessageW( - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - ev, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - &buf[0], - buf.size(), - NULL - ); - - if (retval > 0) - { - buf.resize(retval); - break; - } - else if ( ::GetLastError() != ERROR_INSUFFICIENT_BUFFER ) - { - return std::string("Unknown error"); - } - else - { - buf.resize(buf.size() + buf.size() / 2); - } - } - - int num_chars = (buf.size() + 1) * 2; - LPSTR narrow_buffer = (LPSTR)_alloca( num_chars ); - if (::WideCharToMultiByte(CP_ACP, 0, buf.c_str(), -1, narrow_buffer, num_chars, NULL, NULL) == 0) - { - return std::string("Unknown error"); - } - - std::string str( narrow_buffer ); -#else - LPVOID lpMsgBuf = 0; - DWORD retval = ::FormatMessageA( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - ev, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPSTR) &lpMsgBuf, - 0, - NULL - ); - detail::local_free_on_destruction lfod(lpMsgBuf); - if (retval == 0) - return std::string("Unknown error"); - - std::string str( static_cast(lpMsgBuf) ); -# endif - while ( str.size() - && (str[str.size()-1] == '\n' || str[str.size()-1] == '\r') ) - str.erase( str.size()-1 ); - if ( str.size() && str[str.size()-1] == '.' ) - { str.erase( str.size()-1 ); } - return str; - } -# endif - -} // unnamed namespace - - -# ifndef BOOST_SYSTEM_NO_DEPRECATED - BOOST_SYSTEM_DECL error_code throws; // "throw on error" special error_code; - // note that it doesn't matter if this - // isn't initialized before use since - // the only use is to take its - // address for comparison purposes -# endif - -# ifdef BOOST_ERROR_CODE_HEADER_ONLY -# define BOOST_SYSTEM_LINKAGE inline -# else -# define BOOST_SYSTEM_LINKAGE BOOST_SYSTEM_DECL -# endif - - BOOST_SYSTEM_LINKAGE const error_category & system_category() BOOST_SYSTEM_NOEXCEPT - { - static const system_error_category system_category_const; - return system_category_const; - } - - BOOST_SYSTEM_LINKAGE const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT - { - static const generic_error_category generic_category_const; - return generic_category_const; - } - - } // namespace system -} // namespace boost diff --git a/libraries/boost/boost/system/detail/local_free_on_destruction.hpp b/libraries/boost/boost/system/detail/local_free_on_destruction.hpp deleted file mode 100644 index 110024f3d..000000000 --- a/libraries/boost/boost/system/detail/local_free_on_destruction.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// local_free_on_exit.hpp ------------------------------------------------------------// - -// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// Copyright (c) 2010 Beman Dawes - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - -// This is derived from boost/asio/detail/local_free_on_block_exit.hpp to avoid -// a dependency on asio. Thanks to Chris Kohlhoff for pointing it out. - -#ifndef BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP -#define BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP - -namespace boost { -namespace system { -namespace detail { - -class local_free_on_destruction -{ -public: - explicit local_free_on_destruction(void* p) - : p_(p) {} - - ~local_free_on_destruction() - { - ::LocalFree(p_); - } - -private: - void* p_; - local_free_on_destruction(const local_free_on_destruction&); // = deleted - local_free_on_destruction& operator=(const local_free_on_destruction&); // = deleted -}; - -} // namespace detail -} // namespace system -} // namespace boost - -#endif // BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP diff --git a/libraries/boost/boost/system/error_code.hpp b/libraries/boost/boost/system/error_code.hpp deleted file mode 100644 index d419f3701..000000000 --- a/libraries/boost/boost/system/error_code.hpp +++ /dev/null @@ -1,520 +0,0 @@ -// boost/system/error_code.hpp ---------------------------------------------// - -// Copyright Beman Dawes 2006, 2007 -// Copyright Christoper Kohlhoff 2007 - -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See library home page at http://www.boost.org/libs/system - -#ifndef BOOST_ERROR_CODE_HPP -#define BOOST_ERROR_CODE_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// TODO: undef these macros if not already defined -#include - -#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API) -# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined -#endif - -#include // must be the last #include - -#ifndef BOOST_SYSTEM_NOEXCEPT -#define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT -#endif - -namespace boost -{ - namespace system - { - - class error_code; - class error_condition; - - // "Concept" helpers ---------------------------------------------------// - - template< class T > - struct is_error_code_enum { static const bool value = false; }; - - template< class T > - struct is_error_condition_enum { static const bool value = false; }; - - // generic error_conditions --------------------------------------------// - - namespace errc - { - enum errc_t - { - success = 0, - address_family_not_supported = EAFNOSUPPORT, - address_in_use = EADDRINUSE, - address_not_available = EADDRNOTAVAIL, - already_connected = EISCONN, - argument_list_too_long = E2BIG, - argument_out_of_domain = EDOM, - bad_address = EFAULT, - bad_file_descriptor = EBADF, - bad_message = EBADMSG, - broken_pipe = EPIPE, - connection_aborted = ECONNABORTED, - connection_already_in_progress = EALREADY, - connection_refused = ECONNREFUSED, - connection_reset = ECONNRESET, - cross_device_link = EXDEV, - destination_address_required = EDESTADDRREQ, - device_or_resource_busy = EBUSY, - directory_not_empty = ENOTEMPTY, - executable_format_error = ENOEXEC, - file_exists = EEXIST, - file_too_large = EFBIG, - filename_too_long = ENAMETOOLONG, - function_not_supported = ENOSYS, - host_unreachable = EHOSTUNREACH, - identifier_removed = EIDRM, - illegal_byte_sequence = EILSEQ, - inappropriate_io_control_operation = ENOTTY, - interrupted = EINTR, - invalid_argument = EINVAL, - invalid_seek = ESPIPE, - io_error = EIO, - is_a_directory = EISDIR, - message_size = EMSGSIZE, - network_down = ENETDOWN, - network_reset = ENETRESET, - network_unreachable = ENETUNREACH, - no_buffer_space = ENOBUFS, - no_child_process = ECHILD, - no_link = ENOLINK, - no_lock_available = ENOLCK, - no_message_available = ENODATA, - no_message = ENOMSG, - no_protocol_option = ENOPROTOOPT, - no_space_on_device = ENOSPC, - no_stream_resources = ENOSR, - no_such_device_or_address = ENXIO, - no_such_device = ENODEV, - no_such_file_or_directory = ENOENT, - no_such_process = ESRCH, - not_a_directory = ENOTDIR, - not_a_socket = ENOTSOCK, - not_a_stream = ENOSTR, - not_connected = ENOTCONN, - not_enough_memory = ENOMEM, - not_supported = ENOTSUP, - operation_canceled = ECANCELED, - operation_in_progress = EINPROGRESS, - operation_not_permitted = EPERM, - operation_not_supported = EOPNOTSUPP, - operation_would_block = EWOULDBLOCK, - owner_dead = EOWNERDEAD, - permission_denied = EACCES, - protocol_error = EPROTO, - protocol_not_supported = EPROTONOSUPPORT, - read_only_file_system = EROFS, - resource_deadlock_would_occur = EDEADLK, - resource_unavailable_try_again = EAGAIN, - result_out_of_range = ERANGE, - state_not_recoverable = ENOTRECOVERABLE, - stream_timeout = ETIME, - text_file_busy = ETXTBSY, - timed_out = ETIMEDOUT, - too_many_files_open_in_system = ENFILE, - too_many_files_open = EMFILE, - too_many_links = EMLINK, - too_many_symbolic_link_levels = ELOOP, - value_too_large = EOVERFLOW, - wrong_protocol_type = EPROTOTYPE - }; - - } // namespace errc - -# ifndef BOOST_SYSTEM_NO_DEPRECATED - namespace posix = errc; - namespace posix_error = errc; -# endif - - template<> struct is_error_condition_enum - { static const bool value = true; }; - - - // ----------------------------------------------------------------------// - - // Operating system specific interfaces --------------------------------// - - - // The interface is divided into general and system-specific portions to - // meet these requirements: - // - // * Code calling an operating system API can create an error_code with - // a single category (system_category), even for POSIX-like operating - // systems that return some POSIX errno values and some native errno - // values. This code should not have to pay the cost of distinguishing - // between categories, since it is not yet known if that is needed. - // - // * Users wishing to write system-specific code should be given enums for - // at least the common error cases. - // - // * System specific code should fail at compile time if moved to another - // operating system. - - // The system specific portions of the interface are located in headers - // with names reflecting the operating system. For example, - // - // - // - // - // - // These headers are effectively empty for compiles on operating systems - // where they are not applicable. - - // ----------------------------------------------------------------------// - - // class error_category ------------------------------------------------// - - class error_category : public noncopyable - { - public: - virtual ~error_category(){} - - virtual const char * name() const BOOST_SYSTEM_NOEXCEPT = 0; - virtual std::string message( int ev ) const = 0; - inline virtual error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; - inline virtual bool equivalent( int code, - const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT; - inline virtual bool equivalent( const error_code & code, - int condition ) const BOOST_SYSTEM_NOEXCEPT; - - bool operator==(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this == &rhs; } - bool operator!=(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this != &rhs; } - bool operator<( const error_category & rhs ) const BOOST_SYSTEM_NOEXCEPT - { - return std::less()( this, &rhs ); - } - }; - - // predefined error categories -----------------------------------------// - -# ifdef BOOST_ERROR_CODE_HEADER_ONLY - inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; - inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; -#else - BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; - BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; -#endif - // deprecated synonyms --------------------------------------------------// - -# ifndef BOOST_SYSTEM_NO_DEPRECATED - inline const error_category & get_system_category() { return system_category(); } - inline const error_category & get_generic_category() { return generic_category(); } - inline const error_category & get_posix_category() { return generic_category(); } - static const error_category & posix_category = generic_category(); - static const error_category & errno_ecat = generic_category(); - static const error_category & native_ecat = system_category(); -# endif - - // class error_condition -----------------------------------------------// - - // error_conditions are portable, error_codes are system or library specific - - class error_condition - { - public: - - // constructors: - error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {} - error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {} - - template - error_condition(ErrorConditionEnum e, - typename boost::enable_if >::type* = 0) BOOST_SYSTEM_NOEXCEPT - { - *this = make_error_condition(e); - } - - // modifiers: - - void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT - { - m_val = val; - m_cat = &cat; - } - - template - typename boost::enable_if, error_condition>::type & - operator=( ErrorConditionEnum val ) BOOST_SYSTEM_NOEXCEPT - { - *this = make_error_condition(val); - return *this; - } - - void clear() BOOST_SYSTEM_NOEXCEPT - { - m_val = 0; - m_cat = &generic_category(); - } - - // observers: - int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; } - const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; } - std::string message() const { return m_cat->message(value()); } - - typedef void (*unspecified_bool_type)(); - static void unspecified_bool_true() {} - - operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error - { - return m_val == 0 ? 0 : unspecified_bool_true; - } - - bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error - { - return m_val == 0; - } - - // relationals: - // the more symmetrical non-member syntax allows enum - // conversions work for both rhs and lhs. - inline friend bool operator==( const error_condition & lhs, - const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT - { - return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val; - } - - inline friend bool operator<( const error_condition & lhs, - const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT - // the more symmetrical non-member syntax allows enum - // conversions work for both rhs and lhs. - { - return lhs.m_cat < rhs.m_cat - || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); - } - - private: - int m_val; - const error_category * m_cat; - - }; - - // class error_code ----------------------------------------------------// - - // We want error_code to be a value type that can be copied without slicing - // and without requiring heap allocation, but we also want it to have - // polymorphic behavior based on the error category. This is achieved by - // abstract base class error_category supplying the polymorphic behavior, - // and error_code containing a pointer to an object of a type derived - // from error_category. - class error_code - { - public: - - // constructors: - error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {} - error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {} - - template - error_code(ErrorCodeEnum e, - typename boost::enable_if >::type* = 0) BOOST_SYSTEM_NOEXCEPT - { - *this = make_error_code(e); - } - - // modifiers: - void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT - { - m_val = val; - m_cat = &cat; - } - - template - typename boost::enable_if, error_code>::type & - operator=( ErrorCodeEnum val ) BOOST_SYSTEM_NOEXCEPT - { - *this = make_error_code(val); - return *this; - } - - void clear() BOOST_SYSTEM_NOEXCEPT - { - m_val = 0; - m_cat = &system_category(); - } - - // observers: - int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; } - const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; } - error_condition default_error_condition() const BOOST_SYSTEM_NOEXCEPT { return m_cat->default_error_condition(value()); } - std::string message() const { return m_cat->message(value()); } - - typedef void (*unspecified_bool_type)(); - static void unspecified_bool_true() {} - - operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error - { - return m_val == 0 ? 0 : unspecified_bool_true; - } - - bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error - { - return m_val == 0; - } - - // relationals: - inline friend bool operator==( const error_code & lhs, - const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT - // the more symmetrical non-member syntax allows enum - // conversions work for both rhs and lhs. - { - return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val; - } - - inline friend bool operator<( const error_code & lhs, - const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT - // the more symmetrical non-member syntax allows enum - // conversions work for both rhs and lhs. - { - return lhs.m_cat < rhs.m_cat - || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); - } - - private: - int m_val; - const error_category * m_cat; - - }; - - // predefined error_code object used as "throw on error" tag -# ifndef BOOST_SYSTEM_NO_DEPRECATED - BOOST_SYSTEM_DECL extern error_code throws; -# endif - - // Moving from a "throws" object to a "throws" function without breaking - // existing code is a bit of a problem. The workaround is to place the - // "throws" function in namespace boost rather than namespace boost::system. - - } // namespace system - - namespace detail { inline system::error_code * throws() { return 0; } } - // Misuse of the error_code object is turned into a noisy failure by - // poisoning the reference. This particular implementation doesn't - // produce warnings or errors from popular compilers, is very efficient - // (as determined by inspecting generated code), and does not suffer - // from order of initialization problems. In practice, it also seems - // cause user function error handling implementation errors to be detected - // very early in the development cycle. - - inline system::error_code & throws() - { return *detail::throws(); } - - namespace system - { - // non-member functions ------------------------------------------------// - - inline bool operator!=( const error_code & lhs, - const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT - { - return !(lhs == rhs); - } - - inline bool operator!=( const error_condition & lhs, - const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT - { - return !(lhs == rhs); - } - - inline bool operator==( const error_code & code, - const error_condition & condition ) BOOST_SYSTEM_NOEXCEPT - { - return code.category().equivalent( code.value(), condition ) - || condition.category().equivalent( code, condition.value() ); - } - - inline bool operator!=( const error_code & lhs, - const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT - { - return !(lhs == rhs); - } - - inline bool operator==( const error_condition & condition, - const error_code & code ) BOOST_SYSTEM_NOEXCEPT - { - return condition.category().equivalent( code, condition.value() ) - || code.category().equivalent( code.value(), condition ); - } - - inline bool operator!=( const error_condition & lhs, - const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT - { - return !(lhs == rhs); - } - - // TODO: both of these may move elsewhere, but the LWG hasn't spoken yet. - - template - inline std::basic_ostream& - operator<< (std::basic_ostream& os, error_code ec) - { - os << ec.category().name() << ':' << ec.value(); - return os; - } - - inline std::size_t hash_value( const error_code & ec ) - { - return static_cast(ec.value()) - + reinterpret_cast(&ec.category()); - } - - // make_* functions for errc::errc_t -----------------------------// - - namespace errc - { - // explicit conversion: - inline error_code make_error_code( errc_t e ) BOOST_SYSTEM_NOEXCEPT - { return error_code( e, generic_category() ); } - - // implicit conversion: - inline error_condition make_error_condition( errc_t e ) BOOST_SYSTEM_NOEXCEPT - { return error_condition( e, generic_category() ); } - } - - // error_category default implementation -------------------------------// - - error_condition error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT - { - return error_condition( ev, *this ); - } - - bool error_category::equivalent( int code, - const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT - { - return default_error_condition( code ) == condition; - } - - bool error_category::equivalent( const error_code & code, - int condition ) const BOOST_SYSTEM_NOEXCEPT - { - return *this == code.category() && code.value() == condition; - } - - } // namespace system -} // namespace boost - -#include // pops abi_prefix.hpp pragmas - -# ifdef BOOST_ERROR_CODE_HEADER_ONLY -# include -# endif - -#endif // BOOST_ERROR_CODE_HPP - - diff --git a/libraries/boost/boost/system/linux_error.hpp b/libraries/boost/boost/system/linux_error.hpp deleted file mode 100644 index 0eb22bf25..000000000 --- a/libraries/boost/boost/system/linux_error.hpp +++ /dev/null @@ -1,110 +0,0 @@ -// boost/system/linux_error.hpp -------------------------------------------// - -// Copyright Beman Dawes 2007 - -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See library home page at http://www.boost.org/libs/system - -#ifndef BOOST_LINUX_ERROR_HPP -#define BOOST_LINUX_ERROR_HPP - -// This header is effectively empty for compiles on operating systems where -// it is not applicable. - -#if defined(linux) || defined(__linux) || defined(__linux__) - -#include - -namespace boost -{ - namespace system - { - // To construct an error_code after a API error: - // - // error_code( errno, system_category() ) - - // User code should use the portable "posix" enums for POSIX errors; this - // allows such code to be portable to non-POSIX systems. For the non-POSIX - // errno values that POSIX-based systems typically provide in addition to - // POSIX values, use the system specific enums below. - - namespace linux_error - { - enum linux_errno - { - advertise_error = EADV, - bad_exchange = EBADE, - bad_file_number = EBADFD, - bad_font_format = EBFONT, - bad_request_code = EBADRQC, - bad_request_descriptor = EBADR, - bad_slot = EBADSLT, - channel_range = ECHRNG, - communication_error = ECOMM, - dot_dot_error = EDOTDOT, - exchange_full = EXFULL, - host_down = EHOSTDOWN, - is_named_file_type= EISNAM, - key_expired = EKEYEXPIRED, - key_rejected = EKEYREJECTED, - key_revoked = EKEYREVOKED, - level2_halt= EL2HLT, - level2_no_syncronized= EL2NSYNC, - level3_halt = EL3HLT, - level3_reset = EL3RST, - link_range = ELNRNG, - medium_type = EMEDIUMTYPE, - no_anode= ENOANO, - no_block_device = ENOTBLK, - no_csi = ENOCSI, - no_key = ENOKEY, - no_medium = ENOMEDIUM, - no_network = ENONET, - no_package = ENOPKG, - not_avail = ENAVAIL, - not_named_file_type= ENOTNAM, - not_recoverable = ENOTRECOVERABLE, - not_unique = ENOTUNIQ, - owner_dead = EOWNERDEAD, - protocol_no_supported = EPFNOSUPPORT, - remote_address_changed = EREMCHG, - remote_io_error = EREMOTEIO, - remote_object = EREMOTE, - restart_needed = ERESTART, - shared_library_access = ELIBACC, - shared_library_bad = ELIBBAD, - shared_library_execute = ELIBEXEC, - shared_library_max_ = ELIBMAX, - shared_library_section= ELIBSCN, - shutdown = ESHUTDOWN, - socket_type_not_supported = ESOCKTNOSUPPORT, - srmount_error = ESRMNT, - stream_pipe_error = ESTRPIPE, - too_many_references = ETOOMANYREFS, - too_many_users = EUSERS, - unattached = EUNATCH, - unclean = EUCLEAN - }; - } // namespace linux_error - -# ifndef BOOST_SYSTEM_NO_DEPRECATED - namespace Linux = linux_error; -# endif - - template<> struct is_error_code_enum - { static const bool value = true; }; - - namespace linux_error - { - inline error_code make_error_code( linux_errno e ) - { return error_code( e, system_category() ); } - } - - } // namespace system -} // namespace boost - -#endif // Linux - -#endif // BOOST_LINUX_ERROR_HPP diff --git a/libraries/boost/boost/system/system_error.hpp b/libraries/boost/boost/system/system_error.hpp deleted file mode 100644 index b306aae4b..000000000 --- a/libraries/boost/boost/system/system_error.hpp +++ /dev/null @@ -1,84 +0,0 @@ -// Boost system_error.hpp --------------------------------------------------// - -// Copyright Beman Dawes 2006 - -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_SYSTEM_ERROR_HPP -#define BOOST_SYSTEM_ERROR_HPP - -#include -#include -#include -#include - -namespace boost -{ - namespace system - { - // class system_error ------------------------------------------------------------// - - class BOOST_SYMBOL_VISIBLE system_error : public std::runtime_error - // BOOST_SYMBOL_VISIBLE is needed by GCC to ensure system_error thrown from a shared - // library can be caught. See svn.boost.org/trac/boost/ticket/3697 - { - public: - system_error( error_code ec ) - : std::runtime_error(""), m_error_code(ec) {} - - system_error( error_code ec, const std::string & what_arg ) - : std::runtime_error(what_arg), m_error_code(ec) {} - - system_error( error_code ec, const char* what_arg ) - : std::runtime_error(what_arg), m_error_code(ec) {} - - system_error( int ev, const error_category & ecat ) - : std::runtime_error(""), m_error_code(ev,ecat) {} - - system_error( int ev, const error_category & ecat, - const std::string & what_arg ) - : std::runtime_error(what_arg), m_error_code(ev,ecat) {} - - system_error( int ev, const error_category & ecat, - const char * what_arg ) - : std::runtime_error(what_arg), m_error_code(ev,ecat) {} - - virtual ~system_error() throw() {} - - const error_code & code() const throw() { return m_error_code; } - const char * what() const throw(); - - private: - error_code m_error_code; - mutable std::string m_what; - }; - - // implementation ------------------------------------------------------// - - inline const char * system_error::what() const throw() - // see http://www.boost.org/more/error_handling.html for lazy build rationale - { - if ( m_what.empty() ) - { -#ifndef BOOST_NO_EXCEPTIONS - try -#endif - { - m_what = this->std::runtime_error::what(); - if ( !m_what.empty() ) m_what += ": "; - m_what += m_error_code.message(); - } -#ifndef BOOST_NO_EXCEPTIONS - catch (...) { return std::runtime_error::what(); } -#endif - } - return m_what.c_str(); - } - - } // namespace system -} // namespace boost - -#endif // BOOST_SYSTEM_ERROR_HPP - - diff --git a/libraries/boost/boost/system/windows_error.hpp b/libraries/boost/boost/system/windows_error.hpp deleted file mode 100644 index 9d9d206c6..000000000 --- a/libraries/boost/boost/system/windows_error.hpp +++ /dev/null @@ -1,126 +0,0 @@ -// boost/system/windows_error.hpp ------------------------------------------// - -// Copyright Beman Dawes 2007 - -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See library home page at http://www.boost.org/libs/system - -#ifndef BOOST_WINDOWS_ERROR_HPP -#define BOOST_WINDOWS_ERROR_HPP - -// This header is effectively empty for compiles on operating systems where -// it is not applicable. - -#include - -#ifdef BOOST_WINDOWS_API - -#include - -// Neither MinGW or Cygwin versions of winerror.h work if used alone, so on -// either of those platforms include the full windows.h - -#if defined(__MINGW32__) || defined(__CYGWIN__) -#include -#else -#include -#endif - -namespace boost -{ - namespace system - { - - // Microsoft Windows ---------------------------------------------------// - - // To construct an error_code after a API error: - // - // error_code( ::GetLastError(), system_category() ) - - namespace windows_error - { - enum windows_error_code - { - success = 0, - // These names and values are based on Windows winerror.h - invalid_function = ERROR_INVALID_FUNCTION, - file_not_found = ERROR_FILE_NOT_FOUND, - path_not_found = ERROR_PATH_NOT_FOUND, - too_many_open_files = ERROR_TOO_MANY_OPEN_FILES, - access_denied = ERROR_ACCESS_DENIED, - invalid_handle = ERROR_INVALID_HANDLE, - arena_trashed = ERROR_ARENA_TRASHED, - not_enough_memory = ERROR_NOT_ENOUGH_MEMORY, - invalid_block = ERROR_INVALID_BLOCK, - bad_environment = ERROR_BAD_ENVIRONMENT, - bad_format = ERROR_BAD_FORMAT, - invalid_access = ERROR_INVALID_ACCESS, - outofmemory = ERROR_OUTOFMEMORY, - invalid_drive = ERROR_INVALID_DRIVE, - current_directory = ERROR_CURRENT_DIRECTORY, - not_same_device = ERROR_NOT_SAME_DEVICE, - no_more_files = ERROR_NO_MORE_FILES, - write_protect = ERROR_WRITE_PROTECT, - bad_unit = ERROR_BAD_UNIT, - not_ready = ERROR_NOT_READY, - bad_command = ERROR_BAD_COMMAND, - crc = ERROR_CRC, - bad_length = ERROR_BAD_LENGTH, - seek = ERROR_SEEK, - not_dos_disk = ERROR_NOT_DOS_DISK, - sector_not_found = ERROR_SECTOR_NOT_FOUND, - out_of_paper = ERROR_OUT_OF_PAPER, - write_fault = ERROR_WRITE_FAULT, - read_fault = ERROR_READ_FAULT, - gen_failure = ERROR_GEN_FAILURE, - sharing_violation = ERROR_SHARING_VIOLATION, - lock_violation = ERROR_LOCK_VIOLATION, - wrong_disk = ERROR_WRONG_DISK, - sharing_buffer_exceeded = ERROR_SHARING_BUFFER_EXCEEDED, - handle_eof = ERROR_HANDLE_EOF, - handle_disk_full= ERROR_HANDLE_DISK_FULL, - rem_not_list = ERROR_REM_NOT_LIST, - dup_name = ERROR_DUP_NAME, - bad_net_path = ERROR_BAD_NETPATH, - network_busy = ERROR_NETWORK_BUSY, - // ... - file_exists = ERROR_FILE_EXISTS, - cannot_make = ERROR_CANNOT_MAKE, - // ... - broken_pipe = ERROR_BROKEN_PIPE, - open_failed = ERROR_OPEN_FAILED, - buffer_overflow = ERROR_BUFFER_OVERFLOW, - disk_full= ERROR_DISK_FULL, - // ... - lock_failed = ERROR_LOCK_FAILED, - busy = ERROR_BUSY, - cancel_violation = ERROR_CANCEL_VIOLATION, - already_exists = ERROR_ALREADY_EXISTS - // ... - - // TODO: add more Windows errors - }; - - } // namespace windows - -# ifndef BOOST_SYSTEM_NO_DEPRECATED - namespace windows = windows_error; -# endif - - template<> struct is_error_code_enum - { static const bool value = true; }; - - namespace windows_error - { - inline error_code make_error_code( windows_error_code e ) - { return error_code( e, system_category() ); } - } - - } // namespace system -} // namespace boost - -#endif // BOOST_WINDOWS_API - -#endif // BOOST_WINDOWS_ERROR_HPP diff --git a/libraries/boost/boost/thread/barrier.hpp b/libraries/boost/boost/thread/barrier.hpp deleted file mode 100644 index 4c1b1b59a..000000000 --- a/libraries/boost/boost/thread/barrier.hpp +++ /dev/null @@ -1,255 +0,0 @@ -// Copyright (C) 2002-2003 -// David Moore, William E. Kempf -// Copyright (C) 2007-8 Anthony Williams -// (C) Copyright 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_BARRIER_JDM030602_HPP -#define BOOST_BARRIER_JDM030602_HPP - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace boost -{ - namespace thread_detail - { - typedef detail::nullary_function void_completion_function; - typedef detail::nullary_function size_completion_function; - - struct default_barrier_reseter - { - unsigned int size_; - default_barrier_reseter(unsigned int size) : - size_(size) - { - } - BOOST_THREAD_MOVABLE(default_barrier_reseter) - //BOOST_THREAD_COPYABLE_AND_MOVABLE(default_barrier_reseter) - - default_barrier_reseter(default_barrier_reseter const& other) BOOST_NOEXCEPT : - size_(other.size_) - { - } - default_barrier_reseter(BOOST_THREAD_RV_REF(default_barrier_reseter) other) BOOST_NOEXCEPT : - size_(BOOST_THREAD_RV(other).size_) - { - } - - unsigned int operator()() - { - return size_; - } - }; - - struct void_functor_barrier_reseter - { - unsigned int size_; - void_completion_function fct_; - template - void_functor_barrier_reseter(unsigned int size, BOOST_THREAD_RV_REF(F) funct) - : size_(size), fct_(boost::move(funct)) - {} - template - void_functor_barrier_reseter(unsigned int size, F& funct) - : size_(size), fct_(funct) - {} - - BOOST_THREAD_MOVABLE(void_functor_barrier_reseter) - //BOOST_THREAD_COPYABLE_AND_MOVABLE(void_functor_barrier_reseter) - - void_functor_barrier_reseter(void_functor_barrier_reseter const& other) BOOST_NOEXCEPT : - size_(other.size_), fct_(other.fct_) - { - } - void_functor_barrier_reseter(BOOST_THREAD_RV_REF(void_functor_barrier_reseter) other) BOOST_NOEXCEPT : - size_(BOOST_THREAD_RV(other).size_), fct_(BOOST_THREAD_RV(other).fct_) - //size_(BOOST_THREAD_RV(other).size_), fct_(boost::move(BOOST_THREAD_RV(other).fct_)) - { - } - - unsigned int operator()() - { - fct_(); - return size_; - } - }; - struct void_fct_ptr_barrier_reseter - { - unsigned int size_; - void(*fct_)(); - void_fct_ptr_barrier_reseter(unsigned int size, void(*funct)()) : - size_(size), fct_(funct) - { - } - BOOST_THREAD_MOVABLE(void_fct_ptr_barrier_reseter) - //BOOST_THREAD_COPYABLE_AND_MOVABLE(void_fct_ptr_barrier_reseter) - - void_fct_ptr_barrier_reseter(void_fct_ptr_barrier_reseter const& other) BOOST_NOEXCEPT : - size_(other.size_), fct_(other.fct_) - { - } - void_fct_ptr_barrier_reseter(BOOST_THREAD_RV_REF(void_fct_ptr_barrier_reseter) other) BOOST_NOEXCEPT : - size_(BOOST_THREAD_RV(other).size_), fct_(BOOST_THREAD_RV(other).fct_) - { - } - unsigned int operator()() - { - fct_(); - return size_; - } - }; - } - //BOOST_THREAD_DCL_MOVABLE(thread_detail::default_barrier_reseter) - //BOOST_THREAD_DCL_MOVABLE(thread_detail::void_functor_barrier_reseter) - //BOOST_THREAD_DCL_MOVABLE(thread_detail::void_fct_ptr_barrier_reseter) - - class barrier - { - static inline unsigned int check_counter(unsigned int count) - { - if (count == 0) boost::throw_exception( - thread_exception(system::errc::invalid_argument, "barrier constructor: count cannot be zero.")); - return count; - } - struct dummy - { - }; - - public: - BOOST_THREAD_NO_COPYABLE( barrier) - - explicit barrier(unsigned int count) : - m_count(check_counter(count)), m_generation(0), fct_(BOOST_THREAD_MAKE_RV_REF(thread_detail::default_barrier_reseter(count))) - { - } - - template - barrier( - unsigned int count, - BOOST_THREAD_RV_REF(F) funct, - typename enable_if< - typename is_void::type>::type, dummy* - >::type=0 - ) - : m_count(check_counter(count)), - m_generation(0), - fct_(BOOST_THREAD_MAKE_RV_REF(thread_detail::void_functor_barrier_reseter(count, - boost::move(funct))) - ) - { - } - template - barrier( - unsigned int count, - F &funct, - typename enable_if< - typename is_void::type>::type, dummy* - >::type=0 - ) - : m_count(check_counter(count)), - m_generation(0), - fct_(BOOST_THREAD_MAKE_RV_REF(thread_detail::void_functor_barrier_reseter(count, - funct)) - ) - { - } - - template - barrier( - unsigned int count, - BOOST_THREAD_RV_REF(F) funct, - typename enable_if< - typename is_same::type, unsigned int>::type, dummy* - >::type=0 - ) - : m_count(check_counter(count)), - m_generation(0), - fct_(boost::move(funct)) - { - } - template - barrier( - unsigned int count, - F& funct, - typename enable_if< - typename is_same::type, unsigned int>::type, dummy* - >::type=0 - ) - : m_count(check_counter(count)), - m_generation(0), - fct_(funct) - { - } - - barrier(unsigned int count, void(*funct)()) : - m_count(check_counter(count)), m_generation(0), - fct_(funct - ? BOOST_THREAD_MAKE_RV_REF(thread_detail::size_completion_function(BOOST_THREAD_MAKE_RV_REF(thread_detail::void_fct_ptr_barrier_reseter(count, funct)))) - : BOOST_THREAD_MAKE_RV_REF(thread_detail::size_completion_function(BOOST_THREAD_MAKE_RV_REF(thread_detail::default_barrier_reseter(count)))) - ) - { - } - barrier(unsigned int count, unsigned int(*funct)()) : - m_count(check_counter(count)), m_generation(0), - fct_(funct - ? BOOST_THREAD_MAKE_RV_REF(thread_detail::size_completion_function(funct)) - : BOOST_THREAD_MAKE_RV_REF(thread_detail::size_completion_function(BOOST_THREAD_MAKE_RV_REF(thread_detail::default_barrier_reseter(count)))) - ) - { - } - - bool wait() - { - boost::unique_lock < boost::mutex > lock(m_mutex); - unsigned int gen = m_generation; - - if (--m_count == 0) - { - m_generation++; - m_count = static_cast(fct_()); - BOOST_ASSERT(m_count != 0); - lock.unlock(); - m_cond.notify_all(); - return true; - } - - while (gen == m_generation) - m_cond.wait(lock); - return false; - } - - void count_down_and_wait() - { - wait(); - } - - private: - mutex m_mutex; - condition_variable m_cond; - unsigned int m_count; - unsigned int m_generation; - thread_detail::size_completion_function fct_; - }; - -} // namespace boost - -#include - -#endif diff --git a/libraries/boost/boost/thread/caller_context.hpp b/libraries/boost/boost/thread/caller_context.hpp deleted file mode 100644 index dc50a05f9..000000000 --- a/libraries/boost/boost/thread/caller_context.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// (C) Copyright 2013,2015 Vicente J. Botet Escriba -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -#ifndef BOOST_THREAD_CALL_CONTEXT_HPP -#define BOOST_THREAD_CALL_CONTEXT_HPP - -#include -#if defined BOOST_THREAD_USES_LOG_THREAD_ID -#include -#endif -#include -#include -#include - -#include - -namespace boost -{ - - struct caller_context_t - { - const char * filename; - unsigned lineno; - const char * func; - caller_context_t(const char * filename, unsigned lineno, const char * func) : - filename(filename), lineno(lineno), func(func) - { - } - }; - -#define BOOST_CONTEXTOF boost::caller_context_t(__FILE__, __LINE__, BOOST_CURRENT_FUNCTION) - - template - OStream& operator<<(OStream& os, caller_context_t const& ctx) - { -#if defined BOOST_THREAD_USES_LOG_THREAD_ID - { - io::ios_flags_saver ifs( os ); - os << std::left << std::setw(14) << boost::this_thread::get_id() << " "; - } -#endif - { - io::ios_flags_saver ifs(os); - os << std::setw(50) << ctx.filename << "[" - << std::setw(4) << std::right << std::dec<< ctx.lineno << "] "; -#if defined BOOST_THREAD_USES_LOG_CURRENT_FUNCTION - os << ctx.func << " " ; -#endif - } - return os; - } -} - -#include - -#endif // header diff --git a/libraries/boost/boost/thread/completion_latch.hpp b/libraries/boost/boost/thread/completion_latch.hpp deleted file mode 100644 index 03f4e8962..000000000 --- a/libraries/boost/boost/thread/completion_latch.hpp +++ /dev/null @@ -1,225 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2013 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_COMPLETION_LATCH_HPP -#define BOOST_THREAD_COMPLETION_LATCH_HPP - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -//#include -#include - -#include - -namespace boost -{ - namespace thread_detail - { - void noop() - { - } - } - class completion_latch - { - public: - /// the implementation defined completion function type - //typedef detail::nullary_function completion_function; - typedef csbl::function completion_function; - /// noop completion function factory - static completion_function noop() - { - return completion_function(&thread_detail::noop); - } - - private: - struct around_wait; - friend struct around_wait; - struct around_wait - { - completion_latch &that_; - boost::unique_lock &lk_; - around_wait(completion_latch &that, boost::unique_lock &lk) - : that_(that), lk_(lk) - { - that_.leavers_.cond_.wait(lk, detail::counter_is_zero(that_.leavers_)); - that_.waiters_.inc_and_notify_all(); - that_.leavers_.cond_.wait(lk, detail::counter_is_not_zero(that_.leavers_)); - } - ~around_wait() - { - that_.waiters_.dec_and_notify_all(); - } - }; - - bool count_down(unique_lock &lk) - { - BOOST_ASSERT(count_ > 0); - if (--count_ == 0) - { - waiters_.cond_.wait(lk, detail::counter_is_not_zero(waiters_)); - leavers_.assign_and_notify_all(waiters_); - count_.cond_.notify_all(); - waiters_.cond_.wait(lk, detail::counter_is_zero(waiters_)); - leavers_.assign_and_notify_all(0); - lk.unlock(); - funct_(); - return true; - } - return false; - } - - public: - BOOST_THREAD_NO_COPYABLE( completion_latch ) - - /// Constructs a latch with a given count. - completion_latch(std::size_t count) : - count_(count), funct_(noop()), waiters_(0), leavers_(0) - { - } - - /// Constructs a latch with a given count and a completion function. - template - completion_latch(std::size_t count, BOOST_THREAD_RV_REF(F) funct) : - count_(count), - funct_(boost::move(funct)), - waiters_(0), - leavers_(0) - { - } - completion_latch(std::size_t count, void(*funct)()) : - count_(count), funct_(funct), waiters_(0), leavers_(0) - { - } - - /// - ~completion_latch() - { - } - - /// Blocks until the latch has counted down to zero. - void wait() - { - boost::unique_lock lk(mutex_); - around_wait aw(*this, lk); - count_.cond_.wait(lk, detail::counter_is_zero(count_)); - } - - /// @return true if the internal counter is already 0, false otherwise - bool try_wait() - { - boost::unique_lock lk(mutex_); - around_wait aw(*this, lk); - return (count_ == 0); - } - - /// try to wait for a specified amount of time - /// @return whether there is a timeout or not. - template - cv_status wait_for(const chrono::duration& rel_time) - { - boost::unique_lock lk(mutex_); - around_wait aw(*this, lk); - return count_.cond_.wait_for(lk, rel_time, detail::counter_is_zero(count_)) - ? cv_status::no_timeout - : cv_status::timeout; - } - - /// try to wait until the specified time_point is reached - /// @return whether there is a timeout or not. - template - cv_status wait_until(const chrono::time_point& abs_time) - { - boost::unique_lock lk(mutex_); - around_wait aw(*this, lk); - return count_.cond_.wait_until(lk, abs_time, detail::counter_is_zero(count_)) - ? cv_status::no_timeout - : cv_status::timeout; - } - - /// Decrement the count and notify anyone waiting if we reach zero. - /// @Requires count must be greater than 0 - void count_down() - { - unique_lock lk(mutex_); - count_down(lk); - } - void signal() - { - count_down(); - } - - /// Decrement the count and notify anyone waiting if we reach zero. - /// Blocks until the latch has counted down to zero. - /// @Requires count must be greater than 0 - void count_down_and_wait() - { - boost::unique_lock lk(mutex_); - if (count_down(lk)) - { - return; - } - around_wait aw(*this, lk); - count_.cond_.wait(lk, detail::counter_is_zero(count_)); - } - void sync() - { - count_down_and_wait(); - } - - /// Reset the counter - /// #Requires This method may only be invoked when there are no other threads currently inside the count_down_and_wait() method. - void reset(std::size_t count) - { - boost::lock_guard lk(mutex_); - //BOOST_ASSERT(count_ == 0); - count_ = count; - } - - /// Resets the latch with the new completion function. - /// The next time the internal count reaches 0, this function will be invoked. - /// This completion function may only be invoked when there are no other threads - /// currently inside the count_down and wait related functions. - /// It may also be invoked from within the registered completion function. - /// @Returns the old completion function if any or noop if - -#ifdef BOOST_NO_CXX11_HDR_FUNCTIONAL - template - completion_function then(BOOST_THREAD_RV_REF(F) funct) - { - boost::lock_guard lk(mutex_); - completion_function tmp(funct_); - funct_ = boost::move(funct); - return tmp; - } -#endif - completion_function then(void(*funct)()) - { - boost::lock_guard lk(mutex_); - completion_function tmp(funct_); - funct_ = completion_function(funct); - return tmp; - } - - private: - mutex mutex_; - detail::counter count_; - completion_function funct_; - detail::counter waiters_; - detail::counter leavers_; - }; - -} // namespace boost - -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/deque_adaptor.hpp b/libraries/boost/boost/thread/concurrent_queues/deque_adaptor.hpp deleted file mode 100644 index a8f45f863..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/deque_adaptor.hpp +++ /dev/null @@ -1,209 +0,0 @@ -#ifndef BOOST_THREAD_CONCURRENT_DEQUE_ADAPTOR_HPP -#define BOOST_THREAD_CONCURRENT_DEQUE_ADAPTOR_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace concurrent -{ -namespace detail -{ - - template - class deque_adaptor_copyable_only : - public boost::deque_base - { - Queue queue; - public: - typedef typename Queue::value_type value_type; - typedef typename Queue::size_type size_type; - - // Constructors/Assignment/Destructors - deque_adaptor_copyable_only() {} - - // Observers - bool empty() const { return queue.empty(); } - bool full() const { return queue.full(); } - size_type size() const { return queue.size(); } - bool closed() const { return queue.closed(); } - - // Modifiers - void close() { queue.close(); } - - void push_back(const value_type& x) { queue.push_back(x); } - - void pull_front(value_type& x) { queue.pull_front(x); }; - value_type pull_front() { return queue.pull_front(); } - - queue_op_status try_push_back(const value_type& x) { return queue.try_push_back(x); } - queue_op_status try_pull_front(value_type& x) { return queue.try_pull_front(x); } - - queue_op_status nonblocking_push_back(const value_type& x) { return queue.nonblocking_push_back(x); } - queue_op_status nonblocking_pull_front(value_type& x) { return queue.nonblocking_pull_front(x); } - - queue_op_status wait_push_back(const value_type& x) { return queue.wait_push_back(x); } - queue_op_status wait_pull_front(value_type& x) { return queue.wait_pull_front(x); } - - }; - template - class deque_adaptor_movable_only : - public boost::deque_base - { - Queue queue; - public: - typedef typename Queue::value_type value_type; - typedef typename Queue::size_type size_type; - - // Constructors/Assignment/Destructors - - deque_adaptor_movable_only() {} - - // Observers - bool empty() const { return queue.empty(); } - bool full() const { return queue.full(); } - size_type size() const { return queue.size(); } - bool closed() const { return queue.closed(); } - - // Modifiers - void close() { queue.close(); } - - - void pull_front(value_type& x) { queue.pull_front(x); }; - // enable_if is_nothrow_copy_movable - value_type pull_front() { return queue.pull_front(); } - - queue_op_status try_pull_front(value_type& x) { return queue.try_pull_front(x); } - - queue_op_status nonblocking_pull_front(value_type& x) { return queue.nonblocking_pull_front(x); } - - queue_op_status wait_pull_front(value_type& x) { return queue.wait_pull_front(x); } - - void push_back(BOOST_THREAD_RV_REF(value_type) x) { queue.push_back(boost::move(x)); } - queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.try_push_back(boost::move(x)); } - queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.nonblocking_push_back(boost::move(x)); } - queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.wait_push_back(boost::move(x)); } - }; - - template - class deque_adaptor_copyable_and_movable : - public boost::deque_base - { - Queue queue; - public: - typedef typename Queue::value_type value_type; - typedef typename Queue::size_type size_type; - - // Constructors/Assignment/Destructors - - deque_adaptor_copyable_and_movable() {} - - // Observers - bool empty() const { return queue.empty(); } - bool full() const { return queue.full(); } - size_type size() const { return queue.size(); } - bool closed() const { return queue.closed(); } - - // Modifiers - void close() { queue.close(); } - - - void push_back(const value_type& x) { queue.push_back(x); } - - void pull_front(value_type& x) { queue.pull_front(x); }; - // enable_if is_nothrow_copy_movable - value_type pull_front() { return queue.pull_front(); } - - queue_op_status try_push_back(const value_type& x) { return queue.try_push_back(x); } - queue_op_status try_pull_front(value_type& x) { return queue.try_pull_front(x); } - - queue_op_status nonblocking_push_back(const value_type& x) { return queue.nonblocking_push_back(x); } - queue_op_status nonblocking_pull_front(value_type& x) { return queue.nonblocking_pull_front(x); } - - queue_op_status wait_push_back(const value_type& x) { return queue.wait_push_back(x); } - queue_op_status wait_pull_front(value_type& x) { return queue.wait_pull_front(x); } - - void push_back(BOOST_THREAD_RV_REF(value_type) x) { queue.push_back(boost::move(x)); } - queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.try_push_back(boost::move(x)); } - queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.nonblocking_push_back(boost::move(x)); } - queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) { return queue.wait_push_back(boost::move(x)); } - }; - - - template ::value, - bool Movable = true -#else - bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, - bool Movable = std::is_move_constructible::value && std::is_move_assignable::value -#endif // __GNUC__ -#elif defined _MSC_VER -#if _MSC_VER < 1700 - bool Copyable = is_copy_constructible::value, - bool Movable = true -#else - bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, - bool Movable = std::is_move_constructible::value && std::is_move_assignable::value -#endif // _MSC_VER -#else - bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, - bool Movable = std::is_move_constructible::value && std::is_move_assignable::value -#endif -#else - bool Copyable = is_copy_constructible::value, - bool Movable = has_move_emulation_enabled::value -#endif - > - struct deque_adaptor; - - template - struct deque_adaptor { - typedef deque_adaptor_copyable_and_movable type; - }; - template - struct deque_adaptor { - typedef deque_adaptor_copyable_only type; - }; - template - struct deque_adaptor { - typedef deque_adaptor_movable_only type; - }; - -} - - template - class deque_adaptor : - public detail::deque_adaptor::type - { - public: - typedef typename Queue::value_type value_type; - typedef typename Queue::size_type size_type; - // Constructors/Assignment/Destructors - virtual ~deque_adaptor() {}; - }; -} -using concurrent::deque_adaptor; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/deque_base.hpp b/libraries/boost/boost/thread/concurrent_queues/deque_base.hpp deleted file mode 100644 index f76e8a761..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/deque_base.hpp +++ /dev/null @@ -1,202 +0,0 @@ -#ifndef BOOST_THREAD_CONCURRENT_DEQUE_BASE_HPP -#define BOOST_THREAD_CONCURRENT_DEQUE_BASE_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include - - -#include - -namespace boost -{ -namespace concurrent -{ -namespace detail -{ - - template - class deque_base_copyable_only - { - public: - typedef ValueType value_type; - typedef SizeType size_type; - - // Constructors/Assignment/Destructors - virtual ~deque_base_copyable_only() {}; - - // Observers - virtual bool empty() const = 0; - virtual bool full() const = 0; - virtual size_type size() const = 0; - virtual bool closed() const = 0; - - // Modifiers - virtual void close() = 0; - - virtual void push_back(const value_type& x) = 0; - - virtual void pull_front(value_type&) = 0; - virtual value_type pull_front() = 0; - - virtual queue_op_status try_push_back(const value_type& x) = 0; - virtual queue_op_status try_pull_front(value_type&) = 0; - - virtual queue_op_status nonblocking_push_back(const value_type& x) = 0; - virtual queue_op_status nonblocking_pull_front(value_type&) = 0; - - virtual queue_op_status wait_push_back(const value_type& x) = 0; - virtual queue_op_status wait_pull_front(value_type& elem) = 0; - - }; - - template - class deque_base_movable_only - { - public: - typedef ValueType value_type; - typedef SizeType size_type; - // Constructors/Assignment/Destructors - virtual ~deque_base_movable_only() {}; - - // Observers - virtual bool empty() const = 0; - virtual bool full() const = 0; - virtual size_type size() const = 0; - virtual bool closed() const = 0; - - // Modifiers - virtual void close() = 0; - - virtual void pull_front(value_type&) = 0; - // enable_if is_nothrow_movable - virtual value_type pull_front() = 0; - - virtual queue_op_status try_pull_front(value_type&) = 0; - - virtual queue_op_status nonblocking_pull_front(value_type&) = 0; - - virtual queue_op_status wait_pull_front(value_type& elem) = 0; - - virtual void push_back(BOOST_THREAD_RV_REF(value_type) x) = 0; - virtual queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0; - virtual queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0; - virtual queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0; - }; - - - template - class deque_base_copyable_and_movable - { - public: - typedef ValueType value_type; - typedef SizeType size_type; - // Constructors/Assignment/Destructors - virtual ~deque_base_copyable_and_movable() {}; - - - // Observers - virtual bool empty() const = 0; - virtual bool full() const = 0; - virtual size_type size() const = 0; - virtual bool closed() const = 0; - - // Modifiers - virtual void close() = 0; - - virtual void push_back(const value_type& x) = 0; - - virtual void pull_front(value_type&) = 0; - // enable_if is_nothrow_copy_movable - virtual value_type pull_front() = 0; - - virtual queue_op_status try_push_back(const value_type& x) = 0; - virtual queue_op_status try_pull_front(value_type&) = 0; - - virtual queue_op_status nonblocking_push_back(const value_type& x) = 0; - virtual queue_op_status nonblocking_pull_front(value_type&) = 0; - - virtual queue_op_status wait_push_back(const value_type& x) = 0; - virtual queue_op_status wait_pull_front(value_type& elem) = 0; - - virtual void push_back(BOOST_THREAD_RV_REF(value_type) x) = 0; - virtual queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0; - virtual queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0; - virtual queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0; - }; - - template ::value, - bool Movable = true -#else - bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, - bool Movable = std::is_move_constructible::value && std::is_move_assignable::value -#endif // __GNUC__ -#elif defined _MSC_VER -#if _MSC_VER < 1700 - bool Copyable = is_copy_constructible::value, - bool Movable = true -#else - bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, - bool Movable = std::is_move_constructible::value && std::is_move_assignable::value -#endif // _MSC_VER -#else - bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, - bool Movable = std::is_move_constructible::value && std::is_move_assignable::value -#endif -#else - bool Copyable = is_copy_constructible::value, - bool Movable = has_move_emulation_enabled::value -#endif - > - struct deque_base; - - template - struct deque_base { - typedef deque_base_copyable_and_movable type; - }; - template - struct deque_base { - typedef deque_base_copyable_only type; - }; - template - struct deque_base { - typedef deque_base_movable_only type; - }; - -} - - template - class deque_base : - public detail::deque_base::type - { - public: - typedef ValueType value_type; - typedef SizeType size_type; - // Constructors/Assignment/Destructors - virtual ~deque_base() {}; - }; - -} -using concurrent::deque_base; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/deque_views.hpp b/libraries/boost/boost/thread/concurrent_queues/deque_views.hpp deleted file mode 100644 index 5715fb88c..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/deque_views.hpp +++ /dev/null @@ -1,165 +0,0 @@ -#ifndef BOOST_THREAD_QUEUE_VIEWS_HPP -#define BOOST_THREAD_QUEUE_VIEWS_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace concurrent -{ - - template - class deque_back_view - { - Queue* queue; - public: - typedef typename Queue::value_type value_type; - typedef typename Queue::size_type size_type; - - // Constructors/Assignment/Destructors - deque_back_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {} - - // Observers - bool empty() const { return queue->empty(); } - bool full() const { return queue->full(); } - size_type size() const { return queue->size(); } - bool closed() const { return queue->closed(); } - - // Modifiers - void close() { queue->close(); } - - void push(const value_type& x) { queue->push_back(x); } - - void pull(value_type& x) { queue->pull_back(x); } - // enable_if is_nothrow_copy_movable - value_type pull() { return queue->pull_back(); } - - queue_op_status try_push(const value_type& x) { return queue->try_push_back(x); } - - queue_op_status try_pull(value_type& x) { return queue->try_pull_back(x); } - - queue_op_status nonblocking_push(const value_type& x) { return queue->nonblocking_push_back(x); } - - queue_op_status nonblocking_pull(value_type& x) { return queue->nonblocking_pull_back(x); } - - queue_op_status wait_push(const value_type& x) { return queue->wait_push_back(x); } - queue_op_status wait_pull(value_type& x) { return queue->wait_pull_back(x); } - - void push(BOOST_THREAD_RV_REF(value_type) x) { queue->push_back(boost::move(x)); } - queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->try_push_back(boost::move(x)); } - queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->nonblocking_push_back(boost::move(x)); } - queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->wait_push_back(boost::move(x)); } - }; - - template - class deque_front_view - { - Queue* queue; - public: - typedef typename Queue::value_type value_type; - typedef typename Queue::size_type size_type; - - // Constructors/Assignment/Destructors - deque_front_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {} - - // Observers - bool empty() const { return queue->empty(); } - bool full() const { return queue->full(); } - size_type size() const { return queue->size(); } - bool closed() const { return queue->closed(); } - - // Modifiers - void close() { queue->close(); } - - void push(const value_type& x) { queue->push_front(x); } - - void pull(value_type& x) { queue->pull_front(x); }; - // enable_if is_nothrow_copy_movable - value_type pull() { return queue->pull_front(); } - - queue_op_status try_push(const value_type& x) { return queue->try_push_front(x); } - - queue_op_status try_pull(value_type& x) { return queue->try_pull_front(x); } - - queue_op_status nonblocking_push(const value_type& x) { return queue->nonblocking_push_front(x); } - - queue_op_status nonblocking_pull(value_type& x) { return queue->nonblocking_pull_front(x); } - - queue_op_status wait_push(const value_type& x) { return queue->wait_push_front(x); } - queue_op_status wait_pull(value_type& x) { return queue->wait_pull_front(x); } - void push(BOOST_THREAD_RV_REF(value_type) x) { queue->push_front(forward(x)); } - queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->try_push_front(forward(x)); } - queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->nonblocking_push_front(forward(x)); } - queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->wait_push_front(forward(x)); } - - }; - -#if ! defined BOOST_NO_CXX11_TEMPLATE_ALIASES - - template - using deque_back = deque_back_view > ; - template - using deque_front = deque_front_view > ; - -#else - - template - struct deque_back : deque_back_view > - { - typedef deque_back_view > base_type; - deque_back(deque_base& q) BOOST_NOEXCEPT : base_type(q) {} - }; - template - struct deque_front : deque_front_view > - { - typedef deque_front_view > base_type; - deque_front(deque_base& q) BOOST_NOEXCEPT : base_type(q) {} - - }; - -#endif - -// template -// deque_back_view back(Queue & q) { return deque_back_view(q); } -// template -// deque_front_view front(Queue & q) { return deque_front_view(q); } -//#if 0 -// template -// deque_back back(deque_base & q) { return deque_back(q); } -// template -// deque_front front(deque_base & q) { return deque_front(q); } -//#else -// template -// typename deque_back::type back(deque_base & q) { return typename deque_back::type(q); } -// template -// typename deque_front::type front(deque_base & q) { return typename deque_front::type(q); } -//#endif -} - -using concurrent::deque_back_view; -using concurrent::deque_front_view; -using concurrent::deque_back; -using concurrent::deque_front; -//using concurrent::back; -//using concurrent::front; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/detail/sync_deque_base.hpp b/libraries/boost/boost/thread/concurrent_queues/detail/sync_deque_base.hpp deleted file mode 100644 index 877e1e2eb..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/detail/sync_deque_base.hpp +++ /dev/null @@ -1,223 +0,0 @@ -#ifndef BOOST_THREAD_CONCURRENT_QUEUES_DETAIL_SYNC_DEQUE_BASE_HPP -#define BOOST_THREAD_CONCURRENT_QUEUES_DETAIL_SYNC_DEQUE_BASE_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2013-2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace concurrent -{ -namespace detail -{ - - template - class sync_deque_base - { - public: - typedef ValueType value_type; - typedef Queue underlying_queue_type; - typedef typename Queue::size_type size_type; - typedef queue_op_status op_status; - - typedef typename chrono::steady_clock clock; - typedef typename clock::duration duration; - typedef typename clock::time_point time_point; - - // Constructors/Assignment/Destructors - BOOST_THREAD_NO_COPYABLE(sync_deque_base) - inline sync_deque_base(); - //template - //inline explicit sync_deque(Range range); - inline ~sync_deque_base(); - - // Observers - inline bool empty() const; - inline bool full() const; - inline size_type size() const; - inline bool closed() const; - - // Modifiers - inline void close(); - - inline underlying_queue_type underlying_queue() { - lock_guard lk(mtx_); - return boost::move(data_); - } - - protected: - mutable mutex mtx_; - condition_variable not_empty_; - underlying_queue_type data_; - bool closed_; - - inline bool empty(unique_lock& ) const BOOST_NOEXCEPT - { - return data_.empty(); - } - inline bool empty(lock_guard& ) const BOOST_NOEXCEPT - { - return data_.empty(); - } - - inline size_type size(lock_guard& ) const BOOST_NOEXCEPT - { - return data_.size(); - } - inline bool closed(unique_lock& lk) const; - inline bool closed(lock_guard& lk) const; - - inline void throw_if_closed(unique_lock&); - inline void throw_if_closed(lock_guard&); - - inline void wait_until_not_empty(unique_lock& lk); - inline bool wait_until_not_empty_or_closed(unique_lock& lk); - inline queue_op_status wait_until_not_empty_until(unique_lock& lk, time_point const&); - - inline void notify_not_empty_if_needed(unique_lock& ) - { - not_empty_.notify_one(); - } - inline void notify_not_empty_if_needed(lock_guard& ) - { - not_empty_.notify_one(); - } - - }; - - template - sync_deque_base::sync_deque_base() : - data_(), closed_(false) - { - BOOST_ASSERT(data_.empty()); - } - - template - sync_deque_base::~sync_deque_base() - { - } - - template - void sync_deque_base::close() - { - { - lock_guard lk(mtx_); - closed_ = true; - } - not_empty_.notify_all(); - } - - template - bool sync_deque_base::closed() const - { - lock_guard lk(mtx_); - return closed(lk); - } - template - bool sync_deque_base::closed(unique_lock&) const - { - return closed_; - } - template - bool sync_deque_base::closed(lock_guard&) const - { - return closed_; - } - - template - bool sync_deque_base::empty() const - { - lock_guard lk(mtx_); - return empty(lk); - } - template - bool sync_deque_base::full() const - { - return false; - } - - template - typename sync_deque_base::size_type sync_deque_base::size() const - { - lock_guard lk(mtx_); - return size(lk); - } - - template - void sync_deque_base::throw_if_closed(unique_lock& lk) - { - if (closed(lk)) - { - BOOST_THROW_EXCEPTION( sync_deque_is_closed() ); - } - } - template - void sync_deque_base::throw_if_closed(lock_guard& lk) - { - if (closed(lk)) - { - BOOST_THROW_EXCEPTION( sync_deque_is_closed() ); - } - } - - template - void sync_deque_base::wait_until_not_empty(unique_lock& lk) - { - for (;;) - { - if (! empty(lk)) break; - throw_if_closed(lk); - not_empty_.wait(lk); - } - } - template - bool sync_deque_base::wait_until_not_empty_or_closed(unique_lock& lk) - { - for (;;) - { - if (! empty(lk)) break; - if (closed(lk)) return true; - not_empty_.wait(lk); - } - return false; - } - - template - queue_op_status sync_deque_base::wait_until_not_empty_until(unique_lock& lk, time_point const&tp) - { - for (;;) - { - if (! empty(lk)) return queue_op_status::success; - throw_if_closed(lk); - if (not_empty_.wait_until(lk, tp) == cv_status::timeout ) return queue_op_status::timeout; - } - } - - -} // detail -} // concurrent -} // boost - -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/detail/sync_queue_base.hpp b/libraries/boost/boost/thread/concurrent_queues/detail/sync_queue_base.hpp deleted file mode 100644 index 653e273f8..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/detail/sync_queue_base.hpp +++ /dev/null @@ -1,223 +0,0 @@ -#ifndef BOOST_THREAD_CONCURRENT_QUEUES_DETAIL_SYNC_QUEUE_BASE_HPP -#define BOOST_THREAD_CONCURRENT_QUEUES_DETAIL_SYNC_QUEUE_BASE_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2013-2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace concurrent -{ -namespace detail -{ - - template - class sync_queue_base - { - public: - typedef ValueType value_type; - typedef Queue underlying_queue_type; - typedef typename Queue::size_type size_type; - typedef queue_op_status op_status; - - typedef typename chrono::steady_clock clock; - typedef typename clock::duration duration; - typedef typename clock::time_point time_point; - - // Constructors/Assignment/Destructors - BOOST_THREAD_NO_COPYABLE(sync_queue_base) - inline sync_queue_base(); - //template - //inline explicit sync_queue(Range range); - inline ~sync_queue_base(); - - // Observers - inline bool empty() const; - inline bool full() const; - inline size_type size() const; - inline bool closed() const; - - // Modifiers - inline void close(); - - inline underlying_queue_type underlying_queue() { - lock_guard lk(mtx_); - return boost::move(data_); - } - - protected: - mutable mutex mtx_; - condition_variable not_empty_; - underlying_queue_type data_; - bool closed_; - - inline bool empty(unique_lock& ) const BOOST_NOEXCEPT - { - return data_.empty(); - } - inline bool empty(lock_guard& ) const BOOST_NOEXCEPT - { - return data_.empty(); - } - - inline size_type size(lock_guard& ) const BOOST_NOEXCEPT - { - return data_.size(); - } - inline bool closed(unique_lock& lk) const; - inline bool closed(lock_guard& lk) const; - - inline void throw_if_closed(unique_lock&); - inline void throw_if_closed(lock_guard&); - - inline void wait_until_not_empty(unique_lock& lk); - inline bool wait_until_not_empty_or_closed(unique_lock& lk); - inline queue_op_status wait_until_not_empty_until(unique_lock& lk, time_point const&); - - inline void notify_not_empty_if_needed(unique_lock& ) - { - not_empty_.notify_one(); - } - inline void notify_not_empty_if_needed(lock_guard& ) - { - not_empty_.notify_one(); - } - - }; - - template - sync_queue_base::sync_queue_base() : - data_(), closed_(false) - { - BOOST_ASSERT(data_.empty()); - } - - template - sync_queue_base::~sync_queue_base() - { - } - - template - void sync_queue_base::close() - { - { - lock_guard lk(mtx_); - closed_ = true; - } - not_empty_.notify_all(); - } - - template - bool sync_queue_base::closed() const - { - lock_guard lk(mtx_); - return closed(lk); - } - template - bool sync_queue_base::closed(unique_lock&) const - { - return closed_; - } - template - bool sync_queue_base::closed(lock_guard&) const - { - return closed_; - } - - template - bool sync_queue_base::empty() const - { - lock_guard lk(mtx_); - return empty(lk); - } - template - bool sync_queue_base::full() const - { - return false; - } - - template - typename sync_queue_base::size_type sync_queue_base::size() const - { - lock_guard lk(mtx_); - return size(lk); - } - - template - void sync_queue_base::throw_if_closed(unique_lock& lk) - { - if (closed(lk)) - { - BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - } - } - template - void sync_queue_base::throw_if_closed(lock_guard& lk) - { - if (closed(lk)) - { - BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - } - } - - template - void sync_queue_base::wait_until_not_empty(unique_lock& lk) - { - for (;;) - { - if (! empty(lk)) break; - throw_if_closed(lk); - not_empty_.wait(lk); - } - } - template - bool sync_queue_base::wait_until_not_empty_or_closed(unique_lock& lk) - { - for (;;) - { - if (! empty(lk)) break; - if (closed(lk)) return true; - not_empty_.wait(lk); - } - return false; - } - - template - queue_op_status sync_queue_base::wait_until_not_empty_until(unique_lock& lk, time_point const&tp) - { - for (;;) - { - if (! empty(lk)) return queue_op_status::success; - throw_if_closed(lk); - if (not_empty_.wait_until(lk, tp) == cv_status::timeout ) return queue_op_status::timeout; - } - } - - -} // detail -} // concurrent -} // boost - -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/queue_adaptor.hpp b/libraries/boost/boost/thread/concurrent_queues/queue_adaptor.hpp deleted file mode 100644 index f04e0354f..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/queue_adaptor.hpp +++ /dev/null @@ -1,209 +0,0 @@ -#ifndef BOOST_THREAD_QUEUE_ADAPTOR_HPP -#define BOOST_THREAD_QUEUE_ADAPTOR_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace concurrent -{ -namespace detail -{ - - template - class queue_adaptor_copyable_only : - public boost::queue_base - { - Queue queue; - public: - typedef typename Queue::value_type value_type; - typedef typename Queue::size_type size_type; - - // Constructors/Assignment/Destructors - queue_adaptor_copyable_only() {} - - // Observers - bool empty() const { return queue.empty(); } - bool full() const { return queue.full(); } - size_type size() const { return queue.size(); } - bool closed() const { return queue.closed(); } - - // Modifiers - void close() { queue.close(); } - - void push(const value_type& x) { queue.push(x); } - - void pull(value_type& x) { queue.pull(x); }; - value_type pull() { return queue.pull(); } - - queue_op_status try_push(const value_type& x) { return queue.try_push(x); } - queue_op_status try_pull(value_type& x) { return queue.try_pull(x); } - - queue_op_status nonblocking_push(const value_type& x) { return queue.nonblocking_push(x); } - queue_op_status nonblocking_pull(value_type& x) { return queue.nonblocking_pull(x); } - - queue_op_status wait_push(const value_type& x) { return queue.wait_push(x); } - queue_op_status wait_pull(value_type& x) { return queue.wait_pull(x); } - - }; - template - class queue_adaptor_movable_only : - public boost::queue_base - { - Queue queue; - public: - typedef typename Queue::value_type value_type; - typedef typename Queue::size_type size_type; - - // Constructors/Assignment/Destructors - - queue_adaptor_movable_only() {} - - // Observers - bool empty() const { return queue.empty(); } - bool full() const { return queue.full(); } - size_type size() const { return queue.size(); } - bool closed() const { return queue.closed(); } - - // Modifiers - void close() { queue.close(); } - - - void pull(value_type& x) { queue.pull(x); }; - // enable_if is_nothrow_copy_movable - value_type pull() { return queue.pull(); } - - queue_op_status try_pull(value_type& x) { return queue.try_pull(x); } - - queue_op_status nonblocking_pull(value_type& x) { return queue.nonblocking_pull(x); } - - queue_op_status wait_pull(value_type& x) { return queue.wait_pull(x); } - - void push(BOOST_THREAD_RV_REF(value_type) x) { queue.push(boost::move(x)); } - queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.try_push(boost::move(x)); } - queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.nonblocking_push(boost::move(x)); } - queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.wait_push(boost::move(x)); } - }; - - template - class queue_adaptor_copyable_and_movable : - public boost::queue_base - { - Queue queue; - public: - typedef typename Queue::value_type value_type; - typedef typename Queue::size_type size_type; - - // Constructors/Assignment/Destructors - - queue_adaptor_copyable_and_movable() {} - - // Observers - bool empty() const { return queue.empty(); } - bool full() const { return queue.full(); } - size_type size() const { return queue.size(); } - bool closed() const { return queue.closed(); } - - // Modifiers - void close() { queue.close(); } - - - void push(const value_type& x) { queue.push(x); } - - void pull(value_type& x) { queue.pull(x); }; - // enable_if is_nothrow_copy_movable - value_type pull() { return queue.pull(); } - - queue_op_status try_push(const value_type& x) { return queue.try_push(x); } - queue_op_status try_pull(value_type& x) { return queue.try_pull(x); } - - queue_op_status nonblocking_push(const value_type& x) { return queue.nonblocking_push(x); } - queue_op_status nonblocking_pull(value_type& x) { return queue.nonblocking_pull(x); } - - queue_op_status wait_push(const value_type& x) { return queue.wait_push(x); } - queue_op_status wait_pull(value_type& x) { return queue.wait_pull(x); } - - void push(BOOST_THREAD_RV_REF(value_type) x) { queue.push(boost::move(x)); } - queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.try_push(boost::move(x)); } - queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.nonblocking_push(boost::move(x)); } - queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.wait_push(boost::move(x)); } - }; - - - template ::value, - bool Movable = true -#else - bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, - bool Movable = std::is_move_constructible::value && std::is_move_assignable::value -#endif // __GNUC__ -#elif defined _MSC_VER -#if _MSC_VER < 1700 - bool Copyable = is_copy_constructible::value, - bool Movable = true -#else - bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, - bool Movable = std::is_move_constructible::value && std::is_move_assignable::value -#endif // _MSC_VER -#else - bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, - bool Movable = std::is_move_constructible::value && std::is_move_assignable::value -#endif -#else - bool Copyable = is_copy_constructible::value, - bool Movable = has_move_emulation_enabled::value -#endif - > - struct queue_adaptor; - - template - struct queue_adaptor { - typedef queue_adaptor_copyable_and_movable type; - }; - template - struct queue_adaptor { - typedef queue_adaptor_copyable_only type; - }; - template - struct queue_adaptor { - typedef queue_adaptor_movable_only type; - }; - -} - - template - class queue_adaptor : - public detail::queue_adaptor::type - { - public: - typedef typename Queue::value_type value_type; - typedef typename Queue::size_type size_type; - // Constructors/Assignment/Destructors - virtual ~queue_adaptor() {}; - }; -} -using concurrent::queue_adaptor; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/queue_base.hpp b/libraries/boost/boost/thread/concurrent_queues/queue_base.hpp deleted file mode 100644 index 0d4283915..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/queue_base.hpp +++ /dev/null @@ -1,202 +0,0 @@ -#ifndef BOOST_THREAD_QUEUE_BASE_HPP -#define BOOST_THREAD_QUEUE_BASE_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include - - -#include - -namespace boost -{ -namespace concurrent -{ -namespace detail -{ - - template - class queue_base_copyable_only - { - public: - typedef ValueType value_type; - typedef SizeType size_type; - - // Constructors/Assignment/Destructors - virtual ~queue_base_copyable_only() {}; - - // Observers - virtual bool empty() const = 0; - virtual bool full() const = 0; - virtual size_type size() const = 0; - virtual bool closed() const = 0; - - // Modifiers - virtual void close() = 0; - - virtual void push(const value_type& x) = 0; - - virtual void pull(value_type&) = 0; - virtual value_type pull() = 0; - - virtual queue_op_status try_push(const value_type& x) = 0; - virtual queue_op_status try_pull(value_type&) = 0; - - virtual queue_op_status nonblocking_push(const value_type& x) = 0; - virtual queue_op_status nonblocking_pull(value_type&) = 0; - - virtual queue_op_status wait_push(const value_type& x) = 0; - virtual queue_op_status wait_pull(ValueType& elem) = 0; - - }; - - template - class queue_base_movable_only - { - public: - typedef ValueType value_type; - typedef SizeType size_type; - // Constructors/Assignment/Destructors - virtual ~queue_base_movable_only() {}; - - // Observers - virtual bool empty() const = 0; - virtual bool full() const = 0; - virtual size_type size() const = 0; - virtual bool closed() const = 0; - - // Modifiers - virtual void close() = 0; - - virtual void pull(value_type&) = 0; - // enable_if is_nothrow_movable - virtual value_type pull() = 0; - - virtual queue_op_status try_pull(value_type&) = 0; - - virtual queue_op_status nonblocking_pull(value_type&) = 0; - - virtual queue_op_status wait_pull(value_type& elem) = 0; - - virtual void push(BOOST_THREAD_RV_REF(value_type) x) = 0; - virtual queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) = 0; - virtual queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) = 0; - virtual queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) = 0; - }; - - - template - class queue_base_copyable_and_movable - { - public: - typedef ValueType value_type; - typedef SizeType size_type; - // Constructors/Assignment/Destructors - virtual ~queue_base_copyable_and_movable() {}; - - - // Observers - virtual bool empty() const = 0; - virtual bool full() const = 0; - virtual size_type size() const = 0; - virtual bool closed() const = 0; - - // Modifiers - virtual void close() = 0; - - virtual void push(const value_type& x) = 0; - - virtual void pull(value_type&) = 0; - // enable_if is_nothrow_copy_movable - virtual value_type pull() = 0; - - virtual queue_op_status try_push(const value_type& x) = 0; - virtual queue_op_status try_pull(value_type&) = 0; - - virtual queue_op_status nonblocking_push(const value_type& x) = 0; - virtual queue_op_status nonblocking_pull(value_type&) = 0; - - virtual queue_op_status wait_push(const value_type& x) = 0; - virtual queue_op_status wait_pull(value_type& elem) = 0; - - virtual void push(BOOST_THREAD_RV_REF(value_type) x) = 0; - virtual queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) = 0; - virtual queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) = 0; - virtual queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) = 0; - }; - - template ::value, - bool Movable = true -#else - bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, - bool Movable = std::is_move_constructible::value && std::is_move_assignable::value -#endif // __GNUC__ -#elif defined _MSC_VER -#if _MSC_VER < 1700 - bool Copyable = is_copy_constructible::value, - bool Movable = true -#else - bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, - bool Movable = std::is_move_constructible::value && std::is_move_assignable::value -#endif // _MSC_VER -#else - bool Copyable = std::is_copy_constructible::value && std::is_copy_assignable::value, - bool Movable = std::is_move_constructible::value && std::is_move_assignable::value -#endif -#else - bool Copyable = is_copy_constructible::value, - bool Movable = has_move_emulation_enabled::value -#endif - > - struct queue_base; - - template - struct queue_base { - typedef queue_base_copyable_and_movable type; - }; - template - struct queue_base { - typedef queue_base_copyable_only type; - }; - template - struct queue_base { - typedef queue_base_movable_only type; - }; - -} - - template - class queue_base : - public detail::queue_base::type - { - public: - typedef ValueType value_type; - typedef SizeType size_type; - // Constructors/Assignment/Destructors - virtual ~queue_base() {}; - }; - -} -using concurrent::queue_base; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/queue_op_status.hpp b/libraries/boost/boost/thread/concurrent_queues/queue_op_status.hpp deleted file mode 100644 index 197650d05..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/queue_op_status.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef BOOST_THREAD_QUEUE_OP_STATUS_HPP -#define BOOST_THREAD_QUEUE_OP_STATUS_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include -#include - -#include - -namespace boost -{ -namespace concurrent -{ - - BOOST_SCOPED_ENUM_DECLARE_BEGIN(queue_op_status) - { success = 0, empty, full, closed, busy, timeout, not_ready } - BOOST_SCOPED_ENUM_DECLARE_END(queue_op_status) - - struct sync_queue_is_closed : std::exception - { - }; - -} - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - struct no_block_tag{}; - BOOST_CONSTEXPR_OR_CONST no_block_tag no_block = {}; -#endif - - using concurrent::queue_op_status; - using concurrent::sync_queue_is_closed; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/queue_views.hpp b/libraries/boost/boost/thread/concurrent_queues/queue_views.hpp deleted file mode 100644 index d04f54ed7..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/queue_views.hpp +++ /dev/null @@ -1,144 +0,0 @@ -#ifndef BOOST_THREAD_QUEUE_VIEWS_HPP -#define BOOST_THREAD_QUEUE_VIEWS_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace concurrent -{ - - template - class queue_back_view - { - Queue* queue; - public: - typedef typename Queue::value_type value_type; - typedef typename Queue::size_type size_type; - - // Constructors/Assignment/Destructors - queue_back_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {} - - // Observers - bool empty() const { return queue->empty(); } - bool full() const { return queue->full(); } - size_type size() const { return queue->size(); } - bool closed() const { return queue->closed(); } - - // Modifiers - void close() { queue->close(); } - - void push(const value_type& x) { queue->push(x); } - - queue_op_status try_push(const value_type& x) { return queue->try_push(x); } - - queue_op_status nonblocking_push(const value_type& x) { return queue->nonblocking_push(x); } - queue_op_status wait_push(const value_type& x) { return queue->wait_push(x); } - - void push(BOOST_THREAD_RV_REF(value_type) x) { queue->push(boost::move(x)); } - queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->try_push(boost::move(x)); } - queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->nonblocking_push(boost::move(x)); } - queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->wait_push(boost::move(x)); } - }; - - template - class queue_front_view - { - Queue* queue; - public: - typedef typename Queue::value_type value_type; - typedef typename Queue::size_type size_type; - - // Constructors/Assignment/Destructors - queue_front_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {} - - // Observers - bool empty() const { return queue->empty(); } - bool full() const { return queue->full(); } - size_type size() const { return queue->size(); } - bool closed() const { return queue->closed(); } - - // Modifiers - void close() { queue->close(); } - - void pull(value_type& x) { queue->pull(x); }; - // enable_if is_nothrow_copy_movable - value_type pull() { return queue->pull(); } - - queue_op_status try_pull(value_type& x) { return queue->try_pull(x); } - - queue_op_status nonblocking_pull(value_type& x) { return queue->nonblocking_pull(x); } - - queue_op_status wait_pull(value_type& x) { return queue->wait_pull(x); } - - }; - -#if ! defined BOOST_NO_CXX11_TEMPLATE_ALIASES - - template - using queue_back = queue_back_view > ; - template - using queue_front = queue_front_view > ; - -#else - - template - struct queue_back : queue_back_view > - { - typedef queue_back_view > base_type; - queue_back(queue_base& q) BOOST_NOEXCEPT : base_type(q) {} - }; - template - struct queue_front : queue_front_view > - { - typedef queue_front_view > base_type; - queue_front(queue_base& q) BOOST_NOEXCEPT : base_type(q) {} - - }; - -#endif - -// template -// queue_back_view back(Queue & q) { return queue_back_view(q); } -// template -// queue_front_view front(Queue & q) { return queue_front_view(q); } -//#if 0 -// template -// queue_back back(queue_base & q) { return queue_back(q); } -// template -// queue_front front(queue_base & q) { return queue_front(q); } -//#else -// template -// typename queue_back::type back(queue_base & q) { return typename queue_back::type(q); } -// template -// typename queue_front::type front(queue_base & q) { return typename queue_front::type(q); } -//#endif -} - -using concurrent::queue_back_view; -using concurrent::queue_front_view; -using concurrent::queue_back; -using concurrent::queue_front; -//using concurrent::back; -//using concurrent::front; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/sync_bounded_queue.hpp b/libraries/boost/boost/thread/concurrent_queues/sync_bounded_queue.hpp deleted file mode 100644 index e34fa56f3..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/sync_bounded_queue.hpp +++ /dev/null @@ -1,725 +0,0 @@ -#ifndef BOOST_THREAD_CONCURRENT_QUEUES_SYNC_BOUNDED_QUEUE_HPP -#define BOOST_THREAD_CONCURRENT_QUEUES_SYNC_BOUNDED_QUEUE_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2013-2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD -#include -#include -#endif -#include - -namespace boost -{ -namespace concurrent -{ - template - class sync_bounded_queue - { - public: - typedef ValueType value_type; - typedef std::size_t size_type; - - // Constructors/Assignment/Destructors - BOOST_THREAD_NO_COPYABLE(sync_bounded_queue) - explicit sync_bounded_queue(size_type max_elems); - template - sync_bounded_queue(size_type max_elems, Range range); - ~sync_bounded_queue(); - - // Observers - inline bool empty() const; - inline bool full() const; - inline size_type capacity() const; - inline size_type size() const; - inline bool closed() const; - - // Modifiers - inline void close(); - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - inline void push(const value_type& x); - inline void push(BOOST_THREAD_RV_REF(value_type) x); - inline bool try_push(const value_type& x); - inline bool try_push(BOOST_THREAD_RV_REF(value_type) x); - inline bool try_push(no_block_tag, const value_type& x); - inline bool try_push(no_block_tag, BOOST_THREAD_RV_REF(value_type) x); -#endif - inline void push_back(const value_type& x); - inline void push_back(BOOST_THREAD_RV_REF(value_type) x); - inline queue_op_status try_push_back(const value_type& x); - inline queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x); - inline queue_op_status nonblocking_push_back(const value_type& x); - inline queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x); - inline queue_op_status wait_push_back(const value_type& x); - inline queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x); - - // Observers/Modifiers -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - inline void pull(value_type&); - // enable_if is_nothrow_copy_movable - inline value_type pull(); - inline shared_ptr ptr_pull(); - inline bool try_pull(value_type&); - inline bool try_pull(no_block_tag,value_type&); - inline shared_ptr try_pull(); -#endif - inline void pull_front(value_type&); - // enable_if is_nothrow_copy_movable - inline value_type pull_front(); - inline queue_op_status try_pull_front(value_type&); - inline queue_op_status nonblocking_pull_front(value_type&); - - inline queue_op_status wait_pull_front(ValueType& elem); - - private: - mutable mutex mtx_; - condition_variable not_empty_; - condition_variable not_full_; - size_type waiting_full_; - size_type waiting_empty_; - value_type* data_; - size_type in_; - size_type out_; - size_type capacity_; - bool closed_; - - inline size_type inc(size_type idx) const BOOST_NOEXCEPT - { - return (idx + 1) % capacity_; - } - - inline bool empty(unique_lock& ) const BOOST_NOEXCEPT - { - return in_ == out_; - } - inline bool empty(lock_guard& ) const BOOST_NOEXCEPT - { - return in_ == out_; - } - inline bool full(unique_lock& ) const BOOST_NOEXCEPT - { - return (inc(in_) == out_); - } - inline bool full(lock_guard& ) const BOOST_NOEXCEPT - { - return (inc(in_) == out_); - } - inline size_type capacity(lock_guard& ) const BOOST_NOEXCEPT - { - return capacity_-1; - } - inline size_type size(lock_guard& lk) const BOOST_NOEXCEPT - { - if (full(lk)) return capacity(lk); - return ((out_+capacity(lk)-in_) % capacity(lk)); - } - - inline void throw_if_closed(unique_lock&); - inline bool closed(unique_lock&) const; - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - inline bool try_pull(value_type& x, unique_lock& lk); - inline shared_ptr try_pull(unique_lock& lk); - inline bool try_push(const value_type& x, unique_lock& lk); - inline bool try_push(BOOST_THREAD_RV_REF(value_type) x, unique_lock& lk); -#endif - inline queue_op_status try_pull_front(value_type& x, unique_lock& lk); - inline queue_op_status try_push_back(const value_type& x, unique_lock& lk); - inline queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x, unique_lock& lk); - - inline queue_op_status wait_pull_front(value_type& x, unique_lock& lk); - inline queue_op_status wait_push_back(const value_type& x, unique_lock& lk); - inline queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x, unique_lock& lk); - - inline void wait_until_not_empty(unique_lock& lk); - inline void wait_until_not_empty(unique_lock& lk, bool&); - inline size_type wait_until_not_full(unique_lock& lk); - inline size_type wait_until_not_full(unique_lock& lk, bool&); - - - inline void notify_not_empty_if_needed(unique_lock& lk) - { - if (waiting_empty_ > 0) - { - --waiting_empty_; - lk.unlock(); - not_empty_.notify_one(); - } - } - inline void notify_not_full_if_needed(unique_lock& lk) - { - if (waiting_full_ > 0) - { - --waiting_full_; - lk.unlock(); - not_full_.notify_one(); - } - } - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - inline void pull(value_type& elem, unique_lock& lk) - { - elem = boost::move(data_[out_]); - out_ = inc(out_); - notify_not_full_if_needed(lk); - } - inline value_type pull(unique_lock& lk) - { - value_type elem = boost::move(data_[out_]); - out_ = inc(out_); - notify_not_full_if_needed(lk); - return boost::move(elem); - } - inline boost::shared_ptr ptr_pull(unique_lock& lk) - { - shared_ptr res = make_shared(boost::move(data_[out_])); - out_ = inc(out_); - notify_not_full_if_needed(lk); - return res; - } -#endif - inline void pull_front(value_type& elem, unique_lock& lk) - { - elem = boost::move(data_[out_]); - out_ = inc(out_); - notify_not_full_if_needed(lk); - } - inline value_type pull_front(unique_lock& lk) - { - value_type elem = boost::move(data_[out_]); - out_ = inc(out_); - notify_not_full_if_needed(lk); - return boost::move(elem); - } - - inline void set_in(size_type in, unique_lock& lk) - { - in_ = in; - notify_not_empty_if_needed(lk); - } - - inline void push_at(const value_type& elem, size_type in_p_1, unique_lock& lk) - { - data_[in_] = elem; - set_in(in_p_1, lk); - } - - inline void push_at(BOOST_THREAD_RV_REF(value_type) elem, size_type in_p_1, unique_lock& lk) - { - data_[in_] = boost::move(elem); - set_in(in_p_1, lk); - } - }; - - template - sync_bounded_queue::sync_bounded_queue(typename sync_bounded_queue::size_type max_elems) : - waiting_full_(0), waiting_empty_(0), data_(new value_type[max_elems + 1]), in_(0), out_(0), capacity_(max_elems + 1), - closed_(false) - { - BOOST_ASSERT_MSG(max_elems >= 1, "number of elements must be > 1"); - } - -// template -// template -// sync_bounded_queue::sync_bounded_queue(size_type max_elems, Range range) : -// waiting_full_(0), waiting_empty_(0), data_(new value_type[max_elems + 1]), in_(0), out_(0), capacity_(max_elems + 1), -// closed_(false) -// { -// BOOST_ASSERT_MSG(max_elems >= 1, "number of elements must be > 1"); -// BOOST_ASSERT_MSG(max_elems == size(range), "number of elements must match range's size"); -// try -// { -// typedef typename Range::iterator iterator_t; -// iterator_t first = boost::begin(range); -// iterator_t end = boost::end(range); -// size_type in = 0; -// for (iterator_t cur = first; cur != end; ++cur, ++in) -// { -// data_[in] = *cur; -// } -// set_in(in); -// } -// catch (...) -// { -// delete[] data_; -// } -// } - - template - sync_bounded_queue::~sync_bounded_queue() - { - delete[] data_; - } - - template - void sync_bounded_queue::close() - { - { - lock_guard lk(mtx_); - closed_ = true; - } - not_empty_.notify_all(); - not_full_.notify_all(); - } - - template - bool sync_bounded_queue::closed() const - { - lock_guard lk(mtx_); - return closed_; - } - template - bool sync_bounded_queue::closed(unique_lock& ) const - { - return closed_; - } - - template - bool sync_bounded_queue::empty() const - { - lock_guard lk(mtx_); - return empty(lk); - } - template - bool sync_bounded_queue::full() const - { - lock_guard lk(mtx_); - return full(lk); - } - - template - typename sync_bounded_queue::size_type sync_bounded_queue::capacity() const - { - lock_guard lk(mtx_); - return capacity(lk); - } - - template - typename sync_bounded_queue::size_type sync_bounded_queue::size() const - { - lock_guard lk(mtx_); - return size(lk); - } - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - template - bool sync_bounded_queue::try_pull(ValueType& elem, unique_lock& lk) - { - if (empty(lk)) - { - throw_if_closed(lk); - return false; - } - pull(elem, lk); - return true; - } - template - shared_ptr sync_bounded_queue::try_pull(unique_lock& lk) - { - if (empty(lk)) - { - throw_if_closed(lk); - return shared_ptr(); - } - return ptr_pull(lk); - } - template - bool sync_bounded_queue::try_pull(ValueType& elem) - { - unique_lock lk(mtx_); - return try_pull(elem, lk); - } -#endif - - template - queue_op_status sync_bounded_queue::try_pull_front(ValueType& elem, unique_lock& lk) - { - if (empty(lk)) - { - if (closed(lk)) return queue_op_status::closed; - return queue_op_status::empty; - } - pull_front(elem, lk); - return queue_op_status::success; - } - - template - queue_op_status sync_bounded_queue::try_pull_front(ValueType& elem) - { - unique_lock lk(mtx_); - return try_pull_front(elem, lk); - } - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - template - bool sync_bounded_queue::try_pull(no_block_tag,ValueType& elem) - { - unique_lock lk(mtx_, try_to_lock); - if (!lk.owns_lock()) - { - return false; - } - return try_pull(elem, lk); - } - template - boost::shared_ptr sync_bounded_queue::try_pull() - { - unique_lock lk(mtx_); - return try_pull(lk); - } -#endif - - template - queue_op_status sync_bounded_queue::nonblocking_pull_front(ValueType& elem) - { - unique_lock lk(mtx_, try_to_lock); - if (!lk.owns_lock()) - { - return queue_op_status::busy; - } - return try_pull_front(elem, lk); - } - - template - void sync_bounded_queue::throw_if_closed(unique_lock&) - { - if (closed_) - { - BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - } - } - - template - void sync_bounded_queue::wait_until_not_empty(unique_lock& lk) - { - for (;;) - { - if (out_ != in_) break; - throw_if_closed(lk); - ++waiting_empty_; - not_empty_.wait(lk); - } - } - template - void sync_bounded_queue::wait_until_not_empty(unique_lock& lk, bool & closed) - { - for (;;) - { - if (out_ != in_) break; - if (closed_) {closed=true; return;} - ++waiting_empty_; - not_empty_.wait(lk); - } - } - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - template - void sync_bounded_queue::pull(ValueType& elem) - { - unique_lock lk(mtx_); - wait_until_not_empty(lk); - pull(elem, lk); - } -// template -// void sync_bounded_queue::pull(ValueType& elem, bool & closed) -// { -// unique_lock lk(mtx_); -// wait_until_not_empty(lk, closed); -// if (closed) {return;} -// pull(elem, lk); -// } - - // enable if ValueType is nothrow movable - template - ValueType sync_bounded_queue::pull() - { - unique_lock lk(mtx_); - wait_until_not_empty(lk); - return pull(lk); - } - template - boost::shared_ptr sync_bounded_queue::ptr_pull() - { - unique_lock lk(mtx_); - wait_until_not_empty(lk); - return ptr_pull(lk); - } - -#endif - - template - void sync_bounded_queue::pull_front(ValueType& elem) - { - unique_lock lk(mtx_); - wait_until_not_empty(lk); - pull_front(elem, lk); - } - - // enable if ValueType is nothrow movable - template - ValueType sync_bounded_queue::pull_front() - { - unique_lock lk(mtx_); - wait_until_not_empty(lk); - return pull_front(lk); - } - - template - queue_op_status sync_bounded_queue::wait_pull_front(ValueType& elem, unique_lock& lk) - { - if (empty(lk) && closed(lk)) {return queue_op_status::closed;} - wait_until_not_empty(lk); - pull_front(elem, lk); - return queue_op_status::success; - } - template - queue_op_status sync_bounded_queue::wait_pull_front(ValueType& elem) - { - unique_lock lk(mtx_); - return wait_pull_front(elem, lk); - } - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - template - bool sync_bounded_queue::try_push(const ValueType& elem, unique_lock& lk) - { - throw_if_closed(lk); - size_type in_p_1 = inc(in_); - if (in_p_1 == out_) // full() - { - return false; - } - push_at(elem, in_p_1, lk); - return true; - } - template - bool sync_bounded_queue::try_push(const ValueType& elem) - { - unique_lock lk(mtx_); - return try_push(elem, lk); - } - -#endif - - template - queue_op_status sync_bounded_queue::try_push_back(const ValueType& elem, unique_lock& lk) - { - if (closed(lk)) return queue_op_status::closed; - size_type in_p_1 = inc(in_); - if (in_p_1 == out_) // full() - { - return queue_op_status::full; - } - push_at(elem, in_p_1, lk); - return queue_op_status::success; - } - - template - queue_op_status sync_bounded_queue::try_push_back(const ValueType& elem) - { - unique_lock lk(mtx_); - return try_push_back(elem, lk); - } - - template - queue_op_status sync_bounded_queue::wait_push_back(const ValueType& elem, unique_lock& lk) - { - if (closed(lk)) return queue_op_status::closed; - push_at(elem, wait_until_not_full(lk), lk); - return queue_op_status::success; - } - template - queue_op_status sync_bounded_queue::wait_push_back(const ValueType& elem) - { - unique_lock lk(mtx_); - return wait_push_back(elem, lk); - } - - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - template - bool sync_bounded_queue::try_push(no_block_tag, const ValueType& elem) - { - unique_lock lk(mtx_, try_to_lock); - if (!lk.owns_lock()) return false; - return try_push(elem, lk); - } -#endif - - template - queue_op_status sync_bounded_queue::nonblocking_push_back(const ValueType& elem) - { - unique_lock lk(mtx_, try_to_lock); - if (!lk.owns_lock()) return queue_op_status::busy; - return try_push_back(elem, lk); - } - - template - typename sync_bounded_queue::size_type sync_bounded_queue::wait_until_not_full(unique_lock& lk) - { - for (;;) - { - throw_if_closed(lk); - size_type in_p_1 = inc(in_); - if (in_p_1 != out_) // ! full() - { - return in_p_1; - } - ++waiting_full_; - not_full_.wait(lk); - } - } - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - template - void sync_bounded_queue::push(const ValueType& elem) - { - unique_lock lk(mtx_); - push_at(elem, wait_until_not_full(lk), lk); - } -#endif - template - void sync_bounded_queue::push_back(const ValueType& elem) - { - unique_lock lk(mtx_); - push_at(elem, wait_until_not_full(lk), lk); - } - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - template - bool sync_bounded_queue::try_push(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock& lk) - { - throw_if_closed(lk); - size_type in_p_1 = inc(in_); - if (in_p_1 == out_) // full() - { - return false; - } - push_at(boost::move(elem), in_p_1, lk); - return true; - } - - template - bool sync_bounded_queue::try_push(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(mtx_); - return try_push(boost::move(elem), lk); - } -#endif - - template - queue_op_status sync_bounded_queue::try_push_back(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock& lk) - { - if (closed(lk)) return queue_op_status::closed; - size_type in_p_1 = inc(in_); - if (in_p_1 == out_) // full() - { - return queue_op_status::full; - } - push_at(boost::move(elem), in_p_1, lk); - return queue_op_status::success; - } - template - queue_op_status sync_bounded_queue::try_push_back(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(mtx_); - return try_push_back(boost::move(elem), lk); - } - - template - queue_op_status sync_bounded_queue::wait_push_back(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock& lk) - { - if (closed(lk)) return queue_op_status::closed; - push_at(boost::move(elem), wait_until_not_full(lk), lk); - return queue_op_status::success; - } - template - queue_op_status sync_bounded_queue::wait_push_back(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(mtx_); - return try_push_back(boost::move(elem), lk); - } - - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - template - bool sync_bounded_queue::try_push(no_block_tag, BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(mtx_, try_to_lock); - if (!lk.owns_lock()) - { - return false; - } - return try_push(boost::move(elem), lk); - } -#endif - template - queue_op_status sync_bounded_queue::nonblocking_push_back(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(mtx_, try_to_lock); - if (!lk.owns_lock()) - { - return queue_op_status::busy; - } - return try_push_back(boost::move(elem), lk); - } - -#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD - template - void sync_bounded_queue::push(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(mtx_); - push_at(boost::move(elem), wait_until_not_full(lk), lk); - } -#endif - template - void sync_bounded_queue::push_back(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(mtx_); - push_at(boost::move(elem), wait_until_not_full(lk), lk); - } - - template - sync_bounded_queue& operator<<(sync_bounded_queue& sbq, BOOST_THREAD_RV_REF(ValueType) elem) - { - sbq.push_back(boost::move(elem)); - return sbq; - } - - template - sync_bounded_queue& operator<<(sync_bounded_queue& sbq, ValueType const&elem) - { - sbq.push_back(elem); - return sbq; - } - - template - sync_bounded_queue& operator>>(sync_bounded_queue& sbq, ValueType &elem) - { - sbq.pull_front(elem); - return sbq; - } -} -using concurrent::sync_bounded_queue; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/sync_deque.hpp b/libraries/boost/boost/thread/concurrent_queues/sync_deque.hpp deleted file mode 100644 index c84dae022..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/sync_deque.hpp +++ /dev/null @@ -1,327 +0,0 @@ -#ifndef BOOST_THREAD_CONCURRENT_QUEUES_SYNC_DEQUE_HPP -#define BOOST_THREAD_CONCURRENT_QUEUES_SYNC_DEQUE_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2013-2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -namespace boost -{ -namespace concurrent -{ - template > - class sync_deque - : public detail::sync_queue_base - { - typedef detail::sync_queue_base super; - - public: - typedef ValueType value_type; - //typedef typename super::value_type value_type; // fixme - typedef typename super::underlying_queue_type underlying_queue_type; - typedef typename super::size_type size_type; - typedef typename super::op_status op_status; - - // Constructors/Assignment/Destructors - BOOST_THREAD_NO_COPYABLE(sync_deque) - inline sync_deque(); - //template - //inline explicit sync_deque(Range range); - inline ~sync_deque(); - - // Modifiers - inline void push_back(const value_type& x); - inline queue_op_status try_push_back(const value_type& x); - inline queue_op_status nonblocking_push_back(const value_type& x); - inline queue_op_status wait_push_back(const value_type& x); - inline void push_back(BOOST_THREAD_RV_REF(value_type) x); - inline queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x); - inline queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x); - inline queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x); - - // Observers/Modifiers - inline void pull_front(value_type&); - // enable_if is_nothrow_copy_movable - inline value_type pull_front(); - - inline queue_op_status try_pull_front(value_type&); - inline queue_op_status nonblocking_pull_front(value_type&); - inline queue_op_status wait_pull_front(ValueType& elem); - - private: - - inline queue_op_status try_pull_front(value_type& x, unique_lock& lk); - inline queue_op_status wait_pull_front(value_type& x, unique_lock& lk); - inline queue_op_status try_push_back(const value_type& x, unique_lock& lk); - inline queue_op_status wait_push_back(const value_type& x, unique_lock& lk); - inline queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x, unique_lock& lk); - inline queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x, unique_lock& lk); - - inline void pull_front(value_type& elem, unique_lock& ) - { - elem = boost::move(super::data_.front()); - super::data_.pop_front(); - } - inline value_type pull_front(unique_lock& ) - { - value_type e = boost::move(super::data_.front()); - super::data_.pop_front(); - return boost::move(e); - } - - inline void push_back(const value_type& elem, unique_lock& lk) - { - super::data_.push_back(elem); - super::notify_not_empty_if_needed(lk); - } - - inline void push_back(BOOST_THREAD_RV_REF(value_type) elem, unique_lock& lk) - { - super::data_.push_back(boost::move(elem)); - super::notify_not_empty_if_needed(lk); - } - }; - - template - sync_deque::sync_deque() : - super() - { - } - -// template -// template -// explicit sync_deque::sync_deque(Range range) : -// data_(), closed_(false) -// { -// try -// { -// typedef typename Range::iterator iterator_t; -// iterator_t first = boost::begin(range); -// iterator_t end = boost::end(range); -// for (iterator_t cur = first; cur != end; ++cur) -// { -// data_.push(boost::move(*cur));; -// } -// notify_not_empty_if_needed(lk); -// } -// catch (...) -// { -// delete[] data_; -// } -// } - - template - sync_deque::~sync_deque() - { - } - - template - queue_op_status sync_deque::try_pull_front(ValueType& elem, unique_lock& lk) - { - if (super::empty(lk)) - { - if (super::closed(lk)) return queue_op_status::closed; - return queue_op_status::empty; - } - pull_front(elem, lk); - return queue_op_status::success; - } - template - queue_op_status sync_deque::wait_pull_front(ValueType& elem, unique_lock& lk) - { - if (super::empty(lk)) - { - if (super::closed(lk)) return queue_op_status::closed; - } - bool has_been_closed = super::wait_until_not_empty_or_closed(lk); - if (has_been_closed) return queue_op_status::closed; - pull_front(elem, lk); - return queue_op_status::success; - } - - template - queue_op_status sync_deque::try_pull_front(ValueType& elem) - { - unique_lock lk(super::mtx_); - return try_pull_front(elem, lk); - } - - template - queue_op_status sync_deque::wait_pull_front(ValueType& elem) - { - unique_lock lk(super::mtx_); - return wait_pull_front(elem, lk); - } - - template - queue_op_status sync_deque::nonblocking_pull_front(ValueType& elem) - { - unique_lock lk(super::mtx_, try_to_lock); - if (!lk.owns_lock()) - { - return queue_op_status::busy; - } - return try_pull_front(elem, lk); - } - - template - void sync_deque::pull_front(ValueType& elem) - { - unique_lock lk(super::mtx_); - super::wait_until_not_empty(lk); - pull_front(elem, lk); - } - - // enable if ValueType is nothrow movable - template - ValueType sync_deque::pull_front() - { - unique_lock lk(super::mtx_); - super::wait_until_not_empty(lk); - return pull_front(lk); - } - - template - queue_op_status sync_deque::try_push_back(const ValueType& elem, unique_lock& lk) - { - if (super::closed(lk)) return queue_op_status::closed; - push_back(elem, lk); - return queue_op_status::success; - } - - template - queue_op_status sync_deque::try_push_back(const ValueType& elem) - { - unique_lock lk(super::mtx_); - return try_push_back(elem, lk); - } - - template - queue_op_status sync_deque::wait_push_back(const ValueType& elem, unique_lock& lk) - { - if (super::closed(lk)) return queue_op_status::closed; - push_back(elem, lk); - return queue_op_status::success; - } - - template - queue_op_status sync_deque::wait_push_back(const ValueType& elem) - { - unique_lock lk(super::mtx_); - return wait_push_back(elem, lk); - } - - template - queue_op_status sync_deque::nonblocking_push_back(const ValueType& elem) - { - unique_lock lk(super::mtx_, try_to_lock); - if (!lk.owns_lock()) return queue_op_status::busy; - return try_push_back(elem, lk); - } - - template - void sync_deque::push_back(const ValueType& elem) - { - unique_lock lk(super::mtx_); - super::throw_if_closed(lk); - push_back(elem, lk); - } - - template - queue_op_status sync_deque::try_push_back(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock& lk) - { - if (super::closed(lk)) return queue_op_status::closed; - push_back(boost::move(elem), lk); - return queue_op_status::success; - } - - template - queue_op_status sync_deque::try_push_back(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(super::mtx_); - return try_push_back(boost::move(elem), lk); - } - - template - queue_op_status sync_deque::wait_push_back(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock& lk) - { - if (super::closed(lk)) return queue_op_status::closed; - push_back(boost::move(elem), lk); - return queue_op_status::success; - } - - template - queue_op_status sync_deque::wait_push_back(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(super::mtx_); - return wait_push_back(boost::move(elem), lk); - } - - template - queue_op_status sync_deque::nonblocking_push_back(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(super::mtx_, try_to_lock); - if (!lk.owns_lock()) - { - return queue_op_status::busy; - } - return try_push_back(boost::move(elem), lk); - } - - template - void sync_deque::push_back(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(super::mtx_); - super::throw_if_closed(lk); - push_back(boost::move(elem), lk); - } - - template - sync_deque& operator<<(sync_deque& sbq, BOOST_THREAD_RV_REF(ValueType) elem) - { - sbq.push_back(boost::move(elem)); - return sbq; - } - - template - sync_deque& operator<<(sync_deque& sbq, ValueType const&elem) - { - sbq.push_back(elem); - return sbq; - } - - template - sync_deque& operator>>(sync_deque& sbq, ValueType &elem) - { - sbq.pull_front(elem); - return sbq; - } - -} -using concurrent::sync_deque; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/sync_priority_queue.hpp b/libraries/boost/boost/thread/concurrent_queues/sync_priority_queue.hpp deleted file mode 100644 index d604faa74..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/sync_priority_queue.hpp +++ /dev/null @@ -1,369 +0,0 @@ -// Copyright (C) 2014 Ian Forbed -// Copyright (C) 2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef BOOST_THREAD_SYNC_PRIORITY_QUEUE -#define BOOST_THREAD_SYNC_PRIORITY_QUEUE - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -namespace boost -{ -namespace detail { - - template < - class Type, - class Container = csbl::vector, - class Compare = std::less - > - class priority_queue - { - private: - Container _elements; - Compare _compare; - public: - typedef Type value_type; - typedef typename Container::size_type size_type; - - explicit priority_queue(const Compare& compare = Compare()) - : _elements(), _compare(compare) - { } - - size_type size() const - { - return _elements.size(); - } - - bool empty() const - { - return _elements.empty(); - } - - void push(Type const& element) - { - _elements.push_back(element); - std::push_heap(_elements.begin(), _elements.end(), _compare); - } - void push(BOOST_RV_REF(Type) element) - { - _elements.push_back(boost::move(element)); - std::push_heap(_elements.begin(), _elements.end(), _compare); - } - - void pop() - { - std::pop_heap(_elements.begin(), _elements.end(), _compare); - _elements.pop_back(); - } - Type pull() - { - Type result = boost::move(_elements.front()); - pop(); - return boost::move(result); - } - - Type const& top() - { - return _elements.front(); - } - }; -} - -namespace concurrent -{ - template , - class Compare = std::less > - class sync_priority_queue - : public detail::sync_queue_base > - { - typedef detail::sync_queue_base > super; - - public: - typedef ValueType value_type; - //typedef typename super::value_type value_type; // fixme - typedef typename super::underlying_queue_type underlying_queue_type; - typedef typename super::size_type size_type; - typedef typename super::op_status op_status; - - typedef chrono::steady_clock clock; - protected: - - public: - sync_priority_queue() {} - - ~sync_priority_queue() - { - if(!super::closed()) - { - super::close(); - } - } - - void push(const ValueType& elem); - void push(BOOST_THREAD_RV_REF(ValueType) elem); - - queue_op_status try_push(const ValueType& elem); - queue_op_status try_push(BOOST_THREAD_RV_REF(ValueType) elem); - - ValueType pull(); - - void pull(ValueType&); - - queue_op_status pull_until(const clock::time_point&, ValueType&); - queue_op_status pull_for(const clock::duration&, ValueType&); - - queue_op_status try_pull(ValueType& elem); - queue_op_status wait_pull(ValueType& elem); - queue_op_status nonblocking_pull(ValueType&); - - private: - void push(unique_lock&, const ValueType& elem); - void push(lock_guard&, const ValueType& elem); - void push(unique_lock&, BOOST_THREAD_RV_REF(ValueType) elem); - void push(lock_guard&, BOOST_THREAD_RV_REF(ValueType) elem); - - queue_op_status try_push(unique_lock&, const ValueType& elem); - queue_op_status try_push(unique_lock&, BOOST_THREAD_RV_REF(ValueType) elem); - - ValueType pull(unique_lock&); - ValueType pull(lock_guard&); - - void pull(unique_lock&, ValueType&); - void pull(lock_guard&, ValueType&); - - queue_op_status try_pull(lock_guard& lk, ValueType& elem); - queue_op_status try_pull(unique_lock& lk, ValueType& elem); - - queue_op_status wait_pull(unique_lock& lk, ValueType& elem); - - queue_op_status nonblocking_pull(unique_lock& lk, ValueType&); - - sync_priority_queue(const sync_priority_queue&); - sync_priority_queue& operator= (const sync_priority_queue&); - sync_priority_queue(BOOST_THREAD_RV_REF(sync_priority_queue)); - sync_priority_queue& operator= (BOOST_THREAD_RV_REF(sync_priority_queue)); - }; //end class - - - ////////////////////// - template - void sync_priority_queue::push(unique_lock& lk, const T& elem) - { - super::throw_if_closed(lk); - super::data_.push(elem); - super::notify_not_empty_if_needed(lk); - } - template - void sync_priority_queue::push(lock_guard& lk, const T& elem) - { - super::throw_if_closed(lk); - super::data_.push(elem); - super::notify_not_empty_if_needed(lk); - } - template - void sync_priority_queue::push(const T& elem) - { - lock_guard lk(super::mtx_); - push(lk, elem); - } - - ////////////////////// - template - void sync_priority_queue::push(unique_lock& lk, BOOST_THREAD_RV_REF(T) elem) - { - super::throw_if_closed(lk); - super::data_.push(boost::move(elem)); - super::notify_not_empty_if_needed(lk); - } - template - void sync_priority_queue::push(lock_guard& lk, BOOST_THREAD_RV_REF(T) elem) - { - super::throw_if_closed(lk); - super::data_.push(boost::move(elem)); - super::notify_not_empty_if_needed(lk); - } - template - void sync_priority_queue::push(BOOST_THREAD_RV_REF(T) elem) - { - lock_guard lk(super::mtx_); - push(lk, boost::move(elem)); - } - - ////////////////////// - template - queue_op_status sync_priority_queue::try_push(const T& elem) - { - lock_guard lk(super::mtx_); - if (super::closed(lk)) return queue_op_status::closed; - push(lk, elem); - return queue_op_status::success; - } - - ////////////////////// - template - queue_op_status sync_priority_queue::try_push(BOOST_THREAD_RV_REF(T) elem) - { - lock_guard lk(super::mtx_); - if (super::closed(lk)) return queue_op_status::closed; - push(lk, boost::move(elem)); - - return queue_op_status::success; - } - - ////////////////////// - template - T sync_priority_queue::pull(unique_lock&) - { - return super::data_.pull(); - } - template - T sync_priority_queue::pull(lock_guard&) - { - return super::data_.pull(); - } - - template - T sync_priority_queue::pull() - { - unique_lock lk(super::mtx_); - super::wait_until_not_empty(lk); - return pull(lk); - } - - ////////////////////// - template - void sync_priority_queue::pull(unique_lock&, T& elem) - { - elem = super::data_.pull(); - } - template - void sync_priority_queue::pull(lock_guard&, T& elem) - { - elem = super::data_.pull(); - } - - template - void sync_priority_queue::pull(T& elem) - { - unique_lock lk(super::mtx_); - super::wait_until_not_empty(lk); - pull(lk, elem); - } - - ////////////////////// - template - queue_op_status - sync_priority_queue::pull_until(const clock::time_point& tp, T& elem) - { - unique_lock lk(super::mtx_); - if (queue_op_status::timeout == super::wait_until_not_empty_until(lk, tp)) - return queue_op_status::timeout; - pull(lk, elem); - return queue_op_status::success; - } - - ////////////////////// - template - queue_op_status - sync_priority_queue::pull_for(const clock::duration& dura, T& elem) - { - return pull_until(clock::now() + dura, elem); - } - - ////////////////////// - template - queue_op_status - sync_priority_queue::try_pull(unique_lock& lk, T& elem) - { - if (super::empty(lk)) - { - if (super::closed(lk)) return queue_op_status::closed; - return queue_op_status::empty; - } - pull(lk, elem); - return queue_op_status::success; - } - - template - queue_op_status - sync_priority_queue::try_pull(lock_guard& lk, T& elem) - { - if (super::empty(lk)) - { - if (super::closed(lk)) return queue_op_status::closed; - return queue_op_status::empty; - } - pull(lk, elem); - return queue_op_status::success; - } - - template - queue_op_status - sync_priority_queue::try_pull(T& elem) - { - lock_guard lk(super::mtx_); - return try_pull(lk, elem); - } - - ////////////////////// - template - queue_op_status sync_priority_queue::wait_pull(unique_lock& lk, T& elem) - { - if (super::empty(lk)) - { - if (super::closed(lk)) return queue_op_status::closed; - } - bool has_been_closed = super::wait_until_not_empty_or_closed(lk); - if (has_been_closed) return queue_op_status::closed; - pull(lk, elem); - return queue_op_status::success; - } - - template - queue_op_status sync_priority_queue::wait_pull(T& elem) - { - unique_lock lk(super::mtx_); - return wait_pull(lk, elem); - } - - ////////////////////// - - template - queue_op_status sync_priority_queue::nonblocking_pull(T& elem) - { - unique_lock lk(super::mtx_, try_to_lock); - if (!lk.owns_lock()) return queue_op_status::busy; - return try_pull(lk, elem); - } - - - -} //end concurrent namespace - -using concurrent::sync_priority_queue; - -} //end boost namespace -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/sync_queue.hpp b/libraries/boost/boost/thread/concurrent_queues/sync_queue.hpp deleted file mode 100644 index 1dbbef05d..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/sync_queue.hpp +++ /dev/null @@ -1,335 +0,0 @@ -#ifndef BOOST_THREAD_CONCURRENT_QUEUES_SYNC_QUEUE_HPP -#define BOOST_THREAD_CONCURRENT_QUEUES_SYNC_QUEUE_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2013-2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -namespace boost -{ -namespace concurrent -{ - template > - class sync_queue - : public detail::sync_queue_base - { - typedef detail::sync_queue_base super; - - public: - typedef ValueType value_type; - //typedef typename super::value_type value_type; // fixme - typedef typename super::underlying_queue_type underlying_queue_type; - typedef typename super::size_type size_type; - typedef typename super::op_status op_status; - - // Constructors/Assignment/Destructors - BOOST_THREAD_NO_COPYABLE(sync_queue) - inline sync_queue(); - //template - //inline explicit sync_queue(Range range); - inline ~sync_queue(); - - // Modifiers - - inline void push(const value_type& x); - inline queue_op_status try_push(const value_type& x); - inline queue_op_status nonblocking_push(const value_type& x); - inline queue_op_status wait_push(const value_type& x); - inline void push(BOOST_THREAD_RV_REF(value_type) x); - inline queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x); - inline queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x); - inline queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x); - - // Observers/Modifiers - inline void pull(value_type&); - // enable_if is_nothrow_copy_movable - inline value_type pull(); - - inline queue_op_status try_pull(value_type&); - inline queue_op_status nonblocking_pull(value_type&); - inline queue_op_status wait_pull(ValueType& elem); - - private: - - inline queue_op_status try_pull(value_type& x, unique_lock& lk); - inline queue_op_status wait_pull(value_type& x, unique_lock& lk); - inline queue_op_status try_push(const value_type& x, unique_lock& lk); - inline queue_op_status wait_push(const value_type& x, unique_lock& lk); - inline queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x, unique_lock& lk); - inline queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x, unique_lock& lk); - - inline void pull(value_type& elem, unique_lock& ) - { - elem = boost::move(super::data_.front()); - super::data_.pop_front(); - } - inline value_type pull(unique_lock& ) - { - value_type e = boost::move(super::data_.front()); - super::data_.pop_front(); - return boost::move(e); - } - - inline void push(const value_type& elem, unique_lock& lk) - { - super::data_.push_back(elem); - super::notify_not_empty_if_needed(lk); - } - - inline void push(BOOST_THREAD_RV_REF(value_type) elem, unique_lock& lk) - { - super::data_.push_back(boost::move(elem)); - super::notify_not_empty_if_needed(lk); - } - }; - - template - sync_queue::sync_queue() : - super() - { - } - -// template -// template -// explicit sync_queue::sync_queue(Range range) : -// data_(), closed_(false) -// { -// try -// { -// typedef typename Range::iterator iterator_t; -// iterator_t first = boost::begin(range); -// iterator_t end = boost::end(range); -// for (iterator_t cur = first; cur != end; ++cur) -// { -// data_.push(boost::move(*cur));; -// } -// notify_not_empty_if_needed(lk); -// } -// catch (...) -// { -// delete[] data_; -// } -// } - - template - sync_queue::~sync_queue() - { - } - - template - queue_op_status sync_queue::try_pull(ValueType& elem, unique_lock& lk) - { - if (super::empty(lk)) - { - if (super::closed(lk)) return queue_op_status::closed; - return queue_op_status::empty; - } - pull(elem, lk); - return queue_op_status::success; - } - template - queue_op_status sync_queue::wait_pull(ValueType& elem, unique_lock& lk) - { - //std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl; - if (super::empty(lk)) - { - //std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl; - if (super::closed(lk)) return queue_op_status::closed; - } - //std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl; - bool has_been_closed = super::wait_until_not_empty_or_closed(lk); - //std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl; - if (has_been_closed) return queue_op_status::closed; - //std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl; - pull(elem, lk); - //std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl; - return queue_op_status::success; - } - - template - queue_op_status sync_queue::try_pull(ValueType& elem) - { - unique_lock lk(super::mtx_); - return try_pull(elem, lk); - } - - template - queue_op_status sync_queue::wait_pull(ValueType& elem) - { - unique_lock lk(super::mtx_); - return wait_pull(elem, lk); - } - - template - queue_op_status sync_queue::nonblocking_pull(ValueType& elem) - { - unique_lock lk(super::mtx_, try_to_lock); - if (!lk.owns_lock()) - { - return queue_op_status::busy; - } - return try_pull(elem, lk); - } - - template - void sync_queue::pull(ValueType& elem) - { - unique_lock lk(super::mtx_); - super::wait_until_not_empty(lk); - pull(elem, lk); - } - - // enable if ValueType is nothrow movable - template - ValueType sync_queue::pull() - { - unique_lock lk(super::mtx_); - super::wait_until_not_empty(lk); - return pull(lk); - } - - template - queue_op_status sync_queue::try_push(const ValueType& elem, unique_lock& lk) - { - if (super::closed(lk)) return queue_op_status::closed; - push(elem, lk); - return queue_op_status::success; - } - - template - queue_op_status sync_queue::try_push(const ValueType& elem) - { - unique_lock lk(super::mtx_); - return try_push(elem, lk); - } - - template - queue_op_status sync_queue::wait_push(const ValueType& elem, unique_lock& lk) - { - if (super::closed(lk)) return queue_op_status::closed; - push(elem, lk); - return queue_op_status::success; - } - - template - queue_op_status sync_queue::wait_push(const ValueType& elem) - { - unique_lock lk(super::mtx_); - return wait_push(elem, lk); - } - - template - queue_op_status sync_queue::nonblocking_push(const ValueType& elem) - { - unique_lock lk(super::mtx_, try_to_lock); - if (!lk.owns_lock()) return queue_op_status::busy; - return try_push(elem, lk); - } - - template - void sync_queue::push(const ValueType& elem) - { - unique_lock lk(super::mtx_); - super::throw_if_closed(lk); - push(elem, lk); - } - - template - queue_op_status sync_queue::try_push(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock& lk) - { - if (super::closed(lk)) return queue_op_status::closed; - push(boost::move(elem), lk); - return queue_op_status::success; - } - - template - queue_op_status sync_queue::try_push(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(super::mtx_); - return try_push(boost::move(elem), lk); - } - - template - queue_op_status sync_queue::wait_push(BOOST_THREAD_RV_REF(ValueType) elem, unique_lock& lk) - { - if (super::closed(lk)) return queue_op_status::closed; - push(boost::move(elem), lk); - return queue_op_status::success; - } - - template - queue_op_status sync_queue::wait_push(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(super::mtx_); - return wait_push(boost::move(elem), lk); - } - - template - queue_op_status sync_queue::nonblocking_push(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(super::mtx_, try_to_lock); - if (!lk.owns_lock()) - { - return queue_op_status::busy; - } - return try_push(boost::move(elem), lk); - } - - template - void sync_queue::push(BOOST_THREAD_RV_REF(ValueType) elem) - { - unique_lock lk(super::mtx_); - super::throw_if_closed(lk); - push(boost::move(elem), lk); - } - - template - sync_queue& operator<<(sync_queue& sbq, BOOST_THREAD_RV_REF(ValueType) elem) - { - sbq.push(boost::move(elem)); - return sbq; - } - - template - sync_queue& operator<<(sync_queue& sbq, ValueType const&elem) - { - sbq.push(elem); - return sbq; - } - - template - sync_queue& operator>>(sync_queue& sbq, ValueType &elem) - { - sbq.pull(elem); - return sbq; - } - -} -using concurrent::sync_queue; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/concurrent_queues/sync_timed_queue.hpp b/libraries/boost/boost/thread/concurrent_queues/sync_timed_queue.hpp deleted file mode 100644 index e6a360f2b..000000000 --- a/libraries/boost/boost/thread/concurrent_queues/sync_timed_queue.hpp +++ /dev/null @@ -1,468 +0,0 @@ -// Copyright (C) 2014 Ian Forbed -// Copyright (C) 2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef BOOST_THREAD_SYNC_TIMED_QUEUE_HPP -#define BOOST_THREAD_SYNC_TIMED_QUEUE_HPP - -#include - -#include -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace concurrent -{ -namespace detail -{ - template - struct scheduled_type - { - typedef T value_type; - typedef Clock clock; - typedef typename clock::time_point time_point; - T data; - time_point time; - - BOOST_THREAD_COPYABLE_AND_MOVABLE(scheduled_type) - - scheduled_type(T const& pdata, time_point tp) : data(pdata), time(tp) {} - scheduled_type(BOOST_THREAD_RV_REF(T) pdata, time_point tp) : data(boost::move(pdata)), time(tp) {} - - scheduled_type(scheduled_type const& other) : data(other.data), time(other.time) {} - scheduled_type& operator=(BOOST_THREAD_COPY_ASSIGN_REF(scheduled_type) other) { - data = other.data; - time = other.time; - return *this; - } - - scheduled_type(BOOST_THREAD_RV_REF(scheduled_type) other) : data(boost::move(other.data)), time(other.time) {} - scheduled_type& operator=(BOOST_THREAD_RV_REF(scheduled_type) other) { - data = boost::move(other.data); - time = other.time; - return *this; - } - - bool time_not_reached() const - { - return time > clock::now(); - } - - bool operator <(const scheduled_type other) const - { - return this->time > other.time; - } - }; //end struct - -} //end detail namespace - - template - class sync_timed_queue - : private sync_priority_queue > - { - typedef detail::scheduled_type stype; - typedef sync_priority_queue super; - public: - typedef T value_type; - typedef Clock clock; - typedef typename clock::duration duration; - typedef typename clock::time_point time_point; - typedef typename super::underlying_queue_type underlying_queue_type; - typedef typename super::size_type size_type; - typedef typename super::op_status op_status; - - sync_timed_queue() : super() {}; - ~sync_timed_queue() {} - - using super::size; - using super::empty; - using super::full; - using super::close; - using super::closed; - - T pull(); - void pull(T& elem); - - template - queue_op_status pull_until(chrono::time_point const& tp, T& elem); - template - queue_op_status pull_for(chrono::duration const& dura, T& elem); - - queue_op_status try_pull(T& elem); - queue_op_status wait_pull(T& elem); - queue_op_status nonblocking_pull(T& elem); - - template - void push(const T& elem, chrono::time_point const& tp); - template - void push(const T& elem, chrono::duration const& dura); - - template - void push(BOOST_THREAD_RV_REF(T) elem, chrono::time_point const& tp); - template - void push(BOOST_THREAD_RV_REF(T) elem, chrono::duration const& dura); - - template - queue_op_status try_push(const T& elem, chrono::time_point const& tp); - template - queue_op_status try_push(const T& elem, chrono::duration const& dura); - - template - queue_op_status try_push(BOOST_THREAD_RV_REF(T) elem, chrono::time_point const& tp); - template - queue_op_status try_push(BOOST_THREAD_RV_REF(T) elem, chrono::duration const& dura); - - private: - T pull(unique_lock&); - T pull(lock_guard&); - - void pull(unique_lock&, T& elem); - void pull(lock_guard&, T& elem); - - queue_op_status try_pull(unique_lock&, T& elem); - queue_op_status try_pull(lock_guard&, T& elem); - - queue_op_status wait_pull(unique_lock& lk, T& elem); - - bool wait_until_not_empty_time_reached_or_closed(unique_lock&); - T pull_when_time_reached(unique_lock&); - template - queue_op_status pull_when_time_reached_until(unique_lock&, chrono::time_point const& tp, T& elem); - bool time_not_reached(unique_lock&); - bool time_not_reached(lock_guard&); - bool empty_or_time_not_reached(unique_lock&); - bool empty_or_time_not_reached(lock_guard&); - - sync_timed_queue(const sync_timed_queue&); - sync_timed_queue& operator=(const sync_timed_queue&); - sync_timed_queue(BOOST_THREAD_RV_REF(sync_timed_queue)); - sync_timed_queue& operator=(BOOST_THREAD_RV_REF(sync_timed_queue)); - }; //end class - - - template - template - void sync_timed_queue::push(const T& elem, chrono::time_point const& tp) - { - super::push(stype(elem,tp)); - } - - template - template - void sync_timed_queue::push(const T& elem, chrono::duration const& dura) - { - push(elem, clock::now() + dura); - } - - template - template - void sync_timed_queue::push(BOOST_THREAD_RV_REF(T) elem, chrono::time_point const& tp) - { - super::push(stype(boost::move(elem),tp)); - } - - template - template - void sync_timed_queue::push(BOOST_THREAD_RV_REF(T) elem, chrono::duration const& dura) - { - push(boost::move(elem), clock::now() + dura); - } - - - - template - template - queue_op_status sync_timed_queue::try_push(const T& elem, chrono::time_point const& tp) - { - return super::try_push(stype(elem,tp)); - } - - template - template - queue_op_status sync_timed_queue::try_push(const T& elem, chrono::duration const& dura) - { - return try_push(elem,clock::now() + dura); - } - - template - template - queue_op_status sync_timed_queue::try_push(BOOST_THREAD_RV_REF(T) elem, chrono::time_point const& tp) - { - return super::try_push(stype(boost::move(elem), tp)); - } - - template - template - queue_op_status sync_timed_queue::try_push(BOOST_THREAD_RV_REF(T) elem, chrono::duration const& dura) - { - return try_push(boost::move(elem), clock::now() + dura); - } - - /////////////////////////// - template - bool sync_timed_queue::time_not_reached(unique_lock&) - { - return super::data_.top().time_not_reached(); - } - - template - bool sync_timed_queue::time_not_reached(lock_guard&) - { - return super::data_.top().time_not_reached(); - } - - /////////////////////////// - template - bool sync_timed_queue::wait_until_not_empty_time_reached_or_closed(unique_lock& lk) - { - for (;;) - { - if (super::closed(lk)) return true; - while (! super::empty(lk)) { - if (! time_not_reached(lk)) return false; - time_point tp = super::data_.top().time; - super::not_empty_.wait_until(lk, tp); - if (super::closed(lk)) return true; - } - if (super::closed(lk)) return true; - super::not_empty_.wait(lk); - } - //return false; - } - - /////////////////////////// - template - T sync_timed_queue::pull_when_time_reached(unique_lock& lk) - { - while (time_not_reached(lk)) - { - super::throw_if_closed(lk); - time_point tp = super::data_.top().time; - super::not_empty_.wait_until(lk,tp); - super::wait_until_not_empty(lk); - } - return pull(lk); - } - - template - template - queue_op_status - sync_timed_queue::pull_when_time_reached_until(unique_lock& lk, chrono::time_point const& tp, T& elem) - { - chrono::time_point tpmin = (tp < super::data_.top().time) ? tp : super::data_.top().time; - while (time_not_reached(lk)) - { - super::throw_if_closed(lk); - if (cv_status::timeout == super::not_empty_.wait_until(lk, tpmin)) { - if (time_not_reached(lk)) return queue_op_status::not_ready; - return queue_op_status::timeout; - } - } - pull(lk, elem); - return queue_op_status::success; - } - - /////////////////////////// - template - bool sync_timed_queue::empty_or_time_not_reached(unique_lock& lk) - { - if ( super::empty(lk) ) return true; - if ( time_not_reached(lk) ) return true; - return false; - } - template - bool sync_timed_queue::empty_or_time_not_reached(lock_guard& lk) - { - if ( super::empty(lk) ) return true; - if ( time_not_reached(lk) ) return true; - return false; - } - - /////////////////////////// - template - T sync_timed_queue::pull(unique_lock&) - { -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - return boost::move(super::data_.pull().data); -#else - return super::data_.pull().data; -#endif - } - - template - T sync_timed_queue::pull(lock_guard&) - { -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - return boost::move(super::data_.pull().data); -#else - return super::data_.pull().data; -#endif - } - template - T sync_timed_queue::pull() - { - unique_lock lk(super::mtx_); - super::wait_until_not_empty(lk); - return pull_when_time_reached(lk); - } - - /////////////////////////// - template - void sync_timed_queue::pull(unique_lock&, T& elem) - { -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - elem = boost::move(super::data_.pull().data); -#else - elem = super::data_.pull().data; -#endif - } - - template - void sync_timed_queue::pull(lock_guard&, T& elem) - { -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - elem = boost::move(super::data_.pull().data); -#else - elem = super::data_.pull().data; -#endif - } - - template - void sync_timed_queue::pull(T& elem) - { - unique_lock lk(super::mtx_); - super::wait_until_not_empty(lk); - elem = pull_when_time_reached(lk); - } - - ////////////////////// - template - template - queue_op_status - sync_timed_queue::pull_until(chrono::time_point const& tp, T& elem) - { - unique_lock lk(super::mtx_); - - if (queue_op_status::timeout == super::wait_until_not_empty_until(lk, tp)) - return queue_op_status::timeout; - return pull_when_time_reached_until(lk, tp, elem); - } - - ////////////////////// - template - template - queue_op_status - sync_timed_queue::pull_for(chrono::duration const& dura, T& elem) - { - return pull_until(clock::now() + dura, elem); - } - - /////////////////////////// - template - queue_op_status sync_timed_queue::try_pull(unique_lock& lk, T& elem) - { - if ( super::empty(lk) ) - { - if (super::closed(lk)) return queue_op_status::closed; - return queue_op_status::empty; - } - if ( time_not_reached(lk) ) - { - if (super::closed(lk)) return queue_op_status::closed; - return queue_op_status::not_ready; - } - - pull(lk, elem); - return queue_op_status::success; - } - template - queue_op_status sync_timed_queue::try_pull(lock_guard& lk, T& elem) - { - if ( super::empty(lk) ) - { - if (super::closed(lk)) return queue_op_status::closed; - return queue_op_status::empty; - } - if ( time_not_reached(lk) ) - { - if (super::closed(lk)) return queue_op_status::closed; - return queue_op_status::not_ready; - } - pull(lk, elem); - return queue_op_status::success; - } - - template - queue_op_status sync_timed_queue::try_pull(T& elem) - { - lock_guard lk(super::mtx_); - return try_pull(lk, elem); - } - - /////////////////////////// - template - queue_op_status sync_timed_queue::wait_pull(unique_lock& lk, T& elem) - { - if (super::empty(lk)) - { - if (super::closed(lk)) return queue_op_status::closed; - } - bool has_been_closed = wait_until_not_empty_time_reached_or_closed(lk); - if (has_been_closed) return queue_op_status::closed; - pull(lk, elem); - return queue_op_status::success; - } - - template - queue_op_status sync_timed_queue::wait_pull(T& elem) - { - unique_lock lk(super::mtx_); - return wait_pull(lk, elem); - } - -// /////////////////////////// -// template -// queue_op_status sync_timed_queue::wait_pull(unique_lock &lk, T& elem) -// { -// if (super::empty(lk)) -// { -// if (super::closed(lk)) return queue_op_status::closed; -// } -// bool has_been_closed = super::wait_until_not_empty_or_closed(lk); -// if (has_been_closed) return queue_op_status::closed; -// pull(lk, elem); -// return queue_op_status::success; -// } -// template -// queue_op_status sync_timed_queue::wait_pull(T& elem) -// { -// unique_lock lk(super::mtx_); -// return wait_pull(lk, elem); -// } - - /////////////////////////// - template - queue_op_status sync_timed_queue::nonblocking_pull(T& elem) - { - unique_lock lk(super::mtx_, try_to_lock); - if (! lk.owns_lock()) return queue_op_status::busy; - return try_pull(lk, elem); - } - -} //end concurrent namespace - -using concurrent::sync_timed_queue; - -} //end boost namespace -#include - -#endif diff --git a/libraries/boost/boost/thread/condition.hpp b/libraries/boost/boost/thread/condition.hpp deleted file mode 100644 index 9567df982..000000000 --- a/libraries/boost/boost/thread/condition.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef BOOST_THREAD_CONDITION_HPP -#define BOOST_THREAD_CONDITION_HPP -// (C) Copyright 2007 Anthony Williams -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - -#if defined BOOST_THREAD_PROVIDES_CONDITION - -#include - -namespace boost -{ - typedef condition_variable_any condition; -} - -#endif -#endif diff --git a/libraries/boost/boost/thread/condition_variable.hpp b/libraries/boost/boost/thread/condition_variable.hpp deleted file mode 100644 index 8f8e9f2ed..000000000 --- a/libraries/boost/boost/thread/condition_variable.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef BOOST_THREAD_CONDITION_VARIABLE_HPP -#define BOOST_THREAD_CONDITION_VARIABLE_HPP - -// condition_variable.hpp -// -// (C) Copyright 2007 Anthony Williams -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#if defined(BOOST_THREAD_PLATFORM_WIN32) -#include -#elif defined(BOOST_THREAD_PLATFORM_PTHREAD) -#include -#else -#error "Boost threads unavailable on this platform" -#endif - -#endif diff --git a/libraries/boost/boost/thread/csbl/deque.hpp b/libraries/boost/boost/thread/csbl/deque.hpp deleted file mode 100644 index 2b26a46e1..000000000 --- a/libraries/boost/boost/thread/csbl/deque.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_DEQUE_HPP -#define BOOST_CSBL_DEQUE_HPP - -#include -// MSVC has some trouble instantiating a non_copyable type -//C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xmemory0(606) : error C2248: 'non_copyable::non_copyable' : cannot access private member declared in class 'non_copyable' -// ..\libs\thread\test\sync\mutual_exclusion\queue_views\single_thread_pass.cpp(24) : see declaration of 'non_copyable::non_copyable' -// ..\libs\thread\test\sync\mutual_exclusion\queue_views\single_thread_pass.cpp(23) : see declaration of 'non_copyable' -// C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xmemory0(605) : while compiling class template member function 'void std::allocator<_Ty>::construct(_Ty *,const _Ty &)' -// with -// [ -// _Ty=non_copyable -// ] -#if defined BOOST_THREAD_USES_BOOST_DEQUE || defined BOOST_NO_CXX11_RVALUE_REFERENCES || (defined _MSC_VER && _MSC_FULL_VER < 180020827) -#ifndef BOOST_THREAD_USES_BOOST_DEQUE -#define BOOST_THREAD_USES_BOOST_DEQUE -#endif -#include -#else -#include -#endif - -namespace boost -{ - namespace csbl - { -#if defined BOOST_THREAD_USES_BOOST_DEQUE - using ::boost::container::deque; - -#else - using ::std::deque; - -#endif - - } -} -#endif // header diff --git a/libraries/boost/boost/thread/csbl/devector.hpp b/libraries/boost/boost/thread/csbl/devector.hpp deleted file mode 100644 index c2bc0bbe9..000000000 --- a/libraries/boost/boost/thread/csbl/devector.hpp +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_DEVECTOR_HPP -#define BOOST_CSBL_DEVECTOR_HPP - -#include - -#include -#include - -namespace boost -{ - namespace csbl - { - template - class devector - { - typedef csbl::vector vector_type; - vector_type data_; - std::size_t front_index_; - - BOOST_COPYABLE_AND_MOVABLE(devector) - - template - void priv_push_back(BOOST_FWD_REF(U) x) - { data_.push_back(boost::forward(x)); } - - public: - typedef typename vector_type::size_type size_type; - typedef typename vector_type::reference reference; - typedef typename vector_type::const_reference const_reference; - - - devector() : front_index_(0) {} - devector(devector const& x) BOOST_NOEXCEPT - : data_(x.data_), - front_index_(x.front_index_) - {} - devector(BOOST_RV_REF(devector) x) BOOST_NOEXCEPT - : data_(boost::move(x.data_)), - front_index_(x.front_index_) - {} - - devector& operator=(BOOST_COPY_ASSIGN_REF(devector) x) - { - if (&x != this) - { - data_ = x.data_; - front_index_ = x.front_index_; - } - return *this; - } - - devector& operator=(BOOST_RV_REF(devector) x) -#if defined BOOST_THREAD_USES_BOOST_VECTOR - BOOST_NOEXCEPT_IF(vector_type::allocator_traits_type::propagate_on_container_move_assignment::value) -#endif - { - data_ = boost::move(x.data_); - front_index_ = x.front_index_; - return *this; - } - - bool empty() const BOOST_NOEXCEPT - { return data_.size() == front_index_; } - - size_type size() const BOOST_NOEXCEPT - { return data_.size() - front_index_; } - - reference front() BOOST_NOEXCEPT - { return data_[front_index_]; } - - const_reference front() const BOOST_NOEXCEPT - { return data_[front_index_]; } - - reference back() BOOST_NOEXCEPT - { return data_.back(); } - - const_reference back() const BOOST_NOEXCEPT - { return data_.back(); } - - BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back) - - void pop_front() - { - ++front_index_; - if (empty()) { - data_.clear(); - front_index_=0; - } - } - - }; - } -} -#endif // header diff --git a/libraries/boost/boost/thread/csbl/functional.hpp b/libraries/boost/boost/thread/csbl/functional.hpp deleted file mode 100644 index 7a7e928b7..000000000 --- a/libraries/boost/boost/thread/csbl/functional.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_FUNCTIONAL_HPP -#define BOOST_CSBL_FUNCTIONAL_HPP - -#include - -#include - -#if defined BOOST_THREAD_USES_BOOST_FUNCTIONAL || defined BOOST_NO_CXX11_HDR_FUNCTIONAL || defined BOOST_NO_CXX11_RVALUE_REFERENCES -#ifndef BOOST_THREAD_USES_BOOST_FUNCTIONAL -#define BOOST_THREAD_USES_BOOST_FUNCTIONAL -#endif -#include -#endif - -namespace boost -{ - namespace csbl - { -#if defined BOOST_THREAD_USES_BOOST_FUNCTIONAL - using ::boost::function; -#else - // D.8.1, base (deprecated): - // 20.9.3, reference_wrapper: - // 20.9.4, arithmetic operations: - // 20.9.5, comparisons: - // 20.9.6, logical operations: - // 20.9.7, bitwise operations: - // 20.9.8, negators: - // 20.9.9, bind: - // D.9, binders (deprecated): - // D.8.2.1, adaptors (deprecated): - // D.8.2.2, adaptors (deprecated): - // 20.9.10, member function adaptors: - // 20.9.11 polymorphic function wrappers: - using ::std::function; - // 20.9.12, hash function primary template: -#endif - - } -} -#endif // header diff --git a/libraries/boost/boost/thread/csbl/list.hpp b/libraries/boost/boost/thread/csbl/list.hpp deleted file mode 100644 index 52ff45d34..000000000 --- a/libraries/boost/boost/thread/csbl/list.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_LIST_HPP -#define BOOST_CSBL_LIST_HPP - -#include - -#if defined BOOST_THREAD_USES_BOOST_LIST || defined BOOST_NO_CXX11_RVALUE_REFERENCES -#ifndef BOOST_THREAD_USES_BOOST_LIST -#define BOOST_THREAD_USES_BOOST_LIST -#endif -#include -#else -#include -#endif - -namespace boost -{ - namespace csbl - { -#if defined BOOST_THREAD_USES_BOOST_LIST - using ::boost::container::list; -#else - using ::std::list; -#endif - - } -} -#endif // header diff --git a/libraries/boost/boost/thread/csbl/memory.hpp b/libraries/boost/boost/thread/csbl/memory.hpp deleted file mode 100644 index e076f11ad..000000000 --- a/libraries/boost/boost/thread/csbl/memory.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_MEMORY_HPP -#define BOOST_CSBL_MEMORY_HPP - -// 20.7.2 Header synopsis - -// 20.7.3, pointer traits -#include - -// 20.7.4, pointer safety -// 20.7.5, pointer alignment function - -// 20.7.6, allocator argument tag -#include - -// 20.7.8, allocator traits -#include - -// 20.7.7, uses_allocator -#include - -// 20.7.9, the default allocator: -namespace boost -{ - namespace csbl - { - using ::std::allocator; - } -} -// 20.7.10, raw storage iterator: -// 20.7.11, temporary buffers: -// 20.7.12, specialized algorithms: - -// 20.8.1 class template unique_ptr: -// default_delete -#include -#include - -// 20.8.2.1, class bad_weak_ptr: -// 20.8.2.2, class template shared_ptr: -// 20.8.2.2.6, shared_ptr creation -// 20.8.2.2.7, shared_ptr comparisons: -// 20.8.2.2.8, shared_ptr specialized algorithms: -// 20.8.2.2.9, shared_ptr casts: -// 20.8.2.2.10, shared_ptr get_deleter: -// 20.8.2.2.11, shared_ptr I/O: -// 20.8.2.3, class template weak_ptr: -// 20.8.2.3.6, weak_ptr specialized algorithms: -// 20.8.2.3.7, class template owner_less: -// 20.8.2.4, class template enable_shared_from_this: -// 20.8.2.5, shared_ptr atomic access: -// 20.8.2.6 hash support - -#endif // header diff --git a/libraries/boost/boost/thread/csbl/memory/allocator_arg.hpp b/libraries/boost/boost/thread/csbl/memory/allocator_arg.hpp deleted file mode 100644 index 354cdaee8..000000000 --- a/libraries/boost/boost/thread/csbl/memory/allocator_arg.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_MEMORY_ALLOCATOR_ARG_HPP -#define BOOST_CSBL_MEMORY_ALLOCATOR_ARG_HPP - -#include - -// 20.7.6, allocator argument tag -#if defined BOOST_NO_CXX11_ALLOCATOR -#include - -namespace boost -{ - namespace csbl - { - using ::boost::container::allocator_arg_t; - using ::boost::container::allocator_arg; - } -} -#else -namespace boost -{ - namespace csbl - { - using ::std::allocator_arg_t; - using ::std::allocator_arg; - } -} -#endif // BOOST_NO_CXX11_ALLOCATOR -namespace boost -{ - using ::boost::csbl::allocator_arg_t; - using ::boost::csbl::allocator_arg; -} -#endif // header diff --git a/libraries/boost/boost/thread/csbl/memory/allocator_traits.hpp b/libraries/boost/boost/thread/csbl/memory/allocator_traits.hpp deleted file mode 100644 index 3737cd85d..000000000 --- a/libraries/boost/boost/thread/csbl/memory/allocator_traits.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_MEMORY_ALLOCATOR_TRAITS_HPP -#define BOOST_CSBL_MEMORY_ALLOCATOR_TRAITS_HPP - -#include - -// 20.7.8, allocator traits -#if defined BOOST_NO_CXX11_ALLOCATOR -#include - -namespace boost -{ - namespace csbl - { - using ::boost::container::allocator_traits; - } -} -#else -namespace boost -{ - namespace csbl - { - using ::std::allocator_traits; - } -} -#endif // BOOST_NO_CXX11_POINTER_TRAITS - -#endif // header diff --git a/libraries/boost/boost/thread/csbl/memory/config.hpp b/libraries/boost/boost/thread/csbl/memory/config.hpp deleted file mode 100644 index 7b0596ac4..000000000 --- a/libraries/boost/boost/thread/csbl/memory/config.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_MEMORY_CONFIG_HPP -#define BOOST_CSBL_MEMORY_CONFIG_HPP - -#include - -#include - -#endif // header diff --git a/libraries/boost/boost/thread/csbl/memory/default_delete.hpp b/libraries/boost/boost/thread/csbl/memory/default_delete.hpp deleted file mode 100644 index d20153b30..000000000 --- a/libraries/boost/boost/thread/csbl/memory/default_delete.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_MEMORY_DEFAULT_DELETE_HPP -#define BOOST_CSBL_MEMORY_DEFAULT_DELETE_HPP - -#include - -// 20.8.1 class template unique_ptr: -// default_delete - -#if defined BOOST_NO_CXX11_SMART_PTR -#include - -namespace boost -{ - namespace csbl - { - using ::boost::movelib::default_delete; - } -} -#else -namespace boost -{ - namespace csbl - { - using ::std::default_delete; - } -} -#endif // defined BOOST_NO_CXX11_SMART_PTR - -namespace boost -{ - using ::boost::csbl::default_delete; -} -#endif // header diff --git a/libraries/boost/boost/thread/csbl/memory/pointer_traits.hpp b/libraries/boost/boost/thread/csbl/memory/pointer_traits.hpp deleted file mode 100644 index 320f8e9e7..000000000 --- a/libraries/boost/boost/thread/csbl/memory/pointer_traits.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_MEMORY_POINTER_TRAITS_HPP -#define BOOST_CSBL_MEMORY_POINTER_TRAITS_HPP - -#include - -// 20.7.3, pointer traits -#if defined BOOST_NO_CXX11_ALLOCATOR -#include - -namespace boost -{ - namespace csbl - { - using ::boost::intrusive::pointer_traits; - } -} -#else -namespace boost -{ - namespace csbl - { - using ::std::pointer_traits; - } -} -#endif // BOOST_NO_CXX11_ALLOCATOR - -#endif // header diff --git a/libraries/boost/boost/thread/csbl/memory/scoped_allocator.hpp b/libraries/boost/boost/thread/csbl/memory/scoped_allocator.hpp deleted file mode 100644 index a92f3d851..000000000 --- a/libraries/boost/boost/thread/csbl/memory/scoped_allocator.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_MEMORY_SCOPED_ALLOCATOR_HPP -#define BOOST_CSBL_MEMORY_SCOPED_ALLOCATOR_HPP - -#include - -// 20.7.7, uses_allocator -#if defined BOOST_NO_CXX11_ALLOCATOR -#include - -namespace boost -{ - namespace csbl - { - using ::boost::container::uses_allocator; - } -} -#else -namespace boost -{ - namespace csbl - { - using ::std::uses_allocator; - } -} -#endif // BOOST_NO_CXX11_POINTER_TRAITS - -#endif // header diff --git a/libraries/boost/boost/thread/csbl/memory/shared_ptr.hpp b/libraries/boost/boost/thread/csbl/memory/shared_ptr.hpp deleted file mode 100644 index e9a938372..000000000 --- a/libraries/boost/boost/thread/csbl/memory/shared_ptr.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2014/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_MEMORY_SHARED_PTR_HPP -#define BOOST_CSBL_MEMORY_SHARED_PTR_HPP - -#include - -#if defined BOOST_NO_CXX11_SMART_PTR - -#include -#include - -namespace boost -{ - namespace csbl - { - using ::boost::shared_ptr; - using ::boost::make_shared; - } -} - -#else - -#include - -namespace boost -{ - namespace csbl - { - using std::shared_ptr; - using std::make_shared; - } -} - -#endif -#endif // header diff --git a/libraries/boost/boost/thread/csbl/memory/unique_ptr.hpp b/libraries/boost/boost/thread/csbl/memory/unique_ptr.hpp deleted file mode 100644 index 17abf54e9..000000000 --- a/libraries/boost/boost/thread/csbl/memory/unique_ptr.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2013-2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation using interprocess::unique_ptr. -// 2014/09 Vicente J. Botet Escriba -// Adaptation to movelib::unique_ptr - -#ifndef BOOST_CSBL_MEMORY_UNIQUE_PTR_HPP -#define BOOST_CSBL_MEMORY_UNIQUE_PTR_HPP - -#include - -#include -#include - -namespace boost -{ - namespace csbl - { - using ::boost::movelib::unique_ptr; - using ::boost::movelib::make_unique; - - } -} -#endif // header diff --git a/libraries/boost/boost/thread/csbl/queue.hpp b/libraries/boost/boost/thread/csbl/queue.hpp deleted file mode 100644 index 1aa645d18..000000000 --- a/libraries/boost/boost/thread/csbl/queue.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2015 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_QUEUE_HPP -#define BOOST_CSBL_QUEUE_HPP - -#include -// MSVC has some trouble instantiating a non_copyable type -//C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xmemory0(606) : error C2248: 'non_copyable::non_copyable' : cannot access private member declared in class 'non_copyable' -// ..\libs\thread\test\sync\mutual_exclusion\queue_views\single_thread_pass.cpp(24) : see declaration of 'non_copyable::non_copyable' -// ..\libs\thread\test\sync\mutual_exclusion\queue_views\single_thread_pass.cpp(23) : see declaration of 'non_copyable' -// C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xmemory0(605) : while compiling class template member function 'void std::allocator<_Ty>::construct(_Ty *,const _Ty &)' -// with -// [ -// _Ty=non_copyable -// ] -#if defined BOOST_THREAD_USES_BOOST_QUEUE || defined BOOST_NO_CXX11_RVALUE_REFERENCES || (defined _MSC_VER && _MSC_FULL_VER < 180020827) -#ifndef BOOST_THREAD_USES_BOOST_QUEUE -#define BOOST_THREAD_USES_BOOST_QUEUE -#endif -#include -#else -#include -#endif - -namespace boost -{ - namespace csbl - { -#if defined BOOST_THREAD_USES_BOOST_QUEUE - using ::boost::container::queue; - -#else - using ::std::queue; - -#endif - - } -} -#endif // header diff --git a/libraries/boost/boost/thread/csbl/tuple.hpp b/libraries/boost/boost/thread/csbl/tuple.hpp deleted file mode 100644 index 860229ebe..000000000 --- a/libraries/boost/boost/thread/csbl/tuple.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_TUPLE_HPP -#define BOOST_CSBL_TUPLE_HPP - -#include - -#if defined BOOST_THREAD_USES_BOOST_TUPLE || defined BOOST_NO_CXX11_HDR_TUPLE || defined BOOST_NO_CXX11_RVALUE_REFERENCES -#include -#ifndef BOOST_THREAD_USES_BOOST_TUPLE -#define BOOST_THREAD_USES_BOOST_TUPLE -#endif - -#else -#include -#endif - -namespace boost -{ - namespace csbl - { -#if defined BOOST_THREAD_USES_BOOST_TUPLE - using ::boost::tuple; - using ::boost::get; - using ::boost::make_tuple; - //using ::boost::tuple_size; -#else - // 20.4.2, class template tuple: - using ::std::tuple; - using ::std::get; - using ::std::make_tuple; - using ::std::tuple_size; - // 20.4.2.4, tuple creation functions: - // 20.4.2.5, tuple helper classes: - // 20.4.2.6, element access: - // 20.4.2.7, relational operators: - // 20.4.2.8, allocator-related traits - // 20.4.2.9, specialized algorithms: -#endif - - } -} -#endif // header diff --git a/libraries/boost/boost/thread/csbl/vector.hpp b/libraries/boost/boost/thread/csbl/vector.hpp deleted file mode 100644 index c77a5b143..000000000 --- a/libraries/boost/boost/thread/csbl/vector.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/10 Vicente J. Botet Escriba -// Creation. - -#ifndef BOOST_CSBL_VECTOR_HPP -#define BOOST_CSBL_VECTOR_HPP - -#include - -#if defined BOOST_THREAD_USES_BOOST_VECTOR || defined BOOST_NO_CXX11_RVALUE_REFERENCES || defined BOOST_MSVC -#ifndef BOOST_THREAD_USES_BOOST_VECTOR -#define BOOST_THREAD_USES_BOOST_VECTOR -#endif -#include -#else -#include -#endif - -namespace boost -{ - namespace csbl - { -#if defined BOOST_THREAD_USES_BOOST_VECTOR - using ::boost::container::vector; -#else - using ::std::vector; -#endif - - } -} -#endif // header diff --git a/libraries/boost/boost/thread/cv_status.hpp b/libraries/boost/boost/thread/cv_status.hpp deleted file mode 100644 index e52de4a52..000000000 --- a/libraries/boost/boost/thread/cv_status.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// cv_status.hpp -// -// Copyright (C) 2011 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_CV_STATUS_HPP -#define BOOST_THREAD_CV_STATUS_HPP - -#include - -namespace boost -{ - - // enum class cv_status; - BOOST_SCOPED_ENUM_DECLARE_BEGIN(cv_status) - { - no_timeout, - timeout - } - BOOST_SCOPED_ENUM_DECLARE_END(cv_status) -} - -#endif // header diff --git a/libraries/boost/boost/thread/detail/config.hpp b/libraries/boost/boost/thread/detail/config.hpp deleted file mode 100644 index b060b81c9..000000000 --- a/libraries/boost/boost/thread/detail/config.hpp +++ /dev/null @@ -1,472 +0,0 @@ -// Copyright (C) 2001-2003 -// William E. Kempf -// Copyright (C) 2011-2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_CONFIG_WEK01032003_HPP -#define BOOST_THREAD_CONFIG_WEK01032003_HPP - -#include -#include -#include - -//#define BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS -// ATTRIBUTE_MAY_ALIAS - -#if defined(__GNUC__) && !defined(__INTEL_COMPILER) - - // GCC since 3.3 has may_alias attribute that helps to alleviate optimizer issues with - // regard to violation of the strict aliasing rules. - - #define BOOST_THREAD_DETAIL_USE_ATTRIBUTE_MAY_ALIAS - #define BOOST_THREAD_ATTRIBUTE_MAY_ALIAS __attribute__((__may_alias__)) -#else - #define BOOST_THREAD_ATTRIBUTE_MAY_ALIAS -#endif - - -#if defined BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED -#define BOOST_THREAD_ASSERT_PRECONDITION(EXPR, EX) \ - if (EXPR) {} else boost::throw_exception(EX) -#define BOOST_THREAD_VERIFY_PRECONDITION(EXPR, EX) \ - if (EXPR) {} else boost::throw_exception(EX) -#define BOOST_THREAD_THROW_ELSE_RETURN(EX, RET) \ - boost::throw_exception(EX) -#else -#define BOOST_THREAD_ASSERT_PRECONDITION(EXPR, EX) -#define BOOST_THREAD_VERIFY_PRECONDITION(EXPR, EX) \ - (void)(EXPR) -#define BOOST_THREAD_THROW_ELSE_RETURN(EX, RET) \ - return (RET) -#endif - -// This compiler doesn't support Boost.Chrono -#if defined __IBMCPP__ && (__IBMCPP__ < 1100) \ - && ! defined BOOST_THREAD_DONT_USE_CHRONO -#define BOOST_THREAD_DONT_USE_CHRONO -#if ! defined BOOST_THREAD_USES_DATETIME -#define BOOST_THREAD_USES_DATETIME -#endif -#endif - -// This compiler doesn't support Boost.Move -#if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) \ - && ! defined BOOST_THREAD_DONT_USE_MOVE -#define BOOST_THREAD_DONT_USE_MOVE -#endif - -// This compiler doesn't support Boost.Container Allocators files -#if defined __SUNPRO_CC \ - && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS -#define BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS -#endif - -#if defined _WIN32_WCE && _WIN32_WCE==0x501 \ - && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS -#define BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS -#endif - - -#if defined BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX || defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST -#define BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST -#define BOOST_THREAD_NO_MAKE_LOCK_GUARD -#define BOOST_THREAD_NO_MAKE_STRICT_LOCK -#define BOOST_THREAD_NO_MAKE_NESTED_STRICT_LOCK -#endif - -#if defined(BOOST_NO_CXX11_HDR_TUPLE) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES) -#define BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS -#define BOOST_THREAD_NO_SYNCHRONIZE -#elif defined _MSC_VER && _MSC_VER <= 1600 -// C++ features supported by VC++ 10 (aka 2010) -#define BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS -#define BOOST_THREAD_NO_SYNCHRONIZE -#endif - -/// BASIC_THREAD_ID -#if ! defined BOOST_THREAD_DONT_PROVIDE_BASIC_THREAD_ID \ - && ! defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID -#define BOOST_THREAD_PROVIDES_BASIC_THREAD_ID -#endif - -/// RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR -//#if defined BOOST_NO_CXX11_RVALUE_REFERENCES || defined BOOST_MSVC -#define BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR -//#endif - -// Default version -#if !defined BOOST_THREAD_VERSION -#define BOOST_THREAD_VERSION 2 -#else -#if BOOST_THREAD_VERSION!=2 && BOOST_THREAD_VERSION!=3 && BOOST_THREAD_VERSION!=4 && BOOST_THREAD_VERSION!=5 -#error "BOOST_THREAD_VERSION must be 2, 3, 4 or 5" -#endif -#endif - -// CHRONO -// Uses Boost.Chrono by default if not stated the opposite defining BOOST_THREAD_DONT_USE_CHRONO -#if ! defined BOOST_THREAD_DONT_USE_CHRONO \ - && ! defined BOOST_THREAD_USES_CHRONO -#define BOOST_THREAD_USES_CHRONO -#endif - -#if ! defined BOOST_THREAD_DONT_USE_ATOMIC \ - && ! defined BOOST_THREAD_USES_ATOMIC -#define BOOST_THREAD_USES_ATOMIC -//#define BOOST_THREAD_DONT_USE_ATOMIC -#endif - -#if defined BOOST_THREAD_USES_ATOMIC -// Andrey Semashev -#define BOOST_THREAD_ONCE_ATOMIC -#else -//#elif ! defined BOOST_NO_CXX11_THREAD_LOCAL && ! defined BOOST_NO_THREAD_LOCAL && ! defined BOOST_THREAD_NO_UINT32_PSEUDO_ATOMIC -// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2444.html#Appendix -#define BOOST_THREAD_ONCE_FAST_EPOCH -#endif -#if BOOST_THREAD_VERSION==2 - -// PROVIDE_PROMISE_LAZY -#if ! defined BOOST_THREAD_DONT_PROVIDE_PROMISE_LAZY \ - && ! defined BOOST_THREAD_PROVIDES_PROMISE_LAZY -#define BOOST_THREAD_PROVIDES_PROMISE_LAZY -#endif - -// PROVIDE_THREAD_EQ -#if ! defined BOOST_THREAD_DONT_PROVIDE_THREAD_EQ \ - && ! defined BOOST_THREAD_PROVIDES_THREAD_EQ -#define BOOST_THREAD_PROVIDES_THREAD_EQ -#endif - -#endif - -#if BOOST_THREAD_VERSION>=3 - -// ONCE_CXX11 -// fixme BOOST_THREAD_PROVIDES_ONCE_CXX11 doesn't works when thread.cpp is compiled BOOST_THREAD_VERSION 3 -#if ! defined BOOST_THREAD_DONT_PROVIDE_ONCE_CXX11 \ - && ! defined BOOST_THREAD_PROVIDES_ONCE_CXX11 -#define BOOST_THREAD_DONT_PROVIDE_ONCE_CXX11 -#endif - -// THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE -#if ! defined BOOST_THREAD_DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE \ - && ! defined BOOST_THREAD_PROVIDES_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE -#define BOOST_THREAD_PROVIDES_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE -#endif - -// THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE -#if ! defined BOOST_THREAD_DONT_PROVIDE_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE \ - && ! defined BOOST_THREAD_PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE -#define BOOST_THREAD_PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE -#endif - -// PROVIDE_FUTURE -#if ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE \ - && ! defined BOOST_THREAD_PROVIDES_FUTURE -#define BOOST_THREAD_PROVIDES_FUTURE -#endif - -// FUTURE_CTOR_ALLOCATORS -#if ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS \ - && ! defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS -#define BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS -#endif - -// SHARED_MUTEX_UPWARDS_CONVERSIONS -#if ! defined BOOST_THREAD_DONT_PROVIDE_SHARED_MUTEX_UPWARDS_CONVERSIONS \ - && ! defined BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS -#define BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS -#endif - -// PROVIDE_EXPLICIT_LOCK_CONVERSION -#if ! defined BOOST_THREAD_DONT_PROVIDE_EXPLICIT_LOCK_CONVERSION \ - && ! defined BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION -#define BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION -#endif - -// GENERIC_SHARED_MUTEX_ON_WIN -#if ! defined BOOST_THREAD_DONT_PROVIDE_GENERIC_SHARED_MUTEX_ON_WIN \ - && ! defined BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN -#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN -#endif - -// USE_MOVE -#if ! defined BOOST_THREAD_DONT_USE_MOVE \ - && ! defined BOOST_THREAD_USES_MOVE -#define BOOST_THREAD_USES_MOVE -#endif - -#endif - -// deprecated since version 4 -#if BOOST_THREAD_VERSION < 4 - -// NESTED_LOCKS -#if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS \ - && ! defined BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS -#define BOOST_THREAD_PROVIDES_NESTED_LOCKS -#endif - -// CONDITION -#if ! defined BOOST_THREAD_PROVIDES_CONDITION \ - && ! defined BOOST_THREAD_DONT_PROVIDE_CONDITION -#define BOOST_THREAD_PROVIDES_CONDITION -#endif - -// USE_DATETIME -#if ! defined BOOST_THREAD_DONT_USE_DATETIME \ - && ! defined BOOST_THREAD_USES_DATETIME -#define BOOST_THREAD_USES_DATETIME -#endif -#endif - -#if BOOST_THREAD_VERSION>=4 - -// SIGNATURE_PACKAGED_TASK -#if ! defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK \ - && ! defined BOOST_THREAD_DONT_PROVIDE_SIGNATURE_PACKAGED_TASK -#define BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK -#endif - -// VARIADIC_THREAD -#if ! defined BOOST_THREAD_PROVIDES_VARIADIC_THREAD \ - && ! defined BOOST_THREAD_DONT_PROVIDE_VARIADIC_THREAD - -#if ! defined(BOOST_NO_SFINAE_EXPR) && \ - ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \ - ! defined(BOOST_NO_CXX11_DECLTYPE) && \ - ! defined(BOOST_NO_CXX11_DECLTYPE_N3276) && \ - ! defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) && \ - ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \ - ! defined(BOOST_NO_CXX11_HDR_TUPLE) - -#define BOOST_THREAD_PROVIDES_VARIADIC_THREAD -#endif -#endif - -#if ! defined BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY \ - && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_WHEN_ALL_WHEN_ANY - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \ - ! defined(BOOST_NO_CXX11_HDR_TUPLE) - -#define BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY -#endif -#endif - -// ! defined(BOOST_NO_SFINAE_EXPR) && -// ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && -// ! defined(BOOST_NO_CXX11_AUTO) && -// ! defined(BOOST_NO_CXX11_DECLTYPE) && -// ! defined(BOOST_NO_CXX11_DECLTYPE_N3276) && - - -// MAKE_READY_AT_THREAD_EXIT -#if ! defined BOOST_THREAD_PROVIDES_MAKE_READY_AT_THREAD_EXIT \ - && ! defined BOOST_THREAD_DONT_PROVIDE_MAKE_READY_AT_THREAD_EXIT - -//#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) -#define BOOST_THREAD_PROVIDES_MAKE_READY_AT_THREAD_EXIT -//#endif -#endif - -// FUTURE_CONTINUATION -#if ! defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION \ - && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_CONTINUATION -#define BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION -#endif - -#if ! defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP \ - && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_UNWRAP -#define BOOST_THREAD_PROVIDES_FUTURE_UNWRAP -#endif - -// FUTURE_INVALID_AFTER_GET -#if ! defined BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET \ - && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_INVALID_AFTER_GET -#define BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET -#endif - -// NESTED_LOCKS -#if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS \ - && ! defined BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS -#define BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS -#endif - -// CONDITION -#if ! defined BOOST_THREAD_PROVIDES_CONDITION \ - && ! defined BOOST_THREAD_DONT_PROVIDE_CONDITION -#define BOOST_THREAD_DONT_PROVIDE_CONDITION -#endif - -#endif // BOOST_THREAD_VERSION>=4 - - -#if BOOST_THREAD_VERSION>=5 -//#define BOOST_THREAD_FUTURE_BLOCKING -#else -//#define BOOST_THREAD_FUTURE_BLOCKING -#define BOOST_THREAD_ASYNC_FUTURE_WAITS -#endif -// INTERRUPTIONS -#if ! defined BOOST_THREAD_PROVIDES_INTERRUPTIONS \ - && ! defined BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS -#define BOOST_THREAD_PROVIDES_INTERRUPTIONS -#endif - -// CORRELATIONS - -// EXPLICIT_LOCK_CONVERSION. -#if defined BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION -#define BOOST_THREAD_EXPLICIT_LOCK_CONVERSION explicit -#else -#define BOOST_THREAD_EXPLICIT_LOCK_CONVERSION -#endif - -// BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN is defined if BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS -#if defined BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS \ -&& ! defined BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN -#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN -#endif - -// For C++11 call_once interface the compiler MUST support constexpr. -// Otherwise once_flag would be initialized during dynamic initialization stage, which is not thread-safe. -#if defined(BOOST_THREAD_PROVIDES_ONCE_CXX11) -#if defined(BOOST_NO_CXX11_CONSTEXPR) -#undef BOOST_THREAD_PROVIDES_ONCE_CXX11 -#endif -#endif - -#if defined(BOOST_THREAD_PLATFORM_WIN32) && defined BOOST_THREAD_DONT_USE_DATETIME -#undef BOOST_THREAD_DONT_USE_DATETIME -#define BOOST_THREAD_USES_DATETIME -#endif - -#if defined(BOOST_THREAD_PLATFORM_WIN32) && defined BOOST_THREAD_DONT_USE_CHRONO -#undef BOOST_THREAD_DONT_USE_CHRONO -#define BOOST_THREAD_USES_CHRONO -#endif - -// BOOST_THREAD_PROVIDES_DEPRECATED_FEATURES_SINCE_V3_0_0 defined by default up to Boost 1.55 -// BOOST_THREAD_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V3_0_0 defined by default up to Boost 1.55 -#if defined BOOST_THREAD_PROVIDES_DEPRECATED_FEATURES_SINCE_V3_0_0 - -#if ! defined BOOST_THREAD_PROVIDES_THREAD_EQ -#define BOOST_THREAD_PROVIDES_THREAD_EQ -#endif - -#endif - - -//#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES || defined BOOST_THREAD_USES_MOVE -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES -#define BOOST_THREAD_FUTURE_USES_OPTIONAL -#endif - -#if BOOST_WORKAROUND(__BORLANDC__, < 0x600) -# pragma warn -8008 // Condition always true/false -# pragma warn -8080 // Identifier declared but never used -# pragma warn -8057 // Parameter never used -# pragma warn -8066 // Unreachable code -#endif - -#include - -#if defined(BOOST_THREAD_PLATFORM_WIN32) -#else - # if defined(BOOST_HAS_PTHREAD_DELAY_NP) || defined(BOOST_HAS_NANOSLEEP) - # define BOOST_THREAD_SLEEP_FOR_IS_STEADY - # endif -#endif - -// provided for backwards compatibility, since this -// macro was used for several releases by mistake. -#if defined(BOOST_THREAD_DYN_DLL) && ! defined BOOST_THREAD_DYN_LINK -# define BOOST_THREAD_DYN_LINK -#endif - -// compatibility with the rest of Boost's auto-linking code: -#if defined(BOOST_THREAD_DYN_LINK) || defined(BOOST_ALL_DYN_LINK) -# undef BOOST_THREAD_USE_LIB -# if !defined(BOOST_THREAD_USE_DLL) -# define BOOST_THREAD_USE_DLL -# endif -#endif - -#if defined(BOOST_THREAD_BUILD_DLL) //Build dll -#elif defined(BOOST_THREAD_BUILD_LIB) //Build lib -#elif defined(BOOST_THREAD_USE_DLL) //Use dll -#elif defined(BOOST_THREAD_USE_LIB) //Use lib -#else //Use default -# if defined(BOOST_THREAD_PLATFORM_WIN32) -# if defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) \ - || defined(__MINGW32__) || defined(MINGW32) || defined(BOOST_MINGW32) - //For compilers supporting auto-tss cleanup - //with Boost.Threads lib, use Boost.Threads lib -# define BOOST_THREAD_USE_LIB -# else - //For compilers not yet supporting auto-tss cleanup - //with Boost.Threads lib, use Boost.Threads dll -# define BOOST_THREAD_USE_DLL -# endif -# else -# define BOOST_THREAD_USE_LIB -# endif -#endif - -#if defined(BOOST_HAS_DECLSPEC) -# if defined(BOOST_THREAD_BUILD_DLL) //Build dll -# define BOOST_THREAD_DECL BOOST_SYMBOL_EXPORT -//# define BOOST_THREAD_DECL __declspec(dllexport) - -# elif defined(BOOST_THREAD_USE_DLL) //Use dll -# define BOOST_THREAD_DECL BOOST_SYMBOL_IMPORT -//# define BOOST_THREAD_DECL __declspec(dllimport) -# else -# define BOOST_THREAD_DECL -# endif -#elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# define BOOST_THREAD_DECL BOOST_SYMBOL_VISIBLE - -#else -# define BOOST_THREAD_DECL -#endif // BOOST_HAS_DECLSPEC - -// -// Automatically link to the correct build variant where possible. -// -#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_THREAD_NO_LIB) && !defined(BOOST_THREAD_BUILD_DLL) && !defined(BOOST_THREAD_BUILD_LIB) -// -// Tell the autolink to link dynamically, this will get undef'ed by auto_link.hpp -// once it's done with it: -// -#if defined(BOOST_THREAD_USE_DLL) -# define BOOST_DYN_LINK -#endif -// -// Set the name of our library, this will get undef'ed by auto_link.hpp -// once it's done with it: -// -#if defined(BOOST_THREAD_LIB_NAME) -# define BOOST_LIB_NAME BOOST_THREAD_LIB_NAME -#else -# define BOOST_LIB_NAME boost_thread -#endif -// -// If we're importing code from a dll, then tell auto_link.hpp about it: -// -// And include the header that does the work: -// -#include -#endif // auto-linking disabled - -#endif // BOOST_THREAD_CONFIG_WEK1032003_HPP - -// Change Log: -// 22 Jan 05 Roland Schwarz (speedsnail) -// Usage of BOOST_HAS_DECLSPEC macro. -// Default again is static lib usage. -// BOOST_DYN_LINK only defined when autolink included. diff --git a/libraries/boost/boost/thread/detail/counter.hpp b/libraries/boost/boost/thread/detail/counter.hpp deleted file mode 100644 index 38e1597c5..000000000 --- a/libraries/boost/boost/thread/detail/counter.hpp +++ /dev/null @@ -1,106 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2013 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_COUNTER_HPP -#define BOOST_THREAD_COUNTER_HPP - -#include -#include - -//#include -//#include -#include -#include -#include -#include - -#include - -namespace boost -{ - namespace detail { - struct counter - { - condition_variable cond_; - std::size_t value_; - - counter(std::size_t value) - : value_(value) - { - - } - counter& operator=(counter const& rhs) - { - value_ = rhs.value_; - return *this; - } - counter& operator=(std::size_t value) - { - value_ = value; - return *this; - } - - operator std::size_t() const - { - return value_; - } - operator std::size_t&() - { - return value_; - } - - void inc_and_notify_all() - { - ++value_; - cond_.notify_all(); - } - - void dec_and_notify_all() - { - --value_; - cond_.notify_all(); - } - void assign_and_notify_all(counter const& rhs) - { - value_ = rhs.value_; - cond_.notify_all(); - } - void assign_and_notify_all(std::size_t value) - { - value_ = value; - cond_.notify_all(); - } - }; - struct counter_is_not_zero - { - counter_is_not_zero(counter const& count) : count_(count) {} - bool operator()() const { return count_ != 0; } - counter const& count_; - }; - struct counter_is_zero - { - counter_is_zero(counter const& count) : count_(count) {} - bool operator()() const { return count_ == 0; } - counter const& count_; - }; - struct is_zero - { - is_zero(std::size_t& count) : count_(count) {} - bool operator()() const { return count_ == 0; } - std::size_t& count_; - }; - struct not_equal - { - not_equal(std::size_t& x, std::size_t& y) : x_(x), y_(y) {} - bool operator()() const { return x_ != y_; } - std::size_t& x_; - std::size_t& y_; - }; - } -} // namespace boost - -#include - -#endif diff --git a/libraries/boost/boost/thread/detail/delete.hpp b/libraries/boost/boost/thread/detail/delete.hpp deleted file mode 100644 index 8f8113f4e..000000000 --- a/libraries/boost/boost/thread/detail/delete.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_DETAIL_DELETE_HPP -#define BOOST_THREAD_DETAIL_DELETE_HPP - -#include - -/** - * BOOST_THREAD_DELETE_COPY_CTOR deletes the copy constructor when the compiler supports it or - * makes it private. - * - * BOOST_THREAD_DELETE_COPY_ASSIGN deletes the copy assignment when the compiler supports it or - * makes it private. - */ - -#if ! defined BOOST_NO_CXX11_DELETED_FUNCTIONS && ! defined BOOST_NO_CXX11_RVALUE_REFERENCES -#define BOOST_THREAD_DELETE_COPY_CTOR(CLASS) \ - CLASS(CLASS const&) = delete; \ - -#define BOOST_THREAD_DELETE_COPY_ASSIGN(CLASS) \ - CLASS& operator=(CLASS const&) = delete; - -#else // BOOST_NO_CXX11_DELETED_FUNCTIONS -#if defined(BOOST_MSVC) && _MSC_VER >= 1600 -#define BOOST_THREAD_DELETE_COPY_CTOR(CLASS) \ - private: \ - CLASS(CLASS const&); \ - public: - -#define BOOST_THREAD_DELETE_COPY_ASSIGN(CLASS) \ - private: \ - CLASS& operator=(CLASS const&); \ - public: -#else -#define BOOST_THREAD_DELETE_COPY_CTOR(CLASS) \ - private: \ - CLASS(CLASS&); \ - public: - -#define BOOST_THREAD_DELETE_COPY_ASSIGN(CLASS) \ - private: \ - CLASS& operator=(CLASS&); \ - public: -#endif -#endif // BOOST_NO_CXX11_DELETED_FUNCTIONS - -/** - * BOOST_THREAD_NO_COPYABLE deletes the copy constructor and assignment when the compiler supports it or - * makes them private. - */ -#define BOOST_THREAD_NO_COPYABLE(CLASS) \ - BOOST_THREAD_DELETE_COPY_CTOR(CLASS) \ - BOOST_THREAD_DELETE_COPY_ASSIGN(CLASS) - -#endif // BOOST_THREAD_DETAIL_DELETE_HPP diff --git a/libraries/boost/boost/thread/detail/force_cast.hpp b/libraries/boost/boost/thread/detail/force_cast.hpp deleted file mode 100644 index d5d15adc1..000000000 --- a/libraries/boost/boost/thread/detail/force_cast.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2001-2003 -// Mac Murrett -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org for most recent version including documentation. - -#ifndef BOOST_FORCE_CAST_MJM012402_HPP -#define BOOST_FORCE_CAST_MJM012402_HPP - -#include - -namespace boost { -namespace detail { -namespace thread { - -// force_cast will convert anything to anything. - -// general case -template -inline Return_Type &force_cast(Argument_Type &rSrc) -{ - return(*reinterpret_cast(&rSrc)); -} - -// specialization for const -template -inline const Return_Type &force_cast(const Argument_Type &rSrc) -{ - return(*reinterpret_cast(&rSrc)); -} - -} // namespace thread -} // namespace detail -} // namespace boost - -#endif // BOOST_FORCE_CAST_MJM012402_HPP diff --git a/libraries/boost/boost/thread/detail/function_wrapper.hpp b/libraries/boost/boost/thread/detail/function_wrapper.hpp deleted file mode 100644 index 355f72676..000000000 --- a/libraries/boost/boost/thread/detail/function_wrapper.hpp +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/09 Vicente J. Botet Escriba -// Adapt to boost from CCIA C++11 implementation -// Make use of Boost.Move - -#ifndef BOOST_THREAD_DETAIL_FUNCTION_WRAPPER_HPP -#define BOOST_THREAD_DETAIL_FUNCTION_WRAPPER_HPP - -#include -#include -#include - -#include - -#include -#include - -namespace boost -{ - namespace detail - { - class function_wrapper - { - struct impl_base - { - virtual void call()=0; - virtual ~impl_base() - { - } - }; - typedef boost::csbl::unique_ptr impl_base_type; - impl_base_type impl; - template - struct impl_type: impl_base - { - F f; - impl_type(F const &f_) - : f(f_) - {} - impl_type(BOOST_THREAD_RV_REF(F) f_) - : f(boost::move(f_)) - {} - - void call() - { - if (impl) f(); - } - }; - public: - BOOST_THREAD_MOVABLE_ONLY(function_wrapper) - -//#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - template - function_wrapper(F const& f): - impl(new impl_type(f)) - {} -//#endif - template - function_wrapper(BOOST_THREAD_RV_REF(F) f): - impl(new impl_type(boost::forward(f))) - {} - function_wrapper(BOOST_THREAD_RV_REF(function_wrapper) other) BOOST_NOEXCEPT : - impl(other.impl) - { - other.impl = 0; - } - function_wrapper() - : impl(0) - { - } - ~function_wrapper() - { - } - - function_wrapper& operator=(BOOST_THREAD_RV_REF(function_wrapper) other) BOOST_NOEXCEPT - { - impl=other.impl; - other.impl=0; - return *this; - } - - void operator()() - { impl->call();} - - }; - } -} - -#endif // header diff --git a/libraries/boost/boost/thread/detail/invoke.hpp b/libraries/boost/boost/thread/detail/invoke.hpp deleted file mode 100644 index e772da29e..000000000 --- a/libraries/boost/boost/thread/detail/invoke.hpp +++ /dev/null @@ -1,1604 +0,0 @@ -// Copyright (C) 2012-2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// 2013/04 Vicente J. Botet Escriba -// Provide implementation up to 9 parameters when BOOST_NO_CXX11_VARIADIC_TEMPLATES is defined. -// Make use of Boost.Move -// Make use of Boost.Tuple (movable) -// 2012 Vicente J. Botet Escriba -// Provide implementation _RET using bind when BOOST_NO_CXX11_HDR_FUNCTIONAL and BOOST_NO_SFINAE_EXPR are not defined -// 2012 Vicente J. Botet Escriba -// Adapt to boost libc++ implementation - -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -// The invoke code is based on the one from libcxx. -//===----------------------------------------------------------------------===// - -#ifndef BOOST_THREAD_DETAIL_INVOKE_HPP -#define BOOST_THREAD_DETAIL_INVOKE_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef BOOST_NO_CXX11_HDR_FUNCTIONAL -#include -#endif - -namespace boost -{ - namespace detail - { - - -#if ! defined(BOOST_NO_SFINAE_EXPR) && \ - ! defined(BOOST_NO_CXX11_DECLTYPE) && \ - ! defined(BOOST_NO_CXX11_DECLTYPE_N3276) && \ - ! defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) - -#define BOOST_THREAD_PROVIDES_INVOKE - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - // bullets 1 and 2 - - template - inline auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args) - -> decltype((boost::forward(a0).*f)(boost::forward(args)...)) - { - return (boost::forward(a0).*f)(boost::forward(args)...); - } - template - inline auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args) - -> decltype((boost::forward(a0).*f)(boost::forward(args)...)) - { - return (boost::forward(a0).*f)(boost::forward(args)...); - } - - template - inline auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args) - -> decltype(((*boost::forward(a0)).*f)(boost::forward(args)...)) - { - return ((*boost::forward(a0)).*f)(boost::forward(args)...); - } - template - inline auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args) - -> decltype(((*boost::forward(a0)).*f)(boost::forward(args)...)) - { - return ((*boost::forward(a0)).*f)(boost::forward(args)...); - } - - // bullets 3 and 4 - - template - inline auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0) - -> decltype(boost::forward(a0).*f) - { - return boost::forward(a0).*f; - } - - template - inline auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0) - -> decltype((*boost::forward(a0)).*f) - { - return (*boost::forward(a0)).*f; - } - - template - inline auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0) - -> decltype(boost::forward(a0).*f) - { - return boost::forward(a0).*f; - } - - template - inline auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0) - -> decltype((*boost::forward(a0)).*f) - { - return (*boost::forward(a0)).*f; - } - - - // bullet 5 - - template - inline auto invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(Args) ...args) - -> decltype(boost::forward(f)(boost::forward(args)...)) - { - return boost::forward(f)(boost::forward(args)...); - } - template - inline auto invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(Args) ...args) - -> decltype(boost::forward(f)(boost::forward(args)...)) - { - return boost::forward(f)(boost::forward(args)...); - } - -#else // BOOST_NO_CXX11_VARIADIC_TEMPLATES - - // bullets 1 and 2 - - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0) - -> decltype((boost::forward(a0).*f)()) - { - return (boost::forward(a0).*f)(); - } - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0) - -> decltype((boost::forward(a0).*f)()) - { - return (boost::forward(a0).*f)(); - } - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1) - -> decltype((boost::forward(a0).*f)(boost::forward(a1))) - { - return (boost::forward(a0).*f)(boost::forward(a1)); - } - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1) - -> decltype((boost::forward(a0).*f)(boost::forward(a1))) - { - return (boost::forward(a0).*f)(boost::forward(a1)); - } - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - -> decltype((boost::forward(a0).*f)(boost::forward(a1), boost::forward(a2))) - { - return (boost::forward(a0).*f)(boost::forward(a1), boost::forward(a2)); - } - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - -> decltype((boost::forward(a0).*f)(boost::forward(a1), boost::forward(a2))) - { - return (boost::forward(a0).*f)(boost::forward(a1), boost::forward(a2)); - } - - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0) - -> decltype(((*boost::forward(a0)).*f)()) - { - return ((*boost::forward(a0)).*f)(); - } - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0) - -> decltype(((*boost::forward(a0)).*f)()) - { - return ((*boost::forward(a0)).*f)(); - } - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1) - -> decltype(((*boost::forward(a0)).*f)(boost::forward(a1))) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1)); - } - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1) - -> decltype(((*boost::forward(a0)).*f)(boost::forward(a1))) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1)); - } - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - -> decltype(((*boost::forward(a0)).*f)(boost::forward(a1), boost::forward(a2))) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1), boost::forward(a2)); - } - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - -> decltype(((*boost::forward(a0)).*f)(boost::forward(a1), boost::forward(a2))) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1), boost::forward(a2)); - } - - // bullets 3 and 4 - - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0) - -> decltype(boost::forward(a0).*f) - { - return boost::forward(a0).*f; - } - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0) - -> decltype(boost::forward(a0).*f) - { - return boost::forward(a0).*f; - } - - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0) - -> decltype((*boost::forward(a0)).*f) - { - return (*boost::forward(a0)).*f; - } - template - inline - auto - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0) - -> decltype((*boost::forward(a0)).*f) - { - return (*boost::forward(a0)).*f; - } - - // bullet 5 - - template - inline - auto invoke(BOOST_THREAD_RV_REF(Fp) f) - -> decltype(boost::forward(f)()) - { - return boost::forward(f)(); - } - template - inline - auto invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1) - -> decltype(boost::forward(f)(boost::forward(a1))) - { - return boost::forward(f)(boost::forward(a1)); - } template - inline - auto invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - -> decltype(boost::forward(f)(boost::forward(a1), boost::forward(a2))) - { - return boost::forward(f)(boost::forward(a1), boost::forward(a2)); - } - template - inline - auto invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3) - -> decltype(boost::forward(f)(boost::forward(a1), boost::forward(a2), boost::forward(a3))) - { - return boost::forward(f)(boost::forward(a1), boost::forward(a2), boost::forward(a3)); - } - - - template - inline - auto invoke(BOOST_THREAD_RV_REF(Fp) f) - -> decltype(boost::forward(f)()) - { - return boost::forward(f)(); - } - template - inline - auto invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1) - -> decltype(boost::forward(f)(boost::forward(a1))) - { - return boost::forward(f)(boost::forward(a1)); - } - template - inline - auto invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - -> decltype(boost::forward(f)(boost::forward(a1), boost::forward(a2))) - { - return boost::forward(f)(boost::forward(a1), boost::forward(a2)); - } - template - inline - auto invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3) - -> decltype(boost::forward(f)(boost::forward(a1), boost::forward(a2), boost::forward(a3))) - { - return boost::forward(f)(boost::forward(a1), boost::forward(a2), boost::forward(a3)); - } - -#endif // BOOST_NO_CXX11_VARIADIC_TEMPLATES - -#elif ! defined(BOOST_NO_SFINAE_EXPR) && \ - ! defined BOOST_NO_CXX11_HDR_FUNCTIONAL && \ - defined BOOST_MSVC - - template - inline - Ret invoke(BOOST_THREAD_RV_REF(Fp) f) - { - return f(); - } - template - inline - Ret invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1) - { - return std::bind(boost::forward(f), boost::forward(a1))(); - } - template - inline - Ret invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - { - return std::bind(boost::forward(f), boost::forward(a1), boost::forward(a2))(); - } - template - inline - Ret invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3) - { - return std::bind(boost::forward(f), boost::forward(a1), boost::forward(a2), boost::forward(a3))(); - } - -#define BOOST_THREAD_PROVIDES_INVOKE_RET - -#elif ! defined BOOST_MSVC -//!!!!! WARNING !!!!! THIS DOESN'T WORKS YET -#define BOOST_THREAD_PROVIDES_INVOKE_RET - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - // bullet 1 - // (t1.*f)(t2, ..., tN) when f is a pointer to a member function of a class T and t1 is an object of - // type T or a reference to an object of type T or a reference to an object of a type derived from T - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(Args...), BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args) - { - return (boost::forward(a0).*f)(boost::forward(args)...); - } - - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(Args...) const, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args) - { - return (boost::forward(a0).*f)(boost::forward(args)...); - } - - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(Args...) volatile, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args) - { - return (boost::forward(a0).*f)(boost::forward(args)...); - } - - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(Args...) const volatile, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args) - { - return (boost::forward(a0).*f)(boost::forward(args)...); - } - - // bullet 2 - // ((*t1).*f)(t2, ..., tN) when f is a pointer to a member function of a class T and t1 is not one of - // the types described in the previous item; - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(Args...), BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args) - { - return ((*boost::forward(a0)).*f)(boost::forward(args)...); - } - - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(Args...) const, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args) - { - return ((*boost::forward(a0)).*f)(boost::forward(args)...); - } - - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(Args...) volatile, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args) - { - return ((*boost::forward(a0)).*f)(boost::forward(args)...); - } - - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(Args...) const volatile, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args) - { - return ((*boost::forward(a0)).*f)(boost::forward(args)...); - } - - // bullet 3 - // t1.*f when N == 1 and f is a pointer to member data of a class T and t1 is an object of type T or a - // reference to an object of type T or a reference to an object of a type derived from T; -// template -// inline -// typename enable_if_c -// < -// is_base_of::type>::value, -// typename detail::apply_cv::type& -// >::type -// invoke(Ret A::* f, BOOST_THREAD_RV_REF(A0) a0) -// { -// return boost::forward(a0).*f; -// } - - // bullet 4 - // (*t1).*f when N == 1 and f is a pointer to member data of a class T and t1 is not one of the types - //described in the previous item; - -// template -// struct d4th_helper -// { -// }; -// -// template -// struct d4th_helper -// { -// typedef typename apply_cv()), Ret>::type type; -// }; -// -// template -// inline -// typename detail::4th_helper::type -// >::value -// >::type& -// invoke(Ret A::* f, BOOST_THREAD_RV_REF(A0) a0) -// { -// return (*boost::forward(a0)).*f; -// } - -// template -// inline -// typename enable_if_c -// < -// !is_base_of::type>::value, -// typename detail::ref_return1::type -// >::type -// invoke(Ret A::* f, BOOST_THREAD_RV_REF(A0) a0) -// { -// return (*boost::forward(a0)).*f; -// } - - // bullet 5 - // f(t1, t2, ..., tN) in all other cases. - - template - inline Ret do_invoke(mpl::false_, BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(Args) ...args) - { - return boost::forward(f)(boost::forward(args)...); - } - - template - inline Ret do_invoke(mpl::true_, BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(Args) ...args) - { - return f(boost::forward(args)...); - } - - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(Args) ...args) - { - return boost::detail::do_invoke(boost::is_pointer(), boost::forward(f), boost::forward(args)...); - } -#else // BOOST_NO_CXX11_VARIADIC_TEMPLATES - // bullet 1 - // (t1.*f)(t2, ..., tN) when f is a pointer to a member function of a class T and t1 is an object of - // type T or a reference to an object of type T or a reference to an object of a type derived from T - - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(), A0& a0) - { - return (a0.*f)(); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(), A0* a0) - { - return ((*a0).*f)(); - } - - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1), - A0& a0, BOOST_THREAD_RV_REF(A1) a1 - ) - { - return (a0.*f)(boost::forward(a1)); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1), A0& a0, A1 a1) - { - return (a0.*f)(a1); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1), A0* a0, BOOST_THREAD_RV_REF(A1) a1 - ) - { - return (*(a0).*f)(boost::forward(a1)); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1), A0* a0, A1 a1) - { - return (*a0.*f)(a1); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2), - A0& a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2 - ) - { - return (a0.*f)(boost::forward(a1), boost::forward(a2)); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2), A0* a0, A1 a1, A2 a2) - { - return ((*a0).*f)(a1, a2); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3), - A0& a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3) - { - return (a0.*f)(boost::forward(a1), boost::forward(a2), boost::forward(a3)); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3), A0* a0, A1 a1, A2 a2, A3 a3) - { - return ((*a0).*f)(a1, a2, a3); - } - -/// - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)() const, A0 const& a0) - { - return (a0.*f)(); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)() const, A0 const* a0) - { - return ((*a0).*f)(); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) const, A0 const& a0, BOOST_THREAD_RV_REF(A1) a1) - { - return (a0.*f)(boost::forward(a1)); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) const, A0 const* a0, BOOST_THREAD_RV_REF(A1) a1) - { - return ((*a0).*f)(boost::forward(a1)); - } - - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) const, A0 const& a0, A1 a1) - { - return (a0.*f)(a1); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2) const, - A0 const& a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2 - ) - { - return (boost::forward(a0).*f)(boost::forward(a1), boost::forward(a2) - ); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2) const, A0 const& a0, A1 a1, A2 a2) - { - return (a0.*f)(a1, a2); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3) const, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3 - ) - { - return (boost::forward(a0).*f)(boost::forward(a1), boost::forward(a2), boost::forward(a3)); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3) const, A0 a0, A1 a1, A2 a2, A3 a3) - { - return (a0.*f)(a1, a2, a3); - } - /// - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)() volatile, BOOST_THREAD_RV_REF(A0) a0) - { - return (boost::forward(a0).*f)(); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) volatile, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1) - { - return (boost::forward(a0).*f)(boost::forward(a1)); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) volatile, A0 a0, A1 a1) - { - return (a0.*f)(a1); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2) volatile, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - { - return (boost::forward(a0).*f)(boost::forward(a1), boost::forward(a2)); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2) volatile, A0 a0, A1 a1, A2 a2 ) - { - return (a0.*f)(a1, a2); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3) volatile, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3 - ) - { - return (boost::forward(a0).*f)(boost::forward(a1), boost::forward(a2), boost::forward(a3)); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3) volatile, A0 a0, A1 a1, A2 a2, A3 a3) - { - return (a0.*f)(a1, a2, a3); - } - /// - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)() const volatile, BOOST_THREAD_RV_REF(A0) a0) - { - return (boost::forward(a0).*f)(); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) const volatile, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1) - { - return (boost::forward(a0).*f)(boost::forward(a1)); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) const volatile, A0 a0, A1 a1) - { - return (a0.*f)(a1); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2) const volatile, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2 - ) - { - return (boost::forward(a0).*f)(boost::forward(a1), boost::forward(a2)); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2) const volatile, - A0 a0, A1 a1, A2 a2 - ) - { - return (a0.*f)(a1, a2); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3) const volatile, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3 - ) - { - return (boost::forward(a0).*f)(boost::forward(a1), boost::forward(a2), boost::forward(a3)); - } - template - inline - typename enable_if_c - < - is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3) const volatile, - A0 a0, A1 a1, A2 a2, A3 a3 - ) - { - return (a0.*f)(a1, a2, a3); - } - - // bullet 2 - // ((*t1).*f)(t2, ..., tN) when f is a pointer to a member function of a class T and t1 is not one of - // the types described in the previous item; - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(), BOOST_THREAD_RV_REF(A0) a0) - { - return ((*boost::forward(a0)).*f)(); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1), BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1)); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1), A0 a0, A1 a1) - { - return ((*a0).*f)(a1); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, BOOST_THREAD_RV_REF(A2)), - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1), boost::forward(a2)); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2), A0 a0, A1 a1, A2 a2) - { - return ((*a0).*f)(a1, a2); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, BOOST_THREAD_RV_REF(A2), BOOST_THREAD_RV_REF(A3)), - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1), boost::forward(a2), boost::forward(a3) - ); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3), A0 a0, A1 a1, A2 a2, A3 a3) - { - return ((*a0).*f)(a1, a2, a3); - } - -/// - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)() const, BOOST_THREAD_RV_REF(A0) a0) - { - return ((*boost::forward(a0)).*f)(); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) const, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1)); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) const, BOOST_THREAD_RV_REF(A0) a0, A1 a1) - { - return ((*boost::forward(a0)).*f)(a1); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) const, A0 a0, A1 a1) - { - return ((*a0).*f)(a1); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2) const, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1), boost::forward(a2)); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2) const, A0 a0, A1 a1, A2 a2) - { - return ((*a0).*f)(a1, a2); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3) const, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1), boost::forward(a2), boost::forward(a3)); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3) const, - A0 a0, A1 a1, A2 a2, A3 a3) - { - return ((*a0).*f)(a1, a2, a3); - } - /// - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)() volatile, BOOST_THREAD_RV_REF(A0) a0) - { - return ((*boost::forward(a0)).*f)(); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) volatile, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1)); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) volatile, A0 a0, A1 a1) - { - return ((*a0).*f)(a1); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2) volatile, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1), boost::forward(a2)); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2) volatile, A0 a0, A1 a1, A2 a2) - { - return ((*a0).*f)(a1, a2); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3) volatile, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1), boost::forward(a2), boost::forward(a3)); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3) volatile, A0 a0, A1 a1, A2 a2, A3 a3) - { - return ((*a0).*f)(a1, a2, a3); - } - /// - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)() const volatile, BOOST_THREAD_RV_REF(A0) a0) - { - return ((*boost::forward(a0)).*f)(); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)() const volatile, A0 a0) - { - return ((*a0).*f)(); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) const volatile, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1)); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1) const volatile, A0 a0, A1 a1) - { - return ((*a0).*f)(a1); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2) const volatile, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1), boost::forward(a2)); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2) const volatile, - A0 a0, A1 a1, A2 a2) - { - return ((*a0).*f)(a1, a2); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3) const volatile, - BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3) - { - return ((*boost::forward(a0)).*f)(boost::forward(a1), boost::forward(a2), boost::forward(a3)); - } - template - inline - typename enable_if_c - < - ! is_base_of::type>::value, - Ret - >::type - invoke(Ret (A::*f)(A1, A2, A3) const volatile, - A0 a0, A1 a1, A2 a2, A3 a3) - { - return ((*a0).*f)(a1, a2, a3); - } - // bullet 3 - // t1.*f when N == 1 and f is a pointer to member data of a class T and t1 is an object of type T or a - // reference to an object of type T or a reference to an object of a type derived from T; -// template -// inline -// typename enable_if_c -// < -// is_base_of::type>::value, -// typename detail::apply_cv::type& -// >::type -// invoke(Ret A::* f, BOOST_THREAD_RV_REF(A0) a0) -// { -// return boost::forward(a0).*f; -// } - - // bullet 4 - // (*t1).*f when N == 1 and f is a pointer to member data of a class T and t1 is not one of the types - //described in the previous item; - -// template -// struct d4th_helper -// { -// }; -// -// template -// struct d4th_helper -// { -// typedef typename apply_cv()), Ret>::type type; -// }; -// -// template -// inline -// typename detail::4th_helper::type -// >::value -// >::type& -// invoke(Ret A::* f, BOOST_THREAD_RV_REF(A0) a0) -// { -// return (*boost::forward(a0)).*f; -// } - -// template -// inline -// typename enable_if_c -// < -// !is_base_of::type>::value, -// typename detail::ref_return1::type -// >::type -// invoke(Ret A::* f, BOOST_THREAD_RV_REF(A0) a0) -// { -// return (*boost::forward(a0)).*f; -// } - - // bullet 5 - // f(t1, t2, ..., tN) in all other cases. - - template - inline Ret do_invoke(mpl::false_, BOOST_THREAD_FWD_REF(Fp) f) - { - return boost::forward(f)(); - } - template - inline Ret do_invoke(mpl::true_, BOOST_THREAD_FWD_REF(Fp) f) - { - return f(); - } - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(BOOST_THREAD_FWD_REF(Fp) f) - { - return boost::detail::do_invoke(boost::is_pointer(), boost::forward(f)); - } - - template - inline Ret do_invoke(mpl::false_, BOOST_THREAD_FWD_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1) - { - return boost::forward(f)(boost::forward(a1)); - } - template - inline Ret do_invoke(mpl::true_, BOOST_THREAD_FWD_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1) - { - return f(boost::forward(a1)); - } - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(BOOST_THREAD_FWD_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1) - { - return boost::detail::do_invoke(boost::is_pointer(), boost::forward(f), boost::forward(a1)); - } - - template - inline Ret do_invoke(mpl::false_, BOOST_THREAD_FWD_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - { - return boost::forward(f)(boost::forward(a1), boost::forward(a2)); - } - template - inline Ret do_invoke(mpl::true_, BOOST_THREAD_FWD_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - { - return f(boost::forward(a1), boost::forward(a2)); - } - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(BOOST_THREAD_FWD_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - { - return boost::detail::do_invoke(boost::is_pointer(), boost::forward(f), boost::forward(a1), boost::forward(a2)); - } - - template - inline Ret do_invoke(mpl::false_, BOOST_THREAD_FWD_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3) - { - return boost::forward(f)(boost::forward(a1), boost::forward(a2), boost::forward(a3)); - } - template - inline Ret do_invoke(mpl::true_, BOOST_THREAD_FWD_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3) - { - return f(boost::forward(a1), boost::forward(a2), boost::forward(a3)); - } - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(BOOST_THREAD_FWD_REF(Fp) f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3) - { - return boost::detail::do_invoke(boost::is_pointer(), boost::forward(f), boost::forward(a1), boost::forward(a2), boost::forward(a3)); - } - - - template - inline Ret do_invoke(mpl::false_, BOOST_THREAD_FWD_REF(Fp) f, A1 a1) - { - return boost::forward(f)(a1); - } - template - inline Ret do_invoke(mpl::true_, BOOST_THREAD_FWD_REF(Fp) f, A1 a1) - { - return f(a1); - } - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(BOOST_THREAD_FWD_REF(Fp) f, A1 a1) - { - return boost::detail::do_invoke(boost::is_pointer(), boost::forward(f), a1); - } - - template - inline Ret do_invoke(mpl::false_, BOOST_THREAD_FWD_REF(Fp) f, A1 a1, A2 a2) - { - return boost::forward(f)(a1, a2); - } - template - inline Ret do_invoke(mpl::true_, BOOST_THREAD_FWD_REF(Fp) f, A1 a1, A2 a2) - { - return f(a1, a2); - } - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(BOOST_THREAD_FWD_REF(Fp) f, A1 a1, A2 a2) - { - return boost::detail::do_invoke(boost::is_pointer(), boost::forward(f), a1, a2); - } - - template - inline Ret do_invoke(mpl::false_, BOOST_THREAD_FWD_REF(Fp) f, A1 a1, A2 a2, A3 a3) - { - return boost::forward(f)(a1, a2, a3); - } - template - inline Ret do_invoke(mpl::true_, BOOST_THREAD_FWD_REF(Fp) f, A1 a1, A2 a2, A3 a3) - { - return f(a1, a2, a3); - } - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(BOOST_THREAD_FWD_REF(Fp) f, A1 a1, A2 a2, A3 a3) - { - return boost::detail::do_invoke(boost::is_pointer(), boost::forward(f), a1, a2, a3); - } - - - /// - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(Fp &f) - { - return f(); - } - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(Fp &f, BOOST_THREAD_RV_REF(A1) a1) - { - return f(boost::forward(a1)); - } - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(Fp &f, A1 a1) - { - return f(a1); - } - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(Fp &f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2) - { - return f(boost::forward(a1), boost::forward(a2)); - } - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(Fp &f, A1 a1, A2 a2) - { - return f(a1, a2); - } - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(Fp &f, BOOST_THREAD_RV_REF(A1) a1, BOOST_THREAD_RV_REF(A2) a2, BOOST_THREAD_RV_REF(A3) a3) - { - return f(boost::forward(a1), boost::forward(a2), boost::forward(a3)); - } - template - inline - typename disable_if_c - < - is_member_function_pointer::value, - Ret - >::type - invoke(Fp &f, A1 a1, A2 a2, A3 a3) - { - return f(a1, a2, a3); - } - /// - -#endif // BOOST_NO_CXX11_VARIADIC_TEMPLATES - -#endif // all - } - } - -#endif // header diff --git a/libraries/boost/boost/thread/detail/invoker.hpp b/libraries/boost/boost/thread/detail/invoker.hpp deleted file mode 100644 index 9f38e9798..000000000 --- a/libraries/boost/boost/thread/detail/invoker.hpp +++ /dev/null @@ -1,762 +0,0 @@ -// Copyright (C) 2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// 2013/04 Vicente J. Botet Escriba -// Provide implementation up to 9 parameters when BOOST_NO_CXX11_VARIADIC_TEMPLATES is defined. -// Make use of Boost.Move -// Make use of Boost.Tuple (movable) -// 2012/11 Vicente J. Botet Escriba -// Adapt to boost libc++ implementation - -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -// The invoker code is based on the one from libcxx. -//===----------------------------------------------------------------------===// - -#ifndef BOOST_THREAD_DETAIL_INVOKER_HPP -#define BOOST_THREAD_DETAIL_INVOKER_HPP - -#include - -#include -#include -#include -#include -#include -#include - -#include - -namespace boost -{ - namespace detail - { - -#if defined(BOOST_THREAD_PROVIDES_INVOKE) && ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && ! defined(BOOST_NO_CXX11_HDR_TUPLE) - - template - class invoker - { - //typedef typename decay::type Fpd; - //typedef tuple::type...> Argsd; - - //csbl::tuple f_; - csbl::tuple f_; - - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE( invoker) - //typedef typename invoke_of<_Fp, _Args...>::type Rp; - typedef typename result_of::type result_type; - - template - BOOST_SYMBOL_VISIBLE - explicit invoker(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(As)... args) - : f_(boost::forward(f), boost::forward(args)...) - {} - - BOOST_SYMBOL_VISIBLE - invoker(BOOST_THREAD_RV_REF(invoker) f) : f_(boost::move(BOOST_THREAD_RV(f).f_)) - {} - - BOOST_SYMBOL_VISIBLE - invoker( const invoker& f) : f_(f.f_) - {} - - BOOST_SYMBOL_VISIBLE - invoker& operator=(BOOST_THREAD_RV_REF(invoker) f) - { - if (this != &f) - { - f_ = boost::move(BOOST_THREAD_RV(f).f_); - } - return *this; - } - - BOOST_SYMBOL_VISIBLE - invoker& operator=( BOOST_THREAD_COPY_ASSIGN_REF(invoker) f) - { - if (this != &f) - { - f_ = f.f_; - } - return *this; - } - - result_type operator()() - { - typedef typename make_tuple_indices<1+sizeof...(Args), 1>::type Index; - return execute(Index()); - } - private: - template - result_type - execute(tuple_indices) - { - return detail::invoke(boost::move(csbl::get<0>(f_)), boost::move(csbl::get(f_))...); - } - }; - - template - class invoker_ret - { - //typedef typename decay::type Fpd; - //typedef tuple::type...> Argsd; - - //csbl::tuple f_; - csbl::tuple f_; - - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE( invoker_ret) - typedef R result_type; - - template - BOOST_SYMBOL_VISIBLE - explicit invoker_ret(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(As)... args) - : f_(boost::forward(f), boost::forward(args)...) - {} - - BOOST_SYMBOL_VISIBLE - invoker_ret(BOOST_THREAD_RV_REF(invoker_ret) f) : f_(boost::move(BOOST_THREAD_RV(f).f_)) - {} - - result_type operator()() - { - typedef typename make_tuple_indices<1+sizeof...(Args), 1>::type Index; - return execute(Index()); - } - private: - template - result_type - execute(tuple_indices) - { - return detail::invoke(boost::move(csbl::get<0>(f_)), boost::move(csbl::get(f_))...); - } - }; - //BOOST_THREAD_DCL_MOVABLE_BEG(X) invoker BOOST_THREAD_DCL_MOVABLE_END -#else - -#if ! defined BOOST_MSVC && defined(BOOST_THREAD_PROVIDES_INVOKE) - -#define BOOST_THREAD_RV_REF_ARG_T(z, n, unused) BOOST_PP_COMMA_IF(n) BOOST_THREAD_RV_REF(Arg##n) -#define BOOST_THREAD_RV_REF_A_T(z, n, unused) BOOST_PP_COMMA_IF(n) BOOST_THREAD_RV_REF(A##n) -#define BOOST_THREAD_RV_REF_ARG(z, n, unused) , BOOST_THREAD_RV_REF(Arg##n) arg##n -#define BOOST_THREAD_FWD_REF_A(z, n, unused) , BOOST_THREAD_FWD_REF(A##n) arg##n -#define BOOST_THREAD_FWD_REF_ARG(z, n, unused) , BOOST_THREAD_FWD_REF(Arg##n) arg##n -#define BOOST_THREAD_FWD_PARAM(z, n, unused) , boost::forward(arg##n) -#define BOOST_THREAD_FWD_PARAM_A(z, n, unused) , boost::forward(arg##n) -#define BOOST_THREAD_DCL(z, n, unused) Arg##n v##n; -#define BOOST_THREAD_MOVE_PARAM(z, n, unused) , v##n(boost::move(arg##n)) -#define BOOST_THREAD_FORWARD_PARAM_A(z, n, unused) , v##n(boost::forward(arg##n)) -#define BOOST_THREAD_MOVE_RHS_PARAM(z, n, unused) , v##n(boost::move(x.v##n)) -#define BOOST_THREAD_MOVE_DCL(z, n, unused) , boost::move(v##n) -#define BOOST_THREAD_MOVE_DCL_T(z, n, unused) BOOST_PP_COMMA_IF(n) boost::move(v##n) -#define BOOST_THREAD_ARG_DEF(z, n, unused) , class Arg##n = tuples::null_type - - template - class invoker; - -#define BOOST_THREAD_ASYNC_FUNCT(z, n, unused) \ - template \ - class invoker \ - { \ - Fp fp_; \ - BOOST_PP_REPEAT(n, BOOST_THREAD_DCL, ~) \ - public: \ - BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) \ - typedef typename result_of::type result_type; \ - \ - template \ - BOOST_SYMBOL_VISIBLE \ - explicit invoker(BOOST_THREAD_FWD_REF(F) f \ - BOOST_PP_REPEAT(n, BOOST_THREAD_FWD_REF_A, ~) \ - ) \ - : fp_(boost::forward(f)) \ - BOOST_PP_REPEAT(n, BOOST_THREAD_FORWARD_PARAM_A, ~) \ - {} \ - \ - BOOST_SYMBOL_VISIBLE \ - invoker(BOOST_THREAD_RV_REF(invoker) x) \ - : fp_(boost::move(x.fp_)) \ - BOOST_PP_REPEAT(n, BOOST_THREAD_MOVE_RHS_PARAM, ~) \ - {} \ - \ - result_type operator()() { \ - return detail::invoke(boost::move(fp_) \ - BOOST_PP_REPEAT(n, BOOST_THREAD_MOVE_DCL, ~) \ - ); \ - } \ - }; \ - \ - template \ - class invoker \ - { \ - typedef R(*Fp)(BOOST_PP_REPEAT(n, BOOST_THREAD_RV_REF_ARG_T, ~)); \ - Fp fp_; \ - BOOST_PP_REPEAT(n, BOOST_THREAD_DCL, ~) \ - public: \ - BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) \ - typedef typename result_of::type result_type; \ - \ - template \ - BOOST_SYMBOL_VISIBLE \ - explicit invoker(R2(*f)(BOOST_PP_REPEAT(n, BOOST_THREAD_RV_REF_A_T, ~)) \ - BOOST_PP_REPEAT(n, BOOST_THREAD_FWD_REF_A, ~) \ - ) \ - : fp_(f) \ - BOOST_PP_REPEAT(n, BOOST_THREAD_FORWARD_PARAM_A, ~) \ - {} \ - \ - BOOST_SYMBOL_VISIBLE \ - invoker(BOOST_THREAD_RV_REF(invoker) x) \ - : fp_(x.fp_) \ - BOOST_PP_REPEAT(n, BOOST_THREAD_MOVE_RHS_PARAM, ~) \ - {} \ - \ - result_type operator()() { \ - return fp_( \ - BOOST_PP_REPEAT(n, BOOST_THREAD_MOVE_DCL_T, ~) \ - ); \ - } \ - }; - - BOOST_PP_REPEAT(BOOST_THREAD_MAX_ARGS, BOOST_THREAD_ASYNC_FUNCT, ~) - - #undef BOOST_THREAD_RV_REF_ARG_T - #undef BOOST_THREAD_RV_REF_ARG - #undef BOOST_THREAD_FWD_REF_ARG - #undef BOOST_THREAD_FWD_REF_A - #undef BOOST_THREAD_FWD_PARAM - #undef BOOST_THREAD_FWD_PARAM_A - #undef BOOST_THREAD_DCL - #undef BOOST_THREAD_MOVE_PARAM - #undef BOOST_THREAD_MOVE_RHS_PARAM - #undef BOOST_THREAD_MOVE_DCL - #undef BOOST_THREAD_ARG_DEF - #undef BOOST_THREAD_ASYNC_FUNCT - -#else - - template - class invoker; - - template - class invoker - { - Fp fp_; - T0 v0_; - T1 v1_; - T2 v2_; - T3 v3_; - T4 v4_; - T5 v5_; - T6 v6_; - T7 v7_; - T8 v8_; - //::boost::tuple f_; - - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) - typedef typename result_of::type result_type; - - BOOST_SYMBOL_VISIBLE - explicit invoker(BOOST_THREAD_FWD_REF(Fp) f - , BOOST_THREAD_RV_REF(T0) a0 - , BOOST_THREAD_RV_REF(T1) a1 - , BOOST_THREAD_RV_REF(T2) a2 - , BOOST_THREAD_RV_REF(T3) a3 - , BOOST_THREAD_RV_REF(T4) a4 - , BOOST_THREAD_RV_REF(T5) a5 - , BOOST_THREAD_RV_REF(T6) a6 - , BOOST_THREAD_RV_REF(T7) a7 - , BOOST_THREAD_RV_REF(T8) a8 - ) - : fp_(boost::move(f)) - , v0_(boost::move(a0)) - , v1_(boost::move(a1)) - , v2_(boost::move(a2)) - , v3_(boost::move(a3)) - , v4_(boost::move(a4)) - , v5_(boost::move(a5)) - , v6_(boost::move(a6)) - , v7_(boost::move(a7)) - , v8_(boost::move(a8)) - {} - - BOOST_SYMBOL_VISIBLE - invoker(BOOST_THREAD_RV_REF(invoker) f) - : fp_(boost::move(BOOST_THREAD_RV(f).fp)) - , v0_(boost::move(BOOST_THREAD_RV(f).v0_)) - , v1_(boost::move(BOOST_THREAD_RV(f).v1_)) - , v2_(boost::move(BOOST_THREAD_RV(f).v2_)) - , v3_(boost::move(BOOST_THREAD_RV(f).v3_)) - , v4_(boost::move(BOOST_THREAD_RV(f).v4_)) - , v5_(boost::move(BOOST_THREAD_RV(f).v5_)) - , v6_(boost::move(BOOST_THREAD_RV(f).v6_)) - , v7_(boost::move(BOOST_THREAD_RV(f).v7_)) - , v8_(boost::move(BOOST_THREAD_RV(f).v8_)) - {} - - result_type operator()() - { - return detail::invoke(boost::move(fp_) - , boost::move(v0_) - , boost::move(v1_) - , boost::move(v2_) - , boost::move(v3_) - , boost::move(v4_) - , boost::move(v5_) - , boost::move(v6_) - , boost::move(v7_) - , boost::move(v8_) - ); - } - }; - template - class invoker - { - Fp fp_; - T0 v0_; - T1 v1_; - T2 v2_; - T3 v3_; - T4 v4_; - T5 v5_; - T6 v6_; - T7 v7_; - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) - typedef typename result_of::type result_type; - - BOOST_SYMBOL_VISIBLE - explicit invoker(BOOST_THREAD_FWD_REF(Fp) f - , BOOST_THREAD_RV_REF(T0) a0 - , BOOST_THREAD_RV_REF(T1) a1 - , BOOST_THREAD_RV_REF(T2) a2 - , BOOST_THREAD_RV_REF(T3) a3 - , BOOST_THREAD_RV_REF(T4) a4 - , BOOST_THREAD_RV_REF(T5) a5 - , BOOST_THREAD_RV_REF(T6) a6 - , BOOST_THREAD_RV_REF(T7) a7 - ) - : fp_(boost::move(f)) - , v0_(boost::move(a0)) - , v1_(boost::move(a1)) - , v2_(boost::move(a2)) - , v3_(boost::move(a3)) - , v4_(boost::move(a4)) - , v5_(boost::move(a5)) - , v6_(boost::move(a6)) - , v7_(boost::move(a7)) - {} - - BOOST_SYMBOL_VISIBLE - invoker(BOOST_THREAD_RV_REF(invoker) f) - : fp_(boost::move(BOOST_THREAD_RV(f).fp)) - , v0_(boost::move(BOOST_THREAD_RV(f).v0_)) - , v1_(boost::move(BOOST_THREAD_RV(f).v1_)) - , v2_(boost::move(BOOST_THREAD_RV(f).v2_)) - , v3_(boost::move(BOOST_THREAD_RV(f).v3_)) - , v4_(boost::move(BOOST_THREAD_RV(f).v4_)) - , v5_(boost::move(BOOST_THREAD_RV(f).v5_)) - , v6_(boost::move(BOOST_THREAD_RV(f).v6_)) - , v7_(boost::move(BOOST_THREAD_RV(f).v7_)) - {} - - result_type operator()() - { - return detail::invoke(boost::move(fp_) - , boost::move(v0_) - , boost::move(v1_) - , boost::move(v2_) - , boost::move(v3_) - , boost::move(v4_) - , boost::move(v5_) - , boost::move(v6_) - , boost::move(v7_) - ); - } - }; - template - class invoker - { - Fp fp_; - T0 v0_; - T1 v1_; - T2 v2_; - T3 v3_; - T4 v4_; - T5 v5_; - T6 v6_; - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) - typedef typename result_of::type result_type; - - BOOST_SYMBOL_VISIBLE - explicit invoker(BOOST_THREAD_FWD_REF(Fp) f - , BOOST_THREAD_RV_REF(T0) a0 - , BOOST_THREAD_RV_REF(T1) a1 - , BOOST_THREAD_RV_REF(T2) a2 - , BOOST_THREAD_RV_REF(T3) a3 - , BOOST_THREAD_RV_REF(T4) a4 - , BOOST_THREAD_RV_REF(T5) a5 - , BOOST_THREAD_RV_REF(T6) a6 - ) - : fp_(boost::move(f)) - , v0_(boost::move(a0)) - , v1_(boost::move(a1)) - , v2_(boost::move(a2)) - , v3_(boost::move(a3)) - , v4_(boost::move(a4)) - , v5_(boost::move(a5)) - , v6_(boost::move(a6)) - {} - - BOOST_SYMBOL_VISIBLE - invoker(BOOST_THREAD_RV_REF(invoker) f) - : fp_(boost::move(BOOST_THREAD_RV(f).fp)) - , v0_(boost::move(BOOST_THREAD_RV(f).v0_)) - , v1_(boost::move(BOOST_THREAD_RV(f).v1_)) - , v2_(boost::move(BOOST_THREAD_RV(f).v2_)) - , v3_(boost::move(BOOST_THREAD_RV(f).v3_)) - , v4_(boost::move(BOOST_THREAD_RV(f).v4_)) - , v5_(boost::move(BOOST_THREAD_RV(f).v5_)) - , v6_(boost::move(BOOST_THREAD_RV(f).v6_)) - {} - - result_type operator()() - { - return detail::invoke(boost::move(fp_) - , boost::move(v0_) - , boost::move(v1_) - , boost::move(v2_) - , boost::move(v3_) - , boost::move(v4_) - , boost::move(v5_) - , boost::move(v6_) - ); - } - }; - template - class invoker - { - Fp fp_; - T0 v0_; - T1 v1_; - T2 v2_; - T3 v3_; - T4 v4_; - T5 v5_; - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) - typedef typename result_of::type result_type; - - BOOST_SYMBOL_VISIBLE - explicit invoker(BOOST_THREAD_FWD_REF(Fp) f - , BOOST_THREAD_RV_REF(T0) a0 - , BOOST_THREAD_RV_REF(T1) a1 - , BOOST_THREAD_RV_REF(T2) a2 - , BOOST_THREAD_RV_REF(T3) a3 - , BOOST_THREAD_RV_REF(T4) a4 - , BOOST_THREAD_RV_REF(T5) a5 - ) - : fp_(boost::move(f)) - , v0_(boost::move(a0)) - , v1_(boost::move(a1)) - , v2_(boost::move(a2)) - , v3_(boost::move(a3)) - , v4_(boost::move(a4)) - , v5_(boost::move(a5)) - {} - - BOOST_SYMBOL_VISIBLE - invoker(BOOST_THREAD_RV_REF(invoker) f) - : fp_(boost::move(BOOST_THREAD_RV(f).fp)) - , v0_(boost::move(BOOST_THREAD_RV(f).v0_)) - , v1_(boost::move(BOOST_THREAD_RV(f).v1_)) - , v2_(boost::move(BOOST_THREAD_RV(f).v2_)) - , v3_(boost::move(BOOST_THREAD_RV(f).v3_)) - , v4_(boost::move(BOOST_THREAD_RV(f).v4_)) - , v5_(boost::move(BOOST_THREAD_RV(f).v5_)) - {} - - result_type operator()() - { - return detail::invoke(boost::move(fp_) - , boost::move(v0_) - , boost::move(v1_) - , boost::move(v2_) - , boost::move(v3_) - , boost::move(v4_) - , boost::move(v5_) - ); - } - }; - template - class invoker - { - Fp fp_; - T0 v0_; - T1 v1_; - T2 v2_; - T3 v3_; - T4 v4_; - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) - typedef typename result_of::type result_type; - - BOOST_SYMBOL_VISIBLE - explicit invoker(BOOST_THREAD_FWD_REF(Fp) f - , BOOST_THREAD_RV_REF(T0) a0 - , BOOST_THREAD_RV_REF(T1) a1 - , BOOST_THREAD_RV_REF(T2) a2 - , BOOST_THREAD_RV_REF(T3) a3 - , BOOST_THREAD_RV_REF(T4) a4 - ) - : fp_(boost::move(f)) - , v0_(boost::move(a0)) - , v1_(boost::move(a1)) - , v2_(boost::move(a2)) - , v3_(boost::move(a3)) - , v4_(boost::move(a4)) - {} - - BOOST_SYMBOL_VISIBLE - invoker(BOOST_THREAD_RV_REF(invoker) f) - : fp_(boost::move(BOOST_THREAD_RV(f).fp)) - , v0_(boost::move(BOOST_THREAD_RV(f).v0_)) - , v1_(boost::move(BOOST_THREAD_RV(f).v1_)) - , v2_(boost::move(BOOST_THREAD_RV(f).v2_)) - , v3_(boost::move(BOOST_THREAD_RV(f).v3_)) - , v4_(boost::move(BOOST_THREAD_RV(f).v4_)) - {} - - result_type operator()() - { - return detail::invoke(boost::move(fp_) - , boost::move(v0_) - , boost::move(v1_) - , boost::move(v2_) - , boost::move(v3_) - , boost::move(v4_) - ); - } - }; - template - class invoker - { - Fp fp_; - T0 v0_; - T1 v1_; - T2 v2_; - T3 v3_; - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) - typedef typename result_of::type result_type; - - BOOST_SYMBOL_VISIBLE - explicit invoker(BOOST_THREAD_FWD_REF(Fp) f - , BOOST_THREAD_RV_REF(T0) a0 - , BOOST_THREAD_RV_REF(T1) a1 - , BOOST_THREAD_RV_REF(T2) a2 - , BOOST_THREAD_RV_REF(T3) a3 - ) - : fp_(boost::move(f)) - , v0_(boost::move(a0)) - , v1_(boost::move(a1)) - , v2_(boost::move(a2)) - , v3_(boost::move(a3)) - {} - - BOOST_SYMBOL_VISIBLE - invoker(BOOST_THREAD_RV_REF(invoker) f) - : fp_(boost::move(BOOST_THREAD_RV(f).fp)) - , v0_(boost::move(BOOST_THREAD_RV(f).v0_)) - , v1_(boost::move(BOOST_THREAD_RV(f).v1_)) - , v2_(boost::move(BOOST_THREAD_RV(f).v2_)) - , v3_(boost::move(BOOST_THREAD_RV(f).v3_)) - {} - - result_type operator()() - { - return detail::invoke(boost::move(fp_) - , boost::move(v0_) - , boost::move(v1_) - , boost::move(v2_) - , boost::move(v3_) - ); - } - }; - template - class invoker - { - Fp fp_; - T0 v0_; - T1 v1_; - T2 v2_; - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) - typedef typename result_of::type result_type; - - BOOST_SYMBOL_VISIBLE - explicit invoker(BOOST_THREAD_FWD_REF(Fp) f - , BOOST_THREAD_RV_REF(T0) a0 - , BOOST_THREAD_RV_REF(T1) a1 - , BOOST_THREAD_RV_REF(T2) a2 - ) - : fp_(boost::move(f)) - , v0_(boost::move(a0)) - , v1_(boost::move(a1)) - , v2_(boost::move(a2)) - {} - - BOOST_SYMBOL_VISIBLE - invoker(BOOST_THREAD_RV_REF(invoker) f) - : fp_(boost::move(BOOST_THREAD_RV(f).fp)) - , v0_(boost::move(BOOST_THREAD_RV(f).v0_)) - , v1_(boost::move(BOOST_THREAD_RV(f).v1_)) - , v2_(boost::move(BOOST_THREAD_RV(f).v2_)) - {} - - result_type operator()() - { - return detail::invoke(boost::move(fp_) - , boost::move(v0_) - , boost::move(v1_) - , boost::move(v2_) - ); - } - }; - template - class invoker - { - Fp fp_; - T0 v0_; - T1 v1_; - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) - typedef typename result_of::type result_type; - - BOOST_SYMBOL_VISIBLE - explicit invoker(BOOST_THREAD_FWD_REF(Fp) f - , BOOST_THREAD_RV_REF(T0) a0 - , BOOST_THREAD_RV_REF(T1) a1 - ) - : fp_(boost::move(f)) - , v0_(boost::move(a0)) - , v1_(boost::move(a1)) - {} - - BOOST_SYMBOL_VISIBLE - invoker(BOOST_THREAD_RV_REF(invoker) f) - : fp_(boost::move(BOOST_THREAD_RV(f).fp)) - , v0_(boost::move(BOOST_THREAD_RV(f).v0_)) - , v1_(boost::move(BOOST_THREAD_RV(f).v1_)) - {} - - result_type operator()() - { - return detail::invoke(boost::move(fp_) - , boost::move(v0_) - , boost::move(v1_) - ); - } - }; - template - class invoker - { - Fp fp_; - T0 v0_; - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) - typedef typename result_of::type result_type; - - BOOST_SYMBOL_VISIBLE - explicit invoker(BOOST_THREAD_FWD_REF(Fp) f - , BOOST_THREAD_RV_REF(T0) a0 - ) - : fp_(boost::move(f)) - , v0_(boost::move(a0)) - {} - - BOOST_SYMBOL_VISIBLE - invoker(BOOST_THREAD_RV_REF(invoker) f) - : fp_(boost::move(BOOST_THREAD_RV(f).fp)) - , v0_(boost::move(BOOST_THREAD_RV(f).v0_)) - {} - - result_type operator()() - { - return detail::invoke(boost::move(fp_) - , boost::move(v0_) - ); - } - }; - template - class invoker - { - Fp fp_; - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) - typedef typename result_of::type result_type; - BOOST_SYMBOL_VISIBLE - explicit invoker(BOOST_THREAD_FWD_REF(Fp) f) - : fp_(boost::move(f)) - {} - - BOOST_SYMBOL_VISIBLE - invoker(BOOST_THREAD_RV_REF(invoker) f) - : fp_(boost::move(f.fp_)) - {} - result_type operator()() - { - return fp_(); - } - }; - template - class invoker - { - typedef R(*Fp)(); - Fp fp_; - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) - typedef typename result_of::type result_type; - BOOST_SYMBOL_VISIBLE - explicit invoker(Fp f) - : fp_(f) - {} - - BOOST_SYMBOL_VISIBLE - invoker(BOOST_THREAD_RV_REF(invoker) f) - : fp_(f.fp_) - {} - result_type operator()() - { - return fp_(); - } - }; -#endif -#endif - - } -} - -#include - -#endif // header diff --git a/libraries/boost/boost/thread/detail/is_convertible.hpp b/libraries/boost/boost/thread/detail/is_convertible.hpp deleted file mode 100644 index b77620cf1..000000000 --- a/libraries/boost/boost/thread/detail/is_convertible.hpp +++ /dev/null @@ -1,49 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2011-2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_THREAD_DETAIL_IS_CONVERTIBLE_HPP -#define BOOST_THREAD_DETAIL_IS_CONVERTIBLE_HPP - -#include -#include - -namespace boost -{ - namespace thread_detail - { - template - struct is_convertible : boost::is_convertible {}; - -#if defined BOOST_NO_CXX11_RVALUE_REFERENCES - -#if defined(BOOST_INTEL_CXX_VERSION) && (BOOST_INTEL_CXX_VERSION <= 1300) - -#if defined BOOST_THREAD_USES_MOVE - template - struct is_convertible< - rv &, - rv > & - > : false_type {}; -#endif - -#elif defined __GNUC__ && (__GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ <= 4 )) - - template - struct is_convertible : boost::is_convertible {}; -#endif - -#endif - } - -} // namespace boost - - -#endif // BOOST_THREAD_DETAIL_MEMORY_HPP diff --git a/libraries/boost/boost/thread/detail/lockable_wrapper.hpp b/libraries/boost/boost/thread/detail/lockable_wrapper.hpp deleted file mode 100644 index 8dc5a6cc7..000000000 --- a/libraries/boost/boost/thread/detail/lockable_wrapper.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2012 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_DETAIL_LOCKABLE_WRAPPER_HPP -#define BOOST_THREAD_DETAIL_LOCKABLE_WRAPPER_HPP - -#include - -#if ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST -#include -#endif -#include - -namespace boost -{ - -#if ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST - namespace thread_detail - { - template - struct lockable_wrapper - { - Mutex* m; - explicit lockable_wrapper(Mutex& m_) : - m(&m_) - {} - }; - template - struct lockable_adopt_wrapper - { - Mutex* m; - explicit lockable_adopt_wrapper(Mutex& m_) : - m(&m_) - {} - }; - } -#endif - -} - -#include - -#endif // header diff --git a/libraries/boost/boost/thread/detail/log.hpp b/libraries/boost/boost/thread/detail/log.hpp deleted file mode 100644 index 84dcc8cb4..000000000 --- a/libraries/boost/boost/thread/detail/log.hpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_DETAIL_LOG_HPP -#define BOOST_THREAD_DETAIL_LOG_HPP - -#include -#if defined BOOST_THREAD_USES_LOG -#include -#include -#if defined BOOST_THREAD_USES_LOG_THREAD_ID -#include -#endif -#include - -namespace boost -{ - namespace thread_detail - { - inline boost::recursive_mutex& terminal_mutex() - { - static boost::recursive_mutex mtx; - return mtx; - } - - } -} -#if defined BOOST_THREAD_USES_LOG_THREAD_ID - -#define BOOST_THREAD_LOG \ - { \ - boost::lock_guard _lk_(boost::thread_detail::terminal_mutex()); \ - std::cout << boost::this_thread::get_id() << " - "<<__FILE__<<"["<<__LINE__<<"] " < _lk_(boost::thread_detail::terminal_mutex()); \ - std::cout << __FILE__<<"["<<__LINE__<<"] " < - inline dummy_stream_t const& operator<<(dummy_stream_t const& os, T) - { - return os; - } - - inline dummy_stream_t const& operator<<(dummy_stream_t const& os, dummy_stream_t const&) - { - return os; - } - - - BOOST_CONSTEXPR_OR_CONST dummy_stream_t dummy_stream = {}; - - } -} - -#define BOOST_THREAD_LOG if (true) {} else boost::thread_detail::dummy_stream -#define BOOST_THREAD_END_LOG boost::thread_detail::dummy_stream - -#endif - -#define BOOST_THREAD_TRACE BOOST_THREAD_LOG << BOOST_THREAD_END_LOG - - -#endif // header diff --git a/libraries/boost/boost/thread/detail/make_tuple_indices.hpp b/libraries/boost/boost/thread/detail/make_tuple_indices.hpp deleted file mode 100644 index 73d54f11f..000000000 --- a/libraries/boost/boost/thread/detail/make_tuple_indices.hpp +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright (C) 2012-2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// 2013/04 Vicente J. Botet Escriba -// Provide implementation up to 10 parameters when BOOST_NO_CXX11_VARIADIC_TEMPLATES is defined. -// 2012/11 Vicente J. Botet Escriba -// Adapt to boost libc++ implementation - -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -// The make_tuple_indices C++11 code is based on the one from libcxx. -//===----------------------------------------------------------------------===// - -#ifndef BOOST_THREAD_DETAIL_MAKE_TUPLE_INDICES_HPP -#define BOOST_THREAD_DETAIL_MAKE_TUPLE_INDICES_HPP - -#include -#include - -namespace boost -{ - namespace detail - { - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - // make_tuple_indices - - template struct tuple_indices - {}; - - template - struct make_indices_imp; - - template - struct make_indices_imp, Ep> - { - typedef typename make_indices_imp, Ep>::type type; - }; - - template - struct make_indices_imp, Ep> - { - typedef tuple_indices type; - }; - - template - struct make_tuple_indices - { - BOOST_STATIC_ASSERT_MSG(Sp <= Ep, "make_tuple_indices input error"); - typedef typename make_indices_imp, Ep>::type type; - }; -#else - - // - tuple forward declaration ----------------------------------------------- - template < - std::size_t T0 = 0, std::size_t T1 = 0, std::size_t T2 = 0, - std::size_t T3 = 0, std::size_t T4 = 0, std::size_t T5 = 0, - std::size_t T6 = 0, std::size_t T7 = 0, std::size_t T8 = 0, - std::size_t T9 = 0> - class tuple_indices {}; - - template - struct make_indices_imp; - - template - struct make_indices_imp, Ep> - { - typedef typename make_indices_imp, Ep>::type type; - }; - template - struct make_indices_imp, Ep> - { - typedef typename make_indices_imp, Ep>::type type; - }; - template - struct make_indices_imp, Ep> - { - typedef typename make_indices_imp, Ep>::type type; - }; - template - struct make_indices_imp, Ep> - { - typedef typename make_indices_imp, Ep>::type type; - }; - template - struct make_indices_imp, Ep> - { - typedef typename make_indices_imp, Ep>::type type; - }; - template - struct make_indices_imp, Ep> - { - typedef typename make_indices_imp, Ep>::type type; - }; - template - struct make_indices_imp, Ep> - { - typedef typename make_indices_imp, Ep>::type type; - }; - template - struct make_indices_imp, Ep> - { - typedef typename make_indices_imp, Ep>::type type; - }; - template - struct make_indices_imp, Ep> - { - typedef typename make_indices_imp, Ep>::type type; - }; - template - struct make_indices_imp, Ep> - { - typedef typename make_indices_imp, Ep>::type type; - }; -// template -// struct make_indices_imp, Ep> -// { -// typedef typename make_indices_imp, Ep>::type type; -// }; - - template - struct make_indices_imp, Ep> - { - typedef tuple_indices<> type; - }; - template - struct make_indices_imp, Ep> - { - typedef tuple_indices type; - }; - template - struct make_indices_imp, Ep> - { - typedef tuple_indices type; - }; - template - struct make_indices_imp, Ep> - { - typedef tuple_indices type; - }; - template - struct make_indices_imp, Ep> - { - typedef tuple_indices type; - }; - template - struct make_indices_imp, Ep> - { - typedef tuple_indices type; - }; - template - struct make_indices_imp, Ep> - { - typedef tuple_indices type; - }; - template - struct make_indices_imp, Ep> - { - typedef tuple_indices type; - }; - template - struct make_indices_imp, Ep> - { - typedef tuple_indices type; - }; - template - struct make_indices_imp, Ep> - { - typedef tuple_indices type; - }; - - template - struct make_indices_imp, Ep> - { - typedef tuple_indices type; - }; - - template - struct make_tuple_indices - { - BOOST_STATIC_ASSERT_MSG(Sp <= Ep, "make_tuple_indices input error"); - typedef typename make_indices_imp, Ep>::type type; - }; - -#endif - } -} - -#endif // header diff --git a/libraries/boost/boost/thread/detail/memory.hpp b/libraries/boost/boost/thread/detail/memory.hpp deleted file mode 100644 index 51ce84f40..000000000 --- a/libraries/boost/boost/thread/detail/memory.hpp +++ /dev/null @@ -1,48 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2011-2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_THREAD_DETAIL_MEMORY_HPP -#define BOOST_THREAD_DETAIL_MEMORY_HPP - -#include - -#include -#include -#include -#include - -namespace boost -{ - namespace thread_detail - { - template - class allocator_destructor - { - typedef csbl::allocator_traits<_Alloc> alloc_traits; - public: - typedef typename alloc_traits::pointer pointer; - typedef typename alloc_traits::size_type size_type; - private: - _Alloc alloc_; - size_type s_; - public: - allocator_destructor(_Alloc& a, size_type s)BOOST_NOEXCEPT - : alloc_(a), s_(s) - {} - void operator()(pointer p)BOOST_NOEXCEPT - { - alloc_traits::destroy(alloc_, p); - alloc_traits::deallocate(alloc_, p, s_); - } - }; - } //namespace thread_detail -} -#endif // BOOST_THREAD_DETAIL_MEMORY_HPP diff --git a/libraries/boost/boost/thread/detail/move.hpp b/libraries/boost/boost/thread/detail/move.hpp deleted file mode 100644 index 26e4f9dc6..000000000 --- a/libraries/boost/boost/thread/detail/move.hpp +++ /dev/null @@ -1,374 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007-8 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_MOVE_HPP -#define BOOST_THREAD_MOVE_HPP - -#include -#ifndef BOOST_NO_SFINAE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#include -#include -#include -#include -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -#include -#endif -namespace boost -{ - - namespace detail - { - template - struct enable_move_utility_emulation_dummy_specialization; - template - struct thread_move_t - { - T& t; - explicit thread_move_t(T& t_): - t(t_) - {} - - T& operator*() const - { - return t; - } - - T* operator->() const - { - return &t; - } - private: - void operator=(thread_move_t&); - }; - } - -#if !defined BOOST_THREAD_USES_MOVE - -#ifndef BOOST_NO_SFINAE - template - typename enable_if >, boost::detail::thread_move_t >::type move(T& t) - { - return boost::detail::thread_move_t(t); - } -#endif - - template - boost::detail::thread_move_t move(boost::detail::thread_move_t t) - { - return t; - } - -#endif //#if !defined BOOST_THREAD_USES_MOVE -} - -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - -#define BOOST_THREAD_COPY_ASSIGN_REF(TYPE) BOOST_COPY_ASSIGN_REF(TYPE) -#define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE) -#define BOOST_THREAD_RV_REF_2_TEMPL_ARGS(TYPE) BOOST_RV_REF_2_TEMPL_ARGS(TYPE) -#define BOOST_THREAD_RV_REF_BEG BOOST_RV_REF_BEG -#define BOOST_THREAD_RV_REF_END BOOST_RV_REF_END -#define BOOST_THREAD_RV(V) V -#define BOOST_THREAD_MAKE_RV_REF(RVALUE) RVALUE -#define BOOST_THREAD_FWD_REF(TYPE) BOOST_FWD_REF(TYPE) -#define BOOST_THREAD_DCL_MOVABLE(TYPE) -#define BOOST_THREAD_DCL_MOVABLE_BEG(T) \ - namespace detail { \ - template \ - struct enable_move_utility_emulation_dummy_specialization< - -#define BOOST_THREAD_DCL_MOVABLE_BEG2(T1, T2) \ - namespace detail { \ - template \ - struct enable_move_utility_emulation_dummy_specialization< - -#define BOOST_THREAD_DCL_MOVABLE_END > \ - : integral_constant \ - {}; \ - } - -#elif ! defined BOOST_NO_CXX11_RVALUE_REFERENCES && defined BOOST_MSVC - -#define BOOST_THREAD_COPY_ASSIGN_REF(TYPE) BOOST_COPY_ASSIGN_REF(TYPE) -#define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE) -#define BOOST_THREAD_RV_REF_2_TEMPL_ARGS(TYPE) BOOST_RV_REF_2_TEMPL_ARGS(TYPE) -#define BOOST_THREAD_RV_REF_BEG BOOST_RV_REF_BEG -#define BOOST_THREAD_RV_REF_END BOOST_RV_REF_END -#define BOOST_THREAD_RV(V) V -#define BOOST_THREAD_MAKE_RV_REF(RVALUE) RVALUE -#define BOOST_THREAD_FWD_REF(TYPE) BOOST_FWD_REF(TYPE) -#define BOOST_THREAD_DCL_MOVABLE(TYPE) -#define BOOST_THREAD_DCL_MOVABLE_BEG(T) \ - namespace detail { \ - template \ - struct enable_move_utility_emulation_dummy_specialization< - -#define BOOST_THREAD_DCL_MOVABLE_BEG2(T1, T2) \ - namespace detail { \ - template \ - struct enable_move_utility_emulation_dummy_specialization< - -#define BOOST_THREAD_DCL_MOVABLE_END > \ - : integral_constant \ - {}; \ - } - -#else - -#if defined BOOST_THREAD_USES_MOVE -#define BOOST_THREAD_COPY_ASSIGN_REF(TYPE) BOOST_COPY_ASSIGN_REF(TYPE) -#define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE) -#define BOOST_THREAD_RV_REF_2_TEMPL_ARGS(TYPE) BOOST_RV_REF_2_TEMPL_ARGS(TYPE) -#define BOOST_THREAD_RV_REF_BEG BOOST_RV_REF_BEG -#define BOOST_THREAD_RV_REF_END BOOST_RV_REF_END -#define BOOST_THREAD_RV(V) V -#define BOOST_THREAD_FWD_REF(TYPE) BOOST_FWD_REF(TYPE) -#define BOOST_THREAD_DCL_MOVABLE(TYPE) -#define BOOST_THREAD_DCL_MOVABLE_BEG(T) \ - namespace detail { \ - template \ - struct enable_move_utility_emulation_dummy_specialization< - -#define BOOST_THREAD_DCL_MOVABLE_BEG2(T1, T2) \ - namespace detail { \ - template \ - struct enable_move_utility_emulation_dummy_specialization< - -#define BOOST_THREAD_DCL_MOVABLE_END > \ - : integral_constant \ - {}; \ - } - -#else - -#define BOOST_THREAD_COPY_ASSIGN_REF(TYPE) const TYPE& -#define BOOST_THREAD_RV_REF(TYPE) boost::detail::thread_move_t< TYPE > -#define BOOST_THREAD_RV_REF_BEG boost::detail::thread_move_t< -#define BOOST_THREAD_RV_REF_END > -#define BOOST_THREAD_RV(V) (*V) -#define BOOST_THREAD_FWD_REF(TYPE) BOOST_FWD_REF(TYPE) - -#define BOOST_THREAD_DCL_MOVABLE(TYPE) \ -template <> \ -struct enable_move_utility_emulation< TYPE > \ -{ \ - static const bool value = false; \ -}; - -#define BOOST_THREAD_DCL_MOVABLE_BEG(T) \ -template \ -struct enable_move_utility_emulation< - -#define BOOST_THREAD_DCL_MOVABLE_BEG2(T1, T2) \ -template \ -struct enable_move_utility_emulation< - -#define BOOST_THREAD_DCL_MOVABLE_END > \ -{ \ - static const bool value = false; \ -}; - -#endif - -namespace boost -{ -namespace detail -{ - template - BOOST_THREAD_RV_REF(typename ::boost::remove_cv::type>::type) - make_rv_ref(T v) BOOST_NOEXCEPT - { - return (BOOST_THREAD_RV_REF(typename ::boost::remove_cv::type>::type))(v); - } -// template -// BOOST_THREAD_RV_REF(typename ::boost::remove_cv::type>::type) -// make_rv_ref(T &v) BOOST_NOEXCEPT -// { -// return (BOOST_THREAD_RV_REF(typename ::boost::remove_cv::type>::type))(v); -// } -// template -// const BOOST_THREAD_RV_REF(typename ::boost::remove_cv::type>::type) -// make_rv_ref(T const&v) BOOST_NOEXCEPT -// { -// return (const BOOST_THREAD_RV_REF(typename ::boost::remove_cv::type>::type))(v); -// } -} -} - -#define BOOST_THREAD_MAKE_RV_REF(RVALUE) RVALUE.move() -//#define BOOST_THREAD_MAKE_RV_REF(RVALUE) boost::detail::make_rv_ref(RVALUE) -#endif - - -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - -#define BOOST_THREAD_MOVABLE(TYPE) - -#define BOOST_THREAD_COPYABLE(TYPE) - -#else - -#if defined BOOST_THREAD_USES_MOVE - -#define BOOST_THREAD_MOVABLE(TYPE) \ - ::boost::rv& move() BOOST_NOEXCEPT \ - { \ - return *static_cast< ::boost::rv* >(this); \ - } \ - const ::boost::rv& move() const BOOST_NOEXCEPT \ - { \ - return *static_cast* >(this); \ - } \ - operator ::boost::rv&() \ - { \ - return *static_cast< ::boost::rv* >(this); \ - } \ - operator const ::boost::rv&() const \ - { \ - return *static_cast* >(this); \ - }\ - -#define BOOST_THREAD_COPYABLE(TYPE) \ - TYPE& operator=(TYPE &t)\ - { this->operator=(static_cast &>(const_cast(t))); return *this;} - - -#else - -#define BOOST_THREAD_MOVABLE(TYPE) \ - operator ::boost::detail::thread_move_t() BOOST_NOEXCEPT \ - { \ - return move(); \ - } \ - ::boost::detail::thread_move_t move() BOOST_NOEXCEPT \ - { \ - ::boost::detail::thread_move_t x(*this); \ - return x; \ - } \ - -#define BOOST_THREAD_COPYABLE(TYPE) - -#endif -#endif - -#define BOOST_THREAD_MOVABLE_ONLY(TYPE) \ - BOOST_THREAD_NO_COPYABLE(TYPE) \ - BOOST_THREAD_MOVABLE(TYPE) \ - typedef int boost_move_no_copy_constructor_or_assign; \ - - -#define BOOST_THREAD_COPYABLE_AND_MOVABLE(TYPE) \ - BOOST_THREAD_COPYABLE(TYPE) \ - BOOST_THREAD_MOVABLE(TYPE) \ - - - -namespace boost -{ - namespace thread_detail - { - -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES -#elif defined BOOST_THREAD_USES_MOVE - template - struct is_rv - : ::boost::move_detail::is_rv - {}; - -#else - template - struct is_rv - : ::boost::integral_constant - {}; - - template - struct is_rv< ::boost::detail::thread_move_t > - : ::boost::integral_constant - {}; - - template - struct is_rv< const ::boost::detail::thread_move_t > - : ::boost::integral_constant - {}; -#endif - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template - struct remove_reference : boost::remove_reference {}; - template - struct decay : boost::decay {}; -#else - template - struct remove_reference - { - typedef Tp type; - }; - template - struct remove_reference - { - typedef Tp type; - }; - template - struct remove_reference< rv > { - typedef Tp type; - }; - - template - struct decay - { - private: - typedef typename boost::move_detail::remove_rvalue_reference::type Up0; - typedef typename boost::remove_reference::type Up; - public: - typedef typename conditional - < - is_array::value, - typename remove_extent::type*, - typename conditional - < - is_function::value, - typename add_pointer::type, - typename remove_cv::type - >::type - >::type type; - }; -#endif - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template - typename decay::type - decay_copy(T&& t) - { - return boost::forward(t); - } -#else - template - typename decay::type - decay_copy(BOOST_THREAD_FWD_REF(T) t) - { - return boost::forward(t); - } -#endif - } -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/detail/nullary_function.hpp b/libraries/boost/boost/thread/detail/nullary_function.hpp deleted file mode 100644 index b3989cf68..000000000 --- a/libraries/boost/boost/thread/detail/nullary_function.hpp +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/09 Vicente J. Botet Escriba -// Adapt to boost from CCIA C++11 implementation -// Make use of Boost.Move - -#ifndef BOOST_THREAD_DETAIL_NULLARY_FUNCTION_HPP -#define BOOST_THREAD_DETAIL_NULLARY_FUNCTION_HPP - -#include -#include -#include -#include -#include - -namespace boost -{ - namespace detail - { - - template - class nullary_function; - template <> - class nullary_function - { - struct impl_base - { - virtual void call()=0; - virtual ~impl_base() - { - } - }; - csbl::shared_ptr impl; - template - struct impl_type: impl_base - { - F f; -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - impl_type(F &f_) - : f(f_) - {} -#endif - impl_type(BOOST_THREAD_RV_REF(F) f_) - : f(boost::move(f_)) - {} - - void call() - { - f(); - } - }; - struct impl_type_ptr: impl_base - { - void (*f)(); - impl_type_ptr(void (*f_)()) - : f(f_) - {} - void call() - { - f(); - } - }; - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(nullary_function) - - explicit nullary_function(void (*f)()): - impl(new impl_type_ptr(f)) - {} - -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - template - explicit nullary_function(F& f): - impl(new impl_type(f)) - {} -#endif - template - nullary_function(BOOST_THREAD_RV_REF(F) f): - impl(new impl_type::type>(thread_detail::decay_copy(boost::forward(f)))) - {} - - nullary_function() - : impl() - { - } - nullary_function(nullary_function const& other) BOOST_NOEXCEPT : - impl(other.impl) - { - } - nullary_function(BOOST_THREAD_RV_REF(nullary_function) other) BOOST_NOEXCEPT : -#if defined BOOST_NO_CXX11_SMART_PTR - impl(BOOST_THREAD_RV(other).impl) - { - BOOST_THREAD_RV(other).impl.reset(); - } -#else - impl(boost::move(other.impl)) - { - } -#endif - ~nullary_function() - { - } - - nullary_function& operator=(BOOST_THREAD_COPY_ASSIGN_REF(nullary_function) other) BOOST_NOEXCEPT - { - impl=other.impl; - return *this; - } - nullary_function& operator=(BOOST_THREAD_RV_REF(nullary_function) other) BOOST_NOEXCEPT - { -#if defined BOOST_NO_CXX11_SMART_PTR - impl=BOOST_THREAD_RV(other).impl; - BOOST_THREAD_RV(other).impl.reset(); -#else - impl = boost::move(other.impl); -#endif - return *this; - } - - - void operator()() - { if (impl) impl->call();} - - }; - - template - class nullary_function - { - struct impl_base - { - virtual R call()=0; - virtual ~impl_base() - { - } - }; - csbl::shared_ptr impl; - template - struct impl_type: impl_base - { - F f; -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - impl_type(F &f_) - : f(f_) - {} -#endif - impl_type(BOOST_THREAD_RV_REF(F) f_) - : f(boost::move(f_)) - {} - - R call() - { - return f(); - } - }; - struct impl_type_ptr: impl_base - { - R (*f)(); - impl_type_ptr(R (*f_)()) - : f(f_) - {} - - R call() - { - return f(); - } - }; - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(nullary_function) - - nullary_function(R (*f)()): - impl(new impl_type_ptr(f)) - {} -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - template - nullary_function(F& f): - impl(new impl_type(f)) - {} -#endif - template - nullary_function(BOOST_THREAD_RV_REF(F) f): - impl(new impl_type::type>(thread_detail::decay_copy(boost::forward(f)))) - {} - - nullary_function(nullary_function const& other) BOOST_NOEXCEPT : - impl(other.impl) - { - } - nullary_function(BOOST_THREAD_RV_REF(nullary_function) other) BOOST_NOEXCEPT : -#if defined BOOST_NO_CXX11_SMART_PTR - impl(BOOST_THREAD_RV(other).impl) - { - BOOST_THREAD_RV(other).impl.reset(); - } -#else - impl(boost::move(other.impl)) - { - } -#endif - nullary_function() - : impl() - { - } - ~nullary_function() - { - } - - nullary_function& operator=(BOOST_THREAD_COPY_ASSIGN_REF(nullary_function) other) BOOST_NOEXCEPT - { - impl=other.impl; - return *this; - } - nullary_function& operator=(BOOST_THREAD_RV_REF(nullary_function) other) BOOST_NOEXCEPT - { -#if defined BOOST_NO_CXX11_SMART_PTR - impl=BOOST_THREAD_RV(other).impl; - BOOST_THREAD_RV(other).impl.reset(); -#else - impl = boost::move(other.impl); -#endif - return *this; - } - - R operator()() - { if (impl) return impl->call(); else return R();} - - }; - } - BOOST_THREAD_DCL_MOVABLE_BEG(F) detail::nullary_function BOOST_THREAD_DCL_MOVABLE_END -} - -#endif // header diff --git a/libraries/boost/boost/thread/detail/platform.hpp b/libraries/boost/boost/thread/detail/platform.hpp deleted file mode 100644 index 1f33b1a67..000000000 --- a/libraries/boost/boost/thread/detail/platform.hpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2006 Roland Schwarz. -// (C) Copyright 2007 Anthony Williams -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// This work is a reimplementation along the design and ideas -// of William E. Kempf. - -#ifndef BOOST_THREAD_RS06040501_HPP -#define BOOST_THREAD_RS06040501_HPP - -// fetch compiler and platform configuration -#include - -// insist on threading support being available: -#include - -// choose platform -#if defined(linux) || defined(__linux) || defined(__linux__) -# define BOOST_THREAD_LINUX -//# define BOOST_THREAD_WAIT_BUG boost::posix_time::microseconds(100000) -#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) -# define BOOST_THREAD_BSD -#elif defined(sun) || defined(__sun) -# define BOOST_THREAD_SOLARIS -#elif defined(__sgi) -# define BOOST_THREAD_IRIX -#elif defined(__hpux) -# define BOOST_THREAD_HPUX -#elif defined(__CYGWIN__) -# define BOOST_THREAD_CYGWIN -#elif (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) && !defined(BOOST_DISABLE_WIN32) -# define BOOST_THREAD_WIN32 -#elif defined(__BEOS__) -# define BOOST_THREAD_BEOS -#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) -# define BOOST_THREAD_MACOS -//# define BOOST_THREAD_WAIT_BUG boost::posix_time::microseconds(1000) -#elif defined(__IBMCPP__) || defined(_AIX) -# define BOOST_THREAD_AIX -#elif defined(__amigaos__) -# define BOOST_THREAD_AMIGAOS -#elif defined(__QNXNTO__) -# define BOOST_THREAD_QNXNTO -#elif defined(unix) || defined(__unix) || defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE) -# if defined(BOOST_HAS_PTHREADS) && !defined(BOOST_THREAD_POSIX) -# define BOOST_THREAD_POSIX -# endif -#endif - -// For every supported platform add a new entry into the dispatch table below. -// BOOST_THREAD_POSIX is tested first, so on platforms where posix and native -// threading is available, the user may choose, by defining BOOST_THREAD_POSIX -// in her source. If a platform is known to support pthreads and no native -// port of boost_thread is available just specify "pthread" in the -// dispatcher table. If there is no entry for a platform but pthreads is -// available on the platform, pthread is choosen as default. If nothing is -// available the preprocessor will fail with a diagnostic message. - -#if defined(BOOST_THREAD_POSIX) -# define BOOST_THREAD_PLATFORM_PTHREAD -#else -# if defined(BOOST_THREAD_WIN32) -# define BOOST_THREAD_PLATFORM_WIN32 -# elif defined(BOOST_HAS_PTHREADS) -# define BOOST_THREAD_PLATFORM_PTHREAD -# else -# error "Sorry, no boost threads are available for this platform." -# endif -#endif - -#endif // BOOST_THREAD_RS06040501_HPP diff --git a/libraries/boost/boost/thread/detail/singleton.hpp b/libraries/boost/boost/thread/detail/singleton.hpp deleted file mode 100644 index a20a42908..000000000 --- a/libraries/boost/boost/thread/detail/singleton.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2001-2003 -// Mac Murrett -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org for most recent version including documentation. - -#ifndef BOOST_SINGLETON_MJM012402_HPP -#define BOOST_SINGLETON_MJM012402_HPP - -#include - -namespace boost { -namespace detail { -namespace thread { - -// class singleton has the same goal as all singletons: create one instance of -// a class on demand, then dish it out as requested. - -template -class singleton : private T -{ -private: - singleton(); - ~singleton(); - -public: - static T &instance(); -}; - - -template -inline singleton::singleton() -{ - /* no-op */ -} - -template -inline singleton::~singleton() -{ - /* no-op */ -} - -template -/*static*/ T &singleton::instance() -{ - // function-local static to force this to work correctly at static - // initialization time. - static singleton s_oT; - return(s_oT); -} - -} // namespace thread -} // namespace detail -} // namespace boost - -#endif // BOOST_SINGLETON_MJM012402_HPP diff --git a/libraries/boost/boost/thread/detail/thread.hpp b/libraries/boost/boost/thread/detail/thread.hpp deleted file mode 100644 index 9e7e8b8f5..000000000 --- a/libraries/boost/boost/thread/detail/thread.hpp +++ /dev/null @@ -1,873 +0,0 @@ -#ifndef BOOST_THREAD_THREAD_COMMON_HPP -#define BOOST_THREAD_THREAD_COMMON_HPP -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007-2010 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - -#include -#include - -#include -#ifndef BOOST_NO_IOSTREAM -#include -#endif -#include -#include -#if defined BOOST_THREAD_USES_DATETIME -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef BOOST_THREAD_USES_CHRONO -#include -#include -#endif - -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) -#include -#endif -#include - -#ifdef BOOST_MSVC -#pragma warning(push) -#pragma warning(disable:4251) -#endif - -namespace boost -{ - - namespace detail - { - -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - - template - class thread_data: - public detail::thread_data_base - { - public: - BOOST_THREAD_NO_COPYABLE(thread_data) - thread_data(BOOST_THREAD_RV_REF(F) f_, BOOST_THREAD_RV_REF(ArgTypes)... args_): - fp(boost::forward(f_), boost::forward(args_)...) - {} - template - void run2(tuple_indices) - { - - detail::invoke(std::move(std::get<0>(fp)), std::move(std::get(fp))...); - } - void run() - { - typedef typename make_tuple_indices >::value, 1>::type index_type; - - run2(index_type()); - } - - private: - std::tuple::type, typename decay::type...> fp; - }; -#else // defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - - template - class thread_data: - public detail::thread_data_base - { - public: - BOOST_THREAD_NO_COPYABLE(thread_data) -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - thread_data(BOOST_THREAD_RV_REF(F) f_): - f(boost::forward(f_)) - {} -// This overloading must be removed if we want the packaged_task's tests to pass. -// thread_data(F& f_): -// f(f_) -// {} -#else - - thread_data(BOOST_THREAD_RV_REF(F) f_): - f(f_) - {} - thread_data(F f_): - f(f_) - {} -#endif - //thread_data() {} - - void run() - { - f(); - } - - private: - F f; - }; - - template - class thread_data >: - public detail::thread_data_base - { - private: - F& f; - public: - BOOST_THREAD_NO_COPYABLE(thread_data) - thread_data(boost::reference_wrapper f_): - f(f_) - {} - void run() - { - f(); - } - }; - - template - class thread_data >: - public detail::thread_data_base - { - private: - F& f; - public: - BOOST_THREAD_NO_COPYABLE(thread_data) - thread_data(const boost::reference_wrapper f_): - f(f_) - {} - void run() - { - f(); - } - }; -#endif - } - - class BOOST_THREAD_DECL thread - { - public: - typedef thread_attributes attributes; - - BOOST_THREAD_MOVABLE_ONLY(thread) - private: - - struct dummy; - - void release_handle(); - - detail::thread_data_ptr thread_info; - - private: - bool start_thread_noexcept(); - bool start_thread_noexcept(const attributes& attr); - void start_thread() - { - if (!start_thread_noexcept()) - { - boost::throw_exception(thread_resource_error()); - } - } - void start_thread(const attributes& attr) - { - if (!start_thread_noexcept(attr)) - { - boost::throw_exception(thread_resource_error()); - } - } - - explicit thread(detail::thread_data_ptr data); - - detail::thread_data_ptr get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const; - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - template - static inline detail::thread_data_ptr make_thread_info(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_RV_REF(ArgTypes)... args) - { - return detail::thread_data_ptr(detail::heap_new< - detail::thread_data::type, ArgTypes...> - >( - boost::forward(f), boost::forward(args)... - ) - ); - } -#else - template - static inline detail::thread_data_ptr make_thread_info(BOOST_THREAD_RV_REF(F) f) - { - return detail::thread_data_ptr(detail::heap_new::type> >( - boost::forward(f))); - } -#endif - static inline detail::thread_data_ptr make_thread_info(void (*f)()) - { - return detail::thread_data_ptr(detail::heap_new >( - boost::forward(f))); - } -#else - template - static inline detail::thread_data_ptr make_thread_info(F f - , typename disable_if_c< - //boost::thread_detail::is_convertible::value || - is_same::type, thread>::value, - dummy* >::type=0 - ) - { - return detail::thread_data_ptr(detail::heap_new >(f)); - } - template - static inline detail::thread_data_ptr make_thread_info(BOOST_THREAD_RV_REF(F) f) - { - return detail::thread_data_ptr(detail::heap_new >(f)); - } - -#endif - public: -#if 0 // This should not be needed anymore. Use instead BOOST_THREAD_MAKE_RV_REF. -#if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) - thread(const volatile thread&); -#endif -#endif - thread() BOOST_NOEXCEPT; - ~thread() - { - - #if defined BOOST_THREAD_PROVIDES_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE - if (joinable()) { - std::terminate(); - } - #else - detach(); - #endif - } -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template < - class F - > - explicit thread(BOOST_THREAD_RV_REF(F) f - //, typename disable_if::type, thread>, dummy* >::type=0 - ): - thread_info(make_thread_info(thread_detail::decay_copy(boost::forward(f)))) - { - start_thread(); - } - template < - class F - > - thread(attributes const& attrs, BOOST_THREAD_RV_REF(F) f): - thread_info(make_thread_info(thread_detail::decay_copy(boost::forward(f)))) - { - start_thread(attrs); - } - -#else -#ifdef BOOST_NO_SFINAE - template - explicit thread(F f): - thread_info(make_thread_info(f)) - { - start_thread(); - } - template - thread(attributes const& attrs, F f): - thread_info(make_thread_info(f)) - { - start_thread(attrs); - } -#else - template - explicit thread(F f - , typename disable_if_c< - boost::thread_detail::is_rv::value // todo ass a thread_detail::is_rv - //boost::thread_detail::is_convertible::value - //|| is_same::type, thread>::value - , dummy* >::type=0 - ): - thread_info(make_thread_info(f)) - { - start_thread(); - } - template - thread(attributes const& attrs, F f - , typename disable_if, dummy* >::type=0 - //, typename disable_if, dummy* >::type=0 - ): - thread_info(make_thread_info(f)) - { - start_thread(attrs); - } -#endif - template - explicit thread(BOOST_THREAD_RV_REF(F) f - , typename disable_if::type, thread>, dummy* >::type=0 - ): -#ifdef BOOST_THREAD_USES_MOVE - thread_info(make_thread_info(boost::move(f))) // todo : Add forward -#else - thread_info(make_thread_info(f)) // todo : Add forward -#endif - { - start_thread(); - } - - template - thread(attributes const& attrs, BOOST_THREAD_RV_REF(F) f): -#ifdef BOOST_THREAD_USES_MOVE - thread_info(make_thread_info(boost::move(f))) // todo : Add forward -#else - thread_info(make_thread_info(f)) // todo : Add forward -#endif - { - start_thread(attrs); - } -#endif - thread(BOOST_THREAD_RV_REF(thread) x) BOOST_NOEXCEPT - { - thread_info=BOOST_THREAD_RV(x).thread_info; - BOOST_THREAD_RV(x).thread_info.reset(); - } -#if 0 // This should not be needed anymore. Use instead BOOST_THREAD_MAKE_RV_REF. -#if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) - thread& operator=(thread x) - { - swap(x); - return *this; - } -#endif -#endif - - thread& operator=(BOOST_THREAD_RV_REF(thread) other) BOOST_NOEXCEPT - { - -#if defined BOOST_THREAD_PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE - if (joinable()) std::terminate(); -#else - detach(); -#endif - thread_info=BOOST_THREAD_RV(other).thread_info; - BOOST_THREAD_RV(other).thread_info.reset(); - return *this; - } - -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - template - thread(F&& f, Arg&& arg, Args&&... args) : - thread_info(make_thread_info( - thread_detail::decay_copy(boost::forward(f)), - thread_detail::decay_copy(boost::forward(arg)), - thread_detail::decay_copy(boost::forward(args))...) - ) - - { - start_thread(); - } - template - thread(attributes const& attrs, F&& f, Arg&& arg, Args&&... args) : - thread_info(make_thread_info( - thread_detail::decay_copy(boost::forward(f)), - thread_detail::decay_copy(boost::forward(arg)), - thread_detail::decay_copy(boost::forward(args))...) - ) - - { - start_thread(attrs); - } -#else - template - thread(F f,A1 a1,typename disable_if, dummy* >::type=0): - thread_info(make_thread_info(boost::bind(boost::type(),f,a1))) - { - start_thread(); - } - template - thread(F f,A1 a1,A2 a2): - thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2))) - { - start_thread(); - } - - template - thread(F f,A1 a1,A2 a2,A3 a3): - thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3))) - { - start_thread(); - } - - template - thread(F f,A1 a1,A2 a2,A3 a3,A4 a4): - thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3,a4))) - { - start_thread(); - } - - template - thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5): - thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3,a4,a5))) - { - start_thread(); - } - - template - thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6): - thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3,a4,a5,a6))) - { - start_thread(); - } - - template - thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7): - thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3,a4,a5,a6,a7))) - { - start_thread(); - } - - template - thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8): - thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3,a4,a5,a6,a7,a8))) - { - start_thread(); - } - - template - thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9): - thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3,a4,a5,a6,a7,a8,a9))) - { - start_thread(); - } -#endif - void swap(thread& x) BOOST_NOEXCEPT - { - thread_info.swap(x.thread_info); - } - - class id; -#ifdef BOOST_THREAD_PLATFORM_PTHREAD - inline id get_id() const BOOST_NOEXCEPT; -#else - id get_id() const BOOST_NOEXCEPT; -#endif - - - bool joinable() const BOOST_NOEXCEPT; - private: - bool join_noexcept(); - public: - inline void join(); - -#ifdef BOOST_THREAD_USES_CHRONO -#if defined(BOOST_THREAD_PLATFORM_WIN32) - template - bool try_join_for(const chrono::duration& rel_time) - { - chrono::milliseconds rel_time2= chrono::ceil(rel_time); - return do_try_join_until(rel_time2.count()); - } -#else - template - bool try_join_for(const chrono::duration& rel_time) - { - return try_join_until(chrono::steady_clock::now() + rel_time); - } -#endif - template - bool try_join_until(const chrono::time_point& t) - { - using namespace chrono; - bool joined= false; - do { - system_clock::time_point s_now = system_clock::now(); - typename Clock::duration d = ceil(t-Clock::now()); - if (d <= Clock::duration::zero()) return false; // in case the Clock::time_point t is already reached - joined = try_join_until(s_now + d); - } while (! joined); - return true; - } - template - bool try_join_until(const chrono::time_point& t) - { - using namespace chrono; - typedef time_point nano_sys_tmpt; - return try_join_until(nano_sys_tmpt(ceil(t.time_since_epoch()))); - } -#endif -#if defined(BOOST_THREAD_PLATFORM_WIN32) - private: - bool do_try_join_until_noexcept(uintmax_t milli, bool& res); - inline bool do_try_join_until(uintmax_t milli); - public: - bool timed_join(const system_time& abs_time); - //{ - // return do_try_join_until(get_milliseconds_until(wait_until)); - //} - -#ifdef BOOST_THREAD_USES_CHRONO - bool try_join_until(const chrono::time_point& tp) - { - chrono::milliseconds rel_time= chrono::ceil(tp-chrono::system_clock::now()); - return do_try_join_until(rel_time.count()); - } -#endif - - -#else - private: - bool do_try_join_until_noexcept(struct timespec const &timeout, bool& res); - inline bool do_try_join_until(struct timespec const &timeout); - public: -#if defined BOOST_THREAD_USES_DATETIME - bool timed_join(const system_time& abs_time) - { - struct timespec const ts=detail::to_timespec(abs_time); - return do_try_join_until(ts); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - bool try_join_until(const chrono::time_point& tp) - { - using namespace chrono; - nanoseconds d = tp.time_since_epoch(); - timespec ts = boost::detail::to_timespec(d); - return do_try_join_until(ts); - } -#endif - -#endif - public: - -#if defined BOOST_THREAD_USES_DATETIME - template - inline bool timed_join(TimeDuration const& rel_time) - { - return timed_join(get_system_time()+rel_time); - } -#endif - void detach(); - - static unsigned hardware_concurrency() BOOST_NOEXCEPT; - static unsigned physical_concurrency() BOOST_NOEXCEPT; - -#define BOOST_THREAD_DEFINES_THREAD_NATIVE_HANDLE - typedef detail::thread_data_base::native_handle_type native_handle_type; - native_handle_type native_handle(); - -#if defined BOOST_THREAD_PROVIDES_THREAD_EQ - // Use thread::id when comparisions are needed - // backwards compatibility - bool operator==(const thread& other) const; - bool operator!=(const thread& other) const; -#endif -#if defined BOOST_THREAD_USES_DATETIME - static inline void yield() BOOST_NOEXCEPT - { - this_thread::yield(); - } - - static inline void sleep(const system_time& xt) - { - this_thread::sleep(xt); - } -#endif - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - // extensions - void interrupt(); - bool interruption_requested() const BOOST_NOEXCEPT; -#endif - }; - - inline void swap(thread& lhs,thread& rhs) BOOST_NOEXCEPT - { - return lhs.swap(rhs); - } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - inline thread&& move(thread& t) BOOST_NOEXCEPT - { - return static_cast(t); - } -#endif - - BOOST_THREAD_DCL_MOVABLE(thread) - - namespace this_thread - { -#ifdef BOOST_THREAD_PLATFORM_PTHREAD - inline thread::id get_id() BOOST_NOEXCEPT; -#else - thread::id BOOST_THREAD_DECL get_id() BOOST_NOEXCEPT; -#endif - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - void BOOST_THREAD_DECL interruption_point(); - bool BOOST_THREAD_DECL interruption_enabled() BOOST_NOEXCEPT; - bool BOOST_THREAD_DECL interruption_requested() BOOST_NOEXCEPT; -#endif - -#if defined BOOST_THREAD_USES_DATETIME - inline BOOST_SYMBOL_VISIBLE void sleep(xtime const& abs_time) - { - sleep(system_time(abs_time)); - } -#endif - } - - class BOOST_SYMBOL_VISIBLE thread::id - { - private: - friend inline - std::size_t - hash_value(const thread::id &v) - { -#if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID - return hash_value(v.thread_data); -#else - return hash_value(v.thread_data.get()); -#endif - } - -#if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID -#if defined(BOOST_THREAD_PLATFORM_WIN32) - typedef unsigned int data; -#else - typedef thread::native_handle_type data; -#endif -#else - typedef detail::thread_data_ptr data; -#endif - data thread_data; - - id(data thread_data_): - thread_data(thread_data_) - {} - friend class thread; - friend id BOOST_THREAD_DECL this_thread::get_id() BOOST_NOEXCEPT; - public: - id() BOOST_NOEXCEPT: -#if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID - thread_data(0) -#else - thread_data() -#endif - {} - - id(const id& other) BOOST_NOEXCEPT : - thread_data(other.thread_data) - {} - - bool operator==(const id& y) const BOOST_NOEXCEPT - { - return thread_data==y.thread_data; - } - - bool operator!=(const id& y) const BOOST_NOEXCEPT - { - return thread_data!=y.thread_data; - } - - bool operator<(const id& y) const BOOST_NOEXCEPT - { - return thread_data(const id& y) const BOOST_NOEXCEPT - { - return y.thread_data=(const id& y) const BOOST_NOEXCEPT - { - return !(thread_data - friend BOOST_SYMBOL_VISIBLE - std::basic_ostream& - operator<<(std::basic_ostream& os, const id& x) - { - if(x.thread_data) - { - io::ios_flags_saver ifs( os ); - return os<< std::hex << x.thread_data; - } - else - { - return os<<"{Not-any-thread}"; - } - } -#else - template - BOOST_SYMBOL_VISIBLE - std::basic_ostream& - print(std::basic_ostream& os) const - { - if(thread_data) - { - io::ios_flags_saver ifs( os ); - return os<< std::hex << thread_data; - } - else - { - return os<<"{Not-any-thread}"; - } - } - -#endif -#endif - }; - -#ifdef BOOST_THREAD_PLATFORM_PTHREAD - thread::id thread::get_id() const BOOST_NOEXCEPT - { - #if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID - return const_cast(this)->native_handle(); - #else - detail::thread_data_ptr const local_thread_info=(get_thread_info)(); - return (local_thread_info? id(local_thread_info) : id()); - #endif - } - - namespace this_thread - { - inline thread::id get_id() BOOST_NOEXCEPT - { - #if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID - return pthread_self(); - #else - boost::detail::thread_data_base* const thread_info=get_or_make_current_thread_data(); - return (thread_info?thread::id(thread_info->shared_from_this()):thread::id()); - #endif - } - } -#endif - void thread::join() { - if (this_thread::get_id() == get_id()) - boost::throw_exception(thread_resource_error(static_cast(system::errc::resource_deadlock_would_occur), "boost thread: trying joining itself")); - - BOOST_THREAD_VERIFY_PRECONDITION( join_noexcept(), - thread_resource_error(static_cast(system::errc::invalid_argument), "boost thread: thread not joinable") - ); - } - -#ifdef BOOST_THREAD_PLATFORM_PTHREAD - bool thread::do_try_join_until(struct timespec const &timeout) -#else - bool thread::do_try_join_until(uintmax_t timeout) -#endif - { - if (this_thread::get_id() == get_id()) - boost::throw_exception(thread_resource_error(static_cast(system::errc::resource_deadlock_would_occur), "boost thread: trying joining itself")); - bool res; - if (do_try_join_until_noexcept(timeout, res)) - { - return res; - } - else - { - BOOST_THREAD_THROW_ELSE_RETURN( - (thread_resource_error(static_cast(system::errc::invalid_argument), "boost thread: thread not joinable")), - false - ); - } - } - -#if !defined(BOOST_NO_IOSTREAM) && defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) - template - BOOST_SYMBOL_VISIBLE - std::basic_ostream& - operator<<(std::basic_ostream& os, const thread::id& x) - { - return x.print(os); - } -#endif - -#if defined BOOST_THREAD_PROVIDES_THREAD_EQ - inline bool thread::operator==(const thread& other) const - { - return get_id()==other.get_id(); - } - - inline bool thread::operator!=(const thread& other) const - { - return get_id()!=other.get_id(); - } -#endif - - namespace detail - { - struct thread_exit_function_base - { - virtual ~thread_exit_function_base() - {} - virtual void operator()()=0; - }; - - template - struct thread_exit_function: - thread_exit_function_base - { - F f; - - thread_exit_function(F f_): - f(f_) - {} - - void operator()() - { - f(); - } - }; - - void BOOST_THREAD_DECL add_thread_exit_function(thread_exit_function_base*); - struct shared_state_base; -#if defined(BOOST_THREAD_PLATFORM_WIN32) - inline void make_ready_at_thread_exit(shared_ptr as) - { - detail::thread_data_base* const current_thread_data(detail::get_current_thread_data()); - if(current_thread_data) - { - current_thread_data->make_ready_at_thread_exit(as); - } - } -#else - void BOOST_THREAD_DECL make_ready_at_thread_exit(shared_ptr as); -#endif - } - - namespace this_thread - { - template - void at_thread_exit(F f) - { - detail::thread_exit_function_base* const thread_exit_func=detail::heap_new >(f); - detail::add_thread_exit_function(thread_exit_func); - } - } -} - -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif - -#include - -#endif diff --git a/libraries/boost/boost/thread/detail/thread_group.hpp b/libraries/boost/boost/thread/detail/thread_group.hpp deleted file mode 100644 index 4105c7346..000000000 --- a/libraries/boost/boost/thread/detail/thread_group.hpp +++ /dev/null @@ -1,155 +0,0 @@ -#ifndef BOOST_THREAD_DETAIL_THREAD_GROUP_HPP -#define BOOST_THREAD_DETAIL_THREAD_GROUP_HPP -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007-9 Anthony Williams - -#include -#include -#include -#include -#include - -#include - -#ifdef BOOST_MSVC -#pragma warning(push) -#pragma warning(disable:4251) -#endif - -namespace boost -{ - class thread_group - { - private: - thread_group(thread_group const&); - thread_group& operator=(thread_group const&); - public: - thread_group() {} - ~thread_group() - { - for(std::list::iterator it=threads.begin(),end=threads.end(); - it!=end; - ++it) - { - delete *it; - } - } - - bool is_this_thread_in() - { - thread::id id = this_thread::get_id(); - boost::shared_lock guard(m); - for(std::list::iterator it=threads.begin(),end=threads.end(); - it!=end; - ++it) - { - if ((*it)->get_id() == id) - return true; - } - return false; - } - - bool is_thread_in(thread* thrd) - { - if(thrd) - { - thread::id id = thrd->get_id(); - boost::shared_lock guard(m); - for(std::list::iterator it=threads.begin(),end=threads.end(); - it!=end; - ++it) - { - if ((*it)->get_id() == id) - return true; - } - return false; - } - else - { - return false; - } - } - - template - thread* create_thread(F threadfunc) - { - boost::lock_guard guard(m); - boost::csbl::unique_ptr new_thread(new thread(threadfunc)); - threads.push_back(new_thread.get()); - return new_thread.release(); - } - - void add_thread(thread* thrd) - { - if(thrd) - { - BOOST_THREAD_ASSERT_PRECONDITION( ! is_thread_in(thrd) , - thread_resource_error(static_cast(system::errc::resource_deadlock_would_occur), "boost::thread_group: trying to add a duplicated thread") - ); - - boost::lock_guard guard(m); - threads.push_back(thrd); - } - } - - void remove_thread(thread* thrd) - { - boost::lock_guard guard(m); - std::list::iterator const it=std::find(threads.begin(),threads.end(),thrd); - if(it!=threads.end()) - { - threads.erase(it); - } - } - - void join_all() - { - BOOST_THREAD_ASSERT_PRECONDITION( ! is_this_thread_in() , - thread_resource_error(static_cast(system::errc::resource_deadlock_would_occur), "boost::thread_group: trying joining itself") - ); - boost::shared_lock guard(m); - - for(std::list::iterator it=threads.begin(),end=threads.end(); - it!=end; - ++it) - { - if ((*it)->joinable()) - (*it)->join(); - } - } - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - void interrupt_all() - { - boost::shared_lock guard(m); - - for(std::list::iterator it=threads.begin(),end=threads.end(); - it!=end; - ++it) - { - (*it)->interrupt(); - } - } -#endif - - size_t size() const - { - boost::shared_lock guard(m); - return threads.size(); - } - - private: - std::list threads; - mutable shared_mutex m; - }; -} - -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif - -#include - -#endif diff --git a/libraries/boost/boost/thread/detail/thread_heap_alloc.hpp b/libraries/boost/boost/thread/detail/thread_heap_alloc.hpp deleted file mode 100644 index 2f9bfd5c0..000000000 --- a/libraries/boost/boost/thread/detail/thread_heap_alloc.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef BOOST_THREAD_THREAD_HEAP_ALLOC_HPP -#define BOOST_THREAD_THREAD_HEAP_ALLOC_HPP - -// thread_heap_alloc.hpp -// -// (C) Copyright 2008 Anthony Williams -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - -#if defined(BOOST_THREAD_PLATFORM_WIN32) -#include -#elif defined(BOOST_THREAD_PLATFORM_PTHREAD) -#include -#else -#error "Boost threads unavailable on this platform" -#endif - - -#endif diff --git a/libraries/boost/boost/thread/detail/thread_interruption.hpp b/libraries/boost/boost/thread/detail/thread_interruption.hpp deleted file mode 100644 index 5d7d10fec..000000000 --- a/libraries/boost/boost/thread/detail/thread_interruption.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef BOOST_THREAD_DETAIL_THREAD_INTERRUPTION_HPP -#define BOOST_THREAD_DETAIL_THREAD_INTERRUPTION_HPP -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007-9 Anthony Williams -// (C) Copyright 2012 Vicente J. Botet Escriba - -#include -#include - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - -namespace boost -{ - namespace this_thread - { - class BOOST_THREAD_DECL disable_interruption - { - bool interruption_was_enabled; - friend class restore_interruption; - public: - BOOST_THREAD_NO_COPYABLE(disable_interruption) - disable_interruption() BOOST_NOEXCEPT; - ~disable_interruption() BOOST_NOEXCEPT; - }; - - class BOOST_THREAD_DECL restore_interruption - { - public: - BOOST_THREAD_NO_COPYABLE(restore_interruption) - explicit restore_interruption(disable_interruption& d) BOOST_NOEXCEPT; - ~restore_interruption() BOOST_NOEXCEPT; - }; - } -} - -#endif // BOOST_THREAD_PROVIDES_INTERRUPTIONS -#endif // header diff --git a/libraries/boost/boost/thread/detail/tss_hooks.hpp b/libraries/boost/boost/thread/detail/tss_hooks.hpp deleted file mode 100644 index b2ceece3d..000000000 --- a/libraries/boost/boost/thread/detail/tss_hooks.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// (C) Copyright Michael Glassford 2004. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#if !defined(BOOST_TLS_HOOKS_HPP) -#define BOOST_TLS_HOOKS_HPP - -#include - -#include - -#if defined(BOOST_HAS_WINTHREADS) - -namespace boost -{ - BOOST_THREAD_DECL void __cdecl on_process_enter(void); - //Function to be called when the exe or dll - //that uses Boost.Threads first starts - //or is first loaded. - //Should be called only before the first call to - //on_thread_enter(). - //Called automatically by Boost.Threads when - //a method for doing so has been discovered. - //May be omitted; may be called multiple times. - - BOOST_THREAD_DECL void __cdecl on_process_exit(void); - //Function to be called when the exe or dll - //that uses Boost.Threads first starts - //or is first loaded. - //Should be called only after the last call to - //on_exit_thread(). - //Called automatically by Boost.Threads when - //a method for doing so has been discovered. - //Must not be omitted; may be called multiple times. - - BOOST_THREAD_DECL void __cdecl on_thread_enter(void); - //Function to be called just after a thread starts - //in an exe or dll that uses Boost.Threads. - //Must be called in the context of the thread - //that is starting. - //Called automatically by Boost.Threads when - //a method for doing so has been discovered. - //May be omitted; may be called multiple times. - - BOOST_THREAD_DECL void __cdecl on_thread_exit(void); - //Function to be called just be fore a thread ends - //in an exe or dll that uses Boost.Threads. - //Must be called in the context of the thread - //that is ending. - //Called automatically by Boost.Threads when - //a method for doing so has been discovered. - //Must not be omitted; may be called multiple times. - - void tss_cleanup_implemented(); - //Dummy function used both to detect whether tss cleanup - //cleanup has been implemented and to force - //it to be linked into the Boost.Threads library. -} - -#endif //defined(BOOST_HAS_WINTHREADS) - -#include - -#endif //!defined(BOOST_TLS_HOOKS_HPP) diff --git a/libraries/boost/boost/thread/detail/variadic_footer.hpp b/libraries/boost/boost/thread/detail/variadic_footer.hpp deleted file mode 100644 index 9ae25a847..000000000 --- a/libraries/boost/boost/thread/detail/variadic_footer.hpp +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - - -#if defined BOOST_NO_CXX11_VARIADIC_TEMPLATES - - -#endif diff --git a/libraries/boost/boost/thread/detail/variadic_header.hpp b/libraries/boost/boost/thread/detail/variadic_header.hpp deleted file mode 100644 index 8015ae33c..000000000 --- a/libraries/boost/boost/thread/detail/variadic_header.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include - -//#if defined BOOST_NO_CXX11_VARIADIC_TEMPLATES - -#include -#include -#include - -#ifndef BOOST_THREAD_MAX_ARGS -#define BOOST_THREAD_MAX_ARGS 9 -#endif - -//#endif - diff --git a/libraries/boost/boost/thread/exceptional_ptr.hpp b/libraries/boost/boost/thread/exceptional_ptr.hpp deleted file mode 100644 index 49547923d..000000000 --- a/libraries/boost/boost/thread/exceptional_ptr.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2014 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_EXCEPTIONAL_PTR_HPP -#define BOOST_THREAD_EXCEPTIONAL_PTR_HPP - -#include -#include - -#include - -namespace boost -{ - struct exceptional_ptr { - exception_ptr ptr_; - - exceptional_ptr() : ptr_() {} - explicit exceptional_ptr(exception_ptr ex) : ptr_(ex) {} - template - explicit exceptional_ptr(BOOST_FWD_REF(E) ex) : ptr_(boost::copy_exception(boost::forward(ex))) {} - }; - - template - inline exceptional_ptr make_exceptional(BOOST_FWD_REF(E) ex) { - return exceptional_ptr(boost::forward(ex)); - } - - inline exceptional_ptr make_exceptional(exception_ptr ex) - { - return exceptional_ptr(ex); - } - - inline exceptional_ptr make_exceptional() - { - return exceptional_ptr(); - } - -} // namespace boost - -#include - -#endif diff --git a/libraries/boost/boost/thread/exceptions.hpp b/libraries/boost/boost/thread/exceptions.hpp deleted file mode 100644 index d97465b75..000000000 --- a/libraries/boost/boost/thread/exceptions.hpp +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (C) 2001-2003 -// William E. Kempf -// Copyright (C) 2007-9 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_EXCEPTIONS_PDM070801_H -#define BOOST_THREAD_EXCEPTIONS_PDM070801_H - -#include - -// pdm: Sorry, but this class is used all over the place & I end up -// with recursive headers if I don't separate it -// wek: Not sure why recursive headers would cause compilation problems -// given the include guards, but regardless it makes sense to -// seperate this out any way. - -#include -#include -#include -#include - - -#include - -namespace boost -{ - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - class BOOST_SYMBOL_VISIBLE thread_interrupted - {}; -#endif - - class BOOST_SYMBOL_VISIBLE thread_exception: - public system::system_error - //public std::exception - { - typedef system::system_error base_type; - public: - thread_exception() - : base_type(0,system::system_category()) - {} - - thread_exception(int sys_error_code) - : base_type(sys_error_code, system::system_category()) - {} - - thread_exception( int ev, const char * what_arg ) - : base_type(system::error_code(ev, system::system_category()), what_arg) - { - } - thread_exception( int ev, const std::string & what_arg ) - : base_type(system::error_code(ev, system::system_category()), what_arg) - { - } - - ~thread_exception() throw() - {} - - - int native_error() const - { - return code().value(); - } - - }; - - class BOOST_SYMBOL_VISIBLE condition_error: - public system::system_error - //public std::exception - { - typedef system::system_error base_type; - public: - condition_error() - : base_type(system::error_code(0, system::system_category()), "Condition error") - {} - condition_error( int ev ) - : base_type(system::error_code(ev, system::system_category()), "Condition error") - { - } - condition_error( int ev, const char * what_arg ) - : base_type(system::error_code(ev, system::system_category()), what_arg) - { - } - condition_error( int ev, const std::string & what_arg ) - : base_type(system::error_code(ev, system::system_category()), what_arg) - { - } - }; - - - class BOOST_SYMBOL_VISIBLE lock_error: - public thread_exception - { - typedef thread_exception base_type; - public: - lock_error() - : base_type(0, "boost::lock_error") - {} - - lock_error( int ev ) - : base_type(ev, "boost::lock_error") - { - } - lock_error( int ev, const char * what_arg ) - : base_type(ev, what_arg) - { - } - lock_error( int ev, const std::string & what_arg ) - : base_type(ev, what_arg) - { - } - - ~lock_error() throw() - {} - - }; - - class BOOST_SYMBOL_VISIBLE thread_resource_error: - public thread_exception - { - typedef thread_exception base_type; - public: - thread_resource_error() - : base_type(static_cast(system::errc::resource_unavailable_try_again), "boost::thread_resource_error") - {} - - thread_resource_error( int ev ) - : base_type(ev, "boost::thread_resource_error") - { - } - thread_resource_error( int ev, const char * what_arg ) - : base_type(ev, what_arg) - { - } - thread_resource_error( int ev, const std::string & what_arg ) - : base_type(ev, what_arg) - { - } - - - ~thread_resource_error() throw() - {} - - }; - - class BOOST_SYMBOL_VISIBLE unsupported_thread_option: - public thread_exception - { - typedef thread_exception base_type; - public: - unsupported_thread_option() - : base_type(static_cast(system::errc::invalid_argument), "boost::unsupported_thread_option") - {} - - unsupported_thread_option( int ev ) - : base_type(ev, "boost::unsupported_thread_option") - { - } - unsupported_thread_option( int ev, const char * what_arg ) - : base_type(ev, what_arg) - { - } - unsupported_thread_option( int ev, const std::string & what_arg ) - : base_type(ev, what_arg) - { - } - - }; - - class BOOST_SYMBOL_VISIBLE invalid_thread_argument: - public thread_exception - { - typedef thread_exception base_type; - public: - invalid_thread_argument() - : base_type(static_cast(system::errc::invalid_argument), "boost::invalid_thread_argument") - {} - - invalid_thread_argument( int ev ) - : base_type(ev, "boost::invalid_thread_argument") - { - } - invalid_thread_argument( int ev, const char * what_arg ) - : base_type(ev, what_arg) - { - } - invalid_thread_argument( int ev, const std::string & what_arg ) - : base_type(ev, what_arg) - { - } - - }; - - class BOOST_SYMBOL_VISIBLE thread_permission_error: - public thread_exception - { - typedef thread_exception base_type; - public: - thread_permission_error() - : base_type(static_cast(system::errc::permission_denied), "boost::thread_permission_error") - {} - - thread_permission_error( int ev ) - : base_type(ev, "boost::thread_permission_error") - { - } - thread_permission_error( int ev, const char * what_arg ) - : base_type(ev, what_arg) - { - } - thread_permission_error( int ev, const std::string & what_arg ) - : base_type(ev, what_arg) - { - } - - }; - -} // namespace boost - -#include - -#endif diff --git a/libraries/boost/boost/thread/executor.hpp b/libraries/boost/boost/thread/executor.hpp deleted file mode 100644 index c2b85a0ea..000000000 --- a/libraries/boost/boost/thread/executor.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/09 Vicente J. Botet Escriba -// Adapt to boost from CCIA C++11 implementation - -#ifndef BOOST_THREAD_EXECUTOR_HPP -#define BOOST_THREAD_EXECUTOR_HPP - -#include -#include - -#endif diff --git a/libraries/boost/boost/thread/executors/basic_thread_pool.hpp b/libraries/boost/boost/thread/executors/basic_thread_pool.hpp deleted file mode 100644 index e0d4df2c7..000000000 --- a/libraries/boost/boost/thread/executors/basic_thread_pool.hpp +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright (C) 2013-2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/09 Vicente J. Botet Escriba -// Adapt to boost from CCIA C++11 implementation -// first implementation of a simple pool thread using a vector of threads and a sync_queue. - -#ifndef BOOST_THREAD_EXECUTORS_BASIC_THREAD_POOL_HPP -#define BOOST_THREAD_EXECUTORS_BASIC_THREAD_POOL_HPP - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace executors -{ - class basic_thread_pool - { - public: - /// type-erasure to store the works to do - typedef executors::work work; - private: - typedef thread thread_t; - /// A move aware vector type - typedef csbl::vector thread_vector; - - /// A move aware vector - thread_vector threads; - /// the thread safe work queue - concurrent::sync_queue work_queue; - - public: - /** - * Effects: try to execute one task. - * Returns: whether a task has been executed. - * Throws: whatever the current task constructor throws or the task() throws. - */ - bool try_executing_one() - { - try - { - work task; - if (work_queue.try_pull(task) == queue_op_status::success) - { - task(); - return true; - } - return false; - } - catch (...) - { - std::terminate(); - //return false; - } - } - /** - * Effects: schedule one task or yields - * Throws: whatever the current task constructor throws or the task() throws. - */ - void schedule_one_or_yield() - { - if ( ! try_executing_one()) - { - this_thread::yield(); - } - } - private: - - /** - * The main loop of the worker threads - */ - void worker_thread() - { - try - { - for(;;) - { - work task; - queue_op_status st = work_queue.wait_pull(task); - if (st == queue_op_status::closed) { - return; - } - task(); - } - } - catch (...) - { - std::terminate(); - return; - } - } -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - void worker_thread1(AtThreadEntry& at_thread_entry) - { - at_thread_entry(*this); - worker_thread(); - } -#endif - void worker_thread2(void(*at_thread_entry)(basic_thread_pool&)) - { - at_thread_entry(*this); - worker_thread(); - } - template - void worker_thread3(BOOST_THREAD_FWD_REF(AtThreadEntry) at_thread_entry) - { - at_thread_entry(*this); - worker_thread(); - } - static void do_nothing_at_thread_entry(basic_thread_pool&) {} - - public: - /// basic_thread_pool is not copyable. - BOOST_THREAD_NO_COPYABLE(basic_thread_pool) - - /** - * \b Effects: creates a thread pool that runs closures on \c thread_count threads. - * - * \b Throws: Whatever exception is thrown while initializing the needed resources. - */ - basic_thread_pool(unsigned const thread_count = thread::hardware_concurrency()+1) - { - try - { - threads.reserve(thread_count); - for (unsigned i = 0; i < thread_count; ++i) - { -#if 1 - thread th (&basic_thread_pool::worker_thread, this); - threads.push_back(thread_t(boost::move(th))); -#else - threads.push_back(thread_t(&basic_thread_pool::worker_thread, this)); // do not compile -#endif - } - } - catch (...) - { - close(); - throw; - } - } - /** - * \b Effects: creates a thread pool that runs closures on \c thread_count threads - * and executes the at_thread_entry function at the entry of each created thread. . - * - * \b Throws: Whatever exception is thrown while initializing the needed resources. - */ -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - basic_thread_pool( unsigned const thread_count, AtThreadEntry& at_thread_entry) - { - try - { - threads.reserve(thread_count); - for (unsigned i = 0; i < thread_count; ++i) - { - thread th (&basic_thread_pool::worker_thread1, this, at_thread_entry); - threads.push_back(thread_t(boost::move(th))); - //threads.push_back(thread_t(&basic_thread_pool::worker_thread, this)); // do not compile - } - } - catch (...) - { - close(); - throw; - } - } -#endif - basic_thread_pool( unsigned const thread_count, void(*at_thread_entry)(basic_thread_pool&)) - { - try - { - threads.reserve(thread_count); - for (unsigned i = 0; i < thread_count; ++i) - { - thread th (&basic_thread_pool::worker_thread2, this, at_thread_entry); - threads.push_back(thread_t(boost::move(th))); - //threads.push_back(thread_t(&basic_thread_pool::worker_thread, this)); // do not compile - } - } - catch (...) - { - close(); - throw; - } - } - template - basic_thread_pool( unsigned const thread_count, BOOST_THREAD_FWD_REF(AtThreadEntry) at_thread_entry) - { - try - { - threads.reserve(thread_count); - for (unsigned i = 0; i < thread_count; ++i) - { - thread th (&basic_thread_pool::worker_thread3, this, boost::forward(at_thread_entry)); - threads.push_back(thread_t(boost::move(th))); - //threads.push_back(thread_t(&basic_thread_pool::worker_thread, this)); // do not compile - } - } - catch (...) - { - close(); - throw; - } - } - /** - * \b Effects: Destroys the thread pool. - * - * \b Synchronization: The completion of all the closures happen before the completion of the \c basic_thread_pool destructor. - */ - ~basic_thread_pool() - { - // signal to all the worker threads that there will be no more submissions. - close(); - // joins all the threads before destroying the thread pool resources (e.g. the queue). - join(); - } - - /** - * \b Effects: join all the threads. - */ - void join() - { - for (unsigned i = 0; i < threads.size(); ++i) - { - threads[i].join(); - } - } - - /** - * \b Effects: close the \c basic_thread_pool for submissions. - * The worker threads will work until there is no more closures to run. - */ - void close() - { - work_queue.close(); - } - - /** - * \b Returns: whether the pool is closed for submissions. - */ - bool closed() - { - return work_queue.closed(); - } - - /** - * \b Requires: \c Closure is a model of \c Callable(void()) and a model of \c CopyConstructible/MoveConstructible. - * - * \b Effects: The specified \c closure will be scheduled for execution at some point in the future. - * If invoked closure throws an exception the \c basic_thread_pool will call \c std::terminate, as is the case with threads. - * - * \b Synchronization: completion of \c closure on a particular thread happens before destruction of thread's thread local variables. - * - * \b Throws: \c sync_queue_is_closed if the thread pool is closed. - * Whatever exception that can be throw while storing the closure. - */ - void submit(BOOST_THREAD_RV_REF(work) closure) { - work_queue.push(boost::move(closure)); - } - -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - void submit(Closure & closure) - { - submit(work(closure)); - } -#endif - void submit(void (*closure)()) - { - submit(work(closure)); - } - - template - void submit(BOOST_THREAD_FWD_REF(Closure) closure) - { - //submit(work(boost::forward(closure))); - work w((boost::forward(closure))); - submit(boost::move(w)); - } - - /** - * \b Requires: This must be called from an scheduled task. - * - * \b Effects: reschedule functions until pred() - */ - template - bool reschedule_until(Pred const& pred) - { - do { - if ( ! try_executing_one()) - { - return false; - } - } while (! pred()); - return true; - } - - }; -} -using executors::basic_thread_pool; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/executors/detail/priority_executor_base.hpp b/libraries/boost/boost/thread/executors/detail/priority_executor_base.hpp deleted file mode 100644 index 2191c0b37..000000000 --- a/libraries/boost/boost/thread/executors/detail/priority_executor_base.hpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2014 Ian Forbed -// Copyright (C) 2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef BOOST_THREAD_EXECUTORS_DETAIL_PRIORITY_EXECUTOR_BASE_HPP -#define BOOST_THREAD_EXECUTORS_DETAIL_PRIORITY_EXECUTOR_BASE_HPP - -#include -#include -#include -#include -#include - -namespace boost -{ -namespace executors -{ -namespace detail -{ - template - class priority_executor_base - { - public: - //typedef boost::function work; - typedef executors::work_pq work; - protected: - typedef Queue queue_type; - queue_type _workq; - - priority_executor_base() {} - public: - - ~priority_executor_base() - { - if(!closed()) - { - this->close(); - } - } - - void close() - { - _workq.close(); - } - - bool closed() - { - return _workq.closed(); - } - - void loop() - { - try - { - for(;;) - { - work task; - queue_op_status st = _workq.wait_pull(task); - if (st == queue_op_status::closed) return; - task(); - } - } - catch (...) - { - std::terminate(); - return; - } - } - }; //end class - -} //end detail namespace -} //end executors namespace -} //end boost namespace -#endif diff --git a/libraries/boost/boost/thread/executors/detail/scheduled_executor_base.hpp b/libraries/boost/boost/thread/executors/detail/scheduled_executor_base.hpp deleted file mode 100644 index ec0038f7e..000000000 --- a/libraries/boost/boost/thread/executors/detail/scheduled_executor_base.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2014 Ian Forbed -// Copyright (C) 2014-2015 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef BOOST_THREAD_EXECUTORS_DETAIL_SCHEDULED_EXECUTOR_BASE_HPP -#define BOOST_THREAD_EXECUTORS_DETAIL_SCHEDULED_EXECUTOR_BASE_HPP - -#include -#include -#include -#include - -#include -#include - -#include - -namespace boost -{ -namespace executors -{ -namespace detail -{ - template - class scheduled_executor_base : public priority_executor_base > - { - public: - typedef executors::work_pq work; - typedef Clock clock; - typedef typename clock::duration duration; - typedef typename clock::time_point time_point; - protected: - - scheduled_executor_base() {} - public: - - ~scheduled_executor_base() - { - if(! this->closed()) - { - this->close(); - } - } - - void submit_at(work w, const time_point& tp) - { - this->_workq.push(boost::move(w), tp); - } - - void submit_after(work w, const duration& dura) - { - this->_workq.push(boost::move(w), dura+clock::now()); - } - - }; //end class - -} //end detail namespace -} //end executors namespace -} //end boost namespace - -#include - -#endif diff --git a/libraries/boost/boost/thread/executors/executor.hpp b/libraries/boost/boost/thread/executors/executor.hpp deleted file mode 100644 index 96198201f..000000000 --- a/libraries/boost/boost/thread/executors/executor.hpp +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (C) 2013,2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/09 Vicente J. Botet Escriba -// Adapt to boost from CCIA C++11 implementation - -#ifndef BOOST_THREAD_EXECUTORS_EXECUTOR_HPP -#define BOOST_THREAD_EXECUTORS_EXECUTOR_HPP - -#include - -#include -#include -#include - -#include - -namespace boost -{ - namespace executors - { - class executor - { - public: - /// type-erasure to store the works to do - typedef executors::work work; - - /// executor is not copyable. - BOOST_THREAD_NO_COPYABLE(executor) - executor() {} - - /** - * \par Effects - * Destroys the executor. - * - * \par Synchronization - * The completion of all the closures happen before the completion of the executor destructor. - */ - virtual ~executor() {}; - - /** - * \par Effects - * Close the \c executor for submissions. - * The worker threads will work until there is no more closures to run. - */ - virtual void close() = 0; - - /** - * \par Returns - * Whether the pool is closed for submissions. - */ - virtual bool closed() = 0; - - /** - * \par Effects - * The specified closure will be scheduled for execution at some point in the future. - * If invoked closure throws an exception the executor will call std::terminate, as is the case with threads. - * - * \par Synchronization - * Ccompletion of closure on a particular thread happens before destruction of thread's thread local variables. - * - * \par Throws - * \c sync_queue_is_closed if the thread pool is closed. - * Whatever exception that can be throw while storing the closure. - */ - virtual void submit(BOOST_THREAD_RV_REF(work) closure) = 0; -// virtual void submit(work& closure) = 0; - - /** - * \par Requires - * \c Closure is a model of Callable(void()) and a model of CopyConstructible/MoveConstructible. - * - * \par Effects - * The specified closure will be scheduled for execution at some point in the future. - * If invoked closure throws an exception the thread pool will call std::terminate, as is the case with threads. - * - * \par Synchronization - * Completion of closure on a particular thread happens before destruction of thread's thread local variables. - * - * \par Throws - * \c sync_queue_is_closed if the thread pool is closed. - * Whatever exception that can be throw while storing the closure. - */ - -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - void submit(Closure & closure) - { - work w ((closure)); - submit(boost::move(w)); - } -#endif - void submit(void (*closure)()) - { - work w ((closure)); - submit(boost::move(w)); - } - - template - void submit(BOOST_THREAD_FWD_REF(Closure) closure) - { - //submit(work(boost::forward(closure))); - work w((boost::forward(closure))); - submit(boost::move(w)); - } - - /** - * \par Effects - * Try to execute one task. - * - * \par Returns - * Whether a task has been executed. - * - * \par Throws - * Whatever the current task constructor throws or the task() throws. - */ - virtual bool try_executing_one() = 0; - - /** - * \par Requires - * This must be called from an scheduled task. - * - * \par Effects - * Reschedule functions until pred() - */ - template - bool reschedule_until(Pred const& pred) - { - do { - //schedule_one_or_yield(); - if ( ! try_executing_one()) - { - return false; - } - } while (! pred()); - return true; - } - }; - - } - using executors::executor; -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/executors/executor_adaptor.hpp b/libraries/boost/boost/thread/executors/executor_adaptor.hpp deleted file mode 100644 index ca1a35f2d..000000000 --- a/libraries/boost/boost/thread/executors/executor_adaptor.hpp +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (C) 2013,2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/09 Vicente J. Botet Escriba -// Adapt to boost from CCIA C++11 implementation - -#ifndef BOOST_THREAD_EXECUTORS_EXECUTOR_ADAPTOR_HPP -#define BOOST_THREAD_EXECUTORS_EXECUTOR_ADAPTOR_HPP - -#include - -#include - -#include - -namespace boost -{ -namespace executors -{ - /** - * Polymorphic adaptor of a model of Executor to an executor. - */ - template - class executor_adaptor : public executor - { - Executor ex; - public: - /// type-erasure to store the works to do - typedef executor::work work; - - /// executor is not copyable. - BOOST_THREAD_NO_COPYABLE(executor_adaptor) - - /** - * executor_adaptor constructor - */ -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template - executor_adaptor(BOOST_THREAD_RV_REF(Args) ... args) : ex(boost::forward(args)...) {} -#else - /** - * executor_adaptor constructor - */ - executor_adaptor() : ex() {} - - template - executor_adaptor( - BOOST_THREAD_FWD_REF(A1) a1 - ) : - ex( - boost::forward(a1) - ) {} - template - executor_adaptor( - BOOST_THREAD_FWD_REF(A1) a1, - BOOST_THREAD_FWD_REF(A2) a2 - ) : - ex( - boost::forward(a1), - boost::forward(a2) - ) {} - template - executor_adaptor( - BOOST_THREAD_FWD_REF(A1) a1, - BOOST_THREAD_FWD_REF(A2) a2, - BOOST_THREAD_FWD_REF(A3) a3 - ) : - ex( - boost::forward(a1), - boost::forward(a2), - boost::forward(a3) - ) {} -#endif - Executor& underlying_executor() { return ex; } - - /** - * \b Effects: close the \c executor for submissions. - * The worker threads will work until there is no more closures to run. - */ - void close() { ex.close(); } - - /** - * \b Returns: whether the pool is closed for submissions. - */ - bool closed() { return ex.closed(); } - - /** - * \b Effects: The specified closure will be scheduled for execution at some point in the future. - * If invoked closure throws an exception the executor will call std::terminate, as is the case with threads. - * - * \b Synchronization: completion of closure on a particular thread happens before destruction of thread's thread local variables. - * - * \b Throws: \c sync_queue_is_closed if the thread pool is closed. - * Whatever exception that can be throw while storing the closure. - */ - void submit(BOOST_THREAD_RV_REF(work) closure) { - return ex.submit(boost::move(closure)); - } - -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - void submit(Closure & closure) - { - submit(work(closure)); - } -#endif - void submit(void (*closure)()) - { - submit(work(closure)); - } - - template - void submit(BOOST_THREAD_FWD_REF(Closure) closure) - { - //submit(work(boost::forward(closure))); - work w((boost::forward(closure))); - submit(boost::move(w)); - } - - /** - * Effects: try to execute one task. - * Returns: whether a task has been executed. - * Throws: whatever the current task constructor throws or the task() throws. - */ - bool try_executing_one() { return ex.try_executing_one(); } - - }; -} -using executors::executor_adaptor; -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/executors/generic_executor_ref.hpp b/libraries/boost/boost/thread/executors/generic_executor_ref.hpp deleted file mode 100644 index da0382c16..000000000 --- a/libraries/boost/boost/thread/executors/generic_executor_ref.hpp +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright (C) 2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef BOOST_THREAD_EXECUTORS_GENERIC_EXECUTOR_REF_HPP -#define BOOST_THREAD_EXECUTORS_GENERIC_EXECUTOR_REF_HPP - -#include - -#include -#include -#include - -#include - -#include - -namespace boost -{ - namespace executors - { - - template - class executor_ref : public executor - { - Executor& ex; - public: - /// type-erasure to store the works to do - typedef executors::work work; - - /// executor is not copyable. - BOOST_THREAD_NO_COPYABLE(executor_ref) - executor_ref(Executor& ex_) : ex(ex_) {} - - /** - * \par Effects - * Destroys the executor. - * - * \par Synchronization - * The completion of all the closures happen before the completion of the executor destructor. - */ - ~executor_ref() {}; - - /** - * \par Effects - * Close the \c executor for submissions. - * The worker threads will work until there is no more closures to run. - */ - void close() { ex.close(); } - - /** - * \par Returns - * Whether the pool is closed for submissions. - */ - bool closed() { return ex.closed(); } - - /** - * \par Effects - * The specified closure will be scheduled for execution at some point in the future. - * If invoked closure throws an exception the executor will call std::terminate, as is the case with threads. - * - * \par Synchronization - * Ccompletion of closure on a particular thread happens before destruction of thread's thread local variables. - * - * \par Throws - * \c sync_queue_is_closed if the thread pool is closed. - * Whatever exception that can be throw while storing the closure. - */ - void submit(BOOST_THREAD_RV_REF(work) closure) { - ex.submit(boost::move(closure)); - } -// void submit(work& closure) { -// ex.submit(closure); -// } - - - /** - * \par Effects - * Try to execute one task. - * - * \par Returns - * Whether a task has been executed. - * - * \par Throws - * Whatever the current task constructor throws or the task() throws. - */ - bool try_executing_one() { return ex.try_executing_one(); } - - }; - - class generic_executor_ref - { - shared_ptr ex; - public: - /// type-erasure to store the works to do - typedef executors::work work; - - template - generic_executor_ref(Executor& ex_) - //: ex(make_shared >(ex_)) // todo check why this doesn't works with C++03 - : ex( new executor_ref(ex_) ) - { - } - - //generic_executor_ref(generic_executor_ref const& other) noexcept {} - //generic_executor_ref& operator=(generic_executor_ref const& other) noexcept {} - - - /** - * \par Effects - * Close the \c executor for submissions. - * The worker threads will work until there is no more closures to run. - */ - void close() { ex->close(); } - - /** - * \par Returns - * Whether the pool is closed for submissions. - */ - bool closed() { return ex->closed(); } - - /** - * \par Requires - * \c Closure is a model of Callable(void()) and a model of CopyConstructible/MoveConstructible. - * - * \par Effects - * The specified closure will be scheduled for execution at some point in the future. - * If invoked closure throws an exception the thread pool will call std::terminate, as is the case with threads. - * - * \par Synchronization - * Completion of closure on a particular thread happens before destruction of thread's thread local variables. - * - * \par Throws - * \c sync_queue_is_closed if the thread pool is closed. - * Whatever exception that can be throw while storing the closure. - */ - - void submit(BOOST_THREAD_RV_REF(work) closure) - { - ex->submit(boost::move(closure)); - } - -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - void submit(Closure & closure) - { - //work w ((closure)); - //submit(boost::move(w)); - submit(work(closure)); - } -#endif - void submit(void (*closure)()) - { - work w ((closure)); - submit(boost::move(w)); - //submit(work(closure)); - } - - template - void submit(BOOST_THREAD_FWD_REF(Closure) closure) - { - work w((boost::forward(closure))); - submit(boost::move(w)); - } - -// size_t num_pending_closures() const -// { -// return ex->num_pending_closures(); -// } - - /** - * \par Effects - * Try to execute one task. - * - * \par Returns - * Whether a task has been executed. - * - * \par Throws - * Whatever the current task constructor throws or the task() throws. - */ - bool try_executing_one() { return ex->try_executing_one(); } - - /** - * \par Requires - * This must be called from an scheduled task. - * - * \par Effects - * reschedule functions until pred() - */ - template - bool reschedule_until(Pred const& pred) - { - do { - //schedule_one_or_yield(); - if ( ! try_executing_one()) - { - return false; - } - } while (! pred()); - return true; - } - - }; - } - using executors::executor_ref; - using executors::generic_executor_ref; -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/executors/inline_executor.hpp b/libraries/boost/boost/thread/executors/inline_executor.hpp deleted file mode 100644 index 5dd523184..000000000 --- a/libraries/boost/boost/thread/executors/inline_executor.hpp +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (C) 2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/11 Vicente J. Botet Escriba -// first implementation of a simple serial scheduler. - -#ifndef BOOST_THREAD_INLINE_EXECUTOR_HPP -#define BOOST_THREAD_INLINE_EXECUTOR_HPP - -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace executors -{ - class inline_executor - { - public: - /// type-erasure to store the works to do - typedef executors::work work; - bool closed_; - mutable mutex mtx_; - /** - * Effects: try to execute one task. - * Returns: whether a task has been executed. - * Throws: whatever the current task constructor throws or the task() throws. - */ - bool try_executing_one() - { - return false; - } - - public: - /// inline_executor is not copyable. - BOOST_THREAD_NO_COPYABLE(inline_executor) - - /** - * \b Effects: creates a inline executor that runs closures immediately. - * - * \b Throws: Nothing. - */ - inline_executor() - : closed_(false) - { - } - /** - * \b Effects: Destroys the inline executor. - * - * \b Synchronization: The completion of all the closures happen before the completion of the \c inline_executor destructor. - */ - ~inline_executor() - { - // signal to all the worker thread that there will be no more submissions. - close(); - } - - /** - * \b Effects: close the \c inline_executor for submissions. - * The loop will work until there is no more closures to run. - */ - void close() - { - lock_guard lk(mtx_); - closed_ = true; - } - - /** - * \b Returns: whether the pool is closed for submissions. - */ - bool closed(lock_guard& ) - { - return closed_; - } - bool closed() - { - lock_guard lk(mtx_); - return closed(lk); - } - - /** - * \b Requires: \c Closure is a model of \c Callable(void()) and a model of \c CopyConstructible/MoveConstructible. - * - * \b Effects: The specified \c closure will be scheduled for execution at some point in the future. - * If invoked closure throws an exception the \c inline_executor will call \c std::terminate, as is the case with threads. - * - * \b Synchronization: completion of \c closure on a particular thread happens before destruction of thread's thread local variables. - * - * \b Throws: \c sync_queue_is_closed if the thread pool is closed. - * Whatever exception that can be throw while storing the closure. - */ - -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - void submit(Closure & closure) - { - { - lock_guard lk(mtx_); - if (closed(lk)) BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - } - try - { - closure(); - } - catch (...) - { - std::terminate(); - return; - } - } -#endif - void submit(void (*closure)()) - { - { - lock_guard lk(mtx_); - if (closed(lk)) BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - } - try - { - closure(); - } - catch (...) - { - std::terminate(); - return; - } - } - - template - void submit(BOOST_THREAD_FWD_REF(Closure) closure) - { - { - lock_guard lk(mtx_); - if (closed(lk)) BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - } - try - { - closure(); - } - catch (...) - { - std::terminate(); - return; - } - } - - /** - * \b Requires: This must be called from an scheduled task. - * - * \b Effects: reschedule functions until pred() - */ - template - bool reschedule_until(Pred const& ) - { - return false; - } - - }; -} -using executors::inline_executor; -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/executors/loop_executor.hpp b/libraries/boost/boost/thread/executors/loop_executor.hpp deleted file mode 100644 index b08ff76f5..000000000 --- a/libraries/boost/boost/thread/executors/loop_executor.hpp +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright (C) 2013,2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/11 Vicente J. Botet Escriba -// first implementation of a simple user scheduler. -// 2013/11 Vicente J. Botet Escriba -// rename loop_executor. - -#ifndef BOOST_THREAD_EXECUTORS_LOOP_EXECUTOR_HPP -#define BOOST_THREAD_EXECUTORS_LOOP_EXECUTOR_HPP - -#include -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace executors -{ - - class loop_executor - { - public: - /// type-erasure to store the works to do - typedef executors::work work; - private: - /// the thread safe work queue - concurrent::sync_queue work_queue; - - public: - /** - * Effects: try to execute one task. - * Returns: whether a task has been executed. - * Throws: whatever the current task constructor throws or the task() throws. - */ - bool try_executing_one() - { - work task; - try - { - if (work_queue.try_pull(task) == queue_op_status::success) - { - task(); - return true; - } - return false; - } - catch (...) - { - std::terminate(); - //return false; - } - } - private: - /** - * Effects: schedule one task or yields - * Throws: whatever the current task constructor throws or the task() throws. - */ - void schedule_one_or_yield() - { - if ( ! try_executing_one()) - { - this_thread::yield(); - } - } - - - - - public: - /// loop_executor is not copyable. - BOOST_THREAD_NO_COPYABLE(loop_executor) - - /** - * \b Effects: creates a thread pool that runs closures using one of its closure-executing methods. - * - * \b Throws: Whatever exception is thrown while initializing the needed resources. - */ - loop_executor() - { - } - /** - * \b Effects: Destroys the thread pool. - * - * \b Synchronization: The completion of all the closures happen before the completion of the \c loop_executor destructor. - */ - ~loop_executor() - { - // signal to all the worker thread that there will be no more submissions. - close(); - } - - /** - * The main loop of the worker thread - */ - void loop() - { - while (!closed()) - { - schedule_one_or_yield(); - } - while (try_executing_one()) - { - } - } - - /** - * \b Effects: close the \c loop_executor for submissions. - * The loop will work until there is no more closures to run. - */ - void close() - { - work_queue.close(); - } - - /** - * \b Returns: whether the pool is closed for submissions. - */ - bool closed() - { - return work_queue.closed(); - } - - /** - * \b Requires: \c Closure is a model of \c Callable(void()) and a model of \c CopyConstructible/MoveConstructible. - * - * \b Effects: The specified \c closure will be scheduled for execution at some point in the future. - * If invoked closure throws an exception the \c loop_executor will call \c std::terminate, as is the case with threads. - * - * \b Synchronization: completion of \c closure on a particular thread happens before destruction of thread's thread local variables. - * - * \b Throws: \c sync_queue_is_closed if the thread pool is closed. - * Whatever exception that can be throw while storing the closure. - */ - void submit(BOOST_THREAD_RV_REF(work) closure) { - work_queue.push(boost::move(closure)); - } - -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - void submit(Closure & closure) - { - submit(work(closure)); - } -#endif - - void submit(void (*closure)()) - { - submit(work(closure)); - } - - template - void submit(BOOST_THREAD_FWD_REF(Closure) closure) - { - //work_queue.push(work(boost::forward(closure))); - work w((boost::forward(closure))); - submit(boost::move(w)); - } - - /** - * \b Requires: This must be called from an scheduled task. - * - * \b Effects: reschedule functions until pred() - */ - template - bool reschedule_until(Pred const& pred) - { - do { - if ( ! try_executing_one()) - { - return false; - } - } while (! pred()); - return true; - } - - /** - * run queued closures - */ - void run_queued_closures() - { - sync_queue::underlying_queue_type q = work_queue.underlying_queue(); - while (! q.empty()) - { - work& task = q.front(); - task(); - q.pop_front(); - } - } - - }; -} -using executors::loop_executor; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/executors/scheduled_thread_pool.hpp b/libraries/boost/boost/thread/executors/scheduled_thread_pool.hpp deleted file mode 100644 index 408013b28..000000000 --- a/libraries/boost/boost/thread/executors/scheduled_thread_pool.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2014 Ian Forbed -// Copyright (C) 2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef BOOST_THREAD_EXECUTORS_SCHEDULED_THREAD_POOL_HPP -#define BOOST_THREAD_EXECUTORS_SCHEDULED_THREAD_POOL_HPP - -#include - -namespace boost -{ -namespace executors -{ - - class scheduled_thread_pool : public detail::scheduled_executor_base<> - { - private: - thread_group _workers; - public: - - scheduled_thread_pool(size_t num_threads) : super() - { - for(size_t i = 0; i < num_threads; i++) - { - _workers.create_thread(bind(&super::loop, this)); - } - } - - ~scheduled_thread_pool() - { - this->close(); - _workers.join_all(); - } - - private: - typedef detail::scheduled_executor_base<> super; - }; //end class - -} //end executors namespace - -using executors::scheduled_thread_pool; - -} //end boost -#endif - diff --git a/libraries/boost/boost/thread/executors/scheduler.hpp b/libraries/boost/boost/thread/executors/scheduler.hpp deleted file mode 100644 index 5796a7d39..000000000 --- a/libraries/boost/boost/thread/executors/scheduler.hpp +++ /dev/null @@ -1,271 +0,0 @@ -// Copyright (C) 2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef BOOST_THREAD_EXECUTORS_SCHEDULER_HPP -#define BOOST_THREAD_EXECUTORS_SCHEDULER_HPP - -#include -#include - -#include -#include -#include - -#include - -namespace boost -{ - namespace executors - { - /// Wraps the reference to an executor and a function to make a work that submit the function using the executor. - template - class resubmitter - { - public: - resubmitter(Executor& ex, Function funct) : - ex(ex), - funct(boost::move(funct)) - {} - - void operator()() - { - ex.submit(funct); - } - - private: - Executor& ex; - Function funct; - }; - - /// resubmitter factory - template - resubmitter::type> - resubmit(Executor& ex, BOOST_THREAD_FWD_REF(Function) funct) { - return resubmitter::type >(ex, boost::move(funct)); - } - - /// Wraps references to a @c Scheduler and an @c Executor providing an @c Executor that - /// resubmit the function using the referenced Executor at a given @c time_point known at construction. - template - class resubmit_at_executor - { - public: - typedef typename Scheduler::clock clock; - typedef typename Scheduler::work work; - - template - resubmit_at_executor(Scheduler& sch, Executor& ex, chrono::time_point const& tp) : - sch(sch), - ex(ex), - tp(tp), - is_closed(false) - { - } - - ~resubmit_at_executor() - { - close(); - } - - template - void submit(BOOST_THREAD_FWD_REF(Work) w) - { - if (closed()) - { - BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - } - sch.submit_at(resubmit(ex,boost::forward(w)), tp); - } - - Executor& underlying_executor() - { - return ex; - } - Scheduler& underlying_scheduler() - { - return sch; - } - - void close() - { - is_closed = true; - } - - bool closed() - { - return is_closed || sch.closed() || ex.closed(); - } - - private: - Scheduler& sch; - Executor& ex; - typename clock::time_point tp; - bool is_closed; - }; - - - /// Expression template helper storing a pair of references to an @c Scheduler and an @c Executor - /// It provides factory helper functions such as at/after that convert these a pair of @c Scheduler @c Executor - /// into an new @c Executor that submit the work using the referenced @c Executor at/after a specific time/duration - /// respectively, using the referenced @Scheduler. - template - class scheduler_executor_wrapper - { - public: - typedef typename Scheduler::clock clock; - typedef typename Scheduler::work work; - typedef resubmit_at_executor the_executor; - - scheduler_executor_wrapper(Scheduler& sch, Executor& ex) : - sch(sch), - ex(ex) - {} - - ~scheduler_executor_wrapper() - { - } - - Executor& underlying_executor() - { - return ex; - } - Scheduler& underlying_scheduler() - { - return sch; - } - - template - the_executor after(chrono::duration const& rel_time) - { - return at(clock::now() + rel_time ); - } - - template - the_executor at(chrono::time_point const& abs_time) - { - return the_executor(sch, ex, abs_time); - } - - private: - Scheduler& sch; - Executor& ex; - }; //end class - - /// Wraps a reference to a @c Scheduler providing an @c Executor that - /// run the function at a given @c time_point known at construction. - template - class at_executor - { - public: - typedef typename Scheduler::clock clock; - typedef typename Scheduler::work work; - typedef typename clock::time_point time_point; - - template - at_executor(Scheduler& sch, chrono::time_point const& tp) : - sch(sch), - tp(tp), - is_closed(false) - {} - - ~at_executor() - { - close(); - } - - Scheduler& underlying_scheduler() - { - return sch; - } - - void close() - { - is_closed = true; - } - - bool closed() - { - return is_closed || sch.closed(); - } - - template - void submit(BOOST_THREAD_FWD_REF(Work) w) - { - if (closed()) - { - BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - } - sch.submit_at(boost::forward(w), tp); - } - - template - resubmit_at_executor on(Executor& ex) - { - return resubmit_at_executor(sch, ex, tp); - } - - private: - Scheduler& sch; - time_point tp; - bool is_closed; - }; //end class - - /// A @c Scheduler using a specific thread. Note that a Scheduler is not an Executor. - /// It provides factory helper functions such as at/after that convert a @c Scheduler into an @c Executor - /// that submit the work at/after a specific time/duration respectively. - template - class scheduler : public detail::scheduled_executor_base - { - public: - typedef typename detail::scheduled_executor_base::work work; - - typedef Clock clock; - - scheduler() - : super(), - thr(&super::loop, this) {} - - ~scheduler() - { - this->close(); - thr.join(); - } - template - scheduler_executor_wrapper on(Ex& ex) - { - return scheduler_executor_wrapper(*this, ex); - } - - template - at_executor after(chrono::duration const& rel_time) - { - return at(rel_time + clock::now()); - } - - template - at_executor at(chrono::time_point const& tp) - { - return at_executor(*this, tp); - } - - private: - typedef detail::scheduled_executor_base super; - thread thr; - }; - - - } - using executors::resubmitter; - using executors::resubmit; - using executors::resubmit_at_executor; - using executors::scheduler_executor_wrapper; - using executors::at_executor; - using executors::scheduler; -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/executors/scheduling_adaptor.hpp b/libraries/boost/boost/thread/executors/scheduling_adaptor.hpp deleted file mode 100644 index ac0a0acbc..000000000 --- a/libraries/boost/boost/thread/executors/scheduling_adaptor.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2014 Ian Forbed -// Copyright (C) 2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef BOOST_THREAD_EXECUTORS_SCHEDULING_ADAPTOR_HPP -#define BOOST_THREAD_EXECUTORS_SCHEDULING_ADAPTOR_HPP - -#include - -namespace boost -{ -namespace executors -{ - - template - class scheduling_adpator : public detail::scheduled_executor_base<> - { - private: - Executor& _exec; - thread _scheduler; - public: - - scheduling_adpator(Executor& ex) - : super(), - _exec(ex), - _scheduler(&super::loop, this) {} - - ~scheduling_adpator() - { - this->close(); - _scheduler.join(); - } - - Executor& underlying_executor() - { - return _exec; - } - - private: - typedef detail::scheduled_executor_base<> super; - }; //end class - -} //end executors - - using executors::scheduling_adpator; - -} //end boost -#endif diff --git a/libraries/boost/boost/thread/executors/serial_executor.hpp b/libraries/boost/boost/thread/executors/serial_executor.hpp deleted file mode 100644 index 6d7ed9be9..000000000 --- a/libraries/boost/boost/thread/executors/serial_executor.hpp +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/11 Vicente J. Botet Escriba -// first implementation of a simple serial scheduler. - -#ifndef BOOST_THREAD_SERIAL_EXECUTOR_HPP -#define BOOST_THREAD_SERIAL_EXECUTOR_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace executors -{ - class serial_executor - { - public: - /// type-erasure to store the works to do - typedef executors::work work; - private: - typedef scoped_thread<> thread_t; - - /// the thread safe work queue - concurrent::sync_queue work_queue; - generic_executor_ref ex; - thread_t thr; - - struct try_executing_one_task { - work& task; - boost::promise &p; - try_executing_one_task(work& task, boost::promise &p) - : task(task), p(p) {} - void operator()() { - try { - task(); - p.set_value(); - } catch (...) - { - p.set_exception(current_exception()); - } - } - }; - public: - /** - * \par Returns - * The underlying executor wrapped on a generic executor reference. - */ - generic_executor_ref& underlying_executor() BOOST_NOEXCEPT { return ex; } - - /** - * Effects: try to execute one task. - * Returns: whether a task has been executed. - * Throws: whatever the current task constructor throws or the task() throws. - */ - bool try_executing_one() - { - work task; - try - { - if (work_queue.try_pull(task) == queue_op_status::success) - { - boost::promise p; - try_executing_one_task tmp(task,p); - ex.submit(tmp); - p.get_future().wait(); - return true; - } - return false; - } - catch (...) - { - std::terminate(); - //return false; - } - } - private: - /** - * Effects: schedule one task or yields - * Throws: whatever the current task constructor throws or the task() throws. - */ - void schedule_one_or_yield() - { - if ( ! try_executing_one()) - { - this_thread::yield(); - } - } - - /** - * The main loop of the worker thread - */ - void worker_thread() - { - while (!closed()) - { - schedule_one_or_yield(); - } - while (try_executing_one()) - { - } - } - - public: - /// serial_executor is not copyable. - BOOST_THREAD_NO_COPYABLE(serial_executor) - - /** - * \b Effects: creates a thread pool that runs closures using one of its closure-executing methods. - * - * \b Throws: Whatever exception is thrown while initializing the needed resources. - */ - template - serial_executor(Executor& ex) - : ex(ex), thr(&serial_executor::worker_thread, this) - { - } - /** - * \b Effects: Destroys the thread pool. - * - * \b Synchronization: The completion of all the closures happen before the completion of the \c serial_executor destructor. - */ - ~serial_executor() - { - // signal to the worker thread that there will be no more submissions. - close(); - } - - /** - * \b Effects: close the \c serial_executor for submissions. - * The loop will work until there is no more closures to run. - */ - void close() - { - work_queue.close(); - } - - /** - * \b Returns: whether the pool is closed for submissions. - */ - bool closed() - { - return work_queue.closed(); - } - - /** - * \b Requires: \c Closure is a model of \c Callable(void()) and a model of \c CopyConstructible/MoveConstructible. - * - * \b Effects: The specified \c closure will be scheduled for execution at some point in the future. - * If invoked closure throws an exception the \c serial_executor will call \c std::terminate, as is the case with threads. - * - * \b Synchronization: completion of \c closure on a particular thread happens before destruction of thread's thread local variables. - * - * \b Throws: \c sync_queue_is_closed if the thread pool is closed. - * Whatever exception that can be throw while storing the closure. - */ - void submit(BOOST_THREAD_RV_REF(work) closure) - { - work_queue.push(boost::move(closure)); - } - -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - void submit(Closure & closure) - { - submit(work(closure)); - } -#endif - void submit(void (*closure)()) - { - submit(work(closure)); - } - - template - void submit(BOOST_THREAD_FWD_REF(Closure) closure) - { - work w((boost::forward(closure))); - submit(boost::move(w)); - } - - /** - * \b Requires: This must be called from an scheduled task. - * - * \b Effects: reschedule functions until pred() - */ - template - bool reschedule_until(Pred const& pred) - { - do { - if ( ! try_executing_one()) - { - return false; - } - } while (! pred()); - return true; - } - - }; -} -using executors::serial_executor; -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/executors/serial_executor_cont.hpp b/libraries/boost/boost/thread/executors/serial_executor_cont.hpp deleted file mode 100644 index 91087890b..000000000 --- a/libraries/boost/boost/thread/executors/serial_executor_cont.hpp +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (C) 2015 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/11 Vicente J. Botet Escriba -// first implementation of a simple serial scheduler. - -#ifndef BOOST_THREAD_SERIAL_EXECUTOR_CONT_HPP -#define BOOST_THREAD_SERIAL_EXECUTOR_CONT_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace executors -{ - class serial_executor_cont - { - public: - /// type-erasure to store the works to do - typedef executors::work work; - private: - - generic_executor_ref ex_; - future fut_; // protected by mtx_ - bool closed_; // protected by mtx_ - mutex mtx_; - - struct continuation { - work task; - template - struct result { - typedef void type; - }; - continuation(BOOST_THREAD_RV_REF(work) tsk) - : task(boost::move(tsk)) {} - void operator()(future f) - { - try { - task(); - } catch (...) { - std::terminate(); - } - } - }; - - bool closed(lock_guard&) const - { - return closed_; - } - public: - /** - * \par Returns - * The underlying executor wrapped on a generic executor reference. - */ - generic_executor_ref& underlying_executor() BOOST_NOEXCEPT { return ex_; } - - /// serial_executor_cont is not copyable. - BOOST_THREAD_NO_COPYABLE(serial_executor_cont) - - /** - * \b Effects: creates a serial executor that runs closures in fifo order using one the associated executor. - * - * \b Throws: Whatever exception is thrown while initializing the needed resources. - * - * \b Notes: - * * The lifetime of the associated executor must outlive the serial executor. - * * The current implementation doesn't support submission from synchronous continuation, that is, - * - the executor must execute the continuation asynchronously or - * - the continuation can not submit to this serial executor. - */ - template - serial_executor_cont(Executor& ex) - : ex_(ex), fut_(make_ready_future()), closed_(false) - { - } - /** - * \b Effects: Destroys the thread pool. - * - * \b Synchronization: The completion of all the closures happen before the completion of the \c serial_executor_cont destructor. - */ - ~serial_executor_cont() - { - // signal to the worker thread that there will be no more submissions. - close(); - } - - /** - * \b Effects: close the \c serial_executor_cont for submissions. - * The loop will work until there is no more closures to run. - */ - void close() - { - lock_guard lk(mtx_); - closed_ = true;; - } - - /** - * \b Returns: whether the pool is closed for submissions. - */ - bool closed() - { - lock_guard lk(mtx_); - return closed(lk); - } - - /** - * Effects: none. - * Returns: always false. - * Throws: No. - * Remark: A serial executor can not execute one of its pending tasks as the tasks depends on the other tasks. - */ - bool try_executing_one() - { - return false; - } - - /** - * \b Requires: \c Closure is a model of \c Callable(void()) and a model of \c CopyConstructible/MoveConstructible. - * - * \b Effects: The specified \c closure will be scheduled for execution after the last submitted closure finish. - * If the invoked closure throws an exception the \c serial_executor_cont will call \c std::terminate, as is the case with threads. - * - * \b Throws: \c sync_queue_is_closed if the executor is closed. - * Whatever exception that can be throw while storing the closure. - * - */ - -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - void submit(Closure & closure) - { - lock_guard lk(mtx_); - if (closed(lk)) BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - fut_ = fut_.then(ex_, continuation(work(closure))); - } -#endif - void submit(void (*closure)()) - { - lock_guard lk(mtx_); - if (closed(lk)) BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - fut_ = fut_.then(ex_, continuation(work(closure))); - } - - template - void submit(BOOST_THREAD_FWD_REF(Closure) closure) - { - lock_guard lk(mtx_); - if (closed(lk)) BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - fut_ = fut_.then(ex_, continuation(work(boost::forward(closure)))); - } - - }; -} -using executors::serial_executor_cont; -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/executors/thread_executor.hpp b/libraries/boost/boost/thread/executors/thread_executor.hpp deleted file mode 100644 index c9f49a7b6..000000000 --- a/libraries/boost/boost/thread/executors/thread_executor.hpp +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (C) 2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2014/01 Vicente J. Botet Escriba -// first implementation of a thread_executor. - -#ifndef BOOST_THREAD_THREAD_EXECUTOR_HPP -#define BOOST_THREAD_THREAD_EXECUTOR_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace boost -{ -namespace executors -{ - class thread_executor - { - public: - /// type-erasure to store the works to do - typedef executors::work work; - bool closed_; - typedef scoped_thread<> thread_t; - typedef csbl::vector threads_type; - threads_type threads_; - mutable mutex mtx_; - - /** - * Effects: try to execute one task. - * Returns: whether a task has been executed. - * Throws: whatever the current task constructor throws or the task() throws. - */ - bool try_executing_one() - { - return false; - } - - public: - /// thread_executor is not copyable. - BOOST_THREAD_NO_COPYABLE(thread_executor) - - /** - * \b Effects: creates a inline executor that runs closures immediately. - * - * \b Throws: Nothing. - */ - thread_executor() - : closed_(false) - { - } - /** - * \b Effects: Waits for closures (if any) to complete, then joins and destroys the threads. - * - * \b Synchronization: The completion of all the closures happen before the completion of the \c thread_executor destructor. - */ - ~thread_executor() - { - // signal to all the worker thread that there will be no more submissions. - close(); - // all the scoped threads will join before destroying - } - - /** - * \b Effects: close the \c thread_executor for submissions. - * The loop will work until there is no more closures to run. - */ - void close() - { - lock_guard lk(mtx_); - closed_ = true; - } - - /** - * \b Returns: whether the pool is closed for submissions. - */ - bool closed(lock_guard& ) - { - return closed_; - } - bool closed() - { - lock_guard lk(mtx_); - return closed(lk); - } - - /** - * \b Requires: \c Closure is a model of \c Callable(void()) and a model of \c CopyConstructible/MoveConstructible. - * - * \b Effects: The specified \c closure will be scheduled for execution at some point in the future. - * If invoked closure throws an exception the \c thread_executor will call \c std::terminate, as is the case with threads. - * - * \b Synchronization: completion of \c closure on a particular thread happens before destruction of thread's thread local variables. - * - * \b Throws: \c sync_queue_is_closed if the thread pool is closed. - * Whatever exception that can be throw while storing the closure. - */ - -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - void submit(Closure & closure) - { - lock_guard lk(mtx_); - if (closed(lk)) BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - threads_.reserve(threads_.size() + 1); - thread th(closure); - threads_.push_back(thread_t(boost::move(th))); - } -#endif - void submit(void (*closure)()) - { - lock_guard lk(mtx_); - if (closed(lk)) BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - threads_.reserve(threads_.size() + 1); - thread th(closure); - threads_.push_back(thread_t(boost::move(th))); - } - - template - void submit(BOOST_THREAD_FWD_REF(Closure) closure) - { - lock_guard lk(mtx_); - if (closed(lk)) BOOST_THROW_EXCEPTION( sync_queue_is_closed() ); - threads_.reserve(threads_.size() + 1); - thread th(boost::forward(closure)); - threads_.push_back(thread_t(boost::move(th))); - } - - /** - * \b Requires: This must be called from an scheduled task. - * - * \b Effects: reschedule functions until pred() - */ - template - bool reschedule_until(Pred const&) - { - return false; - } - - }; -} -using executors::thread_executor; -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/executors/work.hpp b/libraries/boost/boost/thread/executors/work.hpp deleted file mode 100644 index bdaf7651b..000000000 --- a/libraries/boost/boost/thread/executors/work.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// (C) Copyright 2013,2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_EXECUTORS_WORK_HPP -#define BOOST_THREAD_EXECUTORS_WORK_HPP - -#include -#include -#include - -namespace boost -{ - namespace executors - { - typedef detail::nullary_function work; - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - typedef detail::nullary_function work_pq; - //typedef csbl::function work_pq; -#else - typedef csbl::function work_pq; -#endif - } -} // namespace boost - - -#endif // BOOST_THREAD_EXECUTORS_WORK_HPP diff --git a/libraries/boost/boost/thread/experimental/config/inline_namespace.hpp b/libraries/boost/boost/thread/experimental/config/inline_namespace.hpp deleted file mode 100644 index 9c3b081fb..000000000 --- a/libraries/boost/boost/thread/experimental/config/inline_namespace.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef BOOST_THREAD_EXPERIMENTAL_CONFIG_INLINE_NAMESPACE_HPP -#define BOOST_THREAD_EXPERIMENTAL_CONFIG_INLINE_NAMESPACE_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include - -#if !defined(BOOST_NO_CXX11_INLINE_NAMESPACES) -# define BOOST_THREAD_INLINE_NAMESPACE(name) inline namespace name -#else -# define BOOST_THREAD_INLINE_NAMESPACE(name) namespace name -#endif - - -#endif diff --git a/libraries/boost/boost/thread/experimental/exception_list.hpp b/libraries/boost/boost/thread/experimental/exception_list.hpp deleted file mode 100644 index 748bfa85e..000000000 --- a/libraries/boost/boost/thread/experimental/exception_list.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef BOOST_THREAD_EXPERIMENTAL_EXCEPTION_LIST_HPP -#define BOOST_THREAD_EXPERIMENTAL_EXCEPTION_LIST_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include - -#endif diff --git a/libraries/boost/boost/thread/experimental/parallel/v1/exception_list.hpp b/libraries/boost/boost/thread/experimental/parallel/v1/exception_list.hpp deleted file mode 100644 index e4d3354f1..000000000 --- a/libraries/boost/boost/thread/experimental/parallel/v1/exception_list.hpp +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef BOOST_THREAD_EXPERIMENTAL_PARALLEL_V1_EXCEPTION_LIST_HPP -#define BOOST_THREAD_EXPERIMENTAL_PARALLEL_V1_EXCEPTION_LIST_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include -#include - -#include -#include -#include - -#include - -namespace boost -{ -namespace experimental -{ -namespace parallel -{ -BOOST_THREAD_INLINE_NAMESPACE(v1) -{ - - class BOOST_SYMBOL_VISIBLE exception_list: public std::exception - { - typedef std::list exception_ptr_list; - exception_ptr_list list_; - public: - typedef exception_ptr_list::const_iterator const_iterator; - - ~exception_list() BOOST_NOEXCEPT_OR_NOTHROW {} - - void add(exception_ptr const& e) - { - list_.push_back(e); - } - size_t size() const BOOST_NOEXCEPT - { - return list_.size(); - } - const_iterator begin() const BOOST_NOEXCEPT - { - return list_.begin(); - } - const_iterator end() const BOOST_NOEXCEPT - { - return list_.end(); - } - const char* what() const BOOST_NOEXCEPT_OR_NOTHROW - { - return "exception_list"; - } - - }; -} - -} // parallel -} // experimental -} // boost -#include - -#endif diff --git a/libraries/boost/boost/thread/experimental/parallel/v1/inline_namespace.hpp b/libraries/boost/boost/thread/experimental/parallel/v1/inline_namespace.hpp deleted file mode 100644 index a607e53c4..000000000 --- a/libraries/boost/boost/thread/experimental/parallel/v1/inline_namespace.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef BOOST_THREAD_EXPERIMENTAL_PARALLEL_V1_INLINE_NAMESPACE_HPP -#define BOOST_THREAD_EXPERIMENTAL_PARALLEL_V1_INLINE_NAMESPACE_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include -namespace boost { -namespace experimental { -namespace parallel { - - BOOST_THREAD_INLINE_NAMESPACE(v1) {} - -#if defined(BOOST_NO_CXX11_INLINE_NAMESPACES) - using namespace v1; -#endif - -} -} -} -#endif diff --git a/libraries/boost/boost/thread/experimental/parallel/v2/inline_namespace.hpp b/libraries/boost/boost/thread/experimental/parallel/v2/inline_namespace.hpp deleted file mode 100644 index 52d8e2904..000000000 --- a/libraries/boost/boost/thread/experimental/parallel/v2/inline_namespace.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef BOOST_THREAD_EXPERIMENTAL_PARALLEL_V2_INLINE_NAMESPACE_HPP -#define BOOST_THREAD_EXPERIMENTAL_PARALLEL_V2_INLINE_NAMESPACE_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include - -namespace boost { -namespace experimental { -namespace parallel { - - BOOST_THREAD_INLINE_NAMESPACE(v2) {} - -#if defined(BOOST_NO_CXX11_INLINE_NAMESPACES) - using namespace v2; -#endif - -} -} -} -#endif diff --git a/libraries/boost/boost/thread/experimental/parallel/v2/task_region.hpp b/libraries/boost/boost/thread/experimental/parallel/v2/task_region.hpp deleted file mode 100644 index e4a583311..000000000 --- a/libraries/boost/boost/thread/experimental/parallel/v2/task_region.hpp +++ /dev/null @@ -1,316 +0,0 @@ -#ifndef BOOST_THREAD_EXPERIMENTAL_PARALLEL_V2_TASK_REGION_HPP -#define BOOST_THREAD_EXPERIMENTAL_PARALLEL_V2_TASK_REGION_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014-2015. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// -#include - -#include -#if defined BOOST_THREAD_PROVIDES_EXECUTORS -#include -#endif -#include -#include -#include - -#include - -#define BOOST_THREAD_TASK_REGION_HAS_SHARED_CANCELED - -namespace boost -{ -namespace experimental -{ -namespace parallel -{ -BOOST_THREAD_INLINE_NAMESPACE(v2) -{ - class BOOST_SYMBOL_VISIBLE task_canceled_exception: public std::exception - { - public: - //task_canceled_exception() BOOST_NOEXCEPT {} - //task_canceled_exception(const task_canceled_exception&) BOOST_NOEXCEPT {} - //task_canceled_exception& operator=(const task_canceled_exception&) BOOST_NOEXCEPT {} - virtual const char* what() const BOOST_NOEXCEPT_OR_NOTHROW - { return "task_canceled_exception";} - }; - - template - class task_region_handle_gen; - - namespace detail - { - void handle_task_region_exceptions(exception_list& errors) - { - try { - throw; - } -#if defined BOOST_THREAD_TASK_REGION_HAS_SHARED_CANCELED - catch (task_canceled_exception&) - { - } -#endif - catch (exception_list const& el) - { - for (exception_list::const_iterator it = el.begin(); it != el.end(); ++it) - { - boost::exception_ptr const& e = *it; - try { - rethrow_exception(e); - } - catch (...) - { - handle_task_region_exceptions(errors); - } - } - } - catch (...) - { - errors.add(boost::current_exception()); - } - } - -#if defined BOOST_THREAD_TASK_REGION_HAS_SHARED_CANCELED - template - struct wrapped - { - TRH& tr; - F f; - wrapped(TRH& tr, BOOST_THREAD_RV_REF(F) f) : tr(tr), f(move(f)) - {} - void operator()() - { - try - { - f(); - } - catch (...) - { - lock_guard lk(tr.mtx); - tr.canceled = true; - throw; - } - } - }; -#endif - } - - template - class task_region_handle_gen - { - private: - // Private members and friends -#if defined BOOST_THREAD_TASK_REGION_HAS_SHARED_CANCELED - template - friend struct detail::wrapped; -#endif - template - friend void task_region(BOOST_THREAD_FWD_REF(F) f); - template - friend void task_region_final(BOOST_THREAD_FWD_REF(F) f); - template - friend void task_region(Ex&, BOOST_THREAD_FWD_REF(F) f); - template - friend void task_region_final(Ex&, BOOST_THREAD_FWD_REF(F) f); - - void wait_all() - { - wait_for_all(group.begin(), group.end()); - - for (group_type::iterator it = group.begin(); it != group.end(); ++it) - { - future& f = *it; - if (f.has_exception()) - { - try - { - boost::rethrow_exception(f.get_exception_ptr()); - } - catch (...) - { - detail::handle_task_region_exceptions(exs); - } - } - } - if (exs.size() != 0) - { - boost::throw_exception(exs); - } - } -protected: -#if ! defined BOOST_THREAD_TASK_REGION_HAS_SHARED_CANCELED && ! defined BOOST_THREAD_PROVIDES_EXECUTORS - task_region_handle_gen() - {} -#endif - -#if defined BOOST_THREAD_TASK_REGION_HAS_SHARED_CANCELED && defined BOOST_THREAD_PROVIDES_EXECUTORS - task_region_handle_gen() - : canceled(false) - , ex(0) - {} - task_region_handle_gen(Executor& ex) - : canceled(false) - , ex(&ex) - {} - -#endif - -#if ! defined BOOST_THREAD_TASK_REGION_HAS_SHARED_CANCELED && defined BOOST_THREAD_PROVIDES_EXECUTORS - task_region_handle_gen() - : ex(0) - {} - task_region_handle_gen(Executor& ex) - : ex(&ex) - {} -#endif - -#if defined BOOST_THREAD_TASK_REGION_HAS_SHARED_CANCELED && ! defined BOOST_THREAD_PROVIDES_EXECUTORS - task_region_handle_gen() - : canceled(false) - { - } -#endif - - ~task_region_handle_gen() - { - //wait_all(); - } - -#if defined BOOST_THREAD_TASK_REGION_HAS_SHARED_CANCELED - mutable mutex mtx; - bool canceled; -#endif -#if defined BOOST_THREAD_PROVIDES_EXECUTORS - Executor* ex; -#endif - exception_list exs; - typedef csbl::vector > group_type; - group_type group; - - public: - BOOST_DELETED_FUNCTION(task_region_handle_gen(const task_region_handle_gen&)) - BOOST_DELETED_FUNCTION(task_region_handle_gen& operator=(const task_region_handle_gen&)) - BOOST_DELETED_FUNCTION(task_region_handle_gen* operator&() const) - - public: - template - void run(BOOST_THREAD_FWD_REF(F) f) - { -#if defined BOOST_THREAD_TASK_REGION_HAS_SHARED_CANCELED - { - lock_guard lk(mtx); - if (canceled) { - boost::throw_exception(task_canceled_exception()); - } - } -#if defined BOOST_THREAD_PROVIDES_EXECUTORS - group.push_back(async(*ex, detail::wrapped, F>(*this, forward(f)))); -#else - group.push_back(async(detail::wrapped, F>(*this, forward(f)))); -#endif -#else -#if defined BOOST_THREAD_PROVIDES_EXECUTORS - group.push_back(async(*ex, forward(f))); -#else - group.push_back(async(forward(f))); -#endif -#endif - } - - void wait() - { -#if defined BOOST_THREAD_TASK_REGION_HAS_SHARED_CANCELED - { - lock_guard lk(mtx); - if (canceled) { - boost::throw_exception(task_canceled_exception()); - } - } -#endif - wait_all(); - } - }; -#if defined BOOST_THREAD_PROVIDES_EXECUTORS - typedef basic_thread_pool default_executor; -#else - typedef int default_executor; -#endif - class task_region_handle : - public task_region_handle_gen - { - default_executor tp; - template - friend void task_region(BOOST_THREAD_FWD_REF(F) f); - template - friend void task_region_final(BOOST_THREAD_FWD_REF(F) f); - - protected: - task_region_handle() : task_region_handle_gen() - { -#if defined BOOST_THREAD_PROVIDES_EXECUTORS - ex = &tp; -#endif - } - BOOST_DELETED_FUNCTION(task_region_handle(const task_region_handle&)) - BOOST_DELETED_FUNCTION(task_region_handle& operator=(const task_region_handle&)) - BOOST_DELETED_FUNCTION(task_region_handle* operator&() const) - - }; - - template - void task_region_final(Executor& ex, BOOST_THREAD_FWD_REF(F) f) - { - task_region_handle_gen tr(ex); - try - { - f(tr); - } - catch (...) - { - detail::handle_task_region_exceptions(tr.exs); - } - tr.wait_all(); - } - - template - void task_region(Executor& ex, BOOST_THREAD_FWD_REF(F) f) - { - task_region_final(ex, forward(f)); - } - - template - void task_region_final(BOOST_THREAD_FWD_REF(F) f) - { - task_region_handle tr; - try - { - f(tr); - } - catch (...) - { - detail::handle_task_region_exceptions(tr.exs); - } - tr.wait_all(); - } - - template - void task_region(BOOST_THREAD_FWD_REF(F) f) - { - task_region_final(forward(f)); - } - -} // v2 -} // parallel -} // experimental -} // boost - -#include - -#endif // header diff --git a/libraries/boost/boost/thread/experimental/task_region.hpp b/libraries/boost/boost/thread/experimental/task_region.hpp deleted file mode 100644 index 9b60d8b19..000000000 --- a/libraries/boost/boost/thread/experimental/task_region.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef BOOST_THREAD_EXPERIMENTAL_TASK_REGION_HPP -#define BOOST_THREAD_EXPERIMENTAL_TASK_REGION_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include - -#endif diff --git a/libraries/boost/boost/thread/externally_locked.hpp b/libraries/boost/boost/thread/externally_locked.hpp deleted file mode 100644 index 0d4baaa51..000000000 --- a/libraries/boost/boost/thread/externally_locked.hpp +++ /dev/null @@ -1,351 +0,0 @@ -// (C) Copyright 2012 Vicente J. Botet Escriba -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -#ifndef BOOST_THREAD_EXTERNALLY_LOCKED_HPP -#define BOOST_THREAD_EXTERNALLY_LOCKED_HPP - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace boost -{ - - /** - * externally_locked cloaks an object of type T, and actually provides full - * access to that object through the get and set member functions, provided you - * pass a reference to a strict lock object - */ - - //[externally_locked - template - class externally_locked; - template - class externally_locked - { - //BOOST_CONCEPT_ASSERT(( CopyConstructible )); - BOOST_CONCEPT_ASSERT(( BasicLockable )); - - public: - typedef MutexType mutex_type; - - BOOST_THREAD_COPYABLE_AND_MOVABLE( externally_locked ) - /** - * Requires: T is a model of CopyConstructible. - * Effects: Constructs an externally locked object copying the cloaked type. - */ - externally_locked(mutex_type& mtx, const T& obj) : - obj_(obj), mtx_(&mtx) - { - } - - /** - * Requires: T is a model of Movable. - * Effects: Constructs an externally locked object by moving the cloaked type. - */ - externally_locked(mutex_type& mtx, BOOST_THREAD_RV_REF(T) obj) : - obj_(move(obj)), mtx_(&mtx) - { - } - - /** - * Requires: T is a model of DefaultConstructible. - * Effects: Constructs an externally locked object initializing the cloaked type with the default constructor. - */ - externally_locked(mutex_type& mtx) // BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(T())) - : obj_(), mtx_(&mtx) - { - } - - /** - * Copy constructor - */ - externally_locked(externally_locked const& rhs) //BOOST_NOEXCEPT - : obj_(rhs.obj_), mtx_(rhs.mtx_) - { - } - /** - * Move constructor - */ - externally_locked(BOOST_THREAD_RV_REF(externally_locked) rhs) //BOOST_NOEXCEPT - : obj_(move(rhs.obj_)), mtx_(rhs.mtx_) - { - } - - /// assignment - externally_locked& operator=(externally_locked const& rhs) //BOOST_NOEXCEPT - { - obj_=rhs.obj_; - mtx_=rhs.mtx_; - return *this; - } - - /// move assignment - externally_locked& operator=(BOOST_THREAD_RV_REF(externally_locked) rhs) // BOOST_NOEXCEPT - { - obj_=move(BOOST_THREAD_RV(rhs).obj_); - mtx_=rhs.mtx_; - return *this; - } - - void swap(externally_locked& rhs) //BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR) - { - swap(obj_, rhs.obj_); - swap(mtx_, rhs.mtx_); - } - - /** - * Requires: The lk parameter must be locking the associated mtx. - * - * Returns: The address of the cloaked object.. - * - * Throws: lock_error if BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED is not defined and the lk parameter doesn't satisfy the preconditions - */ - T& get(strict_lock& lk) - { - BOOST_THREAD_ASSERT_PRECONDITION( lk.owns_lock(mtx_), lock_error() ); /*< run time check throw if not locks the same >*/ - return obj_; - } - - const T& get(strict_lock& lk) const - { - BOOST_THREAD_ASSERT_PRECONDITION( lk.owns_lock(mtx_), lock_error() ); /*< run time check throw if not locks the same >*/ - return obj_; - } - - template - T& get(nested_strict_lock& lk) - { - BOOST_STATIC_ASSERT( (is_same::value)); /*< that locks the same type >*/ - BOOST_THREAD_ASSERT_PRECONDITION( lk.owns_lock(mtx_), lock_error() ); /*< run time check throw if not locks the same >*/ - return obj_; - } - - template - const T& get(nested_strict_lock& lk) const - { - BOOST_STATIC_ASSERT( (is_same::value)); /*< that locks the same type >*/ - BOOST_THREAD_ASSERT_PRECONDITION( lk.owns_lock(mtx_), lock_error() ); /*< run time check throw if not locks the same >*/ - return obj_; - } - - /** - * Requires: The lk parameter must be locking the associated mtx. - * Returns: The address of the cloaked object.. - * - * Throws: lock_error if BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED is not defined and the lk parameter doesn't satisfy the preconditions - */ - template - T& get(Lock& lk) - { - BOOST_CONCEPT_ASSERT(( StrictLock )); - BOOST_STATIC_ASSERT( (is_strict_lock::value)); /*< lk is a strict lock "sur parolle" >*/ - BOOST_STATIC_ASSERT( (is_same::value)); /*< that locks the same type >*/ - - BOOST_THREAD_ASSERT_PRECONDITION( lk.owns_lock(mtx_), lock_error() ); /*< run time check throw if not locks the same >*/ - - return obj_; - } - - mutex_type* mutex() const BOOST_NOEXCEPT - { - return mtx_; - } - - // modifiers - - void lock() - { - mtx_->lock(); - } - void unlock() - { - mtx_->unlock(); - } - bool try_lock() - { - return mtx_->try_lock(); - } - // todo add time related functions - - private: - T obj_; - mutex_type* mtx_; - }; - //] - - /** - * externally_locked specialization for T& that cloaks an reference to an object of type T, and actually - * provides full access to that object through the get and set member functions, provided you - * pass a reference to a strict lock object. - */ - - //[externally_locked_ref - template - class externally_locked - { - //BOOST_CONCEPT_ASSERT(( CopyConstructible )); - BOOST_CONCEPT_ASSERT(( BasicLockable )); - - public: - typedef MutexType mutex_type; - - BOOST_THREAD_COPYABLE_AND_MOVABLE( externally_locked ) - - /** - * Effects: Constructs an externally locked object storing the cloaked reference object. - */ - externally_locked(T& obj, mutex_type& mtx) BOOST_NOEXCEPT : - obj_(&obj), mtx_(&mtx) - { - } - - /// copy constructor - externally_locked(externally_locked const& rhs) BOOST_NOEXCEPT : - obj_(rhs.obj_), mtx_(rhs.mtx_) - { - } - - /// move constructor - externally_locked(BOOST_THREAD_RV_REF(externally_locked) rhs) BOOST_NOEXCEPT : - obj_(rhs.obj_), mtx_(rhs.mtx_) - { - } - - /// assignment - externally_locked& operator=(externally_locked const& rhs) BOOST_NOEXCEPT - { - obj_=rhs.obj_; - mtx_=rhs.mtx_; - return *this; - } - - /// move assignment - externally_locked& operator=(BOOST_THREAD_RV_REF(externally_locked) rhs) BOOST_NOEXCEPT - { - obj_=rhs.obj_; - mtx_=rhs.mtx_; - return *this; - } - - void swap(externally_locked& rhs) BOOST_NOEXCEPT - { - swap(obj_, rhs.obj_); - swap(mtx_, rhs.mtx_); - } - /** - * Requires: The lk parameter must be locking the associated mtx. - * - * Returns: The address of the cloaked object.. - * - * Throws: lock_error if BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED is not defined and the lk parameter doesn't satisfy the preconditions - */ - T& get(strict_lock const& lk) - { - BOOST_THREAD_ASSERT_PRECONDITION( lk.owns_lock(mtx_), lock_error() ); /*< run time check throw if not locks the same >*/ - return *obj_; - } - - const T& get(strict_lock const& lk) const - { - BOOST_THREAD_ASSERT_PRECONDITION( lk.owns_lock(mtx_), lock_error() ); /*< run time check throw if not locks the same >*/ - return *obj_; - } - - template - T& get(nested_strict_lock const& lk) - { - BOOST_STATIC_ASSERT( (is_same::value)); /*< that locks the same type >*/ - BOOST_THREAD_ASSERT_PRECONDITION( lk.owns_lock(mtx_), lock_error() ); /*< run time check throw if not locks the same >*/ - return *obj_; - } - - template - const T& get(nested_strict_lock const& lk) const - { - BOOST_STATIC_ASSERT( (is_same::value)); /*< that locks the same type >*/ - BOOST_THREAD_ASSERT_PRECONDITION( lk.owns_lock(mtx_), lock_error() ); /*< run time check throw if not locks the same >*/ - return *obj_; - } - - /** - * Requires: The lk parameter must be locking the associated mtx. - * Returns: The address of the cloaked object.. - * - * Throws: lock_error if BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED is not defined and the lk parameter doesn't satisfy the preconditions - */ - template - T& get(Lock const& lk) - { - BOOST_CONCEPT_ASSERT(( StrictLock )); - BOOST_STATIC_ASSERT( (is_strict_lock::value)); /*< lk is a strict lock "sur parolle" >*/ - BOOST_STATIC_ASSERT( (is_same::value)); /*< that locks the same type >*/ - BOOST_THREAD_ASSERT_PRECONDITION( lk.owns_lock(mtx_), lock_error() ); /*< run time check throw if not locks the same >*/ - return *obj_; - } - - /** - * Requires: The lk parameter must be locking the associated mtx. - * Returns: The address of the cloaked object.. - * - * Throws: lock_error if BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED is not defined and the lk parameter doesn't satisfy the preconditions - */ - template - T const& get(Lock const& lk) const - { - BOOST_CONCEPT_ASSERT(( StrictLock )); - BOOST_STATIC_ASSERT( (is_strict_lock::value)); /*< lk is a strict lock "sur parolle" >*/ - BOOST_STATIC_ASSERT( (is_same::value)); /*< that locks the same type >*/ - BOOST_THREAD_ASSERT_PRECONDITION( lk.owns_lock(mtx_), lock_error() ); /*< run time check throw if not locks the same >*/ - return *obj_; - } - mutex_type* mutex() const BOOST_NOEXCEPT - { - return mtx_; - } - - void lock() - { - mtx_->lock(); - } - void unlock() - { - mtx_->unlock(); - } - bool try_lock() - { - return mtx_->try_lock(); - } - // todo add time related functions - - protected: - T* obj_; - mutex_type* mtx_; - }; - //] - - template - void swap(externally_locked & lhs, externally_locked & rhs) // BOOST_NOEXCEPT - { - lhs.swap(rhs); - } - -} - -#include - -#endif // header diff --git a/libraries/boost/boost/thread/externally_locked_stream.hpp b/libraries/boost/boost/thread/externally_locked_stream.hpp deleted file mode 100644 index aa9aeff79..000000000 --- a/libraries/boost/boost/thread/externally_locked_stream.hpp +++ /dev/null @@ -1,170 +0,0 @@ -// (C) Copyright 2012 Vicente J. Botet Escriba -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -#ifndef BOOST_THREAD_EXTERNALLY_LOCKED_STREAM_HPP -#define BOOST_THREAD_EXTERNALLY_LOCKED_STREAM_HPP - -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace boost -{ - - template - class externally_locked_stream; - - template - class stream_guard - { - - friend class externally_locked_stream ; - public: - typedef typename externally_locked_stream::mutex_type mutex_type; - - BOOST_THREAD_MOVABLE_ONLY( stream_guard) - - stream_guard(externally_locked_stream& mtx) : - mtx_(&mtx) - { - mtx.lock(); - } - - stream_guard(externally_locked_stream& mtx, adopt_lock_t) : - mtx_(&mtx) - { - } - - stream_guard(BOOST_THREAD_RV_REF(stream_guard) rhs) BOOST_NOEXCEPT - : mtx_(rhs.mtx_) - { - rhs.mtx_= 0; - } - - ~stream_guard() - { - if (mtx_ != 0) mtx_->unlock(); - } - - bool owns_lock(const mutex_type * l) const BOOST_NOEXCEPT - { - return l == mtx_->mutex(); - } - - /** - * @Requires mtx_ - */ - Stream& get() const - { - BOOST_THREAD_ASSERT_PRECONDITION( mtx_, lock_error() ); - return mtx_->get(*this); - } - Stream& bypass() const - { - return get(); - } - - - private: - externally_locked_stream* mtx_; - }; - - template - struct is_strict_lock_sur_parole > : true_type - { - }; - - /** - * externally_locked_stream cloaks a reference to an stream of type Stream, and actually - * provides full access to that object through the get and set member functions, provided you - * pass a reference to a strict lock object. - */ - - //[externally_locked_stream - template - class externally_locked_stream: public externally_locked - { - typedef externally_locked base_type; - public: - BOOST_THREAD_NO_COPYABLE( externally_locked_stream) - - /** - * Effects: Constructs an externally locked object storing the cloaked reference object. - */ - externally_locked_stream(Stream& stream, RecursiveMutex& mtx) BOOST_NOEXCEPT : - base_type(stream, mtx) - { - } - - stream_guard hold() BOOST_NOEXCEPT - { - return stream_guard (*this); - } - Stream& bypass() const - { - stream_guard lk(*this); - return get(lk); - } - }; - //] - - template - inline const stream_guard& operator<<(const stream_guard& lck, T arg) - { - lck.get() << arg; - return lck; - } - - template - inline const stream_guard& operator<<(const stream_guard& lck, Stream& (*arg)(Stream&)) - { - lck.get() << arg; - return lck; - } - - template - inline const stream_guard& operator>>(const stream_guard& lck, T& arg) - { - lck.get() >> arg; - return lck; - } - - template - inline stream_guard operator<<(externally_locked_stream& mtx, T arg) - { - stream_guard lk(mtx); - mtx.get(lk) << arg; - return boost::move(lk); - } - - template - inline stream_guard operator<<(externally_locked_stream& mtx, Stream& (*arg)(Stream&)) - { - stream_guard lk(mtx); - mtx.get(lk) << arg; - return boost::move(lk); - } - - template - inline stream_guard operator>>(externally_locked_stream& mtx, T& arg) - { - stream_guard lk(mtx); - mtx.get(lk) >> arg; - return boost::move(lk); - } - -} - -#include - -#endif // header diff --git a/libraries/boost/boost/thread/future.hpp b/libraries/boost/boost/thread/future.hpp deleted file mode 100644 index b98ff3d33..000000000 --- a/libraries/boost/boost/thread/future.hpp +++ /dev/null @@ -1,5660 +0,0 @@ -// (C) Copyright 2008-10 Anthony Williams -// (C) Copyright 2011-2015 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_FUTURE_HPP -#define BOOST_THREAD_FUTURE_HPP - -#include - -// boost::thread::future requires exception handling -// due to boost::exception::exception_ptr dependency - -//#define BOOST_THREAD_CONTINUATION_SYNC - -#ifndef BOOST_NO_EXCEPTIONS - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined BOOST_THREAD_FUTURE_USES_OPTIONAL -#include -#else -#include -#endif - -#include -#include -#ifdef BOOST_THREAD_USES_CHRONO -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS -#include -#include -#if ! defined BOOST_NO_CXX11_ALLOCATOR -#include -#endif -#endif - -#if defined BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY -#include -#include -#endif - -#include -#include -#include -#include - -#if defined BOOST_THREAD_PROVIDES_FUTURE -#define BOOST_THREAD_FUTURE future -#else -#define BOOST_THREAD_FUTURE unique_future -#endif - -namespace boost -{ - template - shared_ptr static_shared_from_this(T* that) - { - return static_pointer_cast(that->shared_from_this()); - } - template - shared_ptr static_shared_from_this(T const* that) - { - return static_pointer_cast(that->shared_from_this()); - } - -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS -#else - namespace executors { - class executor; - } -#endif - typedef shared_ptr executor_ptr_type; - - namespace detail - { - - struct relocker - { - boost::unique_lock& lock_; - - relocker(boost::unique_lock& lk): - lock_(lk) - { - lock_.unlock(); - } - ~relocker() - { - if (! lock_.owns_lock()) { - lock_.lock(); - } - } - void lock() { - if (! lock_.owns_lock()) { - lock_.lock(); - } - } - private: - relocker& operator=(relocker const&); - }; - - struct shared_state_base : enable_shared_from_this - { - typedef std::list waiter_list; - typedef waiter_list::iterator notify_when_ready_handle; - // This type should be only included conditionally if interruptions are allowed, but is included to maintain the same layout. - typedef shared_ptr continuation_ptr_type; - typedef std::vector continuations_type; - - boost::exception_ptr exception; - bool done; - bool is_valid_; - bool is_deferred_; - bool is_constructed; - launch policy_; - mutable boost::mutex mutex; - boost::condition_variable waiters; - waiter_list external_waiters; - boost::function callback; - // This declaration should be only included conditionally, but is included to maintain the same layout. - continuations_type continuations; - executor_ptr_type ex; - - // This declaration should be only included conditionally, but is included to maintain the same layout. - virtual void launch_continuation() - { - } - - shared_state_base(): - done(false), - is_valid_(true), - is_deferred_(false), - is_constructed(false), - policy_(launch::none), - continuations(), - ex() - {} - - shared_state_base(exceptional_ptr const& ex_): - exception(ex_.ptr_), - done(true), - is_valid_(true), - is_deferred_(false), - is_constructed(false), - policy_(launch::none), - continuations(), - ex() - {} - - - virtual ~shared_state_base() - { - } - executor_ptr_type get_executor() - { - return ex; - } - - void set_executor_policy(executor_ptr_type aex) - { - set_executor(); - ex = aex; - } - void set_executor_policy(executor_ptr_type aex, boost::lock_guard&) - { - set_executor(); - ex = aex; - } - void set_executor_policy(executor_ptr_type aex, boost::unique_lock&) - { - set_executor(); - ex = aex; - } - - bool valid(boost::unique_lock&) { return is_valid_; } - bool valid() { - boost::unique_lock lk(this->mutex); - return valid(lk); - } - void invalidate(boost::unique_lock&) { is_valid_ = false; } - void invalidate() { - boost::unique_lock lk(this->mutex); - invalidate(lk); - } - void validate(boost::unique_lock&) { is_valid_ = true; } - void validate() { - boost::unique_lock lk(this->mutex); - validate(lk); - } - - void set_deferred() - { - is_deferred_ = true; - policy_ = launch::deferred; - } - void set_async() - { - is_deferred_ = false; - policy_ = launch::async; - } -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - void set_executor() - { - is_deferred_ = false; - policy_ = launch::executor; - } -#else - void set_executor() - { - } -#endif - notify_when_ready_handle notify_when_ready(boost::condition_variable_any& cv) - { - boost::unique_lock lock(this->mutex); - do_callback(lock); - return external_waiters.insert(external_waiters.end(),&cv); - } - - void unnotify_when_ready(notify_when_ready_handle it) - { - boost::lock_guard lock(this->mutex); - external_waiters.erase(it); - } - -#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION - void do_continuation(boost::unique_lock& lock) - { - if (! continuations.empty()) { - continuations_type the_continuations = continuations; - continuations.clear(); - relocker rlk(lock); - for (continuations_type::iterator it = the_continuations.begin(); it != the_continuations.end(); ++it) { - (*it)->launch_continuation(); - } - } - } -#else - void do_continuation(boost::unique_lock&) - { - } -#endif -#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION - virtual void set_continuation_ptr(continuation_ptr_type continuation, boost::unique_lock& lock) - { - continuations.push_back(continuation); - if (done) { - do_continuation(lock); - } - } -#endif - void mark_finished_internal(boost::unique_lock& lock) - { - done=true; - waiters.notify_all(); - for(waiter_list::const_iterator it=external_waiters.begin(), - end=external_waiters.end();it!=end;++it) - { - (*it)->notify_all(); - } - do_continuation(lock); - } - void make_ready() - { - boost::unique_lock lock(this->mutex); - mark_finished_internal(lock); - } - - void do_callback(boost::unique_lock& lock) - { - if(callback && !done) - { - boost::function local_callback=callback; - relocker relock(lock); - local_callback(); - } - } - - virtual bool run_if_is_deferred() - { - boost::unique_lock lk(this->mutex); - if (is_deferred_) - { - is_deferred_=false; - execute(lk); - return true; - } - else - return false; - } - virtual bool run_if_is_deferred_or_ready() - { - boost::unique_lock lk(this->mutex); - if (is_deferred_) - { - is_deferred_=false; - execute(lk); - - return true; - } - else - return done; - } - void wait_internal(boost::unique_lock &lk, bool rethrow=true) - { - do_callback(lk); - if (is_deferred_) - { - is_deferred_=false; - execute(lk); - } - while(!done) - { - waiters.wait(lk); - } - if(rethrow && exception) - { - boost::rethrow_exception(exception); - } - } - - virtual void wait(boost::unique_lock& lock, bool rethrow=true) - { - wait_internal(lock, rethrow); - } - - void wait(bool rethrow=true) - { - boost::unique_lock lock(this->mutex); - wait(lock, rethrow); - } - -#if defined BOOST_THREAD_USES_DATETIME - bool timed_wait_until(boost::system_time const& target_time) - { - boost::unique_lock lock(this->mutex); - if (is_deferred_) - return false; - - do_callback(lock); - while(!done) - { - bool const success=waiters.timed_wait(lock,target_time); - if(!success && !done) - { - return false; - } - } - return true; - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - - template - future_status - wait_until(const chrono::time_point& abs_time) - { - boost::unique_lock lock(this->mutex); - if (is_deferred_) - return future_status::deferred; - do_callback(lock); - while(!done) - { - cv_status const st=waiters.wait_until(lock,abs_time); - if(st==cv_status::timeout && !done) - { - return future_status::timeout; - } - } - return future_status::ready; - } -#endif - void mark_exceptional_finish_internal(boost::exception_ptr const& e, boost::unique_lock& lock) - { - exception=e; - mark_finished_internal(lock); - } - - void mark_exceptional_finish() - { - boost::unique_lock lock(this->mutex); - mark_exceptional_finish_internal(boost::current_exception(), lock); - } - - void set_exception_at_thread_exit(exception_ptr e) - { - unique_lock lk(this->mutex); - if (has_value(lk)) - { - throw_exception(promise_already_satisfied()); - } - exception=e; - this->is_constructed = true; - detail::make_ready_at_thread_exit(shared_from_this()); - } - - bool has_value() const - { - boost::lock_guard lock(this->mutex); - return done && ! exception; - } - - bool has_value(unique_lock& ) const - { - return done && ! exception; - } - - bool has_exception() const - { - boost::lock_guard lock(this->mutex); - return done && exception; - } - - launch launch_policy(boost::unique_lock&) const - { - return policy_; - } - - future_state::state get_state(boost::unique_lock&) const - { - if(!done) - { - return future_state::waiting; - } - else - { - return future_state::ready; - } - } - future_state::state get_state() const - { - boost::lock_guard guard(this->mutex); - if(!done) - { - return future_state::waiting; - } - else - { - return future_state::ready; - } - } - - exception_ptr get_exception_ptr() - { - boost::unique_lock lock(this->mutex); - wait_internal(lock, false); - return exception; - } - - template - void set_wait_callback(F f,U* u) - { - boost::lock_guard lock(this->mutex); - callback=boost::bind(f,boost::ref(*u)); - } - - virtual void execute(boost::unique_lock&) {} - - private: - shared_state_base(shared_state_base const&); - shared_state_base& operator=(shared_state_base const&); - }; - - // Used to create stand-alone futures - template - struct shared_state: - detail::shared_state_base - { -#if defined BOOST_THREAD_FUTURE_USES_OPTIONAL - typedef boost::optional storage_type; -#else - typedef boost::csbl::unique_ptr storage_type; -#endif -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - typedef T const& source_reference_type; - typedef BOOST_THREAD_RV_REF(T) rvalue_source_type; - typedef T move_dest_type; -#elif defined BOOST_THREAD_USES_MOVE - typedef typename conditional::value,T,T const&>::type source_reference_type; - typedef BOOST_THREAD_RV_REF(T) rvalue_source_type; - typedef T move_dest_type; -#else - typedef T& source_reference_type; - typedef typename conditional::value, BOOST_THREAD_RV_REF(T),T const&>::type rvalue_source_type; - typedef typename conditional::value, BOOST_THREAD_RV_REF(T),T>::type move_dest_type; -#endif - - typedef const T& shared_future_get_result_type; - - storage_type result; - - shared_state(): - result() - {} - shared_state(exceptional_ptr const& ex): - detail::shared_state_base(ex), result() - {} - - - ~shared_state() - { - } - - void mark_finished_with_result_internal(source_reference_type result_, boost::unique_lock& lock) - { -#if defined BOOST_THREAD_FUTURE_USES_OPTIONAL - result = result_; -#else - result.reset(new T(result_)); -#endif - this->mark_finished_internal(lock); - } - - void mark_finished_with_result_internal(rvalue_source_type result_, boost::unique_lock& lock) - { -#if defined BOOST_THREAD_FUTURE_USES_OPTIONAL - result = boost::move(result_); -#elif ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - result.reset(new T(boost::move(result_))); -#else - result.reset(new T(static_cast(result_))); -#endif - this->mark_finished_internal(lock); - } - - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template - void mark_finished_with_result_internal(boost::unique_lock& lock, BOOST_THREAD_FWD_REF(Args)... args) - { -#if defined BOOST_THREAD_FUTURE_USES_OPTIONAL - result.emplace(boost::forward(args)...); -#else - result.reset(new T(boost::forward(args)...)); -#endif - this->mark_finished_internal(lock); - } -#endif - - void mark_finished_with_result(source_reference_type result_) - { - boost::unique_lock lock(this->mutex); - this->mark_finished_with_result_internal(result_, lock); - } - - void mark_finished_with_result(rvalue_source_type result_) - { - boost::unique_lock lock(this->mutex); - -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - mark_finished_with_result_internal(boost::move(result_), lock); -#else - mark_finished_with_result_internal(static_cast(result_), lock); -#endif - } - - storage_type& get_storage(boost::unique_lock& lk) - { - wait_internal(lk); - return result; - } - virtual move_dest_type get(boost::unique_lock& lk) - { - return boost::move(*get_storage(lk)); - } - move_dest_type get() - { - boost::unique_lock lk(this->mutex); - return this->get(lk); - } - - virtual shared_future_get_result_type get_sh(boost::unique_lock& lk) - { - return *get_storage(lk); - } - shared_future_get_result_type get_sh() - { - boost::unique_lock lk(this->mutex); - return this->get_sh(lk); - } - - void set_value_at_thread_exit(source_reference_type result_) - { - unique_lock lk(this->mutex); - if (this->has_value(lk)) - { - throw_exception(promise_already_satisfied()); - } -#if defined BOOST_THREAD_FUTURE_USES_OPTIONAL - result = result_; -#else - result.reset(new T(result_)); -#endif - - this->is_constructed = true; - detail::make_ready_at_thread_exit(shared_from_this()); - } - void set_value_at_thread_exit(rvalue_source_type result_) - { - unique_lock lk(this->mutex); - if (this->has_value(lk)) - throw_exception(promise_already_satisfied()); - -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES -#if defined BOOST_THREAD_FUTURE_USES_OPTIONAL - result = boost::move(result_); -#else - result.reset(new T(boost::move(result_))); -#endif -#else -#if defined BOOST_THREAD_FUTURE_USES_OPTIONAL - result = boost::move(result_); -#else - result.reset(new T(static_cast(result_))); -#endif -#endif - this->is_constructed = true; - detail::make_ready_at_thread_exit(shared_from_this()); - } - - private: - shared_state(shared_state const&); - shared_state& operator=(shared_state const&); - }; - - template - struct shared_state: - detail::shared_state_base - { - typedef T* storage_type; - typedef T& source_reference_type; - typedef T& move_dest_type; - typedef T& shared_future_get_result_type; - - T* result; - - shared_state(): - result(0) - {} - - shared_state(exceptional_ptr const& ex): - detail::shared_state_base(ex), result(0) - {} - - ~shared_state() - { - } - - void mark_finished_with_result_internal(source_reference_type result_, boost::unique_lock& lock) - { - result= &result_; - mark_finished_internal(lock); - } - - void mark_finished_with_result(source_reference_type result_) - { - boost::unique_lock lock(this->mutex); - mark_finished_with_result_internal(result_, lock); - } - - virtual T& get(boost::unique_lock& lock) - { - wait_internal(lock); - return *result; - } - T& get() - { - boost::unique_lock lk(this->mutex); - return get(lk); - } - - virtual T& get_sh(boost::unique_lock& lock) - { - wait_internal(lock); - return *result; - } - T& get_sh() - { - boost::unique_lock lock(this->mutex); - return get_sh(lock); - } - - void set_value_at_thread_exit(T& result_) - { - unique_lock lk(this->mutex); - if (this->has_value(lk)) - throw_exception(promise_already_satisfied()); - result= &result_; - this->is_constructed = true; - detail::make_ready_at_thread_exit(shared_from_this()); - } - - private: - shared_state(shared_state const&); - shared_state& operator=(shared_state const&); - }; - - template<> - struct shared_state: - detail::shared_state_base - { - typedef void shared_future_get_result_type; - typedef void move_dest_type; - - shared_state() - {} - - shared_state(exceptional_ptr const& ex): - detail::shared_state_base(ex) - {} - - void mark_finished_with_result_internal(boost::unique_lock& lock) - { - mark_finished_internal(lock); - } - - void mark_finished_with_result() - { - boost::unique_lock lock(this->mutex); - mark_finished_with_result_internal(lock); - } - - virtual void get(boost::unique_lock& lock) - { - this->wait_internal(lock); - } - void get() - { - boost::unique_lock lock(this->mutex); - this->get(lock); - } - - virtual void get_sh(boost::unique_lock& lock) - { - this->wait_internal(lock); - } - void get_sh() - { - boost::unique_lock lock(this->mutex); - this->get_sh(lock); - } - - void set_value_at_thread_exit() - { - unique_lock lk(this->mutex); - if (this->has_value(lk)) - { - throw_exception(promise_already_satisfied()); - } - this->is_constructed = true; - detail::make_ready_at_thread_exit(shared_from_this()); - } - private: - shared_state(shared_state const&); - shared_state& operator=(shared_state const&); - }; - - ///////////////////////// - /// future_async_shared_state_base - ///////////////////////// - template - struct future_async_shared_state_base: shared_state - { - typedef shared_state base_type; - protected: -#ifdef BOOST_THREAD_FUTURE_BLOCKING - boost::thread thr_; - void join() - { - if (this_thread::get_id() == thr_.get_id()) - { - thr_.detach(); - return; - } - if (thr_.joinable()) thr_.join(); - } -#endif - public: - future_async_shared_state_base() - { - this->set_async(); - } - - ~future_async_shared_state_base() - { -#ifdef BOOST_THREAD_FUTURE_BLOCKING - join(); -#elif defined BOOST_THREAD_ASYNC_FUTURE_WAITS - unique_lock lk(this->mutex); - while(!this->done) - { - this->waiters.wait(lk); - } -#endif - } - - virtual void wait(boost::unique_lock& lk, bool rethrow) - { -#ifdef BOOST_THREAD_FUTURE_BLOCKING - { - relocker rlk(lk); - join(); - } -#endif - this->base_type::wait(lk, rethrow); - } - }; - - ///////////////////////// - /// future_async_shared_state - ///////////////////////// - template - struct future_async_shared_state: future_async_shared_state_base - { - future_async_shared_state() - { - } - - void init(BOOST_THREAD_FWD_REF(Fp) f) - { -#ifdef BOOST_THREAD_FUTURE_BLOCKING - this->thr_ = boost::thread(&future_async_shared_state::run, static_shared_from_this(this), boost::forward(f)); -#else - boost::thread(&future_async_shared_state::run, static_shared_from_this(this), boost::forward(f)).detach(); -#endif - } - - static void run(shared_ptr that, BOOST_THREAD_FWD_REF(Fp) f) - { - try - { - that->mark_finished_with_result(f()); - } - catch(...) - { - that->mark_exceptional_finish(); - } - } - }; - - template - struct future_async_shared_state: public future_async_shared_state_base - { - void init(BOOST_THREAD_FWD_REF(Fp) f) - { -#ifdef BOOST_THREAD_FUTURE_BLOCKING - this->thr_ = boost::thread(&future_async_shared_state::run, static_shared_from_this(this), boost::move(f)); -#else - boost::thread(&future_async_shared_state::run, static_shared_from_this(this), boost::move(f)).detach(); -#endif - } - - static void run(shared_ptr that, BOOST_THREAD_FWD_REF(Fp) f) - { - try - { - f(); - that->mark_finished_with_result(); - } - catch(...) - { - that->mark_exceptional_finish(); - } - } - }; - - template - struct future_async_shared_state: future_async_shared_state_base - { - void init(BOOST_THREAD_FWD_REF(Fp) f) - { -#ifdef BOOST_THREAD_FUTURE_BLOCKING - this->thr_ = boost::thread(&future_async_shared_state::run, static_shared_from_this(this), boost::move(f)); -#else - boost::thread(&future_async_shared_state::run, static_shared_from_this(this), boost::move(f)).detach(); -#endif - } - - static void run(shared_ptr that, BOOST_THREAD_FWD_REF(Fp) f) - { - try - { - that->mark_finished_with_result(f()); - } - catch(...) - { - that->mark_exceptional_finish(); - } - } - }; - - ////////////////////////// - /// future_deferred_shared_state - ////////////////////////// - template - struct future_deferred_shared_state: shared_state - { - typedef shared_state base_type; - Fp func_; - - public: - explicit future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f) - : func_(boost::move(f)) - { - this->set_deferred(); - } - - virtual void execute(boost::unique_lock& lck) { - try - { - Fp local_fuct=boost::move(func_); - relocker relock(lck); - Rp res = local_fuct(); - relock.lock(); - this->mark_finished_with_result_internal(boost::move(res), lck); - } - catch (...) - { - this->mark_exceptional_finish_internal(current_exception(), lck); - } - } - }; - template - struct future_deferred_shared_state: shared_state - { - typedef shared_state base_type; - Fp func_; - - public: - explicit future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f) - : func_(boost::move(f)) - { - this->set_deferred(); - } - - virtual void execute(boost::unique_lock& lck) { - try - { - this->mark_finished_with_result_internal(func_(), lck); - } - catch (...) - { - this->mark_exceptional_finish_internal(current_exception(), lck); - } - } - }; - - template - struct future_deferred_shared_state: shared_state - { - typedef shared_state base_type; - Fp func_; - - public: - explicit future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f) - : func_(boost::move(f)) - { - this->set_deferred(); - } - - virtual void execute(boost::unique_lock& lck) { - try - { - Fp local_fuct=boost::move(func_); - relocker relock(lck); - local_fuct(); - relock.lock(); - this->mark_finished_with_result_internal(lck); - } - catch (...) - { - this->mark_exceptional_finish_internal(current_exception(), lck); - } - } - }; - - class future_waiter - { - public: - typedef std::vector::size_type count_type; - private: - struct registered_waiter; - struct registered_waiter - { - boost::shared_ptr future_; - detail::shared_state_base::notify_when_ready_handle handle; - count_type index; - - registered_waiter(boost::shared_ptr const& a_future, - detail::shared_state_base::notify_when_ready_handle handle_, - count_type index_): - future_(a_future),handle(handle_),index(index_) - {} - }; - - struct all_futures_lock - { -#ifdef _MANAGED - typedef std::ptrdiff_t count_type_portable; -#else - typedef count_type count_type_portable; -#endif - count_type_portable count; - boost::scoped_array > locks; - - all_futures_lock(std::vector& futures): - count(futures.size()),locks(new boost::unique_lock[count]) - { - for(count_type_portable i=0;i(futures[i].future_->mutex)); - } - } - - void lock() - { - boost::lock(locks.get(),locks.get()+count); - } - - void unlock() - { - for(count_type_portable i=0;i futures_; - count_type future_count; - - public: - future_waiter(): - future_count(0) - {} - - template - void add(F& f) - { - if(f.future_) - { - registered_waiter waiter(f.future_,f.future_->notify_when_ready(cv),future_count); - try { - futures_.push_back(waiter); - } catch(...) { - f.future_->unnotify_when_ready(waiter.handle); - throw; - } - } - ++future_count; - } - -#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES - template - void add(F1& f1, Fs&... fs) - { - add(f1); add(fs...); - } -#endif - - count_type wait() - { - all_futures_lock lk(futures_); - for(;;) - { - for(count_type i=0;idone) - { - return futures_[i].index; - } - } - cv.wait(lk); - } - } - - ~future_waiter() - { - for(count_type i=0;iunnotify_when_ready(futures_[i].handle); - } - } - }; - - } - - template - class BOOST_THREAD_FUTURE; - - template - class shared_future; - - template - struct is_future_type > : true_type - { - }; - - template - struct is_future_type > : true_type - { - }; - -// template -// typename boost::disable_if,Iterator>::type wait_for_any(Iterator begin,Iterator end) -// { -// if(begin==end) -// return end; -// -// detail::future_waiter waiter; -// for(Iterator current=begin;current!=end;++current) -// { -// waiter.add(*current); -// } -// return boost::next(begin,waiter.wait()); -// } - -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES - template - typename boost::enable_if,typename detail::future_waiter::count_type>::type wait_for_any(F1& f1,F2& f2) - { - detail::future_waiter waiter; - waiter.add(f1); - waiter.add(f2); - return waiter.wait(); - } - - template - typename detail::future_waiter::count_type wait_for_any(F1& f1,F2& f2,F3& f3) - { - detail::future_waiter waiter; - waiter.add(f1); - waiter.add(f2); - waiter.add(f3); - return waiter.wait(); - } - - template - typename detail::future_waiter::count_type wait_for_any(F1& f1,F2& f2,F3& f3,F4& f4) - { - detail::future_waiter waiter; - waiter.add(f1); - waiter.add(f2); - waiter.add(f3); - waiter.add(f4); - return waiter.wait(); - } - - template - typename detail::future_waiter::count_type wait_for_any(F1& f1,F2& f2,F3& f3,F4& f4,F5& f5) - { - detail::future_waiter waiter; - waiter.add(f1); - waiter.add(f2); - waiter.add(f3); - waiter.add(f4); - waiter.add(f5); - return waiter.wait(); - } -#else - template - typename boost::enable_if, typename detail::future_waiter::count_type>::type - wait_for_any(F1& f1, Fs&... fs) - { - detail::future_waiter waiter; - waiter.add(f1, fs...); - return waiter.wait(); - } -#endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - - template - class promise; - - template - class packaged_task; - - namespace detail - { - /// Common implementation for all the futures independently of the return type - class base_future - { - public: - }; - /// Common implementation for future and shared_future. - template - class basic_future : public base_future - { - protected: - public: - - typedef boost::shared_ptr > future_ptr; - typedef typename detail::shared_state::move_dest_type move_dest_type; - - static //BOOST_CONSTEXPR - future_ptr make_exceptional_future_ptr(exceptional_ptr const& ex) { - return future_ptr(new detail::shared_state(ex)); - } - - future_ptr future_; - - basic_future(future_ptr a_future): - future_(a_future) - { - } - - public: - typedef future_state::state state; - - BOOST_THREAD_MOVABLE_ONLY(basic_future) - basic_future(): future_() {} - - - //BOOST_CONSTEXPR - basic_future(exceptional_ptr const& ex) - : future_(make_exceptional_future_ptr(ex)) - { - } - - ~basic_future() { - } - - basic_future(BOOST_THREAD_RV_REF(basic_future) other) BOOST_NOEXCEPT: - future_(BOOST_THREAD_RV(other).future_) - { - BOOST_THREAD_RV(other).future_.reset(); - } - basic_future& operator=(BOOST_THREAD_RV_REF(basic_future) other) BOOST_NOEXCEPT - { - future_=BOOST_THREAD_RV(other).future_; - BOOST_THREAD_RV(other).future_.reset(); - return *this; - } - void swap(basic_future& that) BOOST_NOEXCEPT - { - future_.swap(that.future_); - } - // functions to check state, and wait for ready - state get_state(boost::unique_lock& lk) const - { - if(!future_) - { - return future_state::uninitialized; - } - return future_->get_state(lk); - } - state get_state() const - { - if(!future_) - { - return future_state::uninitialized; - } - return future_->get_state(); - } - - bool is_ready() const - { - return get_state()==future_state::ready; - } - - bool is_ready(boost::unique_lock& lk) const - { - return get_state(lk)==future_state::ready; - } - bool has_exception() const - { - return future_ && future_->has_exception(); - } - - bool has_value() const - { - return future_ && future_->has_value(); - } - - launch launch_policy(boost::unique_lock& lk) const - { - if ( future_ ) return future_->launch_policy(lk); - else return launch(launch::none); - } - - launch launch_policy() const - { - if ( future_ ) { - boost::unique_lock lk(this->future_->mutex); - return future_->launch_policy(lk); - } - else return launch(launch::none); - } - - exception_ptr get_exception_ptr() - { - return future_ - ? future_->get_exception_ptr() - : exception_ptr(); - } - - bool valid() const BOOST_NOEXCEPT - { - return future_ != 0 && future_->valid(); - } - - void wait() const - { - if(!future_) - { - boost::throw_exception(future_uninitialized()); - } - future_->wait(false); - } - - typedef detail::shared_state_base::notify_when_ready_handle notify_when_ready_handle; - - boost::mutex& mutex() { - if(!future_) - { - boost::throw_exception(future_uninitialized()); - } - return future_->mutex; - }; - - notify_when_ready_handle notify_when_ready(boost::condition_variable_any& cv) - { - if(!future_) - { - boost::throw_exception(future_uninitialized()); - } - return future_->notify_when_ready(cv); - } - - void unnotify_when_ready(notify_when_ready_handle h) - { - if(!future_) - { - boost::throw_exception(future_uninitialized()); - } - return future_->unnotify_when_ready(h); - } - -#if defined BOOST_THREAD_USES_DATETIME - template - bool timed_wait(Duration const& rel_time) const - { - return timed_wait_until(boost::get_system_time()+rel_time); - } - - bool timed_wait_until(boost::system_time const& abs_time) const - { - if(!future_) - { - boost::throw_exception(future_uninitialized()); - } - return future_->timed_wait_until(abs_time); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - future_status - wait_for(const chrono::duration& rel_time) const - { - return wait_until(chrono::steady_clock::now() + rel_time); - - } - template - future_status - wait_until(const chrono::time_point& abs_time) const - { - if(!future_) - { - boost::throw_exception(future_uninitialized()); - } - return future_->wait_until(abs_time); - } -#endif - - }; - - } // detail - BOOST_THREAD_DCL_MOVABLE_BEG(R) detail::basic_future BOOST_THREAD_DCL_MOVABLE_END - - namespace detail - { -#if (!defined _MSC_VER || _MSC_VER >= 1400) // _MSC_VER == 1400 on MSVC 2005 - template - BOOST_THREAD_FUTURE - make_future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f); - - template - BOOST_THREAD_FUTURE - make_future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f); -#endif // #if (!defined _MSC_VER || _MSC_VER >= 1400) -#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION - template - struct future_deferred_continuation_shared_state; - template - struct future_async_continuation_shared_state; - - template - BOOST_THREAD_FUTURE - make_future_async_continuation_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - BOOST_THREAD_FUTURE - make_future_sync_continuation_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - BOOST_THREAD_FUTURE - make_future_deferred_continuation_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - BOOST_THREAD_FUTURE - make_shared_future_deferred_continuation_shared_state(boost::unique_lock &lock, F f, BOOST_THREAD_FWD_REF(Fp) c); - - template - BOOST_THREAD_FUTURE - make_shared_future_async_continuation_shared_state(boost::unique_lock &lock, F f, BOOST_THREAD_FWD_REF(Fp) c); - - template - BOOST_THREAD_FUTURE - make_shared_future_sync_continuation_shared_state(boost::unique_lock &lock, F f, BOOST_THREAD_FWD_REF(Fp) c); - - - #ifdef BOOST_THREAD_PROVIDES_EXECUTORS - template - BOOST_THREAD_FUTURE - make_future_executor_continuation_shared_state(Ex& ex, boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - BOOST_THREAD_FUTURE - make_shared_future_executor_continuation_shared_state(Ex& ex, boost::unique_lock &lock, F f, BOOST_THREAD_FWD_REF(Fp) c); - - template - BOOST_THREAD_FUTURE - make_future_executor_shared_state(Executor& ex, BOOST_THREAD_FWD_REF(Fp) f); - #endif -#endif -#if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP - template - struct future_unwrap_shared_state; - template - inline BOOST_THREAD_FUTURE - make_future_unwrap_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f); -#endif - } -#if defined(BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY) - template< typename InputIterator> - typename boost::disable_if, - BOOST_THREAD_FUTURE > - >::type - when_all(InputIterator first, InputIterator last); - - inline BOOST_THREAD_FUTURE > when_all(); - - #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template< typename T0, typename ...T> - BOOST_THREAD_FUTURE::type, typename decay::type...> > - when_all(BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures); - #endif - - template< typename InputIterator> - typename boost::disable_if, - BOOST_THREAD_FUTURE > - >::type - when_any(InputIterator first, InputIterator last); - - inline BOOST_THREAD_FUTURE > when_any(); - - #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template< typename T0, typename ...T> - BOOST_THREAD_FUTURE::type, typename decay::type...> > - when_any(BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures); - #endif -#endif // BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY - - - template - class BOOST_THREAD_FUTURE : public detail::basic_future - { - private: - typedef detail::basic_future base_type; - typedef typename base_type::future_ptr future_ptr; - - friend class shared_future; - friend class promise; -#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION - template - friend struct detail::future_async_continuation_shared_state; - template - friend struct detail::future_deferred_continuation_shared_state; - - template - friend BOOST_THREAD_FUTURE - detail::make_future_async_continuation_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_future_sync_continuation_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_future_deferred_continuation_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_shared_future_deferred_continuation_shared_state(boost::unique_lock &lock, F f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_shared_future_async_continuation_shared_state(boost::unique_lock &lock, F f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_shared_future_sync_continuation_shared_state(boost::unique_lock &lock, F f, BOOST_THREAD_FWD_REF(Fp) c); - - #ifdef BOOST_THREAD_PROVIDES_EXECUTORS - template - friend BOOST_THREAD_FUTURE - detail::make_future_executor_continuation_shared_state(Ex& ex, boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_shared_future_executor_continuation_shared_state(Ex& ex, boost::unique_lock &lock, F f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_future_executor_shared_state(Executor& ex, BOOST_THREAD_FWD_REF(Fp) f); - #endif -#endif -#if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP - template - friend struct detail::future_unwrap_shared_state; - template - friend BOOST_THREAD_FUTURE - detail::make_future_unwrap_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f); -#endif -#if defined(BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY) - template< typename InputIterator> - friend typename boost::disable_if, - BOOST_THREAD_FUTURE > - >::type - when_all(InputIterator first, InputIterator last); - - //friend inline BOOST_THREAD_FUTURE > when_all(); - - #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template< typename T0, typename ...T> - friend BOOST_THREAD_FUTURE::type, typename decay::type...> > - when_all(BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures); - #endif - - template< typename InputIterator> - friend typename boost::disable_if, - BOOST_THREAD_FUTURE > - >::type - when_any(InputIterator first, InputIterator last); - - //friend inline BOOST_THREAD_FUTURE > when_any(); - - #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template< typename T0, typename ...T> - friend BOOST_THREAD_FUTURE::type, typename decay::type...> > - when_any(BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures); - #endif -#endif // BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - template friend class packaged_task; // todo check if this works in windows -#else - friend class packaged_task; -#endif - friend class detail::future_waiter; - - template - friend BOOST_THREAD_FUTURE - detail::make_future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f); - - template - friend BOOST_THREAD_FUTURE - detail::make_future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f); - - typedef typename base_type::move_dest_type move_dest_type; - - BOOST_THREAD_FUTURE(future_ptr a_future): - base_type(a_future) - { - } - - public: - BOOST_THREAD_MOVABLE_ONLY(BOOST_THREAD_FUTURE) - typedef future_state::state state; - typedef R value_type; // EXTENSION - - BOOST_CONSTEXPR BOOST_THREAD_FUTURE() {} - //BOOST_CONSTEXPR - BOOST_THREAD_FUTURE(exceptional_ptr const& ex): - base_type(ex) {} - - ~BOOST_THREAD_FUTURE() { - } - - BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT: - base_type(boost::move(static_cast(BOOST_THREAD_RV(other)))) - { - } - inline explicit BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE >) other); // EXTENSION - - explicit BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(shared_future) other) : - base_type(boost::move(static_cast(BOOST_THREAD_RV(other)))) - {} - - BOOST_THREAD_FUTURE& operator=(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT - { - this->base_type::operator=(boost::move(static_cast(BOOST_THREAD_RV(other)))); - return *this; - } - - shared_future share() - { - return shared_future(::boost::move(*this)); - } - - void swap(BOOST_THREAD_FUTURE& other) - { - static_cast(this)->swap(other); - } - - // todo this function must be private and friendship provided to the internal users. - void set_async() - { - this->future_->set_async(); - } - // todo this function must be private and friendship provided to the internal users. - void set_deferred() - { - this->future_->set_deferred(); - } - bool run_if_is_deferred() { - return this->future_->run_if_is_deferred(); - } - bool run_if_is_deferred_or_ready() { - return this->future_->run_if_is_deferred_or_ready(); - } - // retrieving the value - move_dest_type get() - { - if (this->future_ == 0) - { - boost::throw_exception(future_uninitialized()); - } - unique_lock lk(this->future_->mutex); - if (! this->future_->valid(lk)) - { - boost::throw_exception(future_uninitialized()); - } -#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET - this->future_->invalidate(lk); -#endif - return this->future_->get(lk); - } - - template - typename boost::disable_if< is_void, move_dest_type>::type - get_or(BOOST_THREAD_RV_REF(R2) v) - { - - if (this->future_ == 0) - { - boost::throw_exception(future_uninitialized()); - } - unique_lock lk(this->future_->mutex); - if (! this->future_->valid(lk)) - { - boost::throw_exception(future_uninitialized()); - } - this->future_->wait(lk, false); -#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET - this->future_->invalidate(lk); -#endif - - if (this->future_->has_value(lk)) { - return this->future_->get(lk); - } - else { - return boost::move(v); - } - } - - template - typename boost::disable_if< is_void, move_dest_type>::type - get_or(R2 const& v) // EXTENSION - { - if (this->future_ == 0) - { - boost::throw_exception(future_uninitialized()); - } - unique_lock lk(this->future_->mutex); - if (! this->future_->valid(lk)) - { - boost::throw_exception(future_uninitialized()); - } - this->future_->wait(lk, false); -#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET - this->future_->invalidate(lk); -#endif - if (this->future_->has_value(lk)) { - return this->future_->get(lk); - } - else { - return v; - } - } - -#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION - template - inline BOOST_THREAD_FUTURE::type> - then(BOOST_THREAD_FWD_REF(F) func); // EXTENSION - template - inline BOOST_THREAD_FUTURE::type> - then(launch policy, BOOST_THREAD_FWD_REF(F) func); // EXTENSION - #ifdef BOOST_THREAD_PROVIDES_EXECUTORS - template - inline BOOST_THREAD_FUTURE::type> - then(Ex& ex, BOOST_THREAD_FWD_REF(F) func); // EXTENSION - #endif - - template - inline typename boost::disable_if< is_void, BOOST_THREAD_FUTURE >::type - fallback_to(BOOST_THREAD_RV_REF(R2) v); // EXTENSION - template - inline typename boost::disable_if< is_void, BOOST_THREAD_FUTURE >::type - fallback_to(R2 const& v); // EXTENSION - -#endif - - }; - - BOOST_THREAD_DCL_MOVABLE_BEG(T) BOOST_THREAD_FUTURE BOOST_THREAD_DCL_MOVABLE_END - - template - class BOOST_THREAD_FUTURE > : public detail::basic_future > - { - typedef BOOST_THREAD_FUTURE R; - - private: - typedef detail::basic_future base_type; - typedef typename base_type::future_ptr future_ptr; - - friend class shared_future; - friend class promise; -#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION - template - friend struct detail::future_async_continuation_shared_state; - template - friend struct detail::future_deferred_continuation_shared_state; - - template - friend BOOST_THREAD_FUTURE - detail::make_future_async_continuation_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_future_sync_continuation_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_future_deferred_continuation_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_shared_future_deferred_continuation_shared_state(boost::unique_lock &lock, F f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_shared_future_async_continuation_shared_state(boost::unique_lock &lock, F f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_shared_future_sync_continuation_shared_state(boost::unique_lock &lock, F f, BOOST_THREAD_FWD_REF(Fp) c); - - #ifdef BOOST_THREAD_PROVIDES_EXECUTORS - template - friend BOOST_THREAD_FUTURE - detail::make_future_executor_continuation_shared_state(Ex& ex, boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_shared_future_executor_continuation_shared_state(Ex& ex, boost::unique_lock &lock, F f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_future_executor_shared_state(Executor& ex, BOOST_THREAD_FWD_REF(Fp) f); - #endif - -#endif -#if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP - template - friend struct detail::future_unwrap_shared_state; - template - friend BOOST_THREAD_FUTURE - detail::make_future_unwrap_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f); -#endif -#if defined(BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY) - template< typename InputIterator> - friend typename boost::disable_if, - BOOST_THREAD_FUTURE > - >::type - when_all(InputIterator first, InputIterator last); - - friend inline BOOST_THREAD_FUTURE > when_all(); - - #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template< typename T0, typename ...T> - friend BOOST_THREAD_FUTURE::type, typename decay::type...> > - when_all(BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures); - #endif - - template< typename InputIterator> - friend typename boost::disable_if, - BOOST_THREAD_FUTURE > - >::type - when_any(InputIterator first, InputIterator last); - - friend inline BOOST_THREAD_FUTURE > when_any(); - - #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template< typename T0, typename ...T> - friend BOOST_THREAD_FUTURE::type, typename decay::type...> > - when_any(BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures); - #endif -#endif // BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY - - #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - template friend class packaged_task; // todo check if this works in windows - #else - friend class packaged_task; - #endif - friend class detail::future_waiter; - - template - friend BOOST_THREAD_FUTURE - detail::make_future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f); - - template - friend BOOST_THREAD_FUTURE - detail::make_future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f); - - typedef typename base_type::move_dest_type move_dest_type; - - BOOST_THREAD_FUTURE(future_ptr a_future): - base_type(a_future) - { - } - public: - - BOOST_THREAD_MOVABLE_ONLY(BOOST_THREAD_FUTURE) - typedef future_state::state state; - typedef R value_type; // EXTENSION - - BOOST_CONSTEXPR BOOST_THREAD_FUTURE() {} - //BOOST_CONSTEXPR - BOOST_THREAD_FUTURE(exceptional_ptr const& ex): - base_type(ex) {} - - ~BOOST_THREAD_FUTURE() { - } - - BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT: - base_type(boost::move(static_cast(BOOST_THREAD_RV(other)))) - { - } - - BOOST_THREAD_FUTURE& operator=(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT - { - this->base_type::operator=(boost::move(static_cast(BOOST_THREAD_RV(other)))); - return *this; - } - - shared_future share() - { - return shared_future(::boost::move(*this)); - } - - void swap(BOOST_THREAD_FUTURE& other) - { - static_cast(this)->swap(other); - } - - // todo this function must be private and friendship provided to the internal users. - void set_async() - { - this->future_->set_async(); - } - // todo this function must be private and friendship provided to the internal users. - void set_deferred() - { - this->future_->set_deferred(); - } - bool run_if_is_deferred() { - return this->future_->run_if_is_deferred(); - } - bool run_if_is_deferred_or_ready() { - return this->future_->run_if_is_deferred_or_ready(); - } - // retrieving the value - move_dest_type get() - { - if (this->future_ == 0) - { - boost::throw_exception(future_uninitialized()); - } - unique_lock lk(this->future_->mutex); - if (! this->future_->valid(lk)) - { - boost::throw_exception(future_uninitialized()); - } - #ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET - this->future_->invalidate(lk); - #endif - return this->future_->get(lk); - } - move_dest_type get_or(BOOST_THREAD_RV_REF(R) v) // EXTENSION - { - if (this->future_ == 0) - { - boost::throw_exception(future_uninitialized()); - } - unique_lock lk(this->future_->mutex); - if (! this->future_->valid(lk)) - { - boost::throw_exception(future_uninitialized()); - } - this->future_->wait(lk, false); - #ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET - this->future_->invalidate(lk); - #endif - if (this->future_->has_value(lk)) return this->future_->get(lk); - else return boost::move(v); - } - - move_dest_type get_or(R const& v) // EXTENSION - { - if (this->future_ == 0) - { - boost::throw_exception(future_uninitialized()); - } - unique_lock lk(this->future_->mutex); - if (! this->future_->valid(lk)) - { - boost::throw_exception(future_uninitialized()); - } - this->future_->wait(lk, false); - #ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET - this->future_->invalidate(lk); - #endif - if (this->future_->has_value(lk)) return this->future_->get(lk); - else return v; - } - - - #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION - template - inline BOOST_THREAD_FUTURE::type> - then(BOOST_THREAD_FWD_REF(F) func); // EXTENSION - template - inline BOOST_THREAD_FUTURE::type> - then(launch policy, BOOST_THREAD_FWD_REF(F) func); // EXTENSION - #ifdef BOOST_THREAD_PROVIDES_EXECUTORS - template - inline BOOST_THREAD_FUTURE::type> - then(Ex &ex, BOOST_THREAD_FWD_REF(F) func); // EXTENSION - #endif - #endif - - #if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP - inline - BOOST_THREAD_FUTURE - unwrap(); // EXTENSION - #endif - - }; - - template - class shared_future : public detail::basic_future - { - typedef detail::basic_future base_type; - typedef typename base_type::future_ptr future_ptr; - - friend class detail::future_waiter; - friend class promise; - -#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION - template - friend struct detail::future_async_continuation_shared_state; - template - friend struct detail::future_deferred_continuation_shared_state; - - template - friend BOOST_THREAD_FUTURE - detail::make_future_async_continuation_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_future_sync_continuation_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); - - template - friend BOOST_THREAD_FUTURE - detail::make_future_deferred_continuation_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c); -#endif -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - template friend class packaged_task;// todo check if this works in windows -#else - friend class packaged_task; -#endif - shared_future(future_ptr a_future): - base_type(a_future) - {} - - public: - BOOST_THREAD_COPYABLE_AND_MOVABLE(shared_future) - typedef R value_type; // EXTENSION - - shared_future(shared_future const& other): - base_type(other.future_) - {} - - typedef future_state::state state; - - BOOST_CONSTEXPR shared_future() - {} - //BOOST_CONSTEXPR - shared_future(exceptional_ptr const& ex): - base_type(ex) {} - ~shared_future() - {} - - shared_future& operator=(BOOST_THREAD_COPY_ASSIGN_REF(shared_future) other) - { - this->future_ = other.future_; - return *this; - } - - shared_future(BOOST_THREAD_RV_REF(shared_future) other) BOOST_NOEXCEPT : - base_type(boost::move(static_cast(BOOST_THREAD_RV(other)))) - { - } - shared_future(BOOST_THREAD_RV_REF( BOOST_THREAD_FUTURE ) other) BOOST_NOEXCEPT : - base_type(boost::move(static_cast(BOOST_THREAD_RV(other)))) - { - } - - shared_future& operator=(BOOST_THREAD_RV_REF(shared_future) other) BOOST_NOEXCEPT - { - base_type::operator=(boost::move(static_cast(BOOST_THREAD_RV(other)))); - return *this; - } - shared_future& operator=(BOOST_THREAD_RV_REF( BOOST_THREAD_FUTURE ) other) BOOST_NOEXCEPT - { - base_type::operator=(boost::move(static_cast(BOOST_THREAD_RV(other)))); - return *this; - } - - void swap(shared_future& other) BOOST_NOEXCEPT - { - static_cast(this)->swap(other); - } - bool run_if_is_deferred() { - return this->future_->run_if_is_deferred(); - } - bool run_if_is_deferred_or_ready() { - return this->future_->run_if_is_deferred_or_ready(); - } - // retrieving the value - typename detail::shared_state::shared_future_get_result_type get() const - { - if(!this->future_) - { - boost::throw_exception(future_uninitialized()); - } - return this->future_->get_sh(); - } - - template - typename boost::disable_if< is_void, typename detail::shared_state::shared_future_get_result_type>::type - get_or(BOOST_THREAD_RV_REF(R2) v) const // EXTENSION - { - if(!this->future_) - { - boost::throw_exception(future_uninitialized()); - } - this->future_->wait(); - if (this->future_->has_value()) return this->future_->get_sh(); - else return boost::move(v); - } - -#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION - template - inline BOOST_THREAD_FUTURE::type> - then(BOOST_THREAD_FWD_REF(F) func) const; // EXTENSION - template - inline BOOST_THREAD_FUTURE::type> - then(launch policy, BOOST_THREAD_FWD_REF(F) func) const; // EXTENSION - #ifdef BOOST_THREAD_PROVIDES_EXECUTORS - template - inline BOOST_THREAD_FUTURE::type> - then(Ex& ex, BOOST_THREAD_FWD_REF(F) func) const; // EXTENSION - #endif -#endif - - }; - - BOOST_THREAD_DCL_MOVABLE_BEG(T) shared_future BOOST_THREAD_DCL_MOVABLE_END - - template - class promise - { - typedef boost::shared_ptr > future_ptr; - - typedef typename detail::shared_state::source_reference_type source_reference_type; - typedef typename detail::shared_state::rvalue_source_type rvalue_source_type; - typedef typename detail::shared_state::move_dest_type move_dest_type; - typedef typename detail::shared_state::shared_future_get_result_type shared_future_get_result_type; - - future_ptr future_; - bool future_obtained; - - void lazy_init() - { -#if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY -#include - if(!atomic_load(&future_)) - { - future_ptr blank; - atomic_compare_exchange(&future_,&blank,future_ptr(new detail::shared_state)); - } -#include -#endif - } - - public: - BOOST_THREAD_MOVABLE_ONLY(promise) -#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS - template - promise(boost::allocator_arg_t, Allocator a) - { - typedef typename Allocator::template rebind >::other A2; - A2 a2(a); - typedef thread_detail::allocator_destructor D; - - future_ = future_ptr(::new(a2.allocate(1)) detail::shared_state(), D(a2, 1) ); - future_obtained = false; - } -#endif - promise(): -#if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY - future_(), -#else - future_(new detail::shared_state()), -#endif - future_obtained(false) - {} - - ~promise() - { - if(future_) - { - boost::unique_lock lock(future_->mutex); - - if(!future_->done && !future_->is_constructed) - { - future_->mark_exceptional_finish_internal(boost::copy_exception(broken_promise()), lock); - } - } - } - - // Assignment - promise(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT : - future_(BOOST_THREAD_RV(rhs).future_),future_obtained(BOOST_THREAD_RV(rhs).future_obtained) - { - BOOST_THREAD_RV(rhs).future_.reset(); - BOOST_THREAD_RV(rhs).future_obtained=false; - } - promise & operator=(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT - { - future_=BOOST_THREAD_RV(rhs).future_; - future_obtained=BOOST_THREAD_RV(rhs).future_obtained; - BOOST_THREAD_RV(rhs).future_.reset(); - BOOST_THREAD_RV(rhs).future_obtained=false; - return *this; - } - - void swap(promise& other) - { - future_.swap(other.future_); - std::swap(future_obtained,other.future_obtained); - } - -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - void set_executor(executor_ptr_type aex) - { - lazy_init(); - if (future_.get()==0) - { - boost::throw_exception(promise_moved()); - } - boost::lock_guard lk(future_->mutex); - future_->set_executor_policy(aex, lk); - } -#endif - // Result retrieval - BOOST_THREAD_FUTURE get_future() - { - lazy_init(); - if (future_.get()==0) - { - boost::throw_exception(promise_moved()); - } - if (future_obtained) - { - boost::throw_exception(future_already_retrieved()); - } - future_obtained=true; - return BOOST_THREAD_FUTURE(future_); - } - -#if defined BOOST_NO_CXX11_RVALUE_REFERENCES - template - typename boost::enable_if_c::value && is_same::value, void>::type set_value(TR const & r) - { - lazy_init(); - boost::unique_lock lock(future_->mutex); - if(future_->done) - { - boost::throw_exception(promise_already_satisfied()); - } - future_->mark_finished_with_result_internal(r, lock); - } -#else - void set_value(source_reference_type r) - { - lazy_init(); - boost::unique_lock lock(future_->mutex); - if(future_->done) - { - boost::throw_exception(promise_already_satisfied()); - } - future_->mark_finished_with_result_internal(r, lock); - } -#endif - - void set_value(rvalue_source_type r) - { - lazy_init(); - boost::unique_lock lock(future_->mutex); - if(future_->done) - { - boost::throw_exception(promise_already_satisfied()); - } -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - future_->mark_finished_with_result_internal(boost::move(r), lock); -#else - future_->mark_finished_with_result_internal(static_cast(r), lock); -#endif - } - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template - void emplace(BOOST_THREAD_FWD_REF(Args) ...args) - { - lazy_init(); - boost::unique_lock lock(future_->mutex); - if(future_->done) - { - boost::throw_exception(promise_already_satisfied()); - } - future_->mark_finished_with_result_internal(lock, boost::forward(args)...); - } - -#endif - - void set_exception(boost::exception_ptr p) - { - lazy_init(); - boost::unique_lock lock(future_->mutex); - if(future_->done) - { - boost::throw_exception(promise_already_satisfied()); - } - future_->mark_exceptional_finish_internal(p, lock); - } - template - void set_exception(E ex) - { - set_exception(boost::copy_exception(ex)); - } - // setting the result with deferred notification -#if defined BOOST_NO_CXX11_RVALUE_REFERENCES - template - typename boost::enable_if_c::value && is_same::value, void>::type set_value_at_thread_exit(TR const& r) - { - if (future_.get()==0) - { - boost::throw_exception(promise_moved()); - } - future_->set_value_at_thread_exit(r); - } -#else - void set_value_at_thread_exit(source_reference_type r) - { - if (future_.get()==0) - { - boost::throw_exception(promise_moved()); - } - future_->set_value_at_thread_exit(r); - } -#endif - void set_value_at_thread_exit(BOOST_THREAD_RV_REF(R) r) - { - if (future_.get()==0) - { - boost::throw_exception(promise_moved()); - } - future_->set_value_at_thread_exit(boost::move(r)); - } - void set_exception_at_thread_exit(exception_ptr e) - { - if (future_.get()==0) - { - boost::throw_exception(promise_moved()); - } - future_->set_exception_at_thread_exit(e); - } - template - void set_exception_at_thread_exit(E ex) - { - set_exception_at_thread_exit(boost::copy_exception(ex)); - } - - template - void set_wait_callback(F f) - { - lazy_init(); - future_->set_wait_callback(f,this); - } - - }; - - template - class promise - { - typedef boost::shared_ptr > future_ptr; - - future_ptr future_; - bool future_obtained; - - void lazy_init() - { -#if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY -#include - if(!atomic_load(&future_)) - { - future_ptr blank; - atomic_compare_exchange(&future_,&blank,future_ptr(new detail::shared_state)); - } -#include -#endif - } - - public: - BOOST_THREAD_MOVABLE_ONLY(promise) -#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS - template - promise(boost::allocator_arg_t, Allocator a) - { - typedef typename Allocator::template rebind >::other A2; - A2 a2(a); - typedef thread_detail::allocator_destructor D; - - future_ = future_ptr(::new(a2.allocate(1)) detail::shared_state(), D(a2, 1) ); - future_obtained = false; - } -#endif - promise(): -#if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY - future_(), -#else - future_(new detail::shared_state()), -#endif - future_obtained(false) - {} - - ~promise() - { - if(future_) - { - boost::unique_lock lock(future_->mutex); - - if(!future_->done && !future_->is_constructed) - { - future_->mark_exceptional_finish_internal(boost::copy_exception(broken_promise()), lock); - } - } - } - - // Assignment - promise(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT : - future_(BOOST_THREAD_RV(rhs).future_),future_obtained(BOOST_THREAD_RV(rhs).future_obtained) - { - BOOST_THREAD_RV(rhs).future_.reset(); - BOOST_THREAD_RV(rhs).future_obtained=false; - } - promise & operator=(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT - { - future_=BOOST_THREAD_RV(rhs).future_; - future_obtained=BOOST_THREAD_RV(rhs).future_obtained; - BOOST_THREAD_RV(rhs).future_.reset(); - BOOST_THREAD_RV(rhs).future_obtained=false; - return *this; - } - - void swap(promise& other) - { - future_.swap(other.future_); - std::swap(future_obtained,other.future_obtained); - } - - // Result retrieval - BOOST_THREAD_FUTURE get_future() - { - lazy_init(); - if (future_.get()==0) - { - boost::throw_exception(promise_moved()); - } - if (future_obtained) - { - boost::throw_exception(future_already_retrieved()); - } - future_obtained=true; - return BOOST_THREAD_FUTURE(future_); - } - - void set_value(R& r) - { - lazy_init(); - boost::unique_lock lock(future_->mutex); - if(future_->done) - { - boost::throw_exception(promise_already_satisfied()); - } - future_->mark_finished_with_result_internal(r, lock); - } - - void set_exception(boost::exception_ptr p) - { - lazy_init(); - boost::unique_lock lock(future_->mutex); - if(future_->done) - { - boost::throw_exception(promise_already_satisfied()); - } - future_->mark_exceptional_finish_internal(p, lock); - } - template - void set_exception(E ex) - { - set_exception(boost::copy_exception(ex)); - } - - // setting the result with deferred notification - void set_value_at_thread_exit(R& r) - { - if (future_.get()==0) - { - boost::throw_exception(promise_moved()); - } - future_->set_value_at_thread_exit(r); - } - - void set_exception_at_thread_exit(exception_ptr e) - { - if (future_.get()==0) - { - boost::throw_exception(promise_moved()); - } - future_->set_exception_at_thread_exit(e); - } - template - void set_exception_at_thread_exit(E ex) - { - set_exception_at_thread_exit(boost::copy_exception(ex)); - } - - template - void set_wait_callback(F f) - { - lazy_init(); - future_->set_wait_callback(f,this); - } - }; - - template <> - class promise - { - typedef boost::shared_ptr > future_ptr; - - future_ptr future_; - bool future_obtained; - - void lazy_init() - { -#if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY - if(!atomic_load(&future_)) - { - future_ptr blank; - atomic_compare_exchange(&future_,&blank,future_ptr(new detail::shared_state)); - } -#endif - } - public: - BOOST_THREAD_MOVABLE_ONLY(promise) - -#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS - template - promise(boost::allocator_arg_t, Allocator a) - { - typedef typename Allocator::template rebind >::other A2; - A2 a2(a); - typedef thread_detail::allocator_destructor D; - - future_ = future_ptr(::new(a2.allocate(1)) detail::shared_state(), D(a2, 1) ); - future_obtained = false; - } -#endif - promise(): -#if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY - future_(), -#else - future_(new detail::shared_state), -#endif - future_obtained(false) - {} - - ~promise() - { - if(future_) - { - boost::unique_lock lock(future_->mutex); - - if(!future_->done && !future_->is_constructed) - { - future_->mark_exceptional_finish_internal(boost::copy_exception(broken_promise()), lock); - } - } - } - - // Assignment - promise(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT : - future_(BOOST_THREAD_RV(rhs).future_),future_obtained(BOOST_THREAD_RV(rhs).future_obtained) - { - // we need to release the future as shared_ptr doesn't implements move semantics - BOOST_THREAD_RV(rhs).future_.reset(); - BOOST_THREAD_RV(rhs).future_obtained=false; - } - - promise & operator=(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT - { - future_=BOOST_THREAD_RV(rhs).future_; - future_obtained=BOOST_THREAD_RV(rhs).future_obtained; - BOOST_THREAD_RV(rhs).future_.reset(); - BOOST_THREAD_RV(rhs).future_obtained=false; - return *this; - } - - void swap(promise& other) - { - future_.swap(other.future_); - std::swap(future_obtained,other.future_obtained); - } - - // Result retrieval - BOOST_THREAD_FUTURE get_future() - { - lazy_init(); - - if (future_.get()==0) - { - boost::throw_exception(promise_moved()); - } - if(future_obtained) - { - boost::throw_exception(future_already_retrieved()); - } - future_obtained=true; - //return BOOST_THREAD_MAKE_RV_REF(BOOST_THREAD_FUTURE(future_)); - return BOOST_THREAD_FUTURE(future_); - } - - void set_value() - { - lazy_init(); - boost::unique_lock lock(future_->mutex); - if(future_->done) - { - boost::throw_exception(promise_already_satisfied()); - } - future_->mark_finished_with_result_internal(lock); - } - - void set_exception(boost::exception_ptr p) - { - lazy_init(); - boost::unique_lock lock(future_->mutex); - if(future_->done) - { - boost::throw_exception(promise_already_satisfied()); - } - future_->mark_exceptional_finish_internal(p,lock); - } - template - void set_exception(E ex) - { - set_exception(boost::copy_exception(ex)); - } - - // setting the result with deferred notification - void set_value_at_thread_exit() - { - if (future_.get()==0) - { - boost::throw_exception(promise_moved()); - } - future_->set_value_at_thread_exit(); - } - - void set_exception_at_thread_exit(exception_ptr e) - { - if (future_.get()==0) - { - boost::throw_exception(promise_moved()); - } - future_->set_exception_at_thread_exit(e); - } - template - void set_exception_at_thread_exit(E ex) - { - set_exception_at_thread_exit(boost::copy_exception(ex)); - } - - template - void set_wait_callback(F f) - { - lazy_init(); - future_->set_wait_callback(f,this); - } - - }; -} -#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS -namespace boost { namespace container { - template - struct uses_allocator< ::boost::promise , Alloc> : true_type - { - }; -}} -#if ! defined BOOST_NO_CXX11_ALLOCATOR -namespace std { - template - struct uses_allocator< ::boost::promise , Alloc> : true_type - { - }; -} -#endif -#endif - -namespace boost -{ - - BOOST_THREAD_DCL_MOVABLE_BEG(T) promise BOOST_THREAD_DCL_MOVABLE_END - - namespace detail - { -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - template - struct task_base_shared_state; -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - template - struct task_base_shared_state: -#else - template - struct task_base_shared_state: -#endif -#else - template - struct task_base_shared_state: -#endif - detail::shared_state - { - bool started; - - task_base_shared_state(): - started(false) - {} - - void reset() - { - // todo The packaged_task::reset must be as if an assignemnt froma new packaged_task with the same function - // the reset function is an optimization that avoids reallocating a new task. - started=false; - this->validate(); - } -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - virtual void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args)=0; - void run(BOOST_THREAD_RV_REF(ArgTypes) ... args) -#else - virtual void do_run()=0; - void run() -#endif - { - { - boost::lock_guard lk(this->mutex); - if(started) - { - boost::throw_exception(task_already_started()); - } - started=true; - } -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - do_run(boost::move(args)...); -#else - do_run(); -#endif - } - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - virtual void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)=0; - void apply(BOOST_THREAD_RV_REF(ArgTypes) ... args) -#else - virtual void do_apply()=0; - void apply() -#endif - { - { - boost::lock_guard lk(this->mutex); - if(started) - { - boost::throw_exception(task_already_started()); - } - started=true; - } -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - do_apply(boost::move(args)...); -#else - do_apply(); -#endif - } - - void owner_destroyed() - { - boost::unique_lock lk(this->mutex); - if(!started) - { - started=true; - this->mark_exceptional_finish_internal(boost::copy_exception(boost::broken_promise()), lk); - } - } - }; - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - template - struct task_shared_state; -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - template - struct task_shared_state: - task_base_shared_state -#else - template - struct task_shared_state: - task_base_shared_state -#endif -#else - template - struct task_shared_state: - task_base_shared_state -#endif - { - private: - task_shared_state(task_shared_state&); - public: - F f; - task_shared_state(F const& f_): - f(f_) - {} - task_shared_state(BOOST_THREAD_RV_REF(F) f_): - f(boost::move(f_)) - {} - - F callable() - { - return boost::move(f); - } - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args) - { - try - { - this->set_value_at_thread_exit(f(boost::move(args)...)); - } -#else - void do_apply() - { - try - { - this->set_value_at_thread_exit(f()); - } -#endif - catch(...) - { - this->set_exception_at_thread_exit(current_exception()); - } - } - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args) - { - try - { - this->mark_finished_with_result(f(boost::move(args)...)); - } -#else - void do_run() - { - try - { -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - R res((f())); - this->mark_finished_with_result(boost::move(res)); -#else - this->mark_finished_with_result(f()); -#endif - } -#endif - catch(...) - { - this->mark_exceptional_finish(); - } - } - }; - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - template - struct task_shared_state: - task_base_shared_state -#else - template - struct task_shared_state: - task_base_shared_state -#endif -#else - template - struct task_shared_state: - task_base_shared_state -#endif - { - private: - task_shared_state(task_shared_state&); - public: - F f; - task_shared_state(F const& f_): - f(f_) - {} - task_shared_state(BOOST_THREAD_RV_REF(F) f_): - f(boost::move(f_)) - {} - - F callable() - { - return f; - } - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args) - { - try - { - this->set_value_at_thread_exit(f(boost::move(args)...)); - } -#else - void do_apply() - { - try - { - this->set_value_at_thread_exit(f()); - } -#endif - catch(...) - { - this->set_exception_at_thread_exit(current_exception()); - } - } - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args) - { - try - { - this->mark_finished_with_result(f(boost::move(args)...)); - } -#else - void do_run() - { - try - { - R& res((f())); - this->mark_finished_with_result(res); - } -#endif - catch(...) - { - this->mark_exceptional_finish(); - } - } - }; - -#if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR) - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - template - struct task_shared_state: - task_base_shared_state -#else - template - struct task_shared_state: - task_base_shared_state -#endif -#else - template - struct task_shared_state : - task_base_shared_state -#endif - { - private: - task_shared_state(task_shared_state&); -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - typedef R (*CallableType)(ArgTypes ... ); -#else - typedef R (*CallableType)(); -#endif - public: - CallableType f; - task_shared_state(CallableType f_): - f(f_) - {} - - CallableType callable() - { - return f; - } - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args) - { - try - { - this->set_value_at_thread_exit(f(boost::move(args)...)); - } -#else - void do_apply() - { - try - { - R r((f())); - this->set_value_at_thread_exit(boost::move(r)); - } -#endif - catch(...) - { - this->set_exception_at_thread_exit(current_exception()); - } - } - - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args) - { - try - { - this->mark_finished_with_result(f(boost::move(args)...)); - } -#else - void do_run() - { - try - { - R res((f())); - this->mark_finished_with_result(boost::move(res)); - } -#endif - catch(...) - { - this->mark_exceptional_finish(); - } - } - }; -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - template - struct task_shared_state: - task_base_shared_state -#else - template - struct task_shared_state: - task_base_shared_state -#endif -#else - template - struct task_shared_state : - task_base_shared_state -#endif - { - private: - task_shared_state(task_shared_state&); - public: -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - typedef R& (*CallableType)(BOOST_THREAD_RV_REF(ArgTypes) ... ); -#else - typedef R& (*CallableType)(); -#endif - CallableType f; - task_shared_state(CallableType f_): - f(f_) - {} - - CallableType callable() - { - return boost::move(f); - } - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args) - { - try - { - this->set_value_at_thread_exit(f(boost::move(args)...)); - } -#else - void do_apply() - { - try - { - this->set_value_at_thread_exit(f()); - } -#endif - catch(...) - { - this->set_exception_at_thread_exit(current_exception()); - } - } - - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args) - { - try - { - this->mark_finished_with_result(f(boost::move(args)...)); - } -#else - void do_run() - { - try - { - this->mark_finished_with_result(f()); - } -#endif - catch(...) - { - this->mark_exceptional_finish(); - } - } - }; -#endif -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - template - struct task_shared_state: - task_base_shared_state -#else - template - struct task_shared_state: - task_base_shared_state -#endif -#else - template - struct task_shared_state: - task_base_shared_state -#endif - { - private: - task_shared_state(task_shared_state&); - public: - typedef F CallableType; - F f; - task_shared_state(F const& f_): - f(f_) - {} - task_shared_state(BOOST_THREAD_RV_REF(F) f_): - f(boost::move(f_)) - {} - F callable() - { - return boost::move(f); - } -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args) - { - try - { - f(boost::move(args)...); -#else - void do_apply() - { - try - { - f(); -#endif - this->set_value_at_thread_exit(); - } - catch(...) - { - this->set_exception_at_thread_exit(current_exception()); - } - } - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args) - { - try - { - f(boost::move(args)...); -#else - void do_run() - { - try - { - f(); -#endif - this->mark_finished_with_result(); - } - catch(...) - { - this->mark_exceptional_finish(); - } - } - }; - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - template - struct task_shared_state: - task_base_shared_state -#else - template<> - struct task_shared_state: - task_base_shared_state -#endif -#else - template<> - struct task_shared_state: - task_base_shared_state -#endif - { - private: - task_shared_state(task_shared_state&); -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - typedef void (*CallableType)(ArgTypes...); -#else - typedef void (*CallableType)(); -#endif - public: - CallableType f; - task_shared_state(CallableType f_): - f(f_) - {} - CallableType callable() - { - return f; - } -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args) - { - try - { - f(boost::move(args)...); -#else - void do_apply() - { - try - { - f(); -#endif - this->set_value_at_thread_exit(); - } - catch(...) - { - this->set_exception_at_thread_exit(current_exception()); - } - } - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args) - { - try - { - f(boost::move(args)...); -#else - void do_run() - { - try - { - f(); -#endif - this->mark_finished_with_result(); - } - catch(...) - { - this->mark_exceptional_finish(); - } - } - }; - } - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - template - class packaged_task - { - typedef boost::shared_ptr > task_ptr; - boost::shared_ptr > task; - #else - template - class packaged_task - { - typedef boost::shared_ptr > task_ptr; - boost::shared_ptr > task; - #endif -#else - template - class packaged_task - { - typedef boost::shared_ptr > task_ptr; - boost::shared_ptr > task; -#endif - bool future_obtained; - struct dummy; - - public: - typedef R result_type; - BOOST_THREAD_MOVABLE_ONLY(packaged_task) - - packaged_task(): - future_obtained(false) - {} - - // construction and destruction -#if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR) - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - explicit packaged_task(R(*f)(), BOOST_THREAD_FWD_REF(ArgTypes)... args) - { - typedef R(*FR)(BOOST_THREAD_FWD_REF(ArgTypes)...); - typedef detail::task_shared_state task_shared_state_type; - task= task_ptr(new task_shared_state_type(f, boost::move(args)...)); - future_obtained=false; - } - #else - explicit packaged_task(R(*f)()) - { - typedef R(*FR)(); - typedef detail::task_shared_state task_shared_state_type; - task= task_ptr(new task_shared_state_type(f)); - future_obtained=false; - } - #endif -#else - explicit packaged_task(R(*f)()) - { - typedef R(*FR)(); - typedef detail::task_shared_state task_shared_state_type; - task= task_ptr(new task_shared_state_type(f)); - future_obtained=false; - } -#endif -#endif -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template - explicit packaged_task(BOOST_THREAD_FWD_REF(F) f - , typename boost::disable_if::type, packaged_task>, dummy* >::type=0 - ) - { - typedef typename decay::type FR; -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - typedef detail::task_shared_state task_shared_state_type; - #else - typedef detail::task_shared_state task_shared_state_type; - #endif -#else - typedef detail::task_shared_state task_shared_state_type; -#endif - task = task_ptr(new task_shared_state_type(boost::forward(f))); - future_obtained = false; - - } - -#else - template - explicit packaged_task(F const& f - , typename boost::disable_if::type, packaged_task>, dummy* >::type=0 - ) - { -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - typedef detail::task_shared_state task_shared_state_type; - #else - typedef detail::task_shared_state task_shared_state_type; - #endif -#else - typedef detail::task_shared_state task_shared_state_type; -#endif - task = task_ptr(new task_shared_state_type(f)); - future_obtained=false; - } - template - explicit packaged_task(BOOST_THREAD_RV_REF(F) f) - { -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - typedef detail::task_shared_state task_shared_state_type; - task = task_ptr(new task_shared_state_type(boost::move(f))); -#else - typedef detail::task_shared_state task_shared_state_type; - task = task_ptr(new task_shared_state_type(boost::move(f))); -#endif -#else - typedef detail::task_shared_state task_shared_state_type; - task = task_ptr(new task_shared_state_type(boost::move(f))); -#endif - future_obtained=false; - - } -#endif - -#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS -#if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR) - template - packaged_task(boost::allocator_arg_t, Allocator a, R(*f)()) - { - typedef R(*FR)(); -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - typedef detail::task_shared_state task_shared_state_type; - #else - typedef detail::task_shared_state task_shared_state_type; - #endif -#else - typedef detail::task_shared_state task_shared_state_type; -#endif - typedef typename Allocator::template rebind::other A2; - A2 a2(a); - typedef thread_detail::allocator_destructor D; - - task = task_ptr(::new(a2.allocate(1)) task_shared_state_type(f), D(a2, 1) ); - future_obtained = false; - } -#endif // BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR - -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - template - packaged_task(boost::allocator_arg_t, Allocator a, BOOST_THREAD_FWD_REF(F) f) - { - typedef typename decay::type FR; - -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - typedef detail::task_shared_state task_shared_state_type; - #else - typedef detail::task_shared_state task_shared_state_type; - #endif -#else - typedef detail::task_shared_state task_shared_state_type; -#endif - typedef typename Allocator::template rebind::other A2; - A2 a2(a); - typedef thread_detail::allocator_destructor D; - - task = task_ptr(::new(a2.allocate(1)) task_shared_state_type(boost::forward(f)), D(a2, 1) ); - future_obtained = false; - } -#else // ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - template - packaged_task(boost::allocator_arg_t, Allocator a, const F& f) - { -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - typedef detail::task_shared_state task_shared_state_type; - #else - typedef detail::task_shared_state task_shared_state_type; - #endif -#else - typedef detail::task_shared_state task_shared_state_type; -#endif - typedef typename Allocator::template rebind::other A2; - A2 a2(a); - typedef thread_detail::allocator_destructor D; - - task = task_ptr(::new(a2.allocate(1)) task_shared_state_type(f), D(a2, 1) ); - future_obtained = false; - } - template - packaged_task(boost::allocator_arg_t, Allocator a, BOOST_THREAD_RV_REF(F) f) - { -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - typedef detail::task_shared_state task_shared_state_type; - #else - typedef detail::task_shared_state task_shared_state_type; - #endif -#else - typedef detail::task_shared_state task_shared_state_type; -#endif - typedef typename Allocator::template rebind::other A2; - A2 a2(a); - typedef thread_detail::allocator_destructor D; - - task = task_ptr(::new(a2.allocate(1)) task_shared_state_type(boost::move(f)), D(a2, 1) ); - future_obtained = false; - } - -#endif //BOOST_NO_CXX11_RVALUE_REFERENCES -#endif // BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS - - ~packaged_task() { - if(task) { - task->owner_destroyed(); - } - } - - // assignment - packaged_task(BOOST_THREAD_RV_REF(packaged_task) other) BOOST_NOEXCEPT - : future_obtained(BOOST_THREAD_RV(other).future_obtained) { - task.swap(BOOST_THREAD_RV(other).task); - BOOST_THREAD_RV(other).future_obtained=false; - } - packaged_task& operator=(BOOST_THREAD_RV_REF(packaged_task) other) BOOST_NOEXCEPT { - -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES - packaged_task temp(boost::move(other)); -#else - packaged_task temp(static_cast(other)); -#endif - swap(temp); - return *this; - } - -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - void set_executor(executor_ptr_type aex) - { - if (!valid()) - boost::throw_exception(task_moved()); - boost::lock_guard lk(task->mutex); - task->set_executor_policy(aex, lk); - } -#endif - void reset() { - if (!valid()) - boost::throw_exception(future_error(system::make_error_code(future_errc::no_state))); - - // As if *this = packaged_task(task->callable()); - - task->reset(); - future_obtained=false; - } - - void swap(packaged_task& other) BOOST_NOEXCEPT { - task.swap(other.task); - std::swap(future_obtained,other.future_obtained); - } - bool valid() const BOOST_NOEXCEPT { - return task.get()!=0; - } - - // result retrieval - BOOST_THREAD_FUTURE get_future() { - if(!task) { - boost::throw_exception(task_moved()); - } else if(!future_obtained) { - future_obtained=true; - return BOOST_THREAD_FUTURE(task); - } else { - boost::throw_exception(future_already_retrieved()); - } - } - - // execution -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - void operator()(ArgTypes... args) { - if(!task) { - boost::throw_exception(task_moved()); - } - task->run(boost::move(args)...); - } - void make_ready_at_thread_exit(ArgTypes... args) { - if(!task) { - boost::throw_exception(task_moved()); - } - if (task->has_value()) { - boost::throw_exception(promise_already_satisfied()); - } - task->apply(boost::move(args)...); - } -#else - void operator()() { - if(!task) { - boost::throw_exception(task_moved()); - } - task->run(); - } - void make_ready_at_thread_exit() { - if(!task) { - boost::throw_exception(task_moved()); - } - if (task->has_value()) boost::throw_exception(promise_already_satisfied()); - task->apply(); - } -#endif - template - void set_wait_callback(F f) { - task->set_wait_callback(f,this); - } - }; -} -#if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS -namespace boost { namespace container { - template - struct uses_allocator< ::boost::packaged_task , Alloc> : true_type - {}; -}} -#if ! defined BOOST_NO_CXX11_ALLOCATOR -namespace std { - template - struct uses_allocator< ::boost::packaged_task , Alloc> : true_type - {}; -} -#endif -#endif - -namespace boost -{ - BOOST_THREAD_DCL_MOVABLE_BEG(T) packaged_task BOOST_THREAD_DCL_MOVABLE_END - -namespace detail -{ - //////////////////////////////// - // make_future_deferred_shared_state - //////////////////////////////// - template - BOOST_THREAD_FUTURE - make_future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f) { - shared_ptr > - h(new future_deferred_shared_state(boost::forward(f))); - return BOOST_THREAD_FUTURE(h); - } - - //////////////////////////////// - // make_future_async_shared_state - //////////////////////////////// - template - BOOST_THREAD_FUTURE - make_future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f) { - shared_ptr > - h(new future_async_shared_state()); - h->init(boost::forward(f)); - return BOOST_THREAD_FUTURE(h); - } -} - - //////////////////////////////// - // template - // future async(launch policy, F&&, ArgTypes&&...); - //////////////////////////////// - -#if defined BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR - -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - template - BOOST_THREAD_FUTURE - async(launch policy, R(*f)(BOOST_THREAD_FWD_REF(ArgTypes)...), BOOST_THREAD_FWD_REF(ArgTypes)... args) { - typedef R(*F)(BOOST_THREAD_FWD_REF(ArgTypes)...); - typedef detail::invoker::type, typename decay::type...> BF; - typedef typename BF::result_type Rp; - - if (underlying_cast(policy) & int(launch::async)) { - return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_async_shared_state( - BF( - f - , thread_detail::decay_copy(boost::forward(args))... - ) - )); - } else if (underlying_cast(policy) & int(launch::deferred)) { - return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_deferred_shared_state( - BF( - f - , thread_detail::decay_copy(boost::forward(args))... - ) - )); - } else { - std::terminate(); - //BOOST_THREAD_FUTURE ret; - //return ::boost::move(ret); - } - } - -#else // defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - - template - BOOST_THREAD_FUTURE - async(launch policy, R(*f)()) { - #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - typedef packaged_task packaged_task_type; - #else - typedef packaged_task packaged_task_type; - #endif - - if (underlying_cast(policy) & int(launch::async)) { - packaged_task_type pt( f ); - BOOST_THREAD_FUTURE ret = BOOST_THREAD_MAKE_RV_REF(pt.get_future()); - ret.set_async(); - boost::thread( boost::move(pt) ).detach(); - return ::boost::move(ret); - } else if (underlying_cast(policy) & int(launch::deferred)) { - std::terminate(); - //BOOST_THREAD_FUTURE ret; - //return ::boost::move(ret); - } else { - std::terminate(); - //BOOST_THREAD_FUTURE ret; - //return ::boost::move(ret); - } - } -#endif -#endif // defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR) - -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - - template - BOOST_THREAD_FUTURE::type( - typename decay::type... - )>::type> - async(launch policy, BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(ArgTypes)... args) { - typedef detail::invoker::type, typename decay::type...> BF; - typedef typename BF::result_type Rp; - - if (underlying_cast(policy) & int(launch::async)) { - return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_async_shared_state( - BF( - thread_detail::decay_copy(boost::forward(f)) - , thread_detail::decay_copy(boost::forward(args))... - ) - )); - } else if (underlying_cast(policy) & int(launch::deferred)) { - return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_deferred_shared_state( - BF( - thread_detail::decay_copy(boost::forward(f)) - , thread_detail::decay_copy(boost::forward(args))... - ) - )); - } else { - std::terminate(); - //BOOST_THREAD_FUTURE ret; - //return ::boost::move(ret); - } - } - -#else // defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - - template - BOOST_THREAD_FUTURE::type()>::type> - async(launch policy, BOOST_THREAD_FWD_REF(F) f) { - typedef typename boost::result_of::type()>::type R; -#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - typedef packaged_task packaged_task_type; -#else // defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - typedef packaged_task packaged_task_type; -#endif // defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK - - if (underlying_cast(policy) & int(launch::async)) { - packaged_task_type pt( boost::forward(f) ); - BOOST_THREAD_FUTURE ret = pt.get_future(); - ret.set_async(); - boost::thread( boost::move(pt) ).detach(); - return ::boost::move(ret); - } else if (underlying_cast(policy) & int(launch::deferred)) { - std::terminate(); - //BOOST_THREAD_FUTURE ret; - //return ::boost::move(ret); - // return boost::detail::make_future_deferred_shared_state( - // BF( - // thread_detail::decay_copy(boost::forward(f)) - // ) - // ); - } else { - std::terminate(); - //BOOST_THREAD_FUTURE ret; - //return ::boost::move(ret); - } - } -#endif // defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS -namespace detail { - - ///////////////////////// - /// shared_state_nullary_task - ///////////////////////// - template - struct shared_state_nullary_task - { - - typedef shared_ptr storage_type; - storage_type that; - Fp f_; - public: - - shared_state_nullary_task(storage_type st, BOOST_THREAD_FWD_REF(Fp) f) - : that(st), f_(boost::move(f)) - {}; - -#if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - BOOST_THREAD_COPYABLE_AND_MOVABLE(shared_state_nullary_task) - shared_state_nullary_task(shared_state_nullary_task const& x) //BOOST_NOEXCEPT - : that(x.that), f_(x.f_) - {} - shared_state_nullary_task& operator=(BOOST_THREAD_COPY_ASSIGN_REF(shared_state_nullary_task) x) //BOOST_NOEXCEPT - { - if (this != &x) { - that=x.that; - f_=x.f_; - } - return *this; - } - // move - shared_state_nullary_task(BOOST_THREAD_RV_REF(shared_state_nullary_task) x) //BOOST_NOEXCEPT - : that(x.that), f_(boost::move(x.f_)) - { - x.that.reset(); - } - shared_state_nullary_task& operator=(BOOST_THREAD_RV_REF(shared_state_nullary_task) x) //BOOST_NOEXCEPT - { - if (this != &x) { - that=x.that; - f_=boost::move(x.f_); - x.that.reset(); - } - return *this; - } -#endif - void operator()() { - shared_ptr > that_ = static_pointer_cast >(that); - try { - that_->mark_finished_with_result(f_()); - } catch(...) { - that_->mark_exceptional_finish(); - } - } - ~shared_state_nullary_task() - { - } - }; - - template - struct shared_state_nullary_task - { - typedef shared_ptr storage_type; - storage_type that; - Fp f_; - public: - shared_state_nullary_task(storage_type st, BOOST_THREAD_FWD_REF(Fp) f) - : that(st), f_(boost::move(f)) - {}; - -#if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - BOOST_THREAD_COPYABLE_AND_MOVABLE(shared_state_nullary_task) - shared_state_nullary_task(shared_state_nullary_task const& x) //BOOST_NOEXCEPT - : that(x.that), f_(x.f_) - {} - shared_state_nullary_task& operator=(BOOST_THREAD_COPY_ASSIGN_REF(shared_state_nullary_task) x) //BOOST_NOEXCEPT - { - if (this != &x) { - that=x.that; - f_=x.f_; - } - return *this; - } - // move - shared_state_nullary_task(BOOST_THREAD_RV_REF(shared_state_nullary_task) x) BOOST_NOEXCEPT - : that(x.that), f_(boost::move(x.f_)) - { - x.that.reset(); - } - shared_state_nullary_task& operator=(BOOST_THREAD_RV_REF(shared_state_nullary_task) x) BOOST_NOEXCEPT { - if (this != &x) { - that=x.that; - f_=boost::move(x.f_); - x.that.reset(); - } - return *this; - } -#endif - void operator()() { - shared_ptr > that_ = static_pointer_cast >(that); - try { - f_(); - that_->mark_finished_with_result(); - } catch(...) { - that_->mark_exceptional_finish(); - } - } - }; - -} - BOOST_THREAD_DCL_MOVABLE_BEG2(R,F) detail::shared_state_nullary_task BOOST_THREAD_DCL_MOVABLE_END -namespace detail { - - ///////////////////////// - /// future_executor_shared_state_base - ///////////////////////// - template - struct future_executor_shared_state: shared_state - { - typedef shared_state base_type; - protected: - public: - future_executor_shared_state() { - } - - template - void init(Executor& ex, BOOST_THREAD_FWD_REF(Fp) f) - { - typedef typename decay::type Cont; - this->set_executor_policy(executor_ptr_type(new executor_ref(ex))); - shared_state_nullary_task t(this->shared_from_this(), boost::forward(f)); - ex.submit(boost::move(t)); - } - - ~future_executor_shared_state() {} - }; - - //////////////////////////////// - // make_future_executor_shared_state - //////////////////////////////// - template - BOOST_THREAD_FUTURE - make_future_executor_shared_state(Executor& ex, BOOST_THREAD_FWD_REF(Fp) f) { - shared_ptr > - h(new future_executor_shared_state()); - h->init(ex, boost::forward(f)); - return BOOST_THREAD_FUTURE(h); - } - -} // detail - - //////////////////////////////// - // template - // future async(Executor& ex, F&&, ArgTypes&&...); - //////////////////////////////// - -//#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) -#if defined(BOOST_THREAD_PROVIDES_INVOKE) && ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && ! defined(BOOST_NO_CXX11_HDR_TUPLE) - -#if defined BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR - - template - BOOST_THREAD_FUTURE - async(Executor& ex, R(*f)(BOOST_THREAD_FWD_REF(ArgTypes)...), BOOST_THREAD_FWD_REF(ArgTypes)... args) { - typedef R(*F)(BOOST_THREAD_FWD_REF(ArgTypes)...); - typedef detail::invoker::type, typename decay::type...> BF; - typedef typename BF::result_type Rp; - - return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_executor_shared_state(ex, - BF( - f - , thread_detail::decay_copy(boost::forward(args))... - ) - )); - } -#endif // defined BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR - - template - BOOST_THREAD_FUTURE::type( - typename decay::type... - )>::type> - async(Executor& ex, BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(ArgTypes)... args) { - typedef detail::invoker::type, typename decay::type...> BF; - typedef typename BF::result_type Rp; - - return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_executor_shared_state(ex, - BF( - thread_detail::decay_copy(boost::forward(f)) - , thread_detail::decay_copy(boost::forward(args))... - ) - )); - } - -#else // ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) -#if defined BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR - - template - BOOST_THREAD_FUTURE - async(Executor& ex, R(*f)()) { - typedef R(*F)(); - typedef detail::invoker BF; - typedef typename BF::result_type Rp; - - return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_executor_shared_state(ex, - BF( - f - ) - )); - } - - template - BOOST_THREAD_FUTURE - async(Executor& ex, R(*f)(BOOST_THREAD_FWD_REF(A1)), BOOST_THREAD_FWD_REF(A1) a1) { - typedef R(*F)(BOOST_THREAD_FWD_REF(A1)); - typedef detail::invoker::type> BF; - typedef typename BF::result_type Rp; - - return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_executor_shared_state(ex, - BF( - f - , thread_detail::decay_copy(boost::forward(a1)) - ) - )); - } -#endif // defined BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR - - template - BOOST_THREAD_FUTURE::type()>::type> - async(Executor& ex, BOOST_THREAD_FWD_REF(F) f) { - typedef detail::invoker::type> BF; - typedef typename BF::result_type Rp; - - return boost::detail::make_future_executor_shared_state(ex, - BF( - thread_detail::decay_copy(boost::forward(f)) - ) - ); - } - - template - BOOST_THREAD_FUTURE::type( - typename decay::type - )>::type> - async(Executor& ex, BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1) { - typedef detail::invoker::type, typename decay::type> BF; - typedef typename BF::result_type Rp; - - return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_executor_shared_state(ex, - BF( - thread_detail::decay_copy(boost::forward(f)) - , thread_detail::decay_copy(boost::forward(a1)) - ) - )); - } - - template - BOOST_THREAD_FUTURE::type( - typename decay::type, typename decay::type - )>::type> - async(Executor& ex, BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1, BOOST_THREAD_FWD_REF(A2) a2) { - typedef detail::invoker::type, typename decay::type, typename decay::type> BF; - typedef typename BF::result_type Rp; - - return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_executor_shared_state(ex, - BF( - thread_detail::decay_copy(boost::forward(f)) - , thread_detail::decay_copy(boost::forward(a1)) - , thread_detail::decay_copy(boost::forward(a2)) - ) - )); - } - -#endif //! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) -#endif - - //////////////////////////////// - // template - // future async(F&&, ArgTypes&&...); - //////////////////////////////// - -#if defined BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR - #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - template - BOOST_THREAD_FUTURE - async(R(*f)(BOOST_THREAD_FWD_REF(ArgTypes)...), BOOST_THREAD_FWD_REF(ArgTypes)... args) { - return BOOST_THREAD_MAKE_RV_REF(async(launch(launch::any), f, boost::forward(args)...)); - } - #else - template - BOOST_THREAD_FUTURE - async(R(*f)()) { - return BOOST_THREAD_MAKE_RV_REF(async(launch(launch::any), f)); - } - #endif -#endif - -#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) - template - BOOST_THREAD_FUTURE::type( - typename decay::type... - )>::type> - async(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(ArgTypes)... args) { - return BOOST_THREAD_MAKE_RV_REF(async(launch(launch::any), boost::forward(f), boost::forward(args)...)); - } -#else - template - BOOST_THREAD_FUTURE::type> - async(BOOST_THREAD_FWD_REF(F) f) { - return BOOST_THREAD_MAKE_RV_REF(async(launch(launch::any), boost::forward(f))); - } -#endif - - //////////////////////////////// - // make_future deprecated - //////////////////////////////// - template - BOOST_THREAD_FUTURE::type> make_future(BOOST_THREAD_FWD_REF(T) value) { - typedef typename decay::type future_value_type; - promise p; - p.set_value(boost::forward(value)); - return BOOST_THREAD_MAKE_RV_REF(p.get_future()); - } - -#if defined BOOST_THREAD_USES_MOVE - inline BOOST_THREAD_FUTURE make_future() { - promise p; - p.set_value(); - return BOOST_THREAD_MAKE_RV_REF(p.get_future()); - } -#endif - - //////////////////////////////// - // make_ready_future - //////////////////////////////// - namespace detail { - template - struct deduced_type_impl - { - typedef T type; - }; - - template - struct deduced_type_impl const> - { - typedef T& type; - }; - template - struct deduced_type_impl > - { - typedef T& type; - }; -#if __cplusplus > 201103L - template - struct deduced_type_impl > - { - typedef T& type; - }; -#endif - template - struct deduced_type - { - typedef typename detail::deduced_type_impl::type>::type type; - }; - - } - - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template -#else - template -#endif - BOOST_THREAD_FUTURE::type> make_ready_future(BOOST_THREAD_FWD_REF(T) value) { - typedef typename detail::deduced_type::type future_value_type; - promise p; - p.set_value(boost::forward(value)); - return BOOST_THREAD_MAKE_RV_REF(p.get_future()); - } - - // explicit overloads - template - BOOST_THREAD_FUTURE make_ready_future(typename remove_reference::type & x) - { - promise p; - p.set_value(x); - return p.get_future(); - } - - template - BOOST_THREAD_FUTURE make_ready_future(BOOST_THREAD_FWD_REF(typename remove_reference::type) x) - { - promise p; - p.set_value(forward::type>(x)); - return p.get_future(); - } - - // variadic overload -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template - BOOST_THREAD_FUTURE make_ready_future(Args&&... args) - { - promise p; - p.emplace(forward(args)...); - return p.get_future(); - - } -#endif - - template - BOOST_THREAD_FUTURE make_ready_no_decay_future(T1 value) { - typedef T future_value_type; - promise p; - p.set_value(value); - return BOOST_THREAD_MAKE_RV_REF(p.get_future()); - } - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined BOOST_THREAD_USES_MOVE - inline BOOST_THREAD_FUTURE make_ready_future() { - promise p; - p.set_value(); - return p.get_future(); - } -#endif - - - template - BOOST_THREAD_FUTURE make_exceptional_future(exception_ptr ex) { - promise p; - p.set_exception(ex); - return BOOST_THREAD_MAKE_RV_REF(p.get_future()); - } - - template - BOOST_THREAD_FUTURE make_exceptional_future(E ex) { - promise p; - p.set_exception(boost::copy_exception(ex)); - return BOOST_THREAD_MAKE_RV_REF(p.get_future()); - } - - template - BOOST_THREAD_FUTURE make_exceptional_future() { - promise p; - p.set_exception(boost::current_exception()); - return BOOST_THREAD_MAKE_RV_REF(p.get_future()); - } - template - BOOST_THREAD_FUTURE make_ready_future(exception_ptr ex) { - return make_exceptional_future(ex); - } - -#if 0 - template - make_future(CLOSURE closure) -> BOOST_THREAD_FUTURE { - typedef decltype(closure()) T; - promise p; - try { - p.set_value(closure()); - } catch(...) { - p.set_exception(std::current_exception()); - } - return BOOST_THREAD_MAKE_RV_REF(p.get_future()); - } -#endif - - //////////////////////////////// - // make_shared_future deprecated - //////////////////////////////// - template - shared_future::type> make_shared_future(BOOST_THREAD_FWD_REF(T) value) { - typedef typename decay::type future_type; - promise p; - p.set_value(boost::forward(value)); - return BOOST_THREAD_MAKE_RV_REF(p.get_future().share()); - } - - inline shared_future make_shared_future() { - promise p; - return BOOST_THREAD_MAKE_RV_REF(p.get_future().share()); - } - - //////////////////////////////// - // detail::future_async_continuation_shared_state - //////////////////////////////// -#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION - -namespace detail -{ - ////////////////////// - // detail::continuation_shared_state - ////////////////////// - template > - struct continuation_shared_state: ShSt - { - F parent; - Fp continuation; - - public: - continuation_shared_state(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c) - : parent(boost::move(f)), - continuation(boost::move(c)) - { - } - - void init(boost::unique_lock &lock) - { - parent.future_->set_continuation_ptr(this->shared_from_this(), lock); - } - - void call() { - try { - this->mark_finished_with_result(this->continuation(boost::move(this->parent))); - } catch(...) { - this->mark_exceptional_finish(); - } - // make sure parent is really cleared to prevent memory "leaks" - this->parent = F(); - } - - void call(boost::unique_lock& lck) { - try { - relocker relock(lck); - - // neither continuation nor parent are protected by the lock - call() must only - // be called once, and no one else must modify it. - Rp res = this->continuation(boost::move(this->parent)); - - // make sure parent is really cleared to prevent memory "leaks" - this->parent = F(); - - relock.lock(); - - this->mark_finished_with_result_internal(boost::move(res), lck); - } catch (...) { - this->mark_exceptional_finish_internal(current_exception(), lck); - - // make sure parent is really cleared to prevent memory "leaks" - relocker relock(lck); - this->parent = F(); - } - } - - static void run(shared_ptr that_) - { - continuation_shared_state* that = static_cast(that_.get()); - that->call(); - } - - ~continuation_shared_state() {} - }; - - template - struct continuation_shared_state: ShSt - { - F parent; - Fp continuation; - - public: - continuation_shared_state(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c) - : parent(boost::move(f)), - continuation(boost::move(c)) - { - } - - void init(boost::unique_lock &lock) - { - parent.future_->set_continuation_ptr(this->shared_from_this(), lock); - } - - void call() - { - try { - this->continuation(boost::move(this->parent)); - this->mark_finished_with_result(); - } catch(...) { - this->mark_exceptional_finish(); - } - // make sure parent is really cleared to prevent memory "leaks" - this->parent = F(); - } - - void call(boost::unique_lock& lck) { - try { - { - relocker relock(lck); - // neither continuation nor parent are protected by the lock - call() must only - // be called once, and no one else must modify it. - this->continuation(boost::move(this->parent)); - - // make sure parent is really cleared to prevent memory "leaks" - this->parent = F(); - } - this->mark_finished_with_result_internal(lck); - } catch (...) { - this->mark_exceptional_finish_internal(current_exception(), lck); - - // make sure parent is really cleared to prevent memory "leaks" - relocker relock(lck); - this->parent = F(); - } - } - - static void run(shared_ptr that_) - { - continuation_shared_state* that = static_cast(that_.get()); - that->call(); - } - - ~continuation_shared_state() {} - }; - ///////////////////////// - /// future_async_continuation_shared_state - ///////////////////////// - - template - struct future_async_continuation_shared_state: continuation_shared_state > - { - typedef continuation_shared_state > base_type; - public: - future_async_continuation_shared_state(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c) - : base_type(boost::move(f), boost::forward(c)) - { } - - void launch_continuation() { -#if defined BOOST_THREAD_FUTURE_BLOCKING - boost::lock_guard lk(this->mutex); - this->thr_ = boost::thread(&future_async_continuation_shared_state::run, static_shared_from_this(this)); -#else - boost::thread(&base_type::run, static_shared_from_this(this)).detach(); -#endif - } - }; - - ///////////////////////// - /// future_sync_continuation_shared_state - ///////////////////////// - - template - struct future_sync_continuation_shared_state: continuation_shared_state > - { - typedef continuation_shared_state > base_type; - public: - future_sync_continuation_shared_state(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c) - : base_type(boost::move(f), boost::forward(c)) - { } - - void launch_continuation() { - this->call(); - } - }; - - - ///////////////////////// - /// future_executor_continuation_shared_state - ///////////////////////// -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - - template - struct run_it { - shared_ptr that_; - -#if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - BOOST_THREAD_COPYABLE_AND_MOVABLE(run_it) - run_it(run_it const& x) //BOOST_NOEXCEPT - : that_(x.that_) - {} - run_it& operator=(BOOST_THREAD_COPY_ASSIGN_REF(run_it) x) //BOOST_NOEXCEPT - { - if (this != &x) { - that_=x.that_; - } - return *this; - } - // move - run_it(BOOST_THREAD_RV_REF(run_it) x) BOOST_NOEXCEPT - : that_(x.that_) - { - x.that_.reset(); - } - run_it& operator=(BOOST_THREAD_RV_REF(run_it) x) BOOST_NOEXCEPT { - if (this != &x) { - that_=x.that; - x.that_.reset(); - } - return *this; - } -#endif - run_it(shared_ptr that) : that_ (that) {} - - void operator()() - { - that_->run(that_); - } - }; - -} - BOOST_THREAD_DCL_MOVABLE_BEG(F) detail::run_it BOOST_THREAD_DCL_MOVABLE_END - -namespace detail { - - template - struct future_executor_continuation_shared_state: continuation_shared_state - { - typedef continuation_shared_state base_type; - - public: - future_executor_continuation_shared_state(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c) - : base_type(boost::move(f), boost::forward(c)) - { - } - - template - void init(boost::unique_lock &lk, Ex& ex) - { - this->set_executor_policy(executor_ptr_type(new executor_ref(ex)), lk); - this->base_type::init(lk); - } - - void launch_continuation() { - run_it fct(static_shared_from_this(this)); - this->get_executor()->submit(boost::move(fct)); - } - - ~future_executor_continuation_shared_state() {} - }; -#endif - - ///////////////////////// - /// shared_future_async_continuation_shared_state - ///////////////////////// - - template - struct shared_future_async_continuation_shared_state: continuation_shared_state > - { - typedef continuation_shared_state > base_type; - - public: - shared_future_async_continuation_shared_state(F f, BOOST_THREAD_FWD_REF(Fp) c) - : base_type(boost::move(f), boost::forward(c)) - { - } - - void launch_continuation() { -#if defined BOOST_THREAD_FUTURE_BLOCKING - boost::lock_guard lk(this->mutex); - this->thr_ = boost::thread(&base_type::run, static_shared_from_this(this)); -#else - boost::thread(&base_type::run, static_shared_from_this(this)).detach(); -#endif - } - }; - - ///////////////////////// - /// shared_future_async_continuation_shared_state - ///////////////////////// - - template - struct shared_future_sync_continuation_shared_state: continuation_shared_state > - { - typedef continuation_shared_state > base_type; - - public: - shared_future_sync_continuation_shared_state(F f, BOOST_THREAD_FWD_REF(Fp) c) - : base_type(boost::move(f), boost::forward(c)) - { - } - - void launch_continuation() { - this->call(); - } - }; - - - ///////////////////////// - /// shared_future_executor_continuation_shared_state - ///////////////////////// -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - - template - struct shared_future_executor_continuation_shared_state: continuation_shared_state - { - typedef continuation_shared_state base_type; - - public: - - shared_future_executor_continuation_shared_state(F f, BOOST_THREAD_FWD_REF(Fp) c) - : base_type(boost::move(f), boost::forward(c)) - { - } - - template - void init(boost::unique_lock &lk, Ex& ex) - { - this->set_executor_policy(executor_ptr_type(new executor_ref(ex)), lk); - this->base_type::init(lk); - } - - void launch_continuation() { - run_it fct(static_shared_from_this(this)); - this->get_executor()->submit(boost::move(fct)); - } - - ~shared_future_executor_continuation_shared_state() {} - }; - -#endif - ////////////////////////// - /// future_deferred_continuation_shared_state - ////////////////////////// - template - struct future_deferred_continuation_shared_state: continuation_shared_state - { - typedef continuation_shared_state base_type; - public: - future_deferred_continuation_shared_state(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c) - : base_type(boost::move(f), boost::forward(c)) - { - this->set_deferred(); - } - - virtual void execute(boost::unique_lock& lk) { - this->parent.wait(); - this->call(lk); - } - - virtual void launch_continuation() { } - }; - - ////////////////////////// - /// shared_future_deferred_continuation_shared_state - ////////////////////////// - template - struct shared_future_deferred_continuation_shared_state: continuation_shared_state - { - typedef continuation_shared_state base_type; - - public: - shared_future_deferred_continuation_shared_state(F f, BOOST_THREAD_FWD_REF(Fp) c) - : base_type(boost::move(f), boost::forward(c)) - { - this->set_deferred(); - } - - virtual void execute(boost::unique_lock& lk) { - this->parent.wait(); - this->call(lk); - } - - virtual void launch_continuation() { } - }; - - //////////////////////////////// - // make_future_deferred_continuation_shared_state - //////////////////////////////// - template - BOOST_THREAD_FUTURE - make_future_deferred_continuation_shared_state( - boost::unique_lock &lock, - BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c) { - typedef typename decay::type Cont; - shared_ptr > - h(new future_deferred_continuation_shared_state(boost::move(f), boost::forward(c))); - h->init(lock); - return BOOST_THREAD_FUTURE(h); - } - - //////////////////////////////// - // make_future_async_continuation_shared_state - //////////////////////////////// - template - BOOST_THREAD_FUTURE - make_future_async_continuation_shared_state( - boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, - BOOST_THREAD_FWD_REF(Fp) c) { - typedef typename decay::type Cont; - shared_ptr > - h(new future_async_continuation_shared_state(boost::move(f), boost::forward(c))); - h->init(lock); - - return BOOST_THREAD_FUTURE(h); - } - //////////////////////////////// - // make_future_sync_continuation_shared_state - //////////////////////////////// - template - BOOST_THREAD_FUTURE - make_future_sync_continuation_shared_state( - boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, - BOOST_THREAD_FWD_REF(Fp) c) { - typedef typename decay::type Cont; - shared_ptr > - h(new future_sync_continuation_shared_state(boost::move(f), boost::forward(c))); - h->init(lock); - - return BOOST_THREAD_FUTURE(h); - } - - //////////////////////////////// - // make_future_executor_continuation_shared_state - //////////////////////////////// -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - - template - BOOST_THREAD_FUTURE - make_future_executor_continuation_shared_state(Ex& ex, - boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f, - BOOST_THREAD_FWD_REF(Fp) c) { - typedef typename decay::type Cont; - shared_ptr > - h(new future_executor_continuation_shared_state(boost::move(f), boost::forward(c))); - h->init(lock, ex); - - return BOOST_THREAD_FUTURE(h); - } -#endif - - //////////////////////////////// - // make_shared_future_deferred_continuation_shared_state - //////////////////////////////// - template - BOOST_THREAD_FUTURE - make_shared_future_deferred_continuation_shared_state( - boost::unique_lock &lock, - F f, BOOST_THREAD_FWD_REF(Fp) c) { - typedef typename decay::type Cont; - shared_ptr > - h(new shared_future_deferred_continuation_shared_state(f, boost::forward(c))); - h->init(lock); - - return BOOST_THREAD_FUTURE(h); - } - //////////////////////////////// - // make_shared_future_async_continuation_shared_state - //////////////////////////////// - template - BOOST_THREAD_FUTURE - make_shared_future_async_continuation_shared_state( - boost::unique_lock &lock, F f, - BOOST_THREAD_FWD_REF(Fp) c) { - typedef typename decay::type Cont; - shared_ptr > - h(new shared_future_async_continuation_shared_state(f, boost::forward(c))); - h->init(lock); - - return BOOST_THREAD_FUTURE(h); - } - //////////////////////////////// - // make_shared_future_sync_continuation_shared_state - //////////////////////////////// - template - BOOST_THREAD_FUTURE - make_shared_future_sync_continuation_shared_state( - boost::unique_lock &lock, F f, - BOOST_THREAD_FWD_REF(Fp) c) { - typedef typename decay::type Cont; - shared_ptr > - h(new shared_future_sync_continuation_shared_state(f, boost::forward(c))); - h->init(lock); - - return BOOST_THREAD_FUTURE(h); - } - //////////////////////////////// - // make_shared_future_executor_continuation_shared_state - //////////////////////////////// -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - template - BOOST_THREAD_FUTURE - make_shared_future_executor_continuation_shared_state(Ex& ex, - boost::unique_lock &lock, F f, - BOOST_THREAD_FWD_REF(Fp) c) { - typedef typename decay::type Cont; - shared_ptr > - h(new shared_future_executor_continuation_shared_state(f, boost::forward(c))); - h->init(lock, ex); - - return BOOST_THREAD_FUTURE(h); - } -#endif -} - - //////////////////////////////// - // template - // auto future::then(launch policy, F&& func) -> BOOST_THREAD_FUTURE; - //////////////////////////////// - template - template - inline BOOST_THREAD_FUTURE)>::type> - BOOST_THREAD_FUTURE::then(launch policy, BOOST_THREAD_FWD_REF(F) func) { - typedef typename boost::result_of)>::type future_type; - BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized()); - - // keep state alive as we move ourself but hold the lock - shared_ptr sentinel(this->future_); - boost::unique_lock lock(sentinel->mutex); - - if (underlying_cast(policy) & int(launch::async)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } else if (underlying_cast(policy) & int(launch::deferred)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - } else if (underlying_cast(policy) & int(launch::executor)) { - assert(this->future_->get_executor()); - typedef executor Ex; - Ex& ex = *(this->future_->get_executor()); - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_executor_continuation_shared_state, future_type>(ex, - lock, boost::move(*this), boost::forward(func) - ))); -#endif - } else if (underlying_cast(policy) & int(launch::inherit)) { - - launch policy_ = this->launch_policy(lock); - if (underlying_cast(policy_) & int(launch::async)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } else if (underlying_cast(policy_) & int(launch::deferred)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - } else if (underlying_cast(policy_) & int(launch::executor)) { - assert(this->future_->get_executor()); - typedef executor Ex; - Ex& ex = *(this->future_->get_executor()); - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_executor_continuation_shared_state, future_type>(ex, - lock, boost::move(*this), boost::forward(func) - ))); -#endif - } else { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } - } else { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } - } -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - //////////////////////////////// - // template - // auto future >::then(Ex&, F&& func) -> BOOST_THREAD_FUTURE; - //////////////////////////////// - template - template - inline BOOST_THREAD_FUTURE)>::type> - BOOST_THREAD_FUTURE::then(Ex& ex, BOOST_THREAD_FWD_REF(F) func) { - typedef typename boost::result_of)>::type future_type; - BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized()); - - // keep state alive as we move ourself but hold the lock - shared_ptr sentinel(this->future_); - boost::unique_lock lock(sentinel->mutex); - - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_executor_continuation_shared_state, future_type>(ex, - lock, boost::move(*this), boost::forward(func) - ))); - } -#endif - //////////////////////////////// - // template - // auto future >::then(F&& func) -> BOOST_THREAD_FUTURE; - //////////////////////////////// - template - template - inline BOOST_THREAD_FUTURE)>::type> - BOOST_THREAD_FUTURE::then(BOOST_THREAD_FWD_REF(F) func) { - -#ifndef BOOST_THREAD_CONTINUATION_SYNC - return this->then(this->launch_policy(), boost::forward(func)); -#else - typedef typename boost::result_of)>::type future_type; - BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized()); - - // keep state alive as we move ourself but hold the lock - shared_ptr sentinel(this->future_); - boost::unique_lock lock(sentinel->mutex); - - launch policy = this->launch_policy(lock); - if (underlying_cast(policy) & int(launch::deferred)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } else { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } -#endif - - } - - //////////////////////////////// - // template - // auto future >::then(launch, F&& func) -> BOOST_THREAD_FUTURE; - //////////////////////////////// - template - template - inline BOOST_THREAD_FUTURE >)>::type> - BOOST_THREAD_FUTURE >::then(launch policy, BOOST_THREAD_FWD_REF(F) func) { - typedef BOOST_THREAD_FUTURE R; - typedef typename boost::result_of)>::type future_type; - BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized()); - - // keep state alive as we move ourself but hold the lock - shared_ptr sentinel(this->future_); - boost::unique_lock lock(sentinel->mutex); - - if (underlying_cast(policy) & int(launch::async)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } else if (underlying_cast(policy) & int(launch::deferred)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } else if (underlying_cast(policy) & int(launch::sync)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_sync_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - } else if (underlying_cast(policy) & int(launch::executor)) { - assert(this->future_->get_executor()); - typedef executor Ex; - Ex& ex = *(this->future_->get_executor()); - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_executor_continuation_shared_state, future_type>(ex, - lock, boost::move(*this), boost::forward(func) - ))); -#endif - } else if (underlying_cast(policy) & int(launch::inherit)) { - launch policy_ = this->launch_policy(lock); - - if (underlying_cast(policy_) & int(launch::async)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } else if (underlying_cast(policy_) & int(launch::deferred)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } else if (underlying_cast(policy_) & int(launch::sync)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_sync_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - } else if (underlying_cast(policy_) & int(launch::executor)) { - assert(this->future_->get_executor()); - typedef executor Ex; - Ex& ex = *(this->future_->get_executor()); - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_executor_continuation_shared_state, future_type>(ex, - lock, boost::move(*this), boost::forward(func) - ))); -#endif - } else { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } - } else { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } - } - -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - //////////////////////////////// - // template - // auto future >::then(Ex&, F&& func) -> BOOST_THREAD_FUTURE; - //////////////////////////////// - template - template - inline BOOST_THREAD_FUTURE >)>::type> - BOOST_THREAD_FUTURE >::then(Ex& ex, BOOST_THREAD_FWD_REF(F) func) { - typedef BOOST_THREAD_FUTURE R; - typedef typename boost::result_of)>::type future_type; - BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized()); - - // keep state alive as we move ourself but hold the lock - shared_ptr sentinel(this->future_); - boost::unique_lock lock(sentinel->mutex); - - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_executor_continuation_shared_state, future_type>(ex, - lock, boost::move(*this), boost::forward(func) - ))); - } -#endif - - //////////////////////////////// - // template - // auto future >::then(F&& func) -> BOOST_THREAD_FUTURE; - //////////////////////////////// - template - template - inline BOOST_THREAD_FUTURE >)>::type> - BOOST_THREAD_FUTURE >::then(BOOST_THREAD_FWD_REF(F) func) { - -#ifndef BOOST_THREAD_CONTINUATION_SYNC - return this->then(this->launch_policy(), boost::forward(func)); -#else - typedef BOOST_THREAD_FUTURE R; - typedef typename boost::result_of)>::type future_type; - BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized()); - - // keep state alive as we move ourself but hold the lock - shared_ptr sentinel(this->future_); - boost::unique_lock lock(sentinel->mutex); - - launch policy = this->launch_policy(lock); - - if (underlying_cast(policy) & int(launch::deferred)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } else { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_sync_continuation_shared_state, future_type>( - lock, boost::move(*this), boost::forward(func) - ))); - } -#endif - } - - //////////////////////////////// - // template - // auto shared_future::then(launch policy, F&& func) -> BOOST_THREAD_FUTURE; - //////////////////////////////// - template - template - inline BOOST_THREAD_FUTURE)>::type> - shared_future::then(launch policy, BOOST_THREAD_FWD_REF(F) func) const - { - typedef typename boost::result_of)>::type future_type; - BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized()); - - boost::unique_lock lock(this->future_->mutex); - if (underlying_cast(policy) & int(launch::async)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_async_continuation_shared_state, future_type>( - lock, *this, boost::forward(func) - ))); - } else if (underlying_cast(policy) & int(launch::deferred)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_deferred_continuation_shared_state, future_type>( - lock, *this, boost::forward(func) - ))); - } else if (underlying_cast(policy) & int(launch::sync)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_sync_continuation_shared_state, future_type>( - lock, *this, boost::forward(func) - ))); -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - } else if (underlying_cast(policy) & int(launch::executor)) { - typedef executor Ex; - Ex& ex = *(this->future_->get_executor()); - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_executor_continuation_shared_state, future_type>(ex, - lock, *this, boost::forward(func) - ))); -#endif - } else if (underlying_cast(policy) & int(launch::inherit)) { - - launch policy_ = this->launch_policy(lock); - if (underlying_cast(policy_) & int(launch::async)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_async_continuation_shared_state, future_type>( - lock, *this, boost::forward(func) - ))); - } else if (underlying_cast(policy_) & int(launch::deferred)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_deferred_continuation_shared_state, future_type>( - lock, *this, boost::forward(func) - ))); - } else if (underlying_cast(policy_) & int(launch::sync)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_sync_continuation_shared_state, future_type>( - lock, *this, boost::forward(func) - ))); -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - } else if (underlying_cast(policy_) & int(launch::executor)) { - typedef executor Ex; - Ex& ex = *(this->future_->get_executor()); - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_executor_continuation_shared_state, future_type>(ex, - lock, *this, boost::forward(func) - ))); -#endif - } else { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_async_continuation_shared_state, future_type>( - lock, *this, boost::forward(func) - ))); - } - - } else { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_async_continuation_shared_state, future_type>( - lock, *this, boost::forward(func) - ))); - } - } -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - //////////////////////////////// - // template - // auto shared_future::then(Ex&, F&& func) -> BOOST_THREAD_FUTURE; - //////////////////////////////// - template - template - inline BOOST_THREAD_FUTURE)>::type> - shared_future::then(Ex& ex, BOOST_THREAD_FWD_REF(F) func) const - { - typedef typename boost::result_of)>::type future_type; - BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized()); - - boost::unique_lock lock(this->future_->mutex); - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_executor_continuation_shared_state, future_type>(ex, - lock, *this, boost::forward(func) - ))); - } -#endif - - //////////////////////////////// - // template - // auto shared_future::then(F&& func) -> BOOST_THREAD_FUTURE; - //////////////////////////////// - template - template - inline BOOST_THREAD_FUTURE)>::type> - shared_future::then(BOOST_THREAD_FWD_REF(F) func) const { -#ifndef BOOST_THREAD_CONTINUATION_SYNC - return this->then(this->launch_policy(), boost::forward(func)); -#else - typedef typename boost::result_of)>::type future_type; - BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized()); - - boost::unique_lock lock(this->future_->mutex); - launch policy = this->launch_policy(lock); - if (underlying_cast(policy) & int(launch::deferred)) { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_deferred_continuation_shared_state, future_type>( - lock, *this, boost::forward(func) - ))); - } else { - return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_sync_continuation_shared_state, future_type>( - lock, *this, boost::forward(func) - ))); - } -#endif - } - -namespace detail -{ - template - struct mfallbacker_to - { - T value_; - typedef T result_type; - mfallbacker_to(BOOST_THREAD_RV_REF(T) v) - : value_(boost::move(v)) - {} - - T operator()(BOOST_THREAD_FUTURE fut) { - return fut.get_or(boost::move(value_)); - } - }; - template - struct cfallbacker_to - { - T value_; - typedef T result_type; - cfallbacker_to(T const& v) - : value_(v) - {} - - T operator()(BOOST_THREAD_FUTURE fut) const { - return fut.get_or(value_); - - } - }; -} - //////////////////////////////// - // future future::fallback_to(R&& v); - //////////////////////////////// - - template - template - inline typename boost::disable_if< is_void, BOOST_THREAD_FUTURE >::type - BOOST_THREAD_FUTURE::fallback_to(BOOST_THREAD_RV_REF(R2) v) { - return then(detail::mfallbacker_to(boost::move(v))); - } - - template - template - inline typename boost::disable_if< is_void, BOOST_THREAD_FUTURE >::type - BOOST_THREAD_FUTURE::fallback_to(R2 const& v) { - return then(detail::cfallbacker_to(v)); - } - -#endif - -#if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP -namespace detail -{ - ///////////////////////// - /// future_unwrap_shared_state - ///////////////////////// - - template - struct future_unwrap_shared_state: shared_state - { - F wrapped; - typename F::value_type unwrapped; - public: - explicit future_unwrap_shared_state(BOOST_THREAD_RV_REF(F) f) - : wrapped(boost::move(f)) { - } - - void launch_continuation() - { - boost::unique_lock lk(this->mutex); - // assert(wrapped.is_ready()); - if (! unwrapped.valid() ) - { - if (wrapped.has_exception()) { - this->mark_exceptional_finish_internal(wrapped.get_exception_ptr(), lk); - } else { - unwrapped = wrapped.get(); - if (unwrapped.valid()) - { - lk.unlock(); - boost::unique_lock lk2(unwrapped.future_->mutex); - unwrapped.future_->set_continuation_ptr(this->shared_from_this(), lk2); - } else { - this->mark_exceptional_finish_internal(boost::copy_exception(future_uninitialized()), lk); - } - } - } else { - // assert(unwrapped.is_ready()); - if (unwrapped.has_exception()) { - this->mark_exceptional_finish_internal(unwrapped.get_exception_ptr(), lk); - } else { - this->mark_finished_with_result_internal(unwrapped.get(), lk); - } - } - } - }; - - template - struct future_unwrap_shared_state: shared_state - { - F wrapped; - typename F::value_type unwrapped; - public: - explicit future_unwrap_shared_state(BOOST_THREAD_RV_REF(F) f) - : wrapped(boost::move(f)) { - } - - void launch_continuation() - { - boost::unique_lock lk(this->mutex); - // assert(wrapped.is_ready()); - if (! unwrapped.valid() ) - { - if (wrapped.has_exception()) { - this->mark_exceptional_finish_internal(wrapped.get_exception_ptr(), lk); - } else { - unwrapped = wrapped.get(); - if (unwrapped.valid()) - { - lk.unlock(); - boost::unique_lock lk2(unwrapped.future_->mutex); - unwrapped.future_->set_continuation_ptr(this->shared_from_this(), lk2); - } else { - this->mark_exceptional_finish_internal(boost::copy_exception(future_uninitialized()), lk); - } - } - } else { - // assert(unwrapped.is_ready()); - if (unwrapped.has_exception()) { - this->mark_exceptional_finish_internal(unwrapped.get_exception_ptr(), lk); - } else { - this->mark_finished_with_result_internal(lk); - } - } - } - }; - - template - BOOST_THREAD_FUTURE - make_future_unwrap_shared_state(boost::unique_lock &lock, BOOST_THREAD_RV_REF(F) f) { - shared_ptr > - h(new future_unwrap_shared_state(boost::move(f))); - h->wrapped.future_->set_continuation_ptr(h, lock); - - return BOOST_THREAD_FUTURE(h); - } -} - - template - inline BOOST_THREAD_FUTURE::BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE >) other) - : base_type(other.unwrap()) {} - - template - BOOST_THREAD_FUTURE - BOOST_THREAD_FUTURE >::unwrap() - { - BOOST_THREAD_ASSERT_PRECONDITION(this->future_!=0, future_uninitialized()); - - // keep state alive as we move ourself but hold the lock - shared_ptr sentinel(this->future_); - boost::unique_lock lock(sentinel->mutex); - - return boost::detail::make_future_unwrap_shared_state >, R2>(lock, boost::move(*this)); - } -#endif - -#if defined BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY -namespace detail -{ - struct input_iterator_tag {}; - struct vector_tag {}; - struct values_tag {}; - template - struct alias_t { typedef T type; }; - - BOOST_CONSTEXPR_OR_CONST input_iterator_tag input_iterator_tag_value = {}; - BOOST_CONSTEXPR_OR_CONST vector_tag vector_tag_value = {}; - BOOST_CONSTEXPR_OR_CONST values_tag values_tag_value = {}; - //////////////////////////////// - // detail::future_async_when_all_shared_state - //////////////////////////////// - template - struct future_when_all_vector_shared_state: future_async_shared_state_base > - { - typedef csbl::vector vector_type; - typedef typename F::value_type value_type; - vector_type vec_; - - static void run(shared_ptr that_) { - future_when_all_vector_shared_state* that = static_cast(that_.get()); - try { - boost::wait_for_all(that->vec_.begin(), that->vec_.end()); - that->mark_finished_with_result(boost::move(that->vec_)); - } catch(...) { - that->mark_exceptional_finish(); - } - } - bool run_deferred() { - - bool res = false; - for (typename csbl::vector::iterator it = vec_.begin(); it != vec_.end(); ++it) { - if (! it->run_if_is_deferred()) - { - res = true; - } - } - return res; - } - void init() { - if (! run_deferred()) - { - future_when_all_vector_shared_state::run(this->shared_from_this()); - return; - } -#ifdef BOOST_THREAD_FUTURE_BLOCKING - this->thr_ = boost::thread(&future_when_all_vector_shared_state::run, this->shared_from_this()); -#else - boost::thread(&future_when_all_vector_shared_state::run, this->shared_from_this()).detach(); -#endif - } - - public: - template< typename InputIterator> - future_when_all_vector_shared_state(input_iterator_tag, InputIterator first, InputIterator last) - : vec_(std::make_move_iterator(first), std::make_move_iterator(last)) - { - } - - future_when_all_vector_shared_state(vector_tag, BOOST_THREAD_RV_REF(csbl::vector) v) - : vec_(boost::move(v)) - { - } - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template< typename T0, typename ...T> - future_when_all_vector_shared_state(values_tag, BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures) { - vec_.push_back(boost::forward(f)); - typename alias_t::type{ - ( //first part of magic unpacker - vec_.push_back(boost::forward(futures)),'0' - )..., '0' - }; //second part of magic unpacker - } -#endif - - ~future_when_all_vector_shared_state() {} - }; - - //////////////////////////////// - // detail::future_async_when_any_shared_state - //////////////////////////////// - template - struct future_when_any_vector_shared_state: future_async_shared_state_base > - { - typedef csbl::vector vector_type; - typedef typename F::value_type value_type; - vector_type vec_; - - static void run(shared_ptr that_) - { - future_when_any_vector_shared_state* that = static_cast(that_.get()); - try { - boost::wait_for_any(that->vec_.begin(), that->vec_.end()); - that->mark_finished_with_result(boost::move(that->vec_)); - } catch(...) { - that->mark_exceptional_finish(); - } - } - bool run_deferred() { - - for (typename csbl::vector::iterator it = vec_.begin(); it != vec_.end(); ++it) { - if (it->run_if_is_deferred_or_ready()) - { - return true; - } - } - return false; - } - void init() { - if (run_deferred()) - { - future_when_any_vector_shared_state::run(this->shared_from_this()); - return; - } - -#ifdef BOOST_THREAD_FUTURE_BLOCKING - this->thr_ = boost::thread(&future_when_any_vector_shared_state::run, this->shared_from_this()); -#else - boost::thread(&future_when_any_vector_shared_state::run, this->shared_from_this()).detach(); -#endif - } - - public: - template< typename InputIterator> - future_when_any_vector_shared_state(input_iterator_tag, InputIterator first, InputIterator last) - : vec_(std::make_move_iterator(first), std::make_move_iterator(last)) - { - } - - future_when_any_vector_shared_state(vector_tag, BOOST_THREAD_RV_REF(csbl::vector) v) - : vec_(boost::move(v)) - { - } - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template< typename T0, typename ...T> - future_when_any_vector_shared_state(values_tag, - BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures - ) { - vec_.push_back(boost::forward(f)); - typename alias_t::type{ - ( //first part of magic unpacker - vec_.push_back(boost::forward(futures)) - ,'0' - )..., - '0' - }; //second part of magic unpacker - } -#endif - - ~future_when_any_vector_shared_state() {} - }; - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - struct wait_for_all_fctr { - template - void operator()(T&&... v) { - boost::wait_for_all(boost::forward(v)...); - } - }; - - struct wait_for_any_fctr { - template - void operator()(T&&... v) { - boost::wait_for_any(boost::forward(v)...); - } - }; - - - template ::value> - struct accumulate_run_if_is_deferred { - bool operator ()(Tuple& t) - { - return (! csbl::get(t).run_if_is_deferred()) || accumulate_run_if_is_deferred()(t); - } - }; - template - struct accumulate_run_if_is_deferred { - bool operator ()(Tuple& ) - { - return false; - } - }; - - - template< typename Tuple, typename T0, typename ...T> - struct future_when_all_tuple_shared_state: future_async_shared_state_base - { - Tuple tup_; - typedef typename make_tuple_indices<1+sizeof...(T)>::type Index; - - static void run(shared_ptr that_) { - future_when_all_tuple_shared_state* that = static_cast(that_.get()); - try { - // TODO make use of apply(that->tup_, boost::detail::wait_for_all_fctor()); - that->wait_for_all(Index()); - - that->mark_finished_with_result(boost::move(that->tup_)); - } catch(...) { - that->mark_exceptional_finish(); - } - } - - template - void wait_for_all(tuple_indices) { -#if defined BOOST_THREAD_PROVIDES_INVOKE - return invoke(wait_for_all_fctr(), csbl::get(tup_)...); -#else - return wait_for_all_fctr()(csbl::get(tup_)...); -#endif - } - - bool run_deferred() { - - return accumulate_run_if_is_deferred()(tup_); - } - void init() { - if (! run_deferred()) - { - future_when_all_tuple_shared_state::run(this->shared_from_this()); - return; - } -#ifdef BOOST_THREAD_FUTURE_BLOCKING - this->thr_ = boost::thread(&future_when_all_tuple_shared_state::run, this->shared_from_this()); -#else - boost::thread(&future_when_all_tuple_shared_state::run, this->shared_from_this()).detach(); -#endif - - } - public: - template< typename F, typename ...Fs> - future_when_all_tuple_shared_state(values_tag, BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(Fs) ... futures) : - tup_(boost::csbl::make_tuple(boost::forward(f), boost::forward(futures)...)) - { - } - - ~future_when_all_tuple_shared_state() {} - - }; - - - template ::value> - struct apply_any_run_if_is_deferred_or_ready { - bool operator ()(Tuple& t) - { - if (csbl::get(t).run_if_is_deferred_or_ready()) return true; - return apply_any_run_if_is_deferred_or_ready()(t); - } - }; - template - struct apply_any_run_if_is_deferred_or_ready { - bool operator ()(Tuple& ) - { - return false; - } - }; - - template< typename Tuple, typename T0, typename ...T > - struct future_when_any_tuple_shared_state: future_async_shared_state_base - { - Tuple tup_; - typedef typename make_tuple_indices<1+sizeof...(T)>::type Index; - - static void run(shared_ptr that_) - { - future_when_any_tuple_shared_state* that = static_cast(that_.get()); - try { - // TODO make use of apply(that->tup_, wait_for_any_fctr); - that->wait_for_any(Index()); - - that->mark_finished_with_result(boost::move(that->tup_)); - } catch(...) { - that->mark_exceptional_finish(); - } - } - template - void wait_for_any(tuple_indices) { -#if defined BOOST_THREAD_PROVIDES_INVOKE - return invoke(wait_for_any_fctr(), csbl::get(tup_)...); -#else - return wait_for_any_fctr()(csbl::get(tup_)...); -#endif - } - bool run_deferred() { - return apply_any_run_if_is_deferred_or_ready()(tup_); - } - void init() { - if (run_deferred()) - { - future_when_any_tuple_shared_state::run(this->shared_from_this()); - return; - } - -#ifdef BOOST_THREAD_FUTURE_BLOCKING - this->thr_ = boost::thread(&future_when_any_tuple_shared_state::run, this->shared_from_this()); -#else - boost::thread(&future_when_any_tuple_shared_state::run, this->shared_from_this()).detach(); -#endif - } - - public: - template< typename F, typename ...Fs> - future_when_any_tuple_shared_state(values_tag, - BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(Fs) ... futures - ) : - tup_(boost::csbl::make_tuple(boost::forward(f), boost::forward(futures)...)) - { - } - - ~future_when_any_tuple_shared_state() {} - }; -#endif - -} - - template< typename InputIterator> - typename boost::disable_if, - BOOST_THREAD_FUTURE > - >::type - when_all(InputIterator first, InputIterator last) { - typedef typename InputIterator::value_type value_type; - typedef csbl::vector container_type; - typedef detail::future_when_all_vector_shared_state factory_type; - - if (first==last) return make_ready_future(container_type()); - shared_ptr - h(new factory_type(detail::input_iterator_tag_value, first,last)); - h->init(); - return BOOST_THREAD_FUTURE(h); - } - - inline BOOST_THREAD_FUTURE > when_all() { - return make_ready_future(csbl::tuple<>()); - } - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template< typename T0, typename ...T> - BOOST_THREAD_FUTURE::type, typename decay::type...> > - when_all(BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures) { - typedef csbl::tuple::type, typename decay::type...> container_type; - typedef detail::future_when_all_tuple_shared_state::type, typename decay::type...> factory_type; - - shared_ptr - h(new factory_type(detail::values_tag_value, boost::forward(f), boost::forward(futures)...)); - h->init(); - return BOOST_THREAD_FUTURE(h); - } -#endif - - template< typename InputIterator> - typename boost::disable_if, - BOOST_THREAD_FUTURE > - >::type - when_any(InputIterator first, InputIterator last) { - typedef typename InputIterator::value_type value_type; - typedef csbl::vector container_type; - typedef detail::future_when_any_vector_shared_state factory_type; - - if (first==last) return make_ready_future(container_type()); - shared_ptr - h(new factory_type(detail::input_iterator_tag_value, first,last)); - h->init(); - return BOOST_THREAD_FUTURE(h); - } - - inline BOOST_THREAD_FUTURE > when_any() { - return make_ready_future(csbl::tuple<>()); - } - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template< typename T0, typename ...T> - BOOST_THREAD_FUTURE::type, typename decay::type...> > - when_any(BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures) { - typedef csbl::tuple::type, typename decay::type...> container_type; - typedef detail::future_when_any_tuple_shared_state::type, typename decay::type...> factory_type; - - shared_ptr - h(new factory_type(detail::values_tag_value, boost::forward(f), boost::forward(futures)...)); - h->init(); - return BOOST_THREAD_FUTURE(h); - } -#endif -#endif // BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY -} - -#endif // BOOST_NO_EXCEPTION -#endif // header diff --git a/libraries/boost/boost/thread/futures/future_error.hpp b/libraries/boost/boost/thread/futures/future_error.hpp deleted file mode 100644 index 6212deece..000000000 --- a/libraries/boost/boost/thread/futures/future_error.hpp +++ /dev/null @@ -1,98 +0,0 @@ -// (C) Copyright 2008-10 Anthony Williams -// (C) Copyright 2011-2015 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_FUTURES_FUTURE_ERROR_HPP -#define BOOST_THREAD_FUTURES_FUTURE_ERROR_HPP - -#include - -#include -#include - -#include - -namespace boost -{ - class BOOST_SYMBOL_VISIBLE future_error - : public std::logic_error - { - system::error_code ec_; - public: - future_error(system::error_code ec) - : logic_error(ec.message()), - ec_(ec) - { - } - - const system::error_code& code() const BOOST_NOEXCEPT - { - return ec_; - } - }; - - class BOOST_SYMBOL_VISIBLE future_uninitialized: - public future_error - { - public: - future_uninitialized() : - future_error(system::make_error_code(future_errc::no_state)) - {} - }; - class BOOST_SYMBOL_VISIBLE broken_promise: - public future_error - { - public: - broken_promise(): - future_error(system::make_error_code(future_errc::broken_promise)) - {} - }; - class BOOST_SYMBOL_VISIBLE future_already_retrieved: - public future_error - { - public: - future_already_retrieved(): - future_error(system::make_error_code(future_errc::future_already_retrieved)) - {} - }; - class BOOST_SYMBOL_VISIBLE promise_already_satisfied: - public future_error - { - public: - promise_already_satisfied(): - future_error(system::make_error_code(future_errc::promise_already_satisfied)) - {} - }; - - class BOOST_SYMBOL_VISIBLE task_already_started: - public future_error - { - public: - task_already_started(): - future_error(system::make_error_code(future_errc::promise_already_satisfied)) - {} - }; - - class BOOST_SYMBOL_VISIBLE task_moved: - public future_error - { - public: - task_moved(): - future_error(system::make_error_code(future_errc::no_state)) - {} - }; - - class promise_moved: - public future_error - { - public: - promise_moved(): - future_error(system::make_error_code(future_errc::no_state)) - {} - }; -} - -#endif // header diff --git a/libraries/boost/boost/thread/futures/future_error_code.hpp b/libraries/boost/boost/thread/futures/future_error_code.hpp deleted file mode 100644 index 7c8b6f269..000000000 --- a/libraries/boost/boost/thread/futures/future_error_code.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// (C) Copyright 2008-10 Anthony Williams -// (C) Copyright 2011-2012,2015 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_FUTURES_FUTURE_ERROR_CODE_HPP -#define BOOST_THREAD_FUTURES_FUTURE_ERROR_CODE_HPP - -#include -#include -#include -#include - -namespace boost -{ - - //enum class future_errc - BOOST_SCOPED_ENUM_DECLARE_BEGIN(future_errc) - { - broken_promise = 1, - future_already_retrieved, - promise_already_satisfied, - no_state - } - BOOST_SCOPED_ENUM_DECLARE_END(future_errc) - - namespace system - { - template <> - struct BOOST_SYMBOL_VISIBLE is_error_code_enum< ::boost::future_errc> : public true_type {}; - - #ifdef BOOST_NO_CXX11_SCOPED_ENUMS - template <> - struct BOOST_SYMBOL_VISIBLE is_error_code_enum< ::boost::future_errc::enum_type> : public true_type { }; - #endif - } // system - - BOOST_THREAD_DECL - const system::error_category& future_category() BOOST_NOEXCEPT; - - namespace system - { - inline - error_code - make_error_code(future_errc e) BOOST_NOEXCEPT - { - return error_code(underlying_cast(e), boost::future_category()); - } - - inline - error_condition - make_error_condition(future_errc e) BOOST_NOEXCEPT - { - return error_condition(underlying_cast(e), boost::future_category()); - } - } // system -} // boost - -#endif // header diff --git a/libraries/boost/boost/thread/futures/future_status.hpp b/libraries/boost/boost/thread/futures/future_status.hpp deleted file mode 100644 index 383ac4673..000000000 --- a/libraries/boost/boost/thread/futures/future_status.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// (C) Copyright 2008-10 Anthony Williams -// (C) Copyright 2011-2015 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_FUTURES_FUTURE_STATUS_HPP -#define BOOST_THREAD_FUTURES_FUTURE_STATUS_HPP - -#include -#include - -namespace boost -{ - //enum class future_status - BOOST_SCOPED_ENUM_DECLARE_BEGIN(future_status) - { - ready, - timeout, - deferred - } - BOOST_SCOPED_ENUM_DECLARE_END(future_status) - namespace future_state - { - enum state { uninitialized, waiting, ready, moved, deferred }; - } -} - -#endif // header diff --git a/libraries/boost/boost/thread/futures/is_future_type.hpp b/libraries/boost/boost/thread/futures/is_future_type.hpp deleted file mode 100644 index df7a680fa..000000000 --- a/libraries/boost/boost/thread/futures/is_future_type.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// (C) Copyright 2008-10 Anthony Williams -// (C) Copyright 2011-2015 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_FUTURES_IS_FUTURE_TYPE_HPP -#define BOOST_THREAD_FUTURES_IS_FUTURE_TYPE_HPP - -#include - -namespace boost -{ - template - struct is_future_type : false_type - { - }; -} - -#endif // header diff --git a/libraries/boost/boost/thread/futures/launch.hpp b/libraries/boost/boost/thread/futures/launch.hpp deleted file mode 100644 index 329f40d8f..000000000 --- a/libraries/boost/boost/thread/futures/launch.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// (C) Copyright 2008-10 Anthony Williams -// (C) Copyright 2011-2015 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_FUTURES_LAUNCH_HPP -#define BOOST_THREAD_FUTURES_LAUNCH_HPP - -#include -#include - -namespace boost -{ - //enum class launch - BOOST_SCOPED_ENUM_DECLARE_BEGIN(launch) - { - none = 0, - async = 1, - deferred = 2, -#ifdef BOOST_THREAD_PROVIDES_EXECUTORS - executor = 4, -#endif - inherit = 8, - sync = 16, - any = async | deferred - } - BOOST_SCOPED_ENUM_DECLARE_END(launch) -} - -#endif // header diff --git a/libraries/boost/boost/thread/futures/wait_for_all.hpp b/libraries/boost/boost/thread/futures/wait_for_all.hpp deleted file mode 100644 index 90cc2b77c..000000000 --- a/libraries/boost/boost/thread/futures/wait_for_all.hpp +++ /dev/null @@ -1,74 +0,0 @@ -// (C) Copyright 2008-10 Anthony Williams -// (C) Copyright 2011-2015 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_FUTURES_WAIT_FOR_ALL_HPP -#define BOOST_THREAD_FUTURES_WAIT_FOR_ALL_HPP - -#include -#include - -#include - -namespace boost -{ - template - typename boost::disable_if,void>::type wait_for_all(Iterator begin,Iterator end) - { - for(Iterator current=begin;current!=end;++current) - { - current->wait(); - } - } - -#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES - template - typename boost::enable_if,void>::type wait_for_all(F1& f1,F2& f2) - { - f1.wait(); - f2.wait(); - } - - template - void wait_for_all(F1& f1,F2& f2,F3& f3) - { - f1.wait(); - f2.wait(); - f3.wait(); - } - - template - void wait_for_all(F1& f1,F2& f2,F3& f3,F4& f4) - { - f1.wait(); - f2.wait(); - f3.wait(); - f4.wait(); - } - - template - void wait_for_all(F1& f1,F2& f2,F3& f3,F4& f4,F5& f5) - { - f1.wait(); - f2.wait(); - f3.wait(); - f4.wait(); - f5.wait(); - } -#else - template - void wait_for_all(F1& f1, Fs&... fs) - { - bool dummy[] = { (f1.wait(), true), (fs.wait(), true)... }; - - // prevent unused parameter warning - (void) dummy; - } -#endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)} - -} - -#endif // header diff --git a/libraries/boost/boost/thread/futures/wait_for_any.hpp b/libraries/boost/boost/thread/futures/wait_for_any.hpp deleted file mode 100644 index b869a4318..000000000 --- a/libraries/boost/boost/thread/futures/wait_for_any.hpp +++ /dev/null @@ -1,161 +0,0 @@ -// (C) Copyright 2008-10 Anthony Williams -// (C) Copyright 2011-2015 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_FUTURES_WAIT_FOR_ANY_HPP -#define BOOST_THREAD_FUTURES_WAIT_FOR_ANY_HPP - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -namespace boost -{ - namespace detail - { - template - class waiter_for_any_in_seq - { - struct registered_waiter; - typedef std::vector::size_type count_type; - - struct registered_waiter - { - typedef Future future_type; - future_type* future_; - typedef typename Future::notify_when_ready_handle notify_when_ready_handle; - notify_when_ready_handle handle; - count_type index; - - registered_waiter(future_type & a_future, - notify_when_ready_handle handle_, count_type index_) : - future_(&a_future), handle(handle_), index(index_) - { - } - }; - - struct all_futures_lock - { -#ifdef _MANAGED - typedef std::ptrdiff_t count_type_portable; -#else - typedef count_type count_type_portable; -#endif - count_type_portable count; - boost::scoped_array > locks; - - all_futures_lock(std::vector& waiters) : - count(waiters.size()), locks(new boost::unique_lock[count]) - { - for (count_type_portable i = 0; i < count; ++i) - { - locks[i] = BOOST_THREAD_MAKE_RV_REF(boost::unique_lock(waiters[i].future_->mutex())); - } - } - - void lock() - { - boost::lock(locks.get(), locks.get() + count); - } - - void unlock() - { - for (count_type_portable i = 0; i < count; ++i) - { - locks[i].unlock(); - } - } - }; - - boost::condition_variable_any cv; - std::vector waiters_; - count_type future_count; - - public: - waiter_for_any_in_seq() : - future_count(0) - { - } - - template - void add(F& f) - { - if (f.valid()) - { - registered_waiter waiter(f, f.notify_when_ready(cv), future_count); - try - { - waiters_.push_back(waiter); - } - catch (...) - { - f.future_->unnotify_when_ready(waiter.handle); - throw; - } - ++future_count; - } - } - -#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES - template - void add(F1& f1, Fs&... fs) - { - add(f1); - add(fs...); - } -#endif - - count_type wait() - { - all_futures_lock lk(waiters_); - for (;;) - { - for (count_type i = 0; i < waiters_.size(); ++i) - { - if (waiters_[i].future_->is_ready(lk.locks[i])) - { - return waiters_[i].index; - } - } - cv.wait(lk); - } - } - - ~waiter_for_any_in_seq() - { - for (count_type i = 0; i < waiters_.size(); ++i) - { - waiters_[i].future_->unnotify_when_ready(waiters_[i].handle); - } - } - }; - } - - template - typename boost::disable_if , Iterator>::type wait_for_any(Iterator begin, Iterator end) - { - if (begin == end) return end; - - detail::waiter_for_any_in_seq::value_type> waiter; - for (Iterator current = begin; current != end; ++current) - { - waiter.add(*current); - } - return boost::next(begin, waiter.wait()); - } -} - -#endif // header diff --git a/libraries/boost/boost/thread/is_locked_by_this_thread.hpp b/libraries/boost/boost/thread/is_locked_by_this_thread.hpp deleted file mode 100644 index 6344c0ff6..000000000 --- a/libraries/boost/boost/thread/is_locked_by_this_thread.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// (C) Copyright 2012 Vicente J. Botet Escriba -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -#ifndef BOOST_THREAD_IS_LOCKED_BY_THIS_THREAD_HPP -#define BOOST_THREAD_IS_LOCKED_BY_THIS_THREAD_HPP - -#include - -#include - -namespace boost -{ - template - class testable_mutex; - - /** - * Overloaded function used to check if the mutex is locked when it is testable and do nothing otherwise. - * - * This function is used usually to assert the pre-condition when the function can only be called when the mutex - * must be locked by the current thread. - */ - template - bool is_locked_by_this_thread(testable_mutex const& mtx) - { - return mtx.is_locked_by_this_thread(); - } - template - bool is_locked_by_this_thread(Lockable const&) - { - return true; - } -} - -#include - -#endif // header diff --git a/libraries/boost/boost/thread/latch.hpp b/libraries/boost/boost/thread/latch.hpp deleted file mode 100644 index dc921e68f..000000000 --- a/libraries/boost/boost/thread/latch.hpp +++ /dev/null @@ -1,170 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2013 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_LATCH_HPP -#define BOOST_THREAD_LATCH_HPP - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -namespace boost -{ - class latch - { - /// @Requires: count_ must be greater than 0 - /// Effect: Decrement the count. Unlocks the lock and notify anyone waiting if we reached zero. - /// Returns: true if count_ reached the value 0. - /// @ThreadSafe ensured by the @c lk parameter - bool count_down(unique_lock &) - /// pre_condition (count_ > 0) - { - BOOST_ASSERT(count_ > 0); - if (--count_ == 0) - { - ++generation_; - //lk.unlock(); - cond_.notify_all(); - return true; - } - return false; - } - /// Effect: Decrement the count is > 0. Unlocks the lock notify anyone waiting if we reached zero. - /// Returns: true if count_ is 0. - /// @ThreadSafe ensured by the @c lk parameter - bool try_count_down(unique_lock &lk) - { - if (count_ > 0) - { - return count_down(lk); - } - return true; - } - public: - BOOST_THREAD_NO_COPYABLE( latch) - - /// Constructs a latch with a given count. - latch(std::size_t count) : - count_(count), generation_(0) - { - } - - /// Destructor - /// Precondition: No threads are waiting or invoking count_down on @c *this. - - ~latch() - { - - } - - /// Blocks until the latch has counted down to zero. - void wait() - { - boost::unique_lock lk(mutex_); - if (count_ == 0) return; - std::size_t generation(generation_); - cond_.wait(lk, detail::not_equal(generation, generation_)); - } - - /// @return true if the internal counter is already 0, false otherwise - bool try_wait() - { - boost::unique_lock lk(mutex_); - return (count_ == 0); - } - - /// try to wait for a specified amount of time is elapsed. - /// @return whether there is a timeout or not. - template - cv_status wait_for(const chrono::duration& rel_time) - { - boost::unique_lock lk(mutex_); - if (count_ == 0) return cv_status::no_timeout; - std::size_t generation(generation_); - return cond_.wait_for(lk, rel_time, detail::not_equal(generation, generation_)) - ? cv_status::no_timeout - : cv_status::timeout; - } - - /// try to wait until the specified time_point is reached - /// @return whether there were a timeout or not. - template - cv_status wait_until(const chrono::time_point& abs_time) - { - boost::unique_lock lk(mutex_); - if (count_ == 0) return cv_status::no_timeout; - std::size_t generation(generation_); - return cond_.wait_until(lk, abs_time, detail::not_equal(generation, generation_)) - ? cv_status::no_timeout - : cv_status::timeout; - } - - /// Decrement the count and notify anyone waiting if we reach zero. - /// @Requires count must be greater than 0 - void count_down() - { - boost::unique_lock lk(mutex_); - count_down(lk); - } - /// Effect: Decrement the count if it is > 0 and notify anyone waiting if we reached zero. - /// Returns: true if count_ was 0 or reached 0. - bool try_count_down() - { - boost::unique_lock lk(mutex_); - return try_count_down(lk); - } - void signal() - { - count_down(); - } - - /// Decrement the count and notify anyone waiting if we reach zero. - /// Blocks until the latch has counted down to zero. - /// @Requires count must be greater than 0 - void count_down_and_wait() - { - boost::unique_lock lk(mutex_); - std::size_t generation(generation_); - if (count_down(lk)) - { - return; - } - cond_.wait(lk, detail::not_equal(generation, generation_)); - } - void sync() - { - count_down_and_wait(); - } - - /// Reset the counter - /// #Requires This method may only be invoked when there are no other threads currently inside the count_down_and_wait() method. - void reset(std::size_t count) - { - boost::lock_guard lk(mutex_); - //BOOST_ASSERT(count_ == 0); - count_ = count; - } - - private: - mutex mutex_; - condition_variable cond_; - std::size_t count_; - std::size_t generation_; - }; - -} // namespace boost - -#include - -#endif diff --git a/libraries/boost/boost/thread/lock_algorithms.hpp b/libraries/boost/boost/thread/lock_algorithms.hpp deleted file mode 100644 index 7a55f92a2..000000000 --- a/libraries/boost/boost/thread/lock_algorithms.hpp +++ /dev/null @@ -1,468 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_LOCK_ALGORITHMS_HPP -#define BOOST_THREAD_LOCK_ALGORITHMS_HPP - -#include -#include -#include - -#include -#include - -#include - -namespace boost -{ - namespace detail - { - template - unsigned try_lock_internal(MutexType1& m1, MutexType2& m2) - { - boost::unique_lock l1(m1, boost::try_to_lock); - if (!l1) - { - return 1; - } - if (!m2.try_lock()) - { - return 2; - } - l1.release(); - return 0; - } - - template - unsigned try_lock_internal(MutexType1& m1, MutexType2& m2, MutexType3& m3) - { - boost::unique_lock l1(m1, boost::try_to_lock); - if (!l1) - { - return 1; - } - if (unsigned const failed_lock=try_lock_internal(m2,m3)) - { - return failed_lock + 1; - } - l1.release(); - return 0; - } - - template - unsigned try_lock_internal(MutexType1& m1, MutexType2& m2, MutexType3& m3, MutexType4& m4) - { - boost::unique_lock l1(m1, boost::try_to_lock); - if (!l1) - { - return 1; - } - if (unsigned const failed_lock=try_lock_internal(m2,m3,m4)) - { - return failed_lock + 1; - } - l1.release(); - return 0; - } - - template - unsigned try_lock_internal(MutexType1& m1, MutexType2& m2, MutexType3& m3, MutexType4& m4, MutexType5& m5) - { - boost::unique_lock l1(m1, boost::try_to_lock); - if (!l1) - { - return 1; - } - if (unsigned const failed_lock=try_lock_internal(m2,m3,m4,m5)) - { - return failed_lock + 1; - } - l1.release(); - return 0; - } - - template - unsigned lock_helper(MutexType1& m1, MutexType2& m2) - { - boost::unique_lock l1(m1); - if (!m2.try_lock()) - { - return 1; - } - l1.release(); - return 0; - } - - template - unsigned lock_helper(MutexType1& m1, MutexType2& m2, MutexType3& m3) - { - boost::unique_lock l1(m1); - if (unsigned const failed_lock=try_lock_internal(m2,m3)) - { - return failed_lock; - } - l1.release(); - return 0; - } - - template - unsigned lock_helper(MutexType1& m1, MutexType2& m2, MutexType3& m3, MutexType4& m4) - { - boost::unique_lock l1(m1); - if (unsigned const failed_lock=try_lock_internal(m2,m3,m4)) - { - return failed_lock; - } - l1.release(); - return 0; - } - - template - unsigned lock_helper(MutexType1& m1, MutexType2& m2, MutexType3& m3, MutexType4& m4, MutexType5& m5) - { - boost::unique_lock l1(m1); - if (unsigned const failed_lock=try_lock_internal(m2,m3,m4,m5)) - { - return failed_lock; - } - l1.release(); - return 0; - } - } - - namespace detail - { - template - struct is_mutex_type_wrapper - { - }; - - template - void lock_impl(MutexType1& m1, MutexType2& m2, is_mutex_type_wrapper ) - { - unsigned const lock_count = 2; - unsigned lock_first = 0; - for (;;) - { - switch (lock_first) - { - case 0: - lock_first = detail::lock_helper(m1, m2); - if (!lock_first) return; - break; - case 1: - lock_first = detail::lock_helper(m2, m1); - if (!lock_first) return; - lock_first = (lock_first + 1) % lock_count; - break; - } - } - } - - template - void lock_impl(Iterator begin, Iterator end, is_mutex_type_wrapper ); - } - - template - void lock(MutexType1& m1, MutexType2& m2) - { - detail::lock_impl(m1, m2, detail::is_mutex_type_wrapper::value>()); - } - - template - void lock(const MutexType1& m1, MutexType2& m2) - { - detail::lock_impl(m1, m2, detail::is_mutex_type_wrapper::value>()); - } - - template - void lock(MutexType1& m1, const MutexType2& m2) - { - detail::lock_impl(m1, m2, detail::is_mutex_type_wrapper::value>()); - } - - template - void lock(const MutexType1& m1, const MutexType2& m2) - { - detail::lock_impl(m1, m2, detail::is_mutex_type_wrapper::value>()); - } - - template - void lock(MutexType1& m1, MutexType2& m2, MutexType3& m3) - { - unsigned const lock_count = 3; - unsigned lock_first = 0; - for (;;) - { - switch (lock_first) - { - case 0: - lock_first = detail::lock_helper(m1, m2, m3); - if (!lock_first) return; - break; - case 1: - lock_first = detail::lock_helper(m2, m3, m1); - if (!lock_first) return; - lock_first = (lock_first + 1) % lock_count; - break; - case 2: - lock_first = detail::lock_helper(m3, m1, m2); - if (!lock_first) return; - lock_first = (lock_first + 2) % lock_count; - break; - } - } - } - - template - void lock(MutexType1& m1, MutexType2& m2, MutexType3& m3, MutexType4& m4) - { - unsigned const lock_count = 4; - unsigned lock_first = 0; - for (;;) - { - switch (lock_first) - { - case 0: - lock_first = detail::lock_helper(m1, m2, m3, m4); - if (!lock_first) return; - break; - case 1: - lock_first = detail::lock_helper(m2, m3, m4, m1); - if (!lock_first) return; - lock_first = (lock_first + 1) % lock_count; - break; - case 2: - lock_first = detail::lock_helper(m3, m4, m1, m2); - if (!lock_first) return; - lock_first = (lock_first + 2) % lock_count; - break; - case 3: - lock_first = detail::lock_helper(m4, m1, m2, m3); - if (!lock_first) return; - lock_first = (lock_first + 3) % lock_count; - break; - } - } - } - - template - void lock(MutexType1& m1, MutexType2& m2, MutexType3& m3, MutexType4& m4, MutexType5& m5) - { - unsigned const lock_count = 5; - unsigned lock_first = 0; - for (;;) - { - switch (lock_first) - { - case 0: - lock_first = detail::lock_helper(m1, m2, m3, m4, m5); - if (!lock_first) return; - break; - case 1: - lock_first = detail::lock_helper(m2, m3, m4, m5, m1); - if (!lock_first) return; - lock_first = (lock_first + 1) % lock_count; - break; - case 2: - lock_first = detail::lock_helper(m3, m4, m5, m1, m2); - if (!lock_first) return; - lock_first = (lock_first + 2) % lock_count; - break; - case 3: - lock_first = detail::lock_helper(m4, m5, m1, m2, m3); - if (!lock_first) return; - lock_first = (lock_first + 3) % lock_count; - break; - case 4: - lock_first = detail::lock_helper(m5, m1, m2, m3, m4); - if (!lock_first) return; - lock_first = (lock_first + 4) % lock_count; - break; - } - } - } - - namespace detail - { - template ::value> - struct try_lock_impl_return - { - typedef int type; - }; - - template - struct try_lock_impl_return - { - typedef Iterator type; - }; - - template - int try_lock_impl(MutexType1& m1, MutexType2& m2, is_mutex_type_wrapper ) - { - return ((int) detail::try_lock_internal(m1, m2)) - 1; - } - - template - Iterator try_lock_impl(Iterator begin, Iterator end, is_mutex_type_wrapper ); - } - - template - typename detail::try_lock_impl_return::type try_lock(MutexType1& m1, MutexType2& m2) - { - return detail::try_lock_impl(m1, m2, detail::is_mutex_type_wrapper::value>()); - } - - template - typename detail::try_lock_impl_return::type try_lock(const MutexType1& m1, MutexType2& m2) - { - return detail::try_lock_impl(m1, m2, detail::is_mutex_type_wrapper::value>()); - } - - template - typename detail::try_lock_impl_return::type try_lock(MutexType1& m1, const MutexType2& m2) - { - return detail::try_lock_impl(m1, m2, detail::is_mutex_type_wrapper::value>()); - } - - template - typename detail::try_lock_impl_return::type try_lock(const MutexType1& m1, const MutexType2& m2) - { - return detail::try_lock_impl(m1, m2, detail::is_mutex_type_wrapper::value>()); - } - - template - int try_lock(MutexType1& m1, MutexType2& m2, MutexType3& m3) - { - return ((int) detail::try_lock_internal(m1, m2, m3)) - 1; - } - - template - int try_lock(MutexType1& m1, MutexType2& m2, MutexType3& m3, MutexType4& m4) - { - return ((int) detail::try_lock_internal(m1, m2, m3, m4)) - 1; - } - - template - int try_lock(MutexType1& m1, MutexType2& m2, MutexType3& m3, MutexType4& m4, MutexType5& m5) - { - return ((int) detail::try_lock_internal(m1, m2, m3, m4, m5)) - 1; - } - - namespace detail - { - template - struct range_lock_guard - { - Iterator begin; - Iterator end; - - range_lock_guard(Iterator begin_, Iterator end_) : - begin(begin_), end(end_) - { - boost::lock(begin, end); - } - - void release() - { - begin = end; - } - - ~range_lock_guard() - { - for (; begin != end; ++begin) - { - begin->unlock(); - } - } - }; - - template - Iterator try_lock_impl(Iterator begin, Iterator end, is_mutex_type_wrapper ) - - { - if (begin == end) - { - return end; - } - typedef typename std::iterator_traits::value_type lock_type; - unique_lock guard(*begin, try_to_lock); - - if (!guard.owns_lock()) - { - return begin; - } - Iterator const failed = boost::try_lock(++begin, end); - if (failed == end) - { - guard.release(); - } - - return failed; - } - } - - namespace detail - { - template - void lock_impl(Iterator begin, Iterator end, is_mutex_type_wrapper ) - { - typedef typename std::iterator_traits::value_type lock_type; - - if (begin == end) - { - return; - } - bool start_with_begin = true; - Iterator second = begin; - ++second; - Iterator next = second; - - for (;;) - { - unique_lock begin_lock(*begin, defer_lock); - if (start_with_begin) - { - begin_lock.lock(); - Iterator const failed_lock = boost::try_lock(next, end); - if (failed_lock == end) - { - begin_lock.release(); - return; - } - start_with_begin = false; - next = failed_lock; - } - else - { - detail::range_lock_guard guard(next, end); - if (begin_lock.try_lock()) - { - Iterator const failed_lock = boost::try_lock(second, next); - if (failed_lock == next) - { - begin_lock.release(); - guard.release(); - return; - } - start_with_begin = false; - next = failed_lock; - } - else - { - start_with_begin = true; - next = second; - } - } - } - } - - } - -} -#include - -#endif diff --git a/libraries/boost/boost/thread/lock_concepts.hpp b/libraries/boost/boost/thread/lock_concepts.hpp deleted file mode 100644 index d96c3dc1b..000000000 --- a/libraries/boost/boost/thread/lock_concepts.hpp +++ /dev/null @@ -1,197 +0,0 @@ -// (C) Copyright 2012 Vicente Botet -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_LOCK_CONCEPTS_HPP -#define BOOST_THREAD_LOCK_CONCEPTS_HPP - -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace boost -{ - - /** - * BasicLock object supports the basic features - * required to delimit a critical region - * Supports the basic lock, unlock and try_lock functions and - * defines the lock traits - */ - - template - struct BasicLock - { - typedef typename Lk::mutex_type mutex_type; - void cvt_mutex_ptr(mutex_type*) {} - BOOST_CONCEPT_ASSERT(( BasicLockable )); - - BOOST_CONCEPT_USAGE(BasicLock) - { - const Lk l1(mtx); - Lk l2(mtx, defer_lock); - Lk l3(mtx, adopt_lock); - Lk l4(( Lk())); - Lk l5(( boost::move(l2))); - cvt_mutex_ptr(l1.mutex()); - if (l1.owns_lock()) return; - if (l1) return; - if (!l1) return; - - l2.lock(); - l2.unlock(); - l2.release(); - - } - BasicLock() : - mtx(*static_cast(0)) - {} - private: - BasicLock operator=(BasicLock const&); - mutex_type& mtx; - } - ; - - template - struct Lock - { - BOOST_CONCEPT_ASSERT(( BasicLock )); - typedef typename Lk::mutex_type mutex_type; - BOOST_CONCEPT_ASSERT(( Lockable )); - - BOOST_CONCEPT_USAGE(Lock) - { - Lk l1(mtx, try_to_lock); - if (l1.try_lock()) return; - } - Lock() : - mtx(*static_cast(0)) - {} - private: - Lock operator=(Lock const&); - mutex_type& mtx; - }; - - template - struct TimedLock - { - BOOST_CONCEPT_ASSERT(( Lock )); - typedef typename Lk::mutex_type mutex_type; - BOOST_CONCEPT_ASSERT(( TimedLockable )); - - BOOST_CONCEPT_USAGE(TimedLock) - { - const Lk l1(mtx, t); - Lk l2(mtx, d); - if (l1.try_lock_until(t)) return; - if (l1.try_lock_for(d)) return; - } - TimedLock() : - mtx(*static_cast(0)) - {} - private: - TimedLock operator=(TimedLock const&); - mutex_type& mtx; - boost::chrono::system_clock::time_point t; - boost::chrono::system_clock::duration d; - }; - - template - struct UniqueLock - { - BOOST_CONCEPT_ASSERT(( TimedLock )); - typedef typename Lk::mutex_type mutex_type; - - BOOST_CONCEPT_USAGE(UniqueLock) - { - - } - UniqueLock() : - mtx(*static_cast(0)) - {} - private: - UniqueLock operator=(UniqueLock const&); - mutex_type& mtx; - }; - - template - struct SharedLock - { - BOOST_CONCEPT_ASSERT(( TimedLock )); - typedef typename Lk::mutex_type mutex_type; - - BOOST_CONCEPT_USAGE(SharedLock) - { - } - SharedLock() : - mtx(*static_cast(0)) - {} - private: - SharedLock operator=(SharedLock const&); - mutex_type& mtx; - - }; - - template - struct UpgradeLock - { - BOOST_CONCEPT_ASSERT(( SharedLock )); - typedef typename Lk::mutex_type mutex_type; - - BOOST_CONCEPT_USAGE(UpgradeLock) - { - } - UpgradeLock() : - mtx(*static_cast(0)) - {} - private: - UpgradeLock operator=(UpgradeLock const&); - mutex_type& mtx; - }; - - /** - * An StrictLock is a scoped lock guard ensuring the mutex is locked on the - * scope of the lock, by locking the mutex on construction and unlocking it on - * destruction. - * - * Essentially, a StrictLock's role is only to live on the stack as an - * automatic variable. strict_lock must adhere to a non-copy and non-alias - * policy. StrictLock disables copying by making the copy constructor and the - * assignment operator private. While we're at it, let's disable operator new - * and operator delete; strict locks are not intended to be allocated on the - * heap. StrictLock avoids aliasing by using a slightly less orthodox and - * less well-known technique: disable address taking. - */ - - template - struct StrictLock - { - typedef typename Lk::mutex_type mutex_type; - BOOST_CONCEPT_ASSERT(( BasicLockable )); - BOOST_STATIC_ASSERT(( is_strict_lock::value )); - - BOOST_CONCEPT_USAGE( StrictLock) - { - if (l1.owns_lock(&mtx)) return; - } - StrictLock() : - l1(*static_cast(0)), - mtx(*static_cast(0)) - {} - private: - StrictLock operator=(StrictLock const&); - - Lk const& l1; - mutex_type const& mtx; - - }; - -} -#endif diff --git a/libraries/boost/boost/thread/lock_factories.hpp b/libraries/boost/boost/thread/lock_factories.hpp deleted file mode 100644 index 523b90a5e..000000000 --- a/libraries/boost/boost/thread/lock_factories.hpp +++ /dev/null @@ -1,78 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2012 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_LOCK_FACTORIES_HPP -#define BOOST_THREAD_LOCK_FACTORIES_HPP - -#include -#include -#if ! defined(BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS) -#include // todo change to once Boost.Tuple or Boost.Fusion provides Move semantics. -#endif -#include - -namespace boost -{ - - template - unique_lock make_unique_lock(Lockable& mtx) - { - return unique_lock (mtx); - } - - template - unique_lock make_unique_lock(Lockable& mtx, adopt_lock_t) - { - return unique_lock (mtx, adopt_lock); - } - - template - unique_lock make_unique_lock(Lockable& mtx, defer_lock_t) - { - return unique_lock (mtx, defer_lock); - } - - template - unique_lock make_unique_lock(Lockable& mtx, try_to_lock_t) - { - return unique_lock (mtx, try_to_lock); - } -#if ! defined(BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS) - -#if ! defined BOOST_NO_CXX11_VARIADIC_TEMPLATES - template - std::tuple ...> make_unique_locks(Lockable& ...mtx) - { - boost::lock(mtx...); - return std::tuple ...>(unique_lock(mtx, adopt_lock)...); - } -#else - template - std::tuple, unique_lock > make_unique_locks(L1& m1, L2& m2) - { - boost::lock(m1, m2); - return std::tuple,unique_lock >( - unique_lock(m1, adopt_lock), - unique_lock(m2, adopt_lock) - ); - } - template - std::tuple, unique_lock, unique_lock > make_unique_locks(L1& m1, L2& m2, L3& m3) - { - boost::lock(m1, m2, m3); - return std::tuple,unique_lock,unique_lock >( - unique_lock(m1, adopt_lock), - unique_lock(m2, adopt_lock), - unique_lock(m3, adopt_lock) - ); - } - -#endif -#endif - -} - -#include -#endif diff --git a/libraries/boost/boost/thread/lock_guard.hpp b/libraries/boost/boost/thread/lock_guard.hpp deleted file mode 100644 index 4c2908af4..000000000 --- a/libraries/boost/boost/thread/lock_guard.hpp +++ /dev/null @@ -1,88 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_LOCK_GUARD_HPP -#define BOOST_THREAD_LOCK_GUARD_HPP - -#include -#include -#include -#include -#include -#if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS -#include -#include -#endif - -#include - -namespace boost -{ - - template - class lock_guard - { - private: - Mutex& m; - - public: - typedef Mutex mutex_type; - BOOST_THREAD_NO_COPYABLE( lock_guard ) - - explicit lock_guard(Mutex& m_) : - m(m_) - { - m.lock(); - } - - lock_guard(Mutex& m_, adopt_lock_t) : - m(m_) - { -#if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - BOOST_ASSERT(is_locked_by_this_thread(m)); -#endif - } - -#if ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST - lock_guard(std::initializer_list > l_) : - m(*(const_cast*>(l_.begin())->m)) - { - m.lock(); - } - - lock_guard(std::initializer_list > l_) : - m(*(const_cast*>(l_.begin())->m)) - { -#if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - BOOST_ASSERT(is_locked_by_this_thread(m)); -#endif - } - -#endif - ~lock_guard() - { - m.unlock(); - } - }; - - -#if ! defined BOOST_THREAD_NO_MAKE_LOCK_GUARD - template - lock_guard make_lock_guard(Lockable& mtx) - { - return { thread_detail::lockable_wrapper(mtx) }; - } - template - lock_guard make_lock_guard(Lockable& mtx, adopt_lock_t) - { - return { thread_detail::lockable_adopt_wrapper(mtx) }; - } -#endif -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/lock_options.hpp b/libraries/boost/boost/thread/lock_options.hpp deleted file mode 100644 index 68899ca89..000000000 --- a/libraries/boost/boost/thread/lock_options.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_LOCK_OPTIONS_HPP -#define BOOST_THREAD_LOCK_OPTIONS_HPP - -#include - -namespace boost -{ - struct defer_lock_t - { - }; - struct try_to_lock_t - { - }; - struct adopt_lock_t - { - }; - - BOOST_CONSTEXPR_OR_CONST defer_lock_t defer_lock = {}; - BOOST_CONSTEXPR_OR_CONST try_to_lock_t try_to_lock = {}; - BOOST_CONSTEXPR_OR_CONST adopt_lock_t adopt_lock = {}; - -} -#include - -#endif diff --git a/libraries/boost/boost/thread/lock_traits.hpp b/libraries/boost/boost/thread/lock_traits.hpp deleted file mode 100644 index e45d82298..000000000 --- a/libraries/boost/boost/thread/lock_traits.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2009-2012 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_LOCK_TRAITS_HPP -#define BOOST_THREAD_LOCK_TRAITS_HPP - -#include -//#include -//#include -// -//#ifdef BOOST_THREAD_USES_CHRONO -//#include -//#include -//#endif - -#include - -#include - -namespace boost -{ - -/** - * An strict lock is a lock ensuring the mutex is locked on the scope of the lock - * There is no single way to define a strict lock as the strict_lock and - * nesteed_strict_lock shows. So we need a metafunction that states if a - * lock is a strict lock "sur parole". - */ - -template -struct is_strict_lock_sur_parolle : false_type {}; - - -template -struct is_strict_lock_sur_parole : is_strict_lock_sur_parolle {}; - -template -struct is_strict_lock : is_strict_lock_sur_parole {}; - -} -#include - -#endif diff --git a/libraries/boost/boost/thread/lock_types.hpp b/libraries/boost/boost/thread/lock_types.hpp deleted file mode 100644 index 9b8c57c49..000000000 --- a/libraries/boost/boost/thread/lock_types.hpp +++ /dev/null @@ -1,1230 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_LOCK_TYPES_HPP -#define BOOST_THREAD_LOCK_TYPES_HPP - -#include -#include -#include -#include -#include -#if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS -#include -#endif -#include - -#include -#ifdef BOOST_THREAD_USES_CHRONO -#include -#include -#endif -#include - -#include - -namespace boost -{ - struct xtime; - - template - class shared_lock; - - template - class upgrade_lock; - - template - class unique_lock; - - namespace detail - { - template - class try_lock_wrapper; - } - -#ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES - namespace sync - { - template - struct is_basic_lockable > - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - template - struct is_lockable > - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - - template - struct is_basic_lockable > - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - template - struct is_lockable > - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - - template - struct is_basic_lockable > - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - template - struct is_lockable > - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - - template - struct is_basic_lockable > - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - template - struct is_lockable > - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - } -#endif - - - template - class unique_lock - { - private: - Mutex* m; - bool is_locked; - - private: - explicit unique_lock(upgrade_lock&); - unique_lock& operator=(upgrade_lock& other); - public: - typedef Mutex mutex_type; - BOOST_THREAD_MOVABLE_ONLY( unique_lock) - -#if 0 // This should not be needed anymore. Use instead BOOST_THREAD_MAKE_RV_REF. -#if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) - unique_lock(const volatile unique_lock&); -#endif -#endif - unique_lock()BOOST_NOEXCEPT : - m(0),is_locked(false) - {} - - explicit unique_lock(Mutex& m_) : - m(&m_), is_locked(false) - { - lock(); - } - unique_lock(Mutex& m_, adopt_lock_t) : - m(&m_), is_locked(true) - { -#if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - BOOST_ASSERT(is_locked_by_this_thread(m)); -#endif - } - unique_lock(Mutex& m_, defer_lock_t)BOOST_NOEXCEPT: - m(&m_),is_locked(false) - {} - unique_lock(Mutex& m_, try_to_lock_t) : - m(&m_), is_locked(false) - { - try_lock(); - } -#if defined BOOST_THREAD_USES_DATETIME - template - unique_lock(Mutex& m_,TimeDuration const& target_time): - m(&m_),is_locked(false) - { - timed_lock(target_time); - } - unique_lock(Mutex& m_,system_time const& target_time): - m(&m_),is_locked(false) - { - timed_lock(target_time); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - unique_lock(Mutex& mtx, const chrono::time_point& t) - : m(&mtx), is_locked(mtx.try_lock_until(t)) - { - } - template - unique_lock(Mutex& mtx, const chrono::duration& d) - : m(&mtx), is_locked(mtx.try_lock_for(d)) - { - } -#endif - - unique_lock(BOOST_THREAD_RV_REF(unique_lock) other) BOOST_NOEXCEPT: - m(BOOST_THREAD_RV(other).m),is_locked(BOOST_THREAD_RV(other).is_locked) - { - BOOST_THREAD_RV(other).is_locked=false; - BOOST_THREAD_RV(other).m=0; - } - - BOOST_THREAD_EXPLICIT_LOCK_CONVERSION unique_lock(BOOST_THREAD_RV_REF_BEG upgrade_lock BOOST_THREAD_RV_REF_END other); - -#ifndef BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION - //std-2104 unique_lock move-assignment should not be noexcept - unique_lock& operator=(BOOST_THREAD_RV_REF_BEG upgrade_lock BOOST_THREAD_RV_REF_END other) //BOOST_NOEXCEPT - { - unique_lock temp(::boost::move(other)); - swap(temp); - return *this; - } -#endif - - //std-2104 unique_lock move-assignment should not be noexcept - unique_lock& operator=(BOOST_THREAD_RV_REF(unique_lock) other) //BOOST_NOEXCEPT - { - unique_lock temp(::boost::move(other)); - swap(temp); - return *this; - } -#if 0 // This should not be needed anymore. Use instead BOOST_THREAD_MAKE_RV_REF. -#if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) - unique_lock& operator=(unique_lock other) - { - swap(other); - return *this; - } -#endif // BOOST_WORKAROUND -#endif - - // Conversion from upgrade locking - unique_lock(BOOST_THREAD_RV_REF_BEG upgrade_lock BOOST_THREAD_RV_REF_END ul, try_to_lock_t) - : m(0),is_locked(false) - { - if (BOOST_THREAD_RV(ul).owns_lock()) - { - if (BOOST_THREAD_RV(ul).mutex()->try_unlock_upgrade_and_lock()) - { - m = BOOST_THREAD_RV(ul).release(); - is_locked = true; - } - } - else - { - m = BOOST_THREAD_RV(ul).release(); - } - } - -#ifdef BOOST_THREAD_USES_CHRONO - template - unique_lock(BOOST_THREAD_RV_REF_BEG upgrade_lock BOOST_THREAD_RV_REF_END ul, - const chrono::time_point& abs_time) - : m(0),is_locked(false) - { - if (BOOST_THREAD_RV(ul).owns_lock()) - { - if (BOOST_THREAD_RV(ul).mutex()->try_unlock_upgrade_and_lock_until(abs_time)) - { - m = BOOST_THREAD_RV(ul).release(); - is_locked = true; - } - } - else - { - m = BOOST_THREAD_RV(ul).release(); - } - } - - template - unique_lock(BOOST_THREAD_RV_REF_BEG upgrade_lock BOOST_THREAD_RV_REF_END ul, - const chrono::duration& rel_time) - : m(0),is_locked(false) - { - if (BOOST_THREAD_RV(ul).owns_lock()) - { - if (BOOST_THREAD_RV(ul).mutex()->try_unlock_upgrade_and_lock_for(rel_time)) - { - m = BOOST_THREAD_RV(ul).release(); - is_locked = true; - } - } - else - { - m = BOOST_THREAD_RV(ul).release(); - } - } -#endif - -#ifdef BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS - // Conversion from shared locking - unique_lock(BOOST_THREAD_RV_REF_BEG shared_lock BOOST_THREAD_RV_REF_END sl, try_to_lock_t) - : m(0),is_locked(false) - { - if (BOOST_THREAD_RV(sl).owns_lock()) - { - if (BOOST_THREAD_RV(sl).mutex()->try_unlock_shared_and_lock()) - { - m = BOOST_THREAD_RV(sl).release(); - is_locked = true; - } - } - else - { - m = BOOST_THREAD_RV(sl).release(); - } - } - -#ifdef BOOST_THREAD_USES_CHRONO - template - unique_lock(BOOST_THREAD_RV_REF_BEG shared_lock BOOST_THREAD_RV_REF_END sl, - const chrono::time_point& abs_time) - : m(0),is_locked(false) - { - if (BOOST_THREAD_RV(sl).owns_lock()) - { - if (BOOST_THREAD_RV(sl).mutex()->try_unlock_shared_and_lock_until(abs_time)) - { - m = BOOST_THREAD_RV(sl).release(); - is_locked = true; - } - } - else - { - m = BOOST_THREAD_RV(sl).release(); - } - } - - template - unique_lock(BOOST_THREAD_RV_REF_BEG shared_lock BOOST_THREAD_RV_REF_END sl, - const chrono::duration& rel_time) - : m(0),is_locked(false) - { - if (BOOST_THREAD_RV(sl).owns_lock()) - { - if (BOOST_THREAD_RV(sl).mutex()->try_unlock_shared_and_lock_for(rel_time)) - { - m = BOOST_THREAD_RV(sl).release(); - is_locked = true; - } - } - else - { - m = BOOST_THREAD_RV(sl).release(); - } - } -#endif // BOOST_THREAD_USES_CHRONO -#endif // BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS - - void swap(unique_lock& other)BOOST_NOEXCEPT - { - std::swap(m,other.m); - std::swap(is_locked,other.is_locked); - } - - ~unique_lock() - { - if (owns_lock()) - { - m->unlock(); - } - } - void lock() - { - if (m == 0) - { - boost::throw_exception( - boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost unique_lock has no mutex")); - } - if (owns_lock()) - { - boost::throw_exception( - boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex")); - } - m->lock(); - is_locked = true; - } - bool try_lock() - { - if (m == 0) - { - boost::throw_exception( - boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost unique_lock has no mutex")); - } - if (owns_lock()) - { - boost::throw_exception( - boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex")); - } - is_locked = m->try_lock(); - return is_locked; - } -#if defined BOOST_THREAD_USES_DATETIME - template - bool timed_lock(TimeDuration const& relative_time) - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost unique_lock has no mutex")); - } - if(owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex")); - } - is_locked=m->timed_lock(relative_time); - return is_locked; - } - - bool timed_lock(::boost::system_time const& absolute_time) - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost unique_lock has no mutex")); - } - if(owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex")); - } - is_locked=m->timed_lock(absolute_time); - return is_locked; - } - bool timed_lock(::boost::xtime const& absolute_time) - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost unique_lock has no mutex")); - } - if(owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex")); - } - is_locked=m->timed_lock(absolute_time); - return is_locked; - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - - template - bool try_lock_for(const chrono::duration& rel_time) - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost unique_lock has no mutex")); - } - if(owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex")); - } - is_locked=m->try_lock_for(rel_time); - return is_locked; - } - template - bool try_lock_until(const chrono::time_point& abs_time) - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost unique_lock has no mutex")); - } - if(owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost unique_lock owns already the mutex")); - } - is_locked=m->try_lock_until(abs_time); - return is_locked; - } -#endif - - void unlock() - { - if (m == 0) - { - boost::throw_exception( - boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost unique_lock has no mutex")); - } - if (!owns_lock()) - { - boost::throw_exception( - boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost unique_lock doesn't own the mutex")); - } - m->unlock(); - is_locked = false; - } - -#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) - typedef void (unique_lock::*bool_type)(); - operator bool_type() const BOOST_NOEXCEPT - { - return is_locked?&unique_lock::lock:0; - } - bool operator!() const BOOST_NOEXCEPT - { - return !owns_lock(); - } -#else - explicit operator bool() const BOOST_NOEXCEPT - { - return owns_lock(); - } -#endif - bool owns_lock() const BOOST_NOEXCEPT - { - return is_locked; - } - - Mutex* mutex() const BOOST_NOEXCEPT - { - return m; - } - - Mutex* release()BOOST_NOEXCEPT - { - Mutex* const res=m; - m=0; - is_locked=false; - return res; - } - - friend class shared_lock ; - friend class upgrade_lock ; - }; - - template - void swap(unique_lock& lhs, unique_lock& rhs) - BOOST_NOEXCEPT - { - lhs.swap(rhs); - } - - BOOST_THREAD_DCL_MOVABLE_BEG(Mutex) unique_lock BOOST_THREAD_DCL_MOVABLE_END - - template - class shared_lock - { - protected: - Mutex* m; - bool is_locked; - - public: - typedef Mutex mutex_type; - BOOST_THREAD_MOVABLE_ONLY(shared_lock) - - shared_lock() BOOST_NOEXCEPT: - m(0),is_locked(false) - {} - - explicit shared_lock(Mutex& m_): - m(&m_),is_locked(false) - { - lock(); - } - shared_lock(Mutex& m_,adopt_lock_t): - m(&m_),is_locked(true) - { -#if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - BOOST_ASSERT(is_locked_by_this_thread(m)); -#endif - } - shared_lock(Mutex& m_,defer_lock_t) BOOST_NOEXCEPT: - m(&m_),is_locked(false) - {} - shared_lock(Mutex& m_,try_to_lock_t): - m(&m_),is_locked(false) - { - try_lock(); - } -#if defined BOOST_THREAD_USES_DATETIME - shared_lock(Mutex& m_,system_time const& target_time): - m(&m_),is_locked(false) - { - timed_lock(target_time); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - shared_lock(Mutex& mtx, const chrono::time_point& t) - : m(&mtx), is_locked(mtx.try_lock_shared_until(t)) - { - } - template - shared_lock(Mutex& mtx, const chrono::duration& d) - : m(&mtx), is_locked(mtx.try_lock_shared_for(d)) - { - } -#endif - - shared_lock(BOOST_THREAD_RV_REF_BEG shared_lock BOOST_THREAD_RV_REF_END other) BOOST_NOEXCEPT: - m(BOOST_THREAD_RV(other).m),is_locked(BOOST_THREAD_RV(other).is_locked) - { - BOOST_THREAD_RV(other).is_locked=false; - BOOST_THREAD_RV(other).m=0; - } - - BOOST_THREAD_EXPLICIT_LOCK_CONVERSION shared_lock(BOOST_THREAD_RV_REF_BEG unique_lock BOOST_THREAD_RV_REF_END other): - m(BOOST_THREAD_RV(other).m),is_locked(BOOST_THREAD_RV(other).is_locked) - { - if(is_locked) - { - m->unlock_and_lock_shared(); - } - BOOST_THREAD_RV(other).is_locked=false; - BOOST_THREAD_RV(other).m=0; - } - - BOOST_THREAD_EXPLICIT_LOCK_CONVERSION shared_lock(BOOST_THREAD_RV_REF_BEG upgrade_lock BOOST_THREAD_RV_REF_END other): - m(BOOST_THREAD_RV(other).m),is_locked(BOOST_THREAD_RV(other).is_locked) - { - if(is_locked) - { - m->unlock_upgrade_and_lock_shared(); - } - BOOST_THREAD_RV(other).is_locked=false; - BOOST_THREAD_RV(other).m=0; - } - - //std-2104 unique_lock move-assignment should not be noexcept - shared_lock& operator=(BOOST_THREAD_RV_REF_BEG shared_lock BOOST_THREAD_RV_REF_END other) //BOOST_NOEXCEPT - { - shared_lock temp(::boost::move(other)); - swap(temp); - return *this; - } -#ifndef BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION - shared_lock& operator=(BOOST_THREAD_RV_REF_BEG unique_lock BOOST_THREAD_RV_REF_END other) - { - shared_lock temp(::boost::move(other)); - swap(temp); - return *this; - } - - shared_lock& operator=(BOOST_THREAD_RV_REF_BEG upgrade_lock BOOST_THREAD_RV_REF_END other) - { - shared_lock temp(::boost::move(other)); - swap(temp); - return *this; - } -#endif - - void swap(shared_lock& other) BOOST_NOEXCEPT - { - std::swap(m,other.m); - std::swap(is_locked,other.is_locked); - } - - Mutex* mutex() const BOOST_NOEXCEPT - { - return m; - } - - Mutex* release() BOOST_NOEXCEPT - { - Mutex* const res=m; - m=0; - is_locked=false; - return res; - } - - ~shared_lock() - { - if(owns_lock()) - { - m->unlock_shared(); - } - } - void lock() - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost shared_lock has no mutex")); - } - if(owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex")); - } - m->lock_shared(); - is_locked=true; - } - bool try_lock() - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost shared_lock has no mutex")); - } - if(owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex")); - } - is_locked=m->try_lock_shared(); - return is_locked; - } -#if defined BOOST_THREAD_USES_DATETIME - bool timed_lock(boost::system_time const& target_time) - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost shared_lock has no mutex")); - } - if(owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex")); - } - is_locked=m->timed_lock_shared(target_time); - return is_locked; - } - template - bool timed_lock(Duration const& target_time) - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost shared_lock has no mutex")); - } - if(owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex")); - } - is_locked=m->timed_lock_shared(target_time); - return is_locked; - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_for(const chrono::duration& rel_time) - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost shared_lock has no mutex")); - } - if(owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex")); - } - is_locked=m->try_lock_shared_for(rel_time); - return is_locked; - } - template - bool try_lock_until(const chrono::time_point& abs_time) - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost shared_lock has no mutex")); - } - if(owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost shared_lock owns already the mutex")); - } - is_locked=m->try_lock_shared_until(abs_time); - return is_locked; - } -#endif - void unlock() - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost shared_lock has no mutex")); - } - if(!owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost shared_lock doesn't own the mutex")); - } - m->unlock_shared(); - is_locked=false; - } - -#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) - typedef void (shared_lock::*bool_type)(); - operator bool_type() const BOOST_NOEXCEPT - { - return is_locked?&shared_lock::lock:0; - } - bool operator!() const BOOST_NOEXCEPT - { - return !owns_lock(); - } -#else - explicit operator bool() const BOOST_NOEXCEPT - { - return owns_lock(); - } -#endif - bool owns_lock() const BOOST_NOEXCEPT - { - return is_locked; - } - - }; - - BOOST_THREAD_DCL_MOVABLE_BEG(Mutex) shared_lock BOOST_THREAD_DCL_MOVABLE_END - - template - void swap(shared_lock& lhs,shared_lock& rhs) BOOST_NOEXCEPT - { - lhs.swap(rhs); - } - - template - class upgrade_lock - { - protected: - Mutex* m; - bool is_locked; - - public: - typedef Mutex mutex_type; - BOOST_THREAD_MOVABLE_ONLY( upgrade_lock) - - upgrade_lock()BOOST_NOEXCEPT: - m(0),is_locked(false) - {} - - explicit upgrade_lock(Mutex& m_) : - m(&m_), is_locked(false) - { - lock(); - } - upgrade_lock(Mutex& m_, adopt_lock_t) : - m(&m_), is_locked(true) - { -#if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - BOOST_ASSERT(is_locked_by_this_thread(m)); -#endif - } - upgrade_lock(Mutex& m_, defer_lock_t)BOOST_NOEXCEPT: - m(&m_),is_locked(false) - {} - upgrade_lock(Mutex& m_, try_to_lock_t) : - m(&m_), is_locked(false) - { - try_lock(); - } - -#ifdef BOOST_THREAD_USES_CHRONO - template - upgrade_lock(Mutex& mtx, const chrono::time_point& t) - : m(&mtx), is_locked(mtx.try_lock_upgrade_until(t)) - { - } - template - upgrade_lock(Mutex& mtx, const chrono::duration& d) - : m(&mtx), is_locked(mtx.try_lock_upgrade_for(d)) - { - } -#endif - - upgrade_lock(BOOST_THREAD_RV_REF_BEG upgrade_lock BOOST_THREAD_RV_REF_END other) BOOST_NOEXCEPT: - m(BOOST_THREAD_RV(other).m),is_locked(BOOST_THREAD_RV(other).is_locked) - { - BOOST_THREAD_RV(other).is_locked=false; - BOOST_THREAD_RV(other).m=0; - } - - BOOST_THREAD_EXPLICIT_LOCK_CONVERSION upgrade_lock(BOOST_THREAD_RV_REF_BEG unique_lock BOOST_THREAD_RV_REF_END other): - m(BOOST_THREAD_RV(other).m),is_locked(BOOST_THREAD_RV(other).is_locked) - { - if(is_locked) - { - m->unlock_and_lock_upgrade(); - } - BOOST_THREAD_RV(other).is_locked=false; - BOOST_THREAD_RV(other).m=0; - } - - //std-2104 unique_lock move-assignment should not be noexcept - upgrade_lock& operator=(BOOST_THREAD_RV_REF_BEG upgrade_lock BOOST_THREAD_RV_REF_END other) //BOOST_NOEXCEPT - { - upgrade_lock temp(::boost::move(other)); - swap(temp); - return *this; - } - -#ifndef BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION - upgrade_lock& operator=(BOOST_THREAD_RV_REF_BEG unique_lock BOOST_THREAD_RV_REF_END other) - { - upgrade_lock temp(::boost::move(other)); - swap(temp); - return *this; - } -#endif - -#ifdef BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS - // Conversion from shared locking - upgrade_lock(BOOST_THREAD_RV_REF_BEG shared_lock BOOST_THREAD_RV_REF_END sl, try_to_lock_t) - : m(0),is_locked(false) - { - if (BOOST_THREAD_RV(sl).owns_lock()) - { - if (BOOST_THREAD_RV(sl).mutex()->try_unlock_shared_and_lock_upgrade()) - { - m = BOOST_THREAD_RV(sl).release(); - is_locked = true; - } - } - else - { - m = BOOST_THREAD_RV(sl).release(); - } - } - -#ifdef BOOST_THREAD_USES_CHRONO - template - upgrade_lock(BOOST_THREAD_RV_REF_BEG shared_lock BOOST_THREAD_RV_REF_END sl, - const chrono::time_point& abs_time) - : m(0),is_locked(false) - { - if (BOOST_THREAD_RV(sl).owns_lock()) - { - if (BOOST_THREAD_RV(sl).mutex()->try_unlock_shared_and_lock_upgrade_until(abs_time)) - { - m = BOOST_THREAD_RV(sl).release(); - is_locked = true; - } - } - else - { - m = BOOST_THREAD_RV(sl).release(); - } - } - - template - upgrade_lock(BOOST_THREAD_RV_REF_BEG shared_lock BOOST_THREAD_RV_REF_END sl, - const chrono::duration& rel_time) - : m(0),is_locked(false) - { - if (BOOST_THREAD_RV(sl).owns_lock()) - { - if (BOOST_THREAD_RV(sl).mutex()->try_unlock_shared_and_lock_upgrade_for(rel_time)) - { - m = BOOST_THREAD_RV(sl).release(); - is_locked = true; - } - } - else - { - m = BOOST_THREAD_RV(sl).release(); - } - } -#endif // BOOST_THREAD_USES_CHRONO -#endif // BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS - void swap(upgrade_lock& other)BOOST_NOEXCEPT - { - std::swap(m,other.m); - std::swap(is_locked,other.is_locked); - } - Mutex* mutex() const BOOST_NOEXCEPT - { - return m; - } - - Mutex* release()BOOST_NOEXCEPT - { - Mutex* const res=m; - m=0; - is_locked=false; - return res; - } - ~upgrade_lock() - { - if (owns_lock()) - { - m->unlock_upgrade(); - } - } - void lock() - { - if (m == 0) - { - boost::throw_exception( - boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost upgrade_lock has no mutex")); - } - if (owns_lock()) - { - boost::throw_exception( - boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost upgrade_lock owns already the mutex")); - } - m->lock_upgrade(); - is_locked = true; - } - bool try_lock() - { - if (m == 0) - { - boost::throw_exception( - boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost upgrade_lock has no mutex")); - } - if (owns_lock()) - { - boost::throw_exception( - boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost upgrade_lock owns already the mutex")); - } - is_locked = m->try_lock_upgrade(); - return is_locked; - } - void unlock() - { - if (m == 0) - { - boost::throw_exception( - boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost upgrade_lock has no mutex")); - } - if (!owns_lock()) - { - boost::throw_exception( - boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost upgrade_lock doesn't own the mutex")); - } - m->unlock_upgrade(); - is_locked = false; - } -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_for(const chrono::duration& rel_time) - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost upgrade_lock has no mutex")); - } - if(owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost upgrade_lock owns already the mutex")); - } - is_locked=m->try_lock_upgrade_for(rel_time); - return is_locked; - } - template - bool try_lock_until(const chrono::time_point& abs_time) - { - if(m==0) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::operation_not_permitted), "boost upgrade_lock has no mutex")); - } - if(owns_lock()) - { - boost::throw_exception(boost::lock_error(static_cast(system::errc::resource_deadlock_would_occur), "boost upgrade_lock owns already the mutex")); - } - is_locked=m->try_lock_upgrade_until(abs_time); - return is_locked; - } -#endif -#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) - typedef void (upgrade_lock::*bool_type)(); - operator bool_type() const BOOST_NOEXCEPT - { - return is_locked?&upgrade_lock::lock:0; - } - bool operator!() const BOOST_NOEXCEPT - { - return !owns_lock(); - } -#else - explicit operator bool() const BOOST_NOEXCEPT - { - return owns_lock(); - } -#endif - bool owns_lock() const BOOST_NOEXCEPT - { - return is_locked; - } - friend class shared_lock ; - friend class unique_lock ; - }; - - template - void swap(upgrade_lock& lhs, upgrade_lock& rhs) - BOOST_NOEXCEPT - { - lhs.swap(rhs); - } - - BOOST_THREAD_DCL_MOVABLE_BEG(Mutex) upgrade_lock BOOST_THREAD_DCL_MOVABLE_END - - template - unique_lock::unique_lock(BOOST_THREAD_RV_REF_BEG upgrade_lock BOOST_THREAD_RV_REF_END other): - m(BOOST_THREAD_RV(other).m),is_locked(BOOST_THREAD_RV(other).is_locked) - { - if(is_locked) - { - m->unlock_upgrade_and_lock(); - } - BOOST_THREAD_RV(other).release(); - } - - template - class upgrade_to_unique_lock - { - private: - upgrade_lock* source; - unique_lock exclusive; - - public: - typedef Mutex mutex_type; - BOOST_THREAD_MOVABLE_ONLY( upgrade_to_unique_lock) - - explicit upgrade_to_unique_lock(upgrade_lock& m_) : - source(&m_), exclusive(::boost::move(*source)) - { - } - ~upgrade_to_unique_lock() - { - if (source) - { - *source = BOOST_THREAD_MAKE_RV_REF(upgrade_lock (::boost::move(exclusive))); - } - } - - upgrade_to_unique_lock(BOOST_THREAD_RV_REF_BEG upgrade_to_unique_lock BOOST_THREAD_RV_REF_END other) BOOST_NOEXCEPT: - source(BOOST_THREAD_RV(other).source),exclusive(::boost::move(BOOST_THREAD_RV(other).exclusive)) - { - BOOST_THREAD_RV(other).source=0; - } - - //std-2104 unique_lock move-assignment should not be noexcept - upgrade_to_unique_lock& operator=(BOOST_THREAD_RV_REF_BEG upgrade_to_unique_lock BOOST_THREAD_RV_REF_END other) //BOOST_NOEXCEPT - { - upgrade_to_unique_lock temp(::boost::move(other)); - swap(temp); - return *this; - } - - void swap(upgrade_to_unique_lock& other)BOOST_NOEXCEPT - { - std::swap(source,other.source); - exclusive.swap(other.exclusive); - } - -#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) - typedef void (upgrade_to_unique_lock::*bool_type)(upgrade_to_unique_lock&); - operator bool_type() const BOOST_NOEXCEPT - { - return exclusive.owns_lock()?&upgrade_to_unique_lock::swap:0; - } - bool operator!() const BOOST_NOEXCEPT - { - return !owns_lock(); - } -#else - explicit operator bool() const BOOST_NOEXCEPT - { - return owns_lock(); - } -#endif - - bool owns_lock() const BOOST_NOEXCEPT - { - return exclusive.owns_lock(); - } - Mutex* mutex() const BOOST_NOEXCEPT - { - return exclusive.mutex(); - } - }; - -BOOST_THREAD_DCL_MOVABLE_BEG(Mutex) upgrade_to_unique_lock BOOST_THREAD_DCL_MOVABLE_END - -namespace detail -{ - template - class try_lock_wrapper: -private unique_lock - { - typedef unique_lock base; - public: - BOOST_THREAD_MOVABLE_ONLY(try_lock_wrapper) - - try_lock_wrapper() - {} - - explicit try_lock_wrapper(Mutex& m): - base(m,try_to_lock) - {} - - try_lock_wrapper(Mutex& m_,adopt_lock_t): - base(m_,adopt_lock) - { -#if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - BOOST_ASSERT(is_locked_by_this_thread(m_)); -#endif - } - try_lock_wrapper(Mutex& m_,defer_lock_t): - base(m_,defer_lock) - {} - try_lock_wrapper(Mutex& m_,try_to_lock_t): - base(m_,try_to_lock) - {} -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - try_lock_wrapper(BOOST_THREAD_RV_REF(try_lock_wrapper) other): - base(::boost::move(other)) - {} - -#elif defined BOOST_THREAD_USES_MOVE - try_lock_wrapper(BOOST_THREAD_RV_REF(try_lock_wrapper) other): - base(::boost::move(static_cast(other))) - {} - -#else - try_lock_wrapper(BOOST_THREAD_RV_REF(try_lock_wrapper) other): - base(BOOST_THREAD_RV_REF(base)(*other)) - {} -#endif - try_lock_wrapper& operator=(BOOST_THREAD_RV_REF_BEG try_lock_wrapper BOOST_THREAD_RV_REF_END other) - { - try_lock_wrapper temp(::boost::move(other)); - swap(temp); - return *this; - } - void swap(try_lock_wrapper& other) - { - base::swap(other); - } - void lock() - { - base::lock(); - } - bool try_lock() - { - return base::try_lock(); - } - void unlock() - { - base::unlock(); - } - bool owns_lock() const - { - return base::owns_lock(); - } - Mutex* mutex() const BOOST_NOEXCEPT - { - return base::mutex(); - } - Mutex* release() - { - return base::release(); - } - -#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) - typedef typename base::bool_type bool_type; - operator bool_type() const - { - return base::operator bool_type(); - } - bool operator!() const - { - return !this->owns_lock(); - } -#else - explicit operator bool() const - { - return owns_lock(); - } -#endif - }; - - template - void swap(try_lock_wrapper& lhs,try_lock_wrapper& rhs) - { - lhs.swap(rhs); - } -} -} -#include - -#endif diff --git a/libraries/boost/boost/thread/lockable_adapter.hpp b/libraries/boost/boost/thread/lockable_adapter.hpp deleted file mode 100644 index 93d9ba502..000000000 --- a/libraries/boost/boost/thread/lockable_adapter.hpp +++ /dev/null @@ -1,226 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2008-2009,2012. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_THREAD_LOCKABLE_ADAPTER_HPP -#define BOOST_THREAD_LOCKABLE_ADAPTER_HPP - -#include -#include - -namespace boost -{ - - //[basic_lockable_adapter - template - class basic_lockable_adapter - { - public: - typedef BasicLockable mutex_type; - - protected: - mutex_type& lockable() const - { - return lockable_; - } - mutable mutex_type lockable_; /*< mutable so that it can be modified by const functions >*/ - public: - - BOOST_THREAD_NO_COPYABLE( basic_lockable_adapter) /*< no copyable >*/ - - basic_lockable_adapter() - {} - - void lock() const - { - lockable().lock(); - } - void unlock() const - { - lockable().unlock(); - } - - }; - //] - - //[lockable_adapter - template - class lockable_adapter : public basic_lockable_adapter - { - public: - typedef Lockable mutex_type; - - bool try_lock() const - { - return this->lockable().try_lock(); - } - }; - //] - - //[timed_lockable_adapter - template - class timed_lockable_adapter: public lockable_adapter - { - public: - typedef TimedLock mutex_type; - - template - bool try_lock_until(chrono::time_point const & abs_time) const - { - return this->lockable().try_lock_until(abs_time); - } - template - bool try_lock_for(chrono::duration const & rel_time) const - { - return this->lockable().try_lock_for(rel_time); - } - - }; - //] - - //[shared_lockable_adapter - template - class shared_lockable_adapter: public timed_lockable_adapter - { - public: - typedef SharableLock mutex_type; - - void lock_shared() const - { - this->lockable().lock_shared(); - } - bool try_lock_shared() const - { - return this->lockable().try_lock_shared(); - } - void unlock_shared() const - { - this->lockable().unlock_shared(); - } - - template - bool try_lock_shared_until(chrono::time_point const & abs_time) const - { - return this->lockable().try_lock_shared_until(abs_time); - } - template - bool try_lock_shared_for(chrono::duration const & rel_time) const - { - return this->lockable().try_lock_shared_for(rel_time); - } - - }; - - //] - - //[upgrade_lockable_adapter - template - class upgrade_lockable_adapter: public shared_lockable_adapter - { - public: - typedef UpgradableLock mutex_type; - - void lock_upgrade() const - { - this->lockable().lock_upgrade(); - } - - bool try_lock_upgrade() const - { - return this->lockable().try_lock_upgrade(); - } - - void unlock_upgrade() const - { - this->lockable().unlock_upgrade(); - } - - template - bool try_lock_upgrade_until(chrono::time_point const & abs_time) const - { - return this->lockable().try_lock_upgrade_until(abs_time); - } - template - bool try_lock_upgrade_for(chrono::duration const & rel_time) const - { - return this->lockable().try_lock_upgrade_for(rel_time); - } - - bool try_unlock_shared_and_lock() const - { - return this->lockable().try_unlock_shared_and_lock(); - } - - template - bool try_unlock_shared_and_lock_until(chrono::time_point const & abs_time) const - { - return this->lockable().try_unlock_shared_and_lock_until(abs_time); - } - template - bool try_unlock_shared_and_lock_for(chrono::duration const & rel_time) const - { - return this->lockable().try_unlock_shared_and_lock_for(rel_time); - } - - void unlock_and_lock_shared() const - { - this->lockable().unlock_and_lock_shared(); - } - - bool try_unlock_shared_and_lock_upgrade() const - { - return this->lockable().try_unlock_shared_and_lock_upgrade(); - } - - template - bool try_unlock_shared_and_lock_upgrade_until(chrono::time_point const & abs_time) const - { - return this->lockable().try_unlock_shared_and_lock_upgrade_until(abs_time); - } - template - bool try_unlock_shared_and_lock_upgrade_for(chrono::duration const & rel_time) const - { - return this->lockable().try_unlock_shared_and_lock_upgrade_for(rel_time); - } - - void unlock_and_lock_upgrade() const - { - this->lockable().unlock_and_lock_upgrade(); - } - - void unlock_upgrade_and_lock() const - { - this->lockable().unlock_upgrade_and_lock(); - } - - bool try_unlock_upgrade_and_lock() const - { - return this->lockable().try_unlock_upgrade_and_lock(); - } - template - bool try_unlock_upgrade_and_lock_until(chrono::time_point const & abs_time) const - { - return this->lockable().try_unlock_upgrade_and_lock_until(abs_time); - } - template - bool try_unlock_upgrade_and_lock_for(chrono::duration const & rel_time) const - { - return this->lockable().try_unlock_upgrade_and_lock_for(rel_time); - } - - void unlock_upgrade_and_lock_shared() const - { - this->lockable().unlock_upgrade_and_lock_shared(); - } - - }; -//] - -} -#endif diff --git a/libraries/boost/boost/thread/lockable_concepts.hpp b/libraries/boost/boost/thread/lockable_concepts.hpp deleted file mode 100644 index bedd962e3..000000000 --- a/libraries/boost/boost/thread/lockable_concepts.hpp +++ /dev/null @@ -1,157 +0,0 @@ -// (C) Copyright 2012 Vicente Botet -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_THREAD_LOCKABLE_CONCEPTS_HPP -#define BOOST_THREAD_LOCKABLE_CONCEPTS_HPP - -#include -#include - -namespace boost -{ - - /** - * BasicLockable object supports the basic features - * required to delimit a critical region - * Supports the basic lock and unlock functions. - */ - - //[BasicLockable - template - struct BasicLockable - { - - BOOST_CONCEPT_USAGE(BasicLockable) - { - l.lock(); - l.unlock(); - } - BasicLockable() : l(*static_cast(0)) {} - private: - BasicLockable operator=(BasicLockable const&); - - Mutex& l; - } - ; - //] - /** - * Lockable extends BasicLockable - * with try_lock functions. - */ - - //[Lockable - template - struct Lockable - { - BOOST_CONCEPT_ASSERT(( BasicLockable )); - - BOOST_CONCEPT_USAGE(Lockable) - { - if (l.try_lock()) return; - } - Lockable() : l(*static_cast(0)) {} - private: - Lockable operator=(Lockable const&); - Mutex& l; - }; - //] - - /** - * TimedLockable object extends Lockable - * with timed lock functions: try_lock_until and try_lock_for and the exception based lock_until and lock_for - */ - - //[TimedLockable - template - struct TimedLockable - { - BOOST_CONCEPT_ASSERT(( Lockable )); - - BOOST_CONCEPT_USAGE(TimedLockable) - { - if (l.try_lock_until(t)) return; - if (l.try_lock_for(d)) return; - } - TimedLockable() : l(*static_cast(0)) {} - private: - TimedLockable operator=(TimedLockable const&); - Mutex& l; - chrono::system_clock::time_point t; - chrono::system_clock::duration d; - }; - //] - - /** - * SharedLockable object extends TimedLockable - * with the lock_shared, lock_shared_until, lock_shared_for, try_lock_shared_until, try_lock_shared - * and unlock_shared functions - */ - //[SharedLockable - template - struct SharedLockable - { - BOOST_CONCEPT_ASSERT(( TimedLockable )); - - BOOST_CONCEPT_USAGE(SharedLockable) - { - l.lock_shared(); - l.unlock_shared(); - if (l.try_lock_shared()) return; - if (l.try_lock_shared_until(t)) return; - if (l.try_lock_shared_for(d)) return; - } - SharedLockable() : l(*static_cast(0)) {} - private: - SharedLockable operator=(SharedLockable const&); - Mutex& l; - chrono::system_clock::time_point t; - chrono::system_clock::duration d; - }; - //] - - /** - * UpgradeLockable object extends SharedLockable - * with the lock_upgrade, lock_upgrade_until, unlock_upgrade_and_lock, - * unlock_and_lock_shared and unlock_upgrade_and_lock_shared functions - */ - - //[UpgradeLockable - template - struct UpgradeLockable - { - BOOST_CONCEPT_ASSERT(( SharedLockable )); - - BOOST_CONCEPT_USAGE(UpgradeLockable) - { - l.lock_upgrade(); - l.unlock_upgrade(); - if (l.try_lock_upgrade()) return; - if (l.try_lock_upgrade_until(t)) return; - if (l.try_lock_upgrade_for(d)) return; - if (l.try_unlock_shared_and_lock()) return; - if (l.try_unlock_shared_and_lock_until(t)) return; - if (l.try_unlock_shared_and_lock_for(d)) return; - l.unlock_and_lock_shared(); - if (l.try_unlock_shared_and_lock_upgrade()) return; - if (l.try_unlock_shared_and_lock_upgrade_until(t)) return; - if (l.try_unlock_shared_and_lock_upgrade_for(d)) return; - l.unlock_and_lock_upgrade(); - l.unlock_upgrade_and_lock(); - if (l.try_unlock_upgrade_and_lock()) return; - if (l.try_unlock_upgrade_and_lock_until(t)) return; - if (l.try_unlock_upgrade_and_lock_for(d)) return; - l.unlock_upgrade_and_lock_shared(); - } - UpgradeLockable() : l(*static_cast(0)) {} - private: - UpgradeLockable operator=(UpgradeLockable const&); - Mutex& l; - chrono::system_clock::time_point t; - chrono::system_clock::duration d; - }; - //] - -} -#endif diff --git a/libraries/boost/boost/thread/lockable_traits.hpp b/libraries/boost/boost/thread/lockable_traits.hpp deleted file mode 100644 index 8a17ae72d..000000000 --- a/libraries/boost/boost/thread/lockable_traits.hpp +++ /dev/null @@ -1,207 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_LOCKABLE_TRAITS_HPP -#define BOOST_THREAD_LOCKABLE_TRAITS_HPP - -#include - -#include -#include -#include - -#include - -// todo make use of integral_constant, true_type and false_type - -namespace boost -{ - namespace sync - { - -#if defined(BOOST_NO_SFINAE) || \ - BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) || \ - BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590)) -#if ! defined BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES -#define BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES -#endif -#endif - -#ifndef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES - namespace detail - { -#define BOOST_THREAD_DEFINE_HAS_MEMBER_CALLED(member_name) \ - template::value> \ - struct has_member_called_##member_name \ - { \ - BOOST_STATIC_CONSTANT(bool, value=false); \ - }; \ - \ - template \ - struct has_member_called_##member_name \ - { \ - typedef char true_type; \ - struct false_type \ - { \ - true_type dummy[2]; \ - }; \ - \ - struct fallback { int member_name; }; \ - struct derived: \ - T, fallback \ - { \ - derived(); \ - }; \ - \ - template struct tester; \ - \ - template \ - static false_type has_member(tester<&U::member_name>*); \ - template \ - static true_type has_member(...); \ - \ - BOOST_STATIC_CONSTANT( \ - bool, value=sizeof(has_member(0))==sizeof(true_type)); \ - } - - BOOST_THREAD_DEFINE_HAS_MEMBER_CALLED(lock) -; BOOST_THREAD_DEFINE_HAS_MEMBER_CALLED(unlock); - BOOST_THREAD_DEFINE_HAS_MEMBER_CALLED(try_lock); - - template::value > - struct has_member_lock - { - BOOST_STATIC_CONSTANT(bool, value=false); - }; - - template - struct has_member_lock - { - typedef char true_type; - struct false_type - { - true_type dummy[2]; - }; - - template - static true_type has_member(V (U::*)()); - template - static false_type has_member(U); - - BOOST_STATIC_CONSTANT( - bool,value=sizeof(has_member_lock::has_member(&T::lock))==sizeof(true_type)); - }; - - template::value > - struct has_member_unlock - { - BOOST_STATIC_CONSTANT(bool, value=false); - }; - - template - struct has_member_unlock - { - typedef char true_type; - struct false_type - { - true_type dummy[2]; - }; - - template - static true_type has_member(V (U::*)()); - template - static false_type has_member(U); - - BOOST_STATIC_CONSTANT( - bool,value=sizeof(has_member_unlock::has_member(&T::unlock))==sizeof(true_type)); - }; - - template::value > - struct has_member_try_lock - { - BOOST_STATIC_CONSTANT(bool, value=false); - }; - - template - struct has_member_try_lock - { - typedef char true_type; - struct false_type - { - true_type dummy[2]; - }; - - template - static true_type has_member(bool (U::*)()); - template - static false_type has_member(U); - - BOOST_STATIC_CONSTANT( - bool,value=sizeof(has_member_try_lock::has_member(&T::try_lock))==sizeof(true_type)); - }; - - } - - template - struct is_basic_lockable - { - BOOST_STATIC_CONSTANT(bool, value = detail::has_member_lock::value && - detail::has_member_unlock::value); - }; - template - struct is_lockable - { - BOOST_STATIC_CONSTANT(bool, value = - is_basic_lockable::value && - detail::has_member_try_lock::value); - }; - -#else - template - struct is_basic_lockable - { - BOOST_STATIC_CONSTANT(bool, value = false); - }; - template - struct is_lockable - { - BOOST_STATIC_CONSTANT(bool, value = false); - }; -#endif - - template - struct is_recursive_mutex_sur_parole - { - BOOST_STATIC_CONSTANT(bool, value = false); - }; - template - struct is_recursive_mutex_sur_parolle : is_recursive_mutex_sur_parole - { - }; - - template - struct is_recursive_basic_lockable - { - BOOST_STATIC_CONSTANT(bool, value = is_basic_lockable::value && - is_recursive_mutex_sur_parolle::value); - }; - template - struct is_recursive_lockable - { - BOOST_STATIC_CONSTANT(bool, value = is_lockable::value && - is_recursive_mutex_sur_parolle::value); - }; - } - template - struct is_mutex_type - { - BOOST_STATIC_CONSTANT(bool, value = sync::is_lockable::value); - }; - -} -#include - -#endif diff --git a/libraries/boost/boost/thread/locks.hpp b/libraries/boost/boost/thread/locks.hpp deleted file mode 100644 index 0905aec22..000000000 --- a/libraries/boost/boost/thread/locks.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_LOCKS_HPP -#define BOOST_THREAD_LOCKS_HPP - -#include -#include -#include -#include -#include -#include - -#endif diff --git a/libraries/boost/boost/thread/mutex.hpp b/libraries/boost/boost/thread/mutex.hpp deleted file mode 100644 index 05c60941c..000000000 --- a/libraries/boost/boost/thread/mutex.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef BOOST_THREAD_MUTEX_HPP -#define BOOST_THREAD_MUTEX_HPP - -// mutex.hpp -// -// (C) Copyright 2007 Anthony Williams -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#if defined(BOOST_THREAD_PLATFORM_WIN32) -#include -#elif defined(BOOST_THREAD_PLATFORM_PTHREAD) -#include -#else -#error "Boost threads unavailable on this platform" -#endif - -#include - - -namespace boost -{ - namespace sync - { -#ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES - template<> - struct is_basic_lockable - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - template<> - struct is_lockable - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - template<> - struct is_basic_lockable - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - template<> - struct is_lockable - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; -#endif - } -} - -#endif diff --git a/libraries/boost/boost/thread/null_mutex.hpp b/libraries/boost/boost/thread/null_mutex.hpp deleted file mode 100644 index f439f9ffb..000000000 --- a/libraries/boost/boost/thread/null_mutex.hpp +++ /dev/null @@ -1,243 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2008-2009,2012. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_THREAD_NULL_MUTEX_HPP -#define BOOST_THREAD_NULL_MUTEX_HPP - -#include -#include -#include - -/// \file -/// Describes null_mutex class - -namespace boost -{ - - /// Implements a mutex that simulates a mutex without doing any operation and - /// simulates a successful operation. - class null_mutex - { - public: - - BOOST_THREAD_NO_COPYABLE( null_mutex) /*< no copyable >*/ - - null_mutex() {} - - /// Simulates a mutex lock() operation. Empty function. - void lock() - { - } - - /// Simulates a mutex try_lock() operation. - /// Equivalent to "return true;" - bool try_lock() - { - return true; - } - - /// Simulates a mutex unlock() operation. - /// Empty function. - void unlock() - { - } - -#ifdef BOOST_THREAD_USES_CHRONO - /// Simulates a mutex try_lock_until() operation. - /// Equivalent to "return true;" - template - bool try_lock_until(chrono::time_point const &) - { - return true; - } - - /// Simulates a mutex try_lock_for() operation. - /// Equivalent to "return true;" - template - bool try_lock_for(chrono::duration const &) - { - return true; - } -#endif - - /// Simulates a mutex lock_shared() operation. - /// Empty function. - void lock_shared() - { - } - - /// Simulates a mutex try_lock_shared() operation. - /// Equivalent to "return true;" - bool try_lock_shared() - { - return true; - } - - /// Simulates a mutex unlock_shared() operation. - /// Empty function. - void unlock_shared() - { - } - - /// Simulates a mutex try_lock_shared_until() operation. - /// Equivalent to "return true;" - template - bool try_lock_shared_until(chrono::time_point const &) - { - return true; - } - /// Simulates a mutex try_lock_shared_for() operation. - /// Equivalent to "return true;" - template - bool try_lock_shared_for(chrono::duration const &) - { - return true; - } - - /// Simulates a mutex lock_upgrade() operation. - /// Empty function. - void lock_upgrade() - { - } - - /// Simulates a mutex try_lock_upgrade() operation. - /// Equivalent to "return true;" - bool try_lock_upgrade() - { - return true; - } - - /// Simulates a mutex unlock_upgrade() operation. - /// Empty function. - void unlock_upgrade() - { - } - - /// Simulates a mutex try_lock_upgrade_until() operation. - /// Equivalent to "return true;" - template - bool try_lock_upgrade_until(chrono::time_point const &) - { - return true; - } - - /// Simulates a mutex try_lock_upgrade_for() operation. - /// Equivalent to "return true;" - template - bool try_lock_upgrade_for(chrono::duration const &) - { - return true; - } - - /// Simulates a mutex try_unlock_shared_and_lock() operation. - /// Equivalent to "return true;" - bool try_unlock_shared_and_lock() - { - return true; - } - -#ifdef BOOST_THREAD_USES_CHRONO - /// Simulates a mutex try_unlock_shared_and_lock_until() operation. - /// Equivalent to "return true;" - template - bool try_unlock_shared_and_lock_until(chrono::time_point const &) - { - return true; - } - - /// Simulates a mutex try_unlock_shared_and_lock_for() operation. - /// Equivalent to "return true;" - template - bool try_unlock_shared_and_lock_for(chrono::duration const &) - { - return true; - } -#endif - - /// Simulates unlock_and_lock_shared(). - /// Empty function. - void unlock_and_lock_shared() - { - } - - /// Simulates a mutex try_unlock_shared_and_lock_upgrade() operation. - /// Equivalent to "return true;" - bool try_unlock_shared_and_lock_upgrade() - { - return true; - } - -#ifdef BOOST_THREAD_USES_CHRONO - /// Simulates a mutex try_unlock_shared_and_lock_upgrade_until() operation. - /// Equivalent to "return true;" - template - bool try_unlock_shared_and_lock_upgrade_until(chrono::time_point const &) - { - return true; - } - - /// Simulates a mutex try_unlock_shared_and_lock_upgrade_for() operation. - /// Equivalent to "return true;" - template - bool try_unlock_shared_and_lock_upgrade_for(chrono::duration const &) - { - return true; - } -#endif - - /// Simulates unlock_and_lock_upgrade(). - /// Empty function. - void unlock_and_lock_upgrade() - { - } - - /// Simulates unlock_upgrade_and_lock(). - /// Empty function. - void unlock_upgrade_and_lock() - { - } - - /// Simulates a mutex try_unlock_upgrade_and_lock() operation. - /// Equivalent to "return true;" - bool try_unlock_upgrade_and_lock() - { - return true; - } - -#ifdef BOOST_THREAD_USES_CHRONO - /// Simulates a mutex try_unlock_upgrade_and_lock_until() operation. - /// Equivalent to "return true;" - template - bool try_unlock_upgrade_and_lock_until(chrono::time_point const &) - { - return true; - } - - /// Simulates a mutex try_unlock_upgrade_and_lock_for() operation. - /// Equivalent to "return true;" - template - bool try_unlock_upgrade_and_lock_for(chrono::duration const &) - { - return true; - } -#endif - - /// Simulates unlock_upgrade_and_lock_shared(). - /// Empty function. - void unlock_upgrade_and_lock_shared() - { - } - - }; - -} //namespace boost { - - -#endif diff --git a/libraries/boost/boost/thread/once.hpp b/libraries/boost/boost/thread/once.hpp deleted file mode 100644 index 9fcfb5333..000000000 --- a/libraries/boost/boost/thread/once.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef BOOST_THREAD_ONCE_HPP -#define BOOST_THREAD_ONCE_HPP - -// once.hpp -// -// (C) Copyright 2006-7 Anthony Williams -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#if defined(BOOST_THREAD_PLATFORM_WIN32) -#include -#elif defined(BOOST_THREAD_PLATFORM_PTHREAD) -#if defined BOOST_THREAD_ONCE_FAST_EPOCH -#include -#elif defined BOOST_THREAD_ONCE_ATOMIC -#include -#else -#error "Once Not Implemented" -#endif -#else -#error "Boost threads unavailable on this platform" -#endif - -#include - -namespace boost -{ - // template void - // call_once(once_flag& flag, Callable&& func, Args&&... args); -template -inline void call_once(Function func,once_flag& flag) -//inline void call_once(void (*func)(),once_flag& flag) - { - call_once(flag,func); - } -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/ostream_buffer.hpp b/libraries/boost/boost/thread/ostream_buffer.hpp deleted file mode 100644 index cc02a9c0c..000000000 --- a/libraries/boost/boost/thread/ostream_buffer.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// (C) Copyright 2013 Vicente J. Botet Escriba -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -#ifndef BOOST_THREAD_OSTREAM_BUFFER_HPP -#define BOOST_THREAD_OSTREAM_BUFFER_HPP - -#include -#include -#include - -#include - -namespace boost -{ - - template - class ostream_buffer - { - public: - typedef std::basic_ostringstream stream_type; - ostream_buffer(OStream& os) : - os_(os) - { - } - ~ostream_buffer() - { - os_ << o_str_.str(); - } - stream_type& stream() - { - return o_str_; - } - private: - OStream& os_; - stream_type o_str_; - }; - -} - -#include - -#endif // header diff --git a/libraries/boost/boost/thread/poly_lockable.hpp b/libraries/boost/boost/thread/poly_lockable.hpp deleted file mode 100644 index fffcbce13..000000000 --- a/libraries/boost/boost/thread/poly_lockable.hpp +++ /dev/null @@ -1,68 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2008-2009,2012. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_THREAD_POLY_LOCKABLE_HPP -#define BOOST_THREAD_POLY_LOCKABLE_HPP - -#include -#include - -namespace boost -{ - - //[basic_poly_lockable - class basic_poly_lockable - { - public: - - virtual ~basic_poly_lockable() = 0; - - virtual void lock() = 0; - virtual void unlock() = 0; - - }; - //] - - //[poly_lockable - class poly_lockable : public basic_poly_lockable - { - public: - - virtual ~poly_lockable() = 0; - virtual bool try_lock() = 0; - }; - //] - - //[timed_poly_lockable - class timed_poly_lockable: public poly_lockable - { - public: - virtual ~timed_poly_lockable()=0; - - virtual bool try_lock_until(chrono::system_clock::time_point const & abs_time)=0; - virtual bool try_lock_until(chrono::steady_clock::time_point const & abs_time)=0; - template - bool try_lock_until(chrono::time_point const & abs_time) - { - return try_lock_until(time_point_cast(abs_time)); - } - - virtual bool try_lock_for(chrono::nanoseconds const & relative_time)=0; - template - bool try_lock_for(chrono::duration const & rel_time) - { - return try_lock_for(duration_cast(rel_time)); - } - - }; - //] - -} -#endif diff --git a/libraries/boost/boost/thread/poly_lockable_adapter.hpp b/libraries/boost/boost/thread/poly_lockable_adapter.hpp deleted file mode 100644 index 448789ecb..000000000 --- a/libraries/boost/boost/thread/poly_lockable_adapter.hpp +++ /dev/null @@ -1,89 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2008-2009,2012. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_THREAD_POLY_LOCKABLE_ADAPTER_HPP -#define BOOST_THREAD_POLY_LOCKABLE_ADAPTER_HPP - -#include - -namespace boost -{ - - //[poly_basic_lockable_adapter - template - class poly_basic_lockable_adapter : public Base - { - public: - typedef Mutex mutex_type; - - protected: - mutex_type& mtx() const - { - return mtx_; - } - mutable mutex_type mtx_; /*< mutable so that it can be modified by const functions >*/ - public: - - BOOST_THREAD_NO_COPYABLE( poly_basic_lockable_adapter) /*< no copyable >*/ - - poly_basic_lockable_adapter() - {} - - void lock() - { - mtx().lock(); - } - void unlock() - { - mtx().unlock(); - } - - }; - //] - - //[poly_lockable_adapter - template - class poly_lockable_adapter : public poly_basic_lockable_adapter - { - public: - typedef Mutex mutex_type; - - bool try_lock() - { - return this->mtx().try_lock(); - } - }; - //] - - //[poly_timed_lockable_adapter - template - class poly_timed_lockable_adapter: public poly_lockable_adapter - { - public: - typedef Mutex mutex_type; - - bool try_lock_until(chrono::system_clock::time_point const & abs_time) - { - return this->mtx().try_lock_until(abs_time); - } - bool try_lock_until(chrono::steady_clock::time_point const & abs_time) - { - return this->mtx().try_lock_until(abs_time); - } - bool try_lock_for(chrono::nanoseconds const & rel_time) - { - return this->mtx().try_lock_for(rel_time); - } - - }; - //] - -} -#endif diff --git a/libraries/boost/boost/thread/poly_shared_lockable.hpp b/libraries/boost/boost/thread/poly_shared_lockable.hpp deleted file mode 100644 index 4348ed76c..000000000 --- a/libraries/boost/boost/thread/poly_shared_lockable.hpp +++ /dev/null @@ -1,135 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2008-2009,2012. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_THREAD_POLY_SHARED_LOCKABLE_HPP -#define BOOST_THREAD_POLY_SHARED_LOCKABLE_HPP - -#include -#include - -namespace boost -{ - - - //[shared_poly_lockable - class shared_poly_lockable: public timed_poly_lockable - { - public: - virtual ~shared_poly_lockable() = 0; - - virtual void lock_shared() = 0; - virtual bool try_lock_shared() = 0; - virtual void unlock_shared() = 0; - - virtual bool try_lock_shared_until(chrono::system_clock::time_point const & abs_time)=0; - virtual bool try_lock_shared_until(chrono::steady_clock::time_point const & abs_time)=0; - template - bool try_lock_shared_until(chrono::time_point const & abs_time) - { - return try_lock_shared_until(time_point_cast(abs_time)); - } - - virtual bool try_lock_shared_for(chrono::nanoseconds const & relative_time)=0; - template - bool try_lock_shared_for(chrono::duration const & rel_time) - { - return try_lock_shared_for(duration_cast(rel_time)); - } - - }; - - //] - - //[upgrade_poly_lockable - class upgrade_poly_lockable: public shared_poly_lockable - { - public: - virtual ~upgrade_poly_lockable() = 0; - - virtual void lock_upgrade() = 0; - virtual bool try_lock_upgrade() = 0; - virtual void unlock_upgrade() = 0; - - virtual bool try_lock_upgrade_until(chrono::system_clock::time_point const & abs_time)=0; - virtual bool try_lock_upgrade_until(chrono::steady_clock::time_point const & abs_time)=0; - template - bool try_lock_upgrade_until(chrono::time_point const & abs_time) - { - return try_lock_upgrade_until(time_point_cast(abs_time)); - } - - virtual bool try_lock_upgrade_for(chrono::nanoseconds const & relative_time)=0; - template - bool try_lock_upgrade_for(chrono::duration const & rel_time) - { - return try_lock_upgrade_for(duration_cast(rel_time)); - } - - virtual bool try_unlock_shared_and_lock() = 0; - - virtual bool try_unlock_shared_and_lock_until(chrono::system_clock::time_point const & abs_time)=0; - virtual bool try_unlock_shared_and_lock_until(chrono::steady_clock::time_point const & abs_time)=0; - template - bool try_unlock_shared_and_lock_until(chrono::time_point const & abs_time) - { - return try_unlock_shared_and_lock_until(time_point_cast(abs_time)); - } - - virtual bool try_unlock_shared_and_lock_for(chrono::nanoseconds const & relative_time)=0; - template - bool try_unlock_shared_and_lock_for(chrono::duration const & rel_time) - { - return try_unlock_shared_and_lock_for(duration_cast(rel_time)); - } - - virtual void unlock_and_lock_shared() = 0; - virtual bool try_unlock_shared_and_lock_upgrade() = 0; - - virtual bool try_unlock_shared_and_lock_upgrade_until(chrono::system_clock::time_point const & abs_time)=0; - virtual bool try_unlock_shared_and_lock_upgrade_until(chrono::steady_clock::time_point const & abs_time)=0; - template - bool try_unlock_shared_and_lock_upgrade_until(chrono::time_point const & abs_time) - { - return try_unlock_shared_and_lock_upgrade_until(time_point_cast(abs_time)); - } - - virtual bool try_unlock_shared_and_lock_upgrade_for(chrono::nanoseconds const & relative_time)=0; - template - bool try_unlock_shared_and_lock_upgrade_for(chrono::duration const & rel_time) - { - return try_unlock_shared_and_lock_upgrade_for(duration_cast(rel_time)); - } - - virtual void unlock_and_lock_upgrade() = 0; - virtual void unlock_upgrade_and_lock() = 0; - virtual bool try_unlock_upgrade_and_lock() = 0; - - virtual bool try_unlock_upgrade_and_lock_until(chrono::system_clock::time_point const & abs_time)=0; - virtual bool try_unlock_upgrade_and_lock_until(chrono::steady_clock::time_point const & abs_time)=0; - template - bool try_unlock_upgrade_and_lock_until(chrono::time_point const & abs_time) - { - return try_unlock_upgrade_and_lock_until(time_point_cast(abs_time)); - } - - virtual bool try_unlock_upgrade_and_lock_for(chrono::nanoseconds const & relative_time)=0; - template - bool try_unlock_upgrade_and_lock_for(chrono::duration const & rel_time) - { - return try_unlock_upgrade_and_lock_for(duration_cast(rel_time)); - } - - virtual void unlock_upgrade_and_lock_shared() = 0; - - }; -//] - -} -#endif diff --git a/libraries/boost/boost/thread/poly_shared_lockable_adapter.hpp b/libraries/boost/boost/thread/poly_shared_lockable_adapter.hpp deleted file mode 100644 index f13612890..000000000 --- a/libraries/boost/boost/thread/poly_shared_lockable_adapter.hpp +++ /dev/null @@ -1,170 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2008-2009,2012. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef BOOST_THREAD_POLY_SHARED_LOCKABLE_ADAPTER_HPP -#define BOOST_THREAD_POLY_SHARED_LOCKABLE_ADAPTER_HPP - -#include -#include - -namespace boost -{ - - //[shared_lockable_adapter - template - class poly_shared_lockable_adapter: public poly_timed_lockable_adapter - { - public: - typedef Mutex mutex_type; - - void lock_shared() - { - this->mtx().lock_shared(); - } - bool try_lock_shared() - { - return this->mtx().try_lock_shared(); - } - void unlock_shared() - { - this->mtx().unlock_shared(); - } - - bool try_lock_shared_until(chrono::system_clock::time_point const & abs_time) - { - return this->mtx().try_lock_shared_until(abs_time); - } - bool try_lock_shared_until(chrono::steady_clock::time_point const & abs_time) - { - return this->mtx().try_lock_shared_until(abs_time); - } - bool try_lock_shared_for(chrono::nanoseconds const & rel_time) - { - return this->mtx().try_lock_shared_for(rel_time); - } - - }; - - //] - - //[upgrade_lockable_adapter - template - class upgrade_lockable_adapter: public shared_lockable_adapter - { - public: - typedef Mutex mutex_type; - - void lock_upgrade() - { - this->mtx().lock_upgrade(); - } - - bool try_lock_upgrade() - { - return this->mtx().try_lock_upgrade(); - } - - void unlock_upgrade() - { - this->mtx().unlock_upgrade(); - } - - bool try_lock_upgrade_until(chrono::system_clock::time_point const & abs_time) - { - return this->mtx().try_lock_upgrade_until(abs_time); - } - bool try_lock_upgrade_until(chrono::steady_clock::time_point const & abs_time) - { - return this->mtx().try_lock_upgrade_until(abs_time); - } - bool try_lock_upgrade_for(chrono::nanoseconds const & rel_time) - { - return this->mtx().try_lock_upgrade_for(rel_time); - } - - bool try_unlock_shared_and_lock() - { - return this->mtx().try_unlock_shared_and_lock(); - } - - bool try_unlock_shared_and_lock_until(chrono::system_clock::time_point const & abs_time) - { - return this->mtx().try_unlock_shared_and_lock_until(abs_time); - } - bool try_unlock_shared_and_lock_until(chrono::steady_clock::time_point const & abs_time) - { - return this->mtx().try_unlock_shared_and_lock_until(abs_time); - } - template - bool try_unlock_shared_and_lock_for(chrono::nanoseconds const & rel_time) - { - return this->mtx().try_unlock_shared_and_lock_for(rel_time); - } - - void unlock_and_lock_shared() - { - this->mtx().unlock_and_lock_shared(); - } - - bool try_unlock_shared_and_lock_upgrade() - { - return this->mtx().try_unlock_shared_and_lock_upgrade(); - } - - bool try_unlock_shared_and_lock_upgrade_until(chrono::system_clock::time_point const & abs_time) - { - return this->mtx().try_unlock_shared_and_lock_upgrade_until(abs_time); - } - bool try_unlock_shared_and_lock_upgrade_until(chrono::steady_clock::time_point const & abs_time) - { - return this->mtx().try_unlock_shared_and_lock_upgrade_until(abs_time); - } - bool try_unlock_shared_and_lock_upgrade_for(chrono::nanoseconds const & rel_time) - { - return this->mtx().try_unlock_shared_and_lock_upgrade_for(rel_time); - } - - void unlock_and_lock_upgrade() - { - this->mtx().unlock_and_lock_upgrade(); - } - - void unlock_upgrade_and_lock() - { - this->mtx().unlock_upgrade_and_lock(); - } - - bool try_unlock_upgrade_and_lock() - { - return this->mtx().try_unlock_upgrade_and_lock(); - } - bool try_unlock_upgrade_and_lock_until(chrono::system_clock::time_point const & abs_time) - { - return this->mtx().try_unlock_upgrade_and_lock_until(abs_time); - } - bool try_unlock_upgrade_and_lock_until(chrono::steady_clock::time_point const & abs_time) - { - return this->mtx().try_unlock_upgrade_and_lock_until(abs_time); - } - bool try_unlock_upgrade_and_lock_for(chrono::nanoseconds const & rel_time) - { - return this->mtx().try_unlock_upgrade_and_lock_for(rel_time); - } - - void unlock_upgrade_and_lock_shared() - { - this->mtx().unlock_upgrade_and_lock_shared(); - } - - }; -//] - -} -#endif diff --git a/libraries/boost/boost/thread/pthread/condition_variable.hpp b/libraries/boost/boost/thread/pthread/condition_variable.hpp deleted file mode 100644 index e8378c7d3..000000000 --- a/libraries/boost/boost/thread/pthread/condition_variable.hpp +++ /dev/null @@ -1,429 +0,0 @@ -#ifndef BOOST_THREAD_CONDITION_VARIABLE_PTHREAD_HPP -#define BOOST_THREAD_CONDITION_VARIABLE_PTHREAD_HPP -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007-10 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - -#include -#include -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS -#include -#endif -#include -#ifdef BOOST_THREAD_USES_CHRONO -#include -#include -#endif -#include - -#include - -namespace boost -{ -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - namespace this_thread - { - void BOOST_THREAD_DECL interruption_point(); - } -#endif - - namespace thread_cv_detail - { - template - struct lock_on_exit - { - MutexType* m; - - lock_on_exit(): - m(0) - {} - - void activate(MutexType& m_) - { - m_.unlock(); - m=&m_; - } - ~lock_on_exit() - { - if(m) - { - m->lock(); - } - } - }; - } - - inline void condition_variable::wait(unique_lock& m) - { -#if defined BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED - if(! m.owns_lock()) - { - boost::throw_exception(condition_error(-1, "boost::condition_variable::wait() failed precondition mutex not owned")); - } -#endif - int res=0; - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - thread_cv_detail::lock_on_exit > guard; - detail::interruption_checker check_for_interruption(&internal_mutex,&cond); - pthread_mutex_t* the_mutex = &internal_mutex; - guard.activate(m); -#else - pthread_mutex_t* the_mutex = m.mutex()->native_handle(); -#endif - do { - res = pthread_cond_wait(&cond,the_mutex); - } while (res == EINTR); - } -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - this_thread::interruption_point(); -#endif - if(res) - { - boost::throw_exception(condition_error(res, "boost::condition_variable::wait failed in pthread_cond_wait")); - } - } - - inline bool condition_variable::do_wait_until( - unique_lock& m, - struct timespec const &timeout) - { -#if defined BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED - if (!m.owns_lock()) - { - boost::throw_exception(condition_error(EPERM, "boost::condition_variable::do_wait_until() failed precondition mutex not owned")); - } -#endif - int cond_res; - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - thread_cv_detail::lock_on_exit > guard; - detail::interruption_checker check_for_interruption(&internal_mutex,&cond); - pthread_mutex_t* the_mutex = &internal_mutex; - guard.activate(m); -#else - pthread_mutex_t* the_mutex = m.mutex()->native_handle(); -#endif - cond_res=pthread_cond_timedwait(&cond,the_mutex,&timeout); - } -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - this_thread::interruption_point(); -#endif - if(cond_res==ETIMEDOUT) - { - return false; - } - if(cond_res) - { - boost::throw_exception(condition_error(cond_res, "boost::condition_variable::do_wait_until failed in pthread_cond_timedwait")); - } - return true; - } - - inline void condition_variable::notify_one() BOOST_NOEXCEPT - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex); -#endif - BOOST_VERIFY(!pthread_cond_signal(&cond)); - } - - inline void condition_variable::notify_all() BOOST_NOEXCEPT - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex); -#endif - BOOST_VERIFY(!pthread_cond_broadcast(&cond)); - } - - class condition_variable_any - { - pthread_mutex_t internal_mutex; - pthread_cond_t cond; - - public: - BOOST_THREAD_NO_COPYABLE(condition_variable_any) - condition_variable_any() - { - int const res=pthread_mutex_init(&internal_mutex,NULL); - if(res) - { - boost::throw_exception(thread_resource_error(res, "boost::condition_variable_any::condition_variable_any() failed in pthread_mutex_init")); - } - int const res2 = detail::monotonic_pthread_cond_init(cond); - if(res2) - { - BOOST_VERIFY(!pthread_mutex_destroy(&internal_mutex)); - boost::throw_exception(thread_resource_error(res2, "boost::condition_variable_any::condition_variable_any() failed in detail::monotonic_pthread_cond_init")); - } - } - ~condition_variable_any() - { - BOOST_VERIFY(!pthread_mutex_destroy(&internal_mutex)); - BOOST_VERIFY(!pthread_cond_destroy(&cond)); - } - - template - void wait(lock_type& m) - { - int res=0; - { - thread_cv_detail::lock_on_exit guard; -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - detail::interruption_checker check_for_interruption(&internal_mutex,&cond); -#else - boost::pthread::pthread_mutex_scoped_lock check_for_interruption(&internal_mutex); -#endif - guard.activate(m); - res=pthread_cond_wait(&cond,&internal_mutex); - } -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - this_thread::interruption_point(); -#endif - if(res) - { - boost::throw_exception(condition_error(res, "boost::condition_variable_any::wait() failed in pthread_cond_wait")); - } - } - - template - void wait(lock_type& m,predicate_type pred) - { - while(!pred()) wait(m); - } - -#if defined BOOST_THREAD_USES_DATETIME - template - bool timed_wait(lock_type& m,boost::system_time const& abs_time) - { - struct timespec const timeout=detail::to_timespec(abs_time); - return do_wait_until(m, timeout); - } - template - bool timed_wait(lock_type& m,xtime const& abs_time) - { - return timed_wait(m,system_time(abs_time)); - } - - template - bool timed_wait(lock_type& m,duration_type const& wait_duration) - { - return timed_wait(m,get_system_time()+wait_duration); - } - - template - bool timed_wait(lock_type& m,boost::system_time const& abs_time, predicate_type pred) - { - while (!pred()) - { - if(!timed_wait(m, abs_time)) - return pred(); - } - return true; - } - - template - bool timed_wait(lock_type& m,xtime const& abs_time, predicate_type pred) - { - return timed_wait(m,system_time(abs_time),pred); - } - - template - bool timed_wait(lock_type& m,duration_type const& wait_duration,predicate_type pred) - { - return timed_wait(m,get_system_time()+wait_duration,pred); - } -#endif -#ifndef BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC - -#ifdef BOOST_THREAD_USES_CHRONO - template - cv_status - wait_until( - lock_type& lock, - const chrono::time_point& t) - { - using namespace chrono; - typedef time_point nano_sys_tmpt; - wait_until(lock, - nano_sys_tmpt(ceil(t.time_since_epoch()))); - return system_clock::now() < t ? cv_status::no_timeout : - cv_status::timeout; - } - - template - cv_status - wait_until( - lock_type& lock, - const chrono::time_point& t) - { - using namespace chrono; - system_clock::time_point s_now = system_clock::now(); - typename Clock::time_point c_now = Clock::now(); - wait_until(lock, s_now + ceil(t - c_now)); - return Clock::now() < t ? cv_status::no_timeout : cv_status::timeout; - } - - template - cv_status - wait_for( - lock_type& lock, - const chrono::duration& d) - { - using namespace chrono; - system_clock::time_point s_now = system_clock::now(); - steady_clock::time_point c_now = steady_clock::now(); - wait_until(lock, s_now + ceil(d)); - return steady_clock::now() - c_now < d ? cv_status::no_timeout : - cv_status::timeout; - - } - - template - cv_status wait_until( - lock_type& lk, - chrono::time_point tp) - { - using namespace chrono; - nanoseconds d = tp.time_since_epoch(); - timespec ts = boost::detail::to_timespec(d); - if (do_wait_until(lk, ts)) return cv_status::no_timeout; - else return cv_status::timeout; - } -#endif -#else // defined BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC -#ifdef BOOST_THREAD_USES_CHRONO - - template - cv_status - wait_until( - lock_type& lock, - const chrono::time_point& t) - { - using namespace chrono; - typedef time_point nano_sys_tmpt; - wait_until(lock, - nano_sys_tmpt(ceil(t.time_since_epoch()))); - return steady_clock::now() < t ? cv_status::no_timeout : - cv_status::timeout; - } - - template - cv_status - wait_until( - lock_type& lock, - const chrono::time_point& t) - { - using namespace chrono; - steady_clock::time_point s_now = steady_clock::now(); - typename Clock::time_point c_now = Clock::now(); - wait_until(lock, s_now + ceil(t - c_now)); - return Clock::now() < t ? cv_status::no_timeout : cv_status::timeout; - } - - template - cv_status - wait_for( - lock_type& lock, - const chrono::duration& d) - { - using namespace chrono; - steady_clock::time_point c_now = steady_clock::now(); - wait_until(lock, c_now + ceil(d)); - return steady_clock::now() - c_now < d ? cv_status::no_timeout : - cv_status::timeout; - } - - template - inline cv_status wait_until( - lock_type& lock, - chrono::time_point tp) - { - using namespace chrono; - nanoseconds d = tp.time_since_epoch(); - timespec ts = boost::detail::to_timespec(d); - if (do_wait_until(lock, ts)) return cv_status::no_timeout; - else return cv_status::timeout; - } - -#endif -#endif // defined BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC - -#ifdef BOOST_THREAD_USES_CHRONO - template - bool - wait_until( - lock_type& lock, - const chrono::time_point& t, - Predicate pred) - { - while (!pred()) - { - if (wait_until(lock, t) == cv_status::timeout) - return pred(); - } - return true; - } - - template - bool - wait_for( - lock_type& lock, - const chrono::duration& d, - Predicate pred) - { - return wait_until(lock, chrono::steady_clock::now() + d, boost::move(pred)); - } -#endif - - void notify_one() BOOST_NOEXCEPT - { - boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex); - BOOST_VERIFY(!pthread_cond_signal(&cond)); - } - - void notify_all() BOOST_NOEXCEPT - { - boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex); - BOOST_VERIFY(!pthread_cond_broadcast(&cond)); - } - private: // used by boost::thread::try_join_until - - template - bool do_wait_until( - lock_type& m, - struct timespec const &timeout) - { - int res=0; - { - thread_cv_detail::lock_on_exit guard; -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - detail::interruption_checker check_for_interruption(&internal_mutex,&cond); -#else - boost::pthread::pthread_mutex_scoped_lock check_for_interruption(&internal_mutex); -#endif - guard.activate(m); - res=pthread_cond_timedwait(&cond,&internal_mutex,&timeout); - } -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - this_thread::interruption_point(); -#endif - if(res==ETIMEDOUT) - { - return false; - } - if(res) - { - boost::throw_exception(condition_error(res, "boost::condition_variable_any::do_wait_until() failed in pthread_cond_timedwait")); - } - return true; - } - }; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/pthread/condition_variable_fwd.hpp b/libraries/boost/boost/thread/pthread/condition_variable_fwd.hpp deleted file mode 100644 index 652a8c0ba..000000000 --- a/libraries/boost/boost/thread/pthread/condition_variable_fwd.hpp +++ /dev/null @@ -1,361 +0,0 @@ -#ifndef BOOST_THREAD_PTHREAD_CONDITION_VARIABLE_FWD_HPP -#define BOOST_THREAD_PTHREAD_CONDITION_VARIABLE_FWD_HPP -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007-8 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - -#include -#include -#include -#include -#include -#include -#include -#include -#if defined BOOST_THREAD_USES_DATETIME -#include -#endif -#ifdef BOOST_THREAD_USES_CHRONO -#include -#include -#endif -#include -#include - -#include - -namespace boost -{ - namespace detail { - inline int monotonic_pthread_cond_init(pthread_cond_t& cond) { - -#ifdef BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC - pthread_condattr_t attr; - int res = pthread_condattr_init(&attr); - if (res) - { - return res; - } - pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); - res=pthread_cond_init(&cond,&attr); - pthread_condattr_destroy(&attr); - return res; -#else - return pthread_cond_init(&cond,NULL); -#endif - - } - } - - class condition_variable - { - private: -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - pthread_mutex_t internal_mutex; -#endif - pthread_cond_t cond; - - public: - //private: // used by boost::thread::try_join_until - - inline bool do_wait_until( - unique_lock& lock, - struct timespec const &timeout); - - bool do_wait_for( - unique_lock& lock, - struct timespec const &timeout) - { - return do_wait_until(lock, boost::detail::timespec_plus(timeout, boost::detail::timespec_now())); - } - - public: - BOOST_THREAD_NO_COPYABLE(condition_variable) - condition_variable() - { - int res; -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - res=pthread_mutex_init(&internal_mutex,NULL); - if(res) - { - boost::throw_exception(thread_resource_error(res, "boost::condition_variable::condition_variable() constructor failed in pthread_mutex_init")); - } -#endif - res = detail::monotonic_pthread_cond_init(cond); - if (res) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - BOOST_VERIFY(!pthread_mutex_destroy(&internal_mutex)); -#endif - boost::throw_exception(thread_resource_error(res, "boost::condition_variable::condition_variable() constructor failed in detail::monotonic_pthread_cond_init")); - } - } - ~condition_variable() - { - int ret; -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - do { - ret = pthread_mutex_destroy(&internal_mutex); - } while (ret == EINTR); - BOOST_ASSERT(!ret); -#endif - do { - ret = pthread_cond_destroy(&cond); - } while (ret == EINTR); - BOOST_ASSERT(!ret); - } - - void wait(unique_lock& m); - - template - void wait(unique_lock& m,predicate_type pred) - { - while(!pred()) wait(m); - } - -#if defined BOOST_THREAD_USES_DATETIME - inline bool timed_wait( - unique_lock& m, - boost::system_time const& abs_time) - { -#if defined BOOST_THREAD_WAIT_BUG - struct timespec const timeout=detail::to_timespec(abs_time + BOOST_THREAD_WAIT_BUG); - return do_wait_until(m, timeout); -#else - struct timespec const timeout=detail::to_timespec(abs_time); - return do_wait_until(m, timeout); -#endif - } - bool timed_wait( - unique_lock& m, - xtime const& abs_time) - { - return timed_wait(m,system_time(abs_time)); - } - - template - bool timed_wait( - unique_lock& m, - duration_type const& wait_duration) - { - if (wait_duration.is_pos_infinity()) - { - wait(m); // or do_wait(m,detail::timeout::sentinel()); - return true; - } - if (wait_duration.is_special()) - { - return true; - } - return timed_wait(m,get_system_time()+wait_duration); - } - - template - bool timed_wait( - unique_lock& m, - boost::system_time const& abs_time,predicate_type pred) - { - while (!pred()) - { - if(!timed_wait(m, abs_time)) - return pred(); - } - return true; - } - - template - bool timed_wait( - unique_lock& m, - xtime const& abs_time,predicate_type pred) - { - return timed_wait(m,system_time(abs_time),pred); - } - - template - bool timed_wait( - unique_lock& m, - duration_type const& wait_duration,predicate_type pred) - { - if (wait_duration.is_pos_infinity()) - { - while (!pred()) - { - wait(m); // or do_wait(m,detail::timeout::sentinel()); - } - return true; - } - if (wait_duration.is_special()) - { - return pred(); - } - return timed_wait(m,get_system_time()+wait_duration,pred); - } -#endif - -#ifndef BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC - -#ifdef BOOST_THREAD_USES_CHRONO - - template - cv_status - wait_until( - unique_lock& lock, - const chrono::time_point& t) - { - using namespace chrono; - typedef time_point nano_sys_tmpt; - wait_until(lock, - nano_sys_tmpt(ceil(t.time_since_epoch()))); - return system_clock::now() < t ? cv_status::no_timeout : - cv_status::timeout; - } - - template - cv_status - wait_until( - unique_lock& lock, - const chrono::time_point& t) - { - using namespace chrono; - system_clock::time_point s_now = system_clock::now(); - typename Clock::time_point c_now = Clock::now(); - wait_until(lock, s_now + ceil(t - c_now)); - return Clock::now() < t ? cv_status::no_timeout : cv_status::timeout; - } - - - - template - cv_status - wait_for( - unique_lock& lock, - const chrono::duration& d) - { - using namespace chrono; - system_clock::time_point s_now = system_clock::now(); - steady_clock::time_point c_now = steady_clock::now(); - wait_until(lock, s_now + ceil(d)); - return steady_clock::now() - c_now < d ? cv_status::no_timeout : - cv_status::timeout; - - } - - inline cv_status wait_until( - unique_lock& lk, - chrono::time_point tp) - { - using namespace chrono; - nanoseconds d = tp.time_since_epoch(); - timespec ts = boost::detail::to_timespec(d); - if (do_wait_until(lk, ts)) return cv_status::no_timeout; - else return cv_status::timeout; - } -#endif - -#else // defined BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC -#ifdef BOOST_THREAD_USES_CHRONO - - template - cv_status - wait_until( - unique_lock& lock, - const chrono::time_point& t) - { - using namespace chrono; - typedef time_point nano_sys_tmpt; - wait_until(lock, - nano_sys_tmpt(ceil(t.time_since_epoch()))); - return steady_clock::now() < t ? cv_status::no_timeout : - cv_status::timeout; - } - - template - cv_status - wait_until( - unique_lock& lock, - const chrono::time_point& t) - { - using namespace chrono; - steady_clock::time_point s_now = steady_clock::now(); - typename Clock::time_point c_now = Clock::now(); - wait_until(lock, s_now + ceil(t - c_now)); - return Clock::now() < t ? cv_status::no_timeout : cv_status::timeout; - } - - template - cv_status - wait_for( - unique_lock& lock, - const chrono::duration& d) - { - using namespace chrono; - steady_clock::time_point c_now = steady_clock::now(); - wait_until(lock, c_now + ceil(d)); - return steady_clock::now() - c_now < d ? cv_status::no_timeout : - cv_status::timeout; - } - - inline cv_status wait_until( - unique_lock& lk, - chrono::time_point tp) - { - using namespace chrono; - nanoseconds d = tp.time_since_epoch(); - timespec ts = boost::detail::to_timespec(d); - if (do_wait_until(lk, ts)) return cv_status::no_timeout; - else return cv_status::timeout; - } -#endif - -#endif // defined BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC - -#ifdef BOOST_THREAD_USES_CHRONO - template - bool - wait_until( - unique_lock& lock, - const chrono::time_point& t, - Predicate pred) - { - while (!pred()) - { - if (wait_until(lock, t) == cv_status::timeout) - return pred(); - } - return true; - } - - template - bool - wait_for( - unique_lock& lock, - const chrono::duration& d, - Predicate pred) - { - return wait_until(lock, chrono::steady_clock::now() + d, boost::move(pred)); - } -#endif - -#define BOOST_THREAD_DEFINES_CONDITION_VARIABLE_NATIVE_HANDLE - typedef pthread_cond_t* native_handle_type; - native_handle_type native_handle() - { - return &cond; - } - - void notify_one() BOOST_NOEXCEPT; - void notify_all() BOOST_NOEXCEPT; - - - }; - - BOOST_THREAD_DECL void notify_all_at_thread_exit(condition_variable& cond, unique_lock lk); - -} - - -#include - -#endif diff --git a/libraries/boost/boost/thread/pthread/mutex.hpp b/libraries/boost/boost/thread/pthread/mutex.hpp deleted file mode 100644 index 9ac808b6f..000000000 --- a/libraries/boost/boost/thread/pthread/mutex.hpp +++ /dev/null @@ -1,361 +0,0 @@ -#ifndef BOOST_THREAD_PTHREAD_MUTEX_HPP -#define BOOST_THREAD_PTHREAD_MUTEX_HPP -// (C) Copyright 2007-8 Anthony Williams -// (C) Copyright 2011,2012,2015 Vicente J. Botet Escriba -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include -#include -#include -#include -#if defined BOOST_THREAD_PROVIDES_NESTED_LOCKS -#include -#endif -#include -#include -#include -#include -#include -#include -#ifdef BOOST_THREAD_USES_CHRONO -#include -#include -#endif -#include - -#if (defined(_POSIX_TIMEOUTS) && (_POSIX_TIMEOUTS-0)>=200112L) \ - || (defined(__ANDROID__) && defined(__ANDROID_API__) && __ANDROID_API__ >= 21) -#ifndef BOOST_PTHREAD_HAS_TIMEDLOCK -#define BOOST_PTHREAD_HAS_TIMEDLOCK -#endif -#endif - - -#include - -#ifndef BOOST_THREAD_HAS_NO_EINTR_BUG -#define BOOST_THREAD_HAS_EINTR_BUG -#endif - -namespace boost -{ - namespace posix { -#ifdef BOOST_THREAD_HAS_EINTR_BUG - BOOST_FORCEINLINE int pthread_mutex_destroy(pthread_mutex_t* m) - { - int ret; - do - { - ret = ::pthread_mutex_destroy(m); - } while (ret == EINTR); - return ret; - } - BOOST_FORCEINLINE int pthread_mutex_lock(pthread_mutex_t* m) - { - int ret; - do - { - ret = ::pthread_mutex_lock(m); - } while (ret == EINTR); - return ret; - } - BOOST_FORCEINLINE int pthread_mutex_unlock(pthread_mutex_t* m) - { - int ret; - do - { - ret = ::pthread_mutex_unlock(m); - } while (ret == EINTR); - return ret; - } -#else - BOOST_FORCEINLINE int pthread_mutex_destroy(pthread_mutex_t* m) - { - return ::pthread_mutex_destroy(m); - } - BOOST_FORCEINLINE int pthread_mutex_lock(pthread_mutex_t* m) - { - return ::pthread_mutex_lock(m); - } - BOOST_FORCEINLINE int pthread_mutex_unlock(pthread_mutex_t* m) - { - return ::pthread_mutex_unlock(m); - } - -#endif - - } - class mutex - { - private: - pthread_mutex_t m; - public: - BOOST_THREAD_NO_COPYABLE(mutex) - - mutex() - { - int const res=pthread_mutex_init(&m,NULL); - if(res) - { - boost::throw_exception(thread_resource_error(res, "boost:: mutex constructor failed in pthread_mutex_init")); - } - } - ~mutex() - { - int const res = posix::pthread_mutex_destroy(&m); - boost::ignore_unused(res); - BOOST_ASSERT(!res); - } - - void lock() - { - int res = posix::pthread_mutex_lock(&m); - if (res) - { - boost::throw_exception(lock_error(res,"boost: mutex lock failed in pthread_mutex_lock")); - } - } - - void unlock() - { - int res = posix::pthread_mutex_unlock(&m); - (void)res; - BOOST_ASSERT(res == 0); -// if (res) -// { -// boost::throw_exception(lock_error(res,"boost: mutex unlock failed in pthread_mutex_unlock")); -// } - } - - bool try_lock() - { - int res; - do - { - res = pthread_mutex_trylock(&m); - } while (res == EINTR); - if (res==EBUSY) - { - return false; - } - - return !res; - } - -#define BOOST_THREAD_DEFINES_MUTEX_NATIVE_HANDLE - typedef pthread_mutex_t* native_handle_type; - native_handle_type native_handle() - { - return &m; - } - -#if defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - typedef unique_lock scoped_lock; - typedef detail::try_lock_wrapper scoped_try_lock; -#endif - }; - - typedef mutex try_mutex; - - class timed_mutex - { - private: - pthread_mutex_t m; -#ifndef BOOST_PTHREAD_HAS_TIMEDLOCK - pthread_cond_t cond; - bool is_locked; -#endif - public: - BOOST_THREAD_NO_COPYABLE(timed_mutex) - timed_mutex() - { - int const res=pthread_mutex_init(&m,NULL); - if(res) - { - boost::throw_exception(thread_resource_error(res, "boost:: timed_mutex constructor failed in pthread_mutex_init")); - } -#ifndef BOOST_PTHREAD_HAS_TIMEDLOCK - int const res2=pthread_cond_init(&cond,NULL); - if(res2) - { - BOOST_VERIFY(!posix::pthread_mutex_destroy(&m)); - //BOOST_VERIFY(!pthread_mutex_destroy(&m)); - boost::throw_exception(thread_resource_error(res2, "boost:: timed_mutex constructor failed in pthread_cond_init")); - } - is_locked=false; -#endif - } - ~timed_mutex() - { - BOOST_VERIFY(!posix::pthread_mutex_destroy(&m)); -#ifndef BOOST_PTHREAD_HAS_TIMEDLOCK - BOOST_VERIFY(!pthread_cond_destroy(&cond)); -#endif - } - -#if defined BOOST_THREAD_USES_DATETIME - template - bool timed_lock(TimeDuration const & relative_time) - { - return timed_lock(get_system_time()+relative_time); - } - bool timed_lock(boost::xtime const & absolute_time) - { - return timed_lock(system_time(absolute_time)); - } -#endif -#ifdef BOOST_PTHREAD_HAS_TIMEDLOCK - void lock() - { - int res = posix::pthread_mutex_lock(&m); - if (res) - { - boost::throw_exception(lock_error(res,"boost: mutex lock failed in pthread_mutex_lock")); - } - } - - void unlock() - { - int res = posix::pthread_mutex_unlock(&m); - (void)res; - BOOST_ASSERT(res == 0); -// if (res) -// { -// boost::throw_exception(lock_error(res,"boost: mutex unlock failed in pthread_mutex_unlock")); -// } - } - - bool try_lock() - { - int res; - do - { - res = pthread_mutex_trylock(&m); - } while (res == EINTR); - if (res==EBUSY) - { - return false; - } - - return !res; - } - - - private: - bool do_try_lock_until(struct timespec const &timeout) - { - int const res=pthread_mutex_timedlock(&m,&timeout); - BOOST_ASSERT(!res || res==ETIMEDOUT); - return !res; - } - public: - -#else - void lock() - { - boost::pthread::pthread_mutex_scoped_lock const local_lock(&m); - while(is_locked) - { - BOOST_VERIFY(!pthread_cond_wait(&cond,&m)); - } - is_locked=true; - } - - void unlock() - { - boost::pthread::pthread_mutex_scoped_lock const local_lock(&m); - is_locked=false; - BOOST_VERIFY(!pthread_cond_signal(&cond)); - } - - bool try_lock() - { - boost::pthread::pthread_mutex_scoped_lock const local_lock(&m); - if(is_locked) - { - return false; - } - is_locked=true; - return true; - } - - private: - bool do_try_lock_until(struct timespec const &timeout) - { - boost::pthread::pthread_mutex_scoped_lock const local_lock(&m); - while(is_locked) - { - int const cond_res=pthread_cond_timedwait(&cond,&m,&timeout); - if(cond_res==ETIMEDOUT) - { - return false; - } - BOOST_ASSERT(!cond_res); - } - is_locked=true; - return true; - } - public: -#endif - -#if defined BOOST_THREAD_USES_DATETIME - bool timed_lock(system_time const & abs_time) - { - struct timespec const ts=boost::detail::to_timespec(abs_time); - return do_try_lock_until(ts); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_for(const chrono::duration& rel_time) - { - return try_lock_until(chrono::steady_clock::now() + rel_time); - } - template - bool try_lock_until(const chrono::time_point& t) - { - using namespace chrono; - system_clock::time_point s_now = system_clock::now(); - typename Clock::time_point c_now = Clock::now(); - return try_lock_until(s_now + ceil(t - c_now)); - } - template - bool try_lock_until(const chrono::time_point& t) - { - using namespace chrono; - typedef time_point nano_sys_tmpt; - return try_lock_until(nano_sys_tmpt(ceil(t.time_since_epoch()))); - } - bool try_lock_until(const chrono::time_point& tp) - { - //using namespace chrono; - chrono::nanoseconds d = tp.time_since_epoch(); - timespec ts = boost::detail::to_timespec(d); - return do_try_lock_until(ts); - } -#endif - -#define BOOST_THREAD_DEFINES_TIMED_MUTEX_NATIVE_HANDLE - typedef pthread_mutex_t* native_handle_type; - native_handle_type native_handle() - { - return &m; - } - -#if defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - typedef unique_lock scoped_timed_lock; - typedef detail::try_lock_wrapper scoped_try_lock; - typedef scoped_timed_lock scoped_lock; -#endif - }; - -} - -#include - - -#endif diff --git a/libraries/boost/boost/thread/pthread/once.hpp b/libraries/boost/boost/thread/pthread/once.hpp deleted file mode 100644 index 0bef0387d..000000000 --- a/libraries/boost/boost/thread/pthread/once.hpp +++ /dev/null @@ -1,540 +0,0 @@ -#ifndef BOOST_THREAD_PTHREAD_ONCE_HPP -#define BOOST_THREAD_PTHREAD_ONCE_HPP - -// once.hpp -// -// (C) Copyright 2007-8 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -namespace boost -{ - - struct once_flag; - - #define BOOST_ONCE_INITIAL_FLAG_VALUE 0 - - namespace thread_detail - { - typedef boost::uint32_t uintmax_atomic_t; - #define BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_C2(value) value##u - #define BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_MAX_C BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_C2(~0) - - } - -#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11 -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(ArgTypes)... args); -#else - template - inline void call_once(once_flag& flag, Function f); - template - inline void call_once(once_flag& flag, Function f, T1 p1); - template - inline void call_once(once_flag& flag, Function f, T1 p1, T2 p2); - template - inline void call_once(once_flag& flag, Function f, T1 p1, T2 p2, T3 p3); -#endif - - struct once_flag - { - BOOST_THREAD_NO_COPYABLE(once_flag) - BOOST_CONSTEXPR once_flag() BOOST_NOEXCEPT - : epoch(BOOST_ONCE_INITIAL_FLAG_VALUE) - {} - private: - volatile thread_detail::uintmax_atomic_t epoch; - -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - friend void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(ArgTypes)... args); -#else - template - friend void call_once(once_flag& flag, Function f); - template - friend void call_once(once_flag& flag, Function f, T1 p1); - template - friend void call_once(once_flag& flag, Function f, T1 p1, T2 p2); - template - friend void call_once(once_flag& flag, Function f, T1 p1, T2 p2, T3 p3); - -#endif - - }; - -#define BOOST_ONCE_INIT once_flag() - -#else // BOOST_THREAD_PROVIDES_ONCE_CXX11 - - struct once_flag - { - volatile thread_detail::uintmax_atomic_t epoch; - }; - -#define BOOST_ONCE_INIT {BOOST_ONCE_INITIAL_FLAG_VALUE} -#endif // BOOST_THREAD_PROVIDES_ONCE_CXX11 - - -#if defined BOOST_THREAD_PROVIDES_INVOKE -#define BOOST_THREAD_INVOKE_RET_VOID detail::invoke -#define BOOST_THREAD_INVOKE_RET_VOID_CALL -#elif defined BOOST_THREAD_PROVIDES_INVOKE_RET -#define BOOST_THREAD_INVOKE_RET_VOID detail::invoke -#define BOOST_THREAD_INVOKE_RET_VOID_CALL -#else -#define BOOST_THREAD_INVOKE_RET_VOID boost::bind -#define BOOST_THREAD_INVOKE_RET_VOID_CALL () -#endif - - namespace thread_detail - { - BOOST_THREAD_DECL uintmax_atomic_t& get_once_per_thread_epoch(); - BOOST_THREAD_DECL extern uintmax_atomic_t once_global_epoch; - BOOST_THREAD_DECL extern pthread_mutex_t once_epoch_mutex; - BOOST_THREAD_DECL extern pthread_cond_t once_epoch_cv; - } - - // Based on Mike Burrows fast_pthread_once algorithm as described in - // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2444.html - - -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - - - template - inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(ArgTypes)... args) - { - static thread_detail::uintmax_atomic_t const uninitialized_flag=BOOST_ONCE_INITIAL_FLAG_VALUE; - static thread_detail::uintmax_atomic_t const being_initialized=uninitialized_flag+1; - thread_detail::uintmax_atomic_t const epoch=flag.epoch; - thread_detail::uintmax_atomic_t& this_thread_epoch=thread_detail::get_once_per_thread_epoch(); - - if(epoch(f)), - thread_detail::decay_copy(boost::forward(args))... - ) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH (...) - { - flag.epoch=uninitialized_flag; - BOOST_VERIFY(!pthread_cond_broadcast(&thread_detail::once_epoch_cv)); - BOOST_RETHROW - } - BOOST_CATCH_END - flag.epoch=--thread_detail::once_global_epoch; - BOOST_VERIFY(!pthread_cond_broadcast(&thread_detail::once_epoch_cv)); - } - else - { - while(flag.epoch==being_initialized) - { - BOOST_VERIFY(!pthread_cond_wait(&thread_detail::once_epoch_cv,&thread_detail::once_epoch_mutex)); - } - } - } - this_thread_epoch=thread_detail::once_global_epoch; - - } - } -#else - template - inline void call_once(once_flag& flag, Function f) - { - static thread_detail::uintmax_atomic_t const uninitialized_flag=BOOST_ONCE_INITIAL_FLAG_VALUE; - static thread_detail::uintmax_atomic_t const being_initialized=uninitialized_flag+1; - thread_detail::uintmax_atomic_t const epoch=flag.epoch; - thread_detail::uintmax_atomic_t& this_thread_epoch=thread_detail::get_once_per_thread_epoch(); - - if(epoch - inline void call_once(once_flag& flag, Function f, T1 p1) - { - static thread_detail::uintmax_atomic_t const uninitialized_flag=BOOST_ONCE_INITIAL_FLAG_VALUE; - static thread_detail::uintmax_atomic_t const being_initialized=uninitialized_flag+1; - thread_detail::uintmax_atomic_t const epoch=flag.epoch; - thread_detail::uintmax_atomic_t& this_thread_epoch=thread_detail::get_once_per_thread_epoch(); - - if(epoch - inline void call_once(once_flag& flag, Function f, T1 p1, T2 p2) - { - static thread_detail::uintmax_atomic_t const uninitialized_flag=BOOST_ONCE_INITIAL_FLAG_VALUE; - static thread_detail::uintmax_atomic_t const being_initialized=uninitialized_flag+1; - thread_detail::uintmax_atomic_t const epoch=flag.epoch; - thread_detail::uintmax_atomic_t& this_thread_epoch=thread_detail::get_once_per_thread_epoch(); - - if(epoch - inline void call_once(once_flag& flag, Function f, T1 p1, T2 p2, T3 p3) - { - static thread_detail::uintmax_atomic_t const uninitialized_flag=BOOST_ONCE_INITIAL_FLAG_VALUE; - static thread_detail::uintmax_atomic_t const being_initialized=uninitialized_flag+1; - thread_detail::uintmax_atomic_t const epoch=flag.epoch; - thread_detail::uintmax_atomic_t& this_thread_epoch=thread_detail::get_once_per_thread_epoch(); - - if(epoch - inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f) - { - static thread_detail::uintmax_atomic_t const uninitialized_flag=BOOST_ONCE_INITIAL_FLAG_VALUE; - static thread_detail::uintmax_atomic_t const being_initialized=uninitialized_flag+1; - thread_detail::uintmax_atomic_t const epoch=flag.epoch; - thread_detail::uintmax_atomic_t& this_thread_epoch=thread_detail::get_once_per_thread_epoch(); - - if(epoch - inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1) - { - static thread_detail::uintmax_atomic_t const uninitialized_flag=BOOST_ONCE_INITIAL_FLAG_VALUE; - static thread_detail::uintmax_atomic_t const being_initialized=uninitialized_flag+1; - thread_detail::uintmax_atomic_t const epoch=flag.epoch; - thread_detail::uintmax_atomic_t& this_thread_epoch=thread_detail::get_once_per_thread_epoch(); - - if(epoch(f)), - thread_detail::decay_copy(boost::forward(p1)) - ) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH (...) - { - flag.epoch=uninitialized_flag; - BOOST_VERIFY(!pthread_cond_broadcast(&thread_detail::once_epoch_cv)); - BOOST_RETHROW - } - BOOST_CATCH_END - flag.epoch=--thread_detail::once_global_epoch; - BOOST_VERIFY(!pthread_cond_broadcast(&thread_detail::once_epoch_cv)); - } - else - { - while(flag.epoch==being_initialized) - { - BOOST_VERIFY(!pthread_cond_wait(&thread_detail::once_epoch_cv,&thread_detail::once_epoch_mutex)); - } - } - } - this_thread_epoch=thread_detail::once_global_epoch; - } - } - template - inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2) - { - static thread_detail::uintmax_atomic_t const uninitialized_flag=BOOST_ONCE_INITIAL_FLAG_VALUE; - static thread_detail::uintmax_atomic_t const being_initialized=uninitialized_flag+1; - thread_detail::uintmax_atomic_t const epoch=flag.epoch; - thread_detail::uintmax_atomic_t& this_thread_epoch=thread_detail::get_once_per_thread_epoch(); - - if(epoch(f)), - thread_detail::decay_copy(boost::forward(p1)), - thread_detail::decay_copy(boost::forward(p2)) - ) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH (...) - { - flag.epoch=uninitialized_flag; - BOOST_VERIFY(!pthread_cond_broadcast(&thread_detail::once_epoch_cv)); - BOOST_RETHROW - } - BOOST_CATCH_END - flag.epoch=--thread_detail::once_global_epoch; - BOOST_VERIFY(!pthread_cond_broadcast(&thread_detail::once_epoch_cv)); - } - else - { - while(flag.epoch==being_initialized) - { - BOOST_VERIFY(!pthread_cond_wait(&thread_detail::once_epoch_cv,&thread_detail::once_epoch_mutex)); - } - } - } - this_thread_epoch=thread_detail::once_global_epoch; - } - } - - template - inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2, BOOST_THREAD_RV_REF(T3) p3) - { - static thread_detail::uintmax_atomic_t const uninitialized_flag=BOOST_ONCE_INITIAL_FLAG_VALUE; - static thread_detail::uintmax_atomic_t const being_initialized=uninitialized_flag+1; - thread_detail::uintmax_atomic_t const epoch=flag.epoch; - thread_detail::uintmax_atomic_t& this_thread_epoch=thread_detail::get_once_per_thread_epoch(); - - if(epoch(f)), - thread_detail::decay_copy(boost::forward(p1)), - thread_detail::decay_copy(boost::forward(p2)), - thread_detail::decay_copy(boost::forward(p3)) - ) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH (...) - { - flag.epoch=uninitialized_flag; - BOOST_VERIFY(!pthread_cond_broadcast(&thread_detail::once_epoch_cv)); - BOOST_RETHROW - } - BOOST_CATCH_END - flag.epoch=--thread_detail::once_global_epoch; - BOOST_VERIFY(!pthread_cond_broadcast(&thread_detail::once_epoch_cv)); - } - else - { - while(flag.epoch==being_initialized) - { - BOOST_VERIFY(!pthread_cond_wait(&thread_detail::once_epoch_cv,&thread_detail::once_epoch_mutex)); - } - } - } - this_thread_epoch=thread_detail::once_global_epoch; - } - } - -#endif - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/pthread/once_atomic.hpp b/libraries/boost/boost/thread/pthread/once_atomic.hpp deleted file mode 100644 index c54a35c54..000000000 --- a/libraries/boost/boost/thread/pthread/once_atomic.hpp +++ /dev/null @@ -1,313 +0,0 @@ -#ifndef BOOST_THREAD_PTHREAD_ONCE_ATOMIC_HPP -#define BOOST_THREAD_PTHREAD_ONCE_ATOMIC_HPP - -// once.hpp -// -// (C) Copyright 2013 Andrey Semashev -// (C) Copyright 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - -#include -#include -#include -#include -#include -#include - -#include - -namespace boost -{ - - struct once_flag; - - namespace thread_detail - { - -#if BOOST_ATOMIC_INT_LOCK_FREE == 2 - typedef unsigned int atomic_int_type; -#elif BOOST_ATOMIC_SHORT_LOCK_FREE == 2 - typedef unsigned short atomic_int_type; -#elif BOOST_ATOMIC_CHAR_LOCK_FREE == 2 - typedef unsigned char atomic_int_type; -#elif BOOST_ATOMIC_LONG_LOCK_FREE == 2 - typedef unsigned long atomic_int_type; -#elif defined(BOOST_HAS_LONG_LONG) && BOOST_ATOMIC_LLONG_LOCK_FREE == 2 - typedef ulong_long_type atomic_int_type; -#else - // All tested integer types are not atomic, the spinlock pool will be used - typedef unsigned int atomic_int_type; -#endif - - typedef boost::atomic atomic_type; - - BOOST_THREAD_DECL bool enter_once_region(once_flag& flag) BOOST_NOEXCEPT; - BOOST_THREAD_DECL void commit_once_region(once_flag& flag) BOOST_NOEXCEPT; - BOOST_THREAD_DECL void rollback_once_region(once_flag& flag) BOOST_NOEXCEPT; - inline atomic_type& get_atomic_storage(once_flag& flag) BOOST_NOEXCEPT; - } - -#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11 - - struct once_flag - { - BOOST_THREAD_NO_COPYABLE(once_flag) - BOOST_CONSTEXPR once_flag() BOOST_NOEXCEPT : storage(0) - { - } - - private: - thread_detail::atomic_type storage; - - friend BOOST_THREAD_DECL bool thread_detail::enter_once_region(once_flag& flag) BOOST_NOEXCEPT; - friend BOOST_THREAD_DECL void thread_detail::commit_once_region(once_flag& flag) BOOST_NOEXCEPT; - friend BOOST_THREAD_DECL void thread_detail::rollback_once_region(once_flag& flag) BOOST_NOEXCEPT; - friend thread_detail::atomic_type& thread_detail::get_atomic_storage(once_flag& flag) BOOST_NOEXCEPT; - }; - -#define BOOST_ONCE_INIT boost::once_flag() - - namespace thread_detail - { - inline atomic_type& get_atomic_storage(once_flag& flag) BOOST_NOEXCEPT - { - //return reinterpret_cast< atomic_type& >(flag.storage); - return flag.storage; - } - } - -#else // BOOST_THREAD_PROVIDES_ONCE_CXX11 - struct once_flag - { - // The thread_detail::atomic_int_type storage is marked - // with this attribute in order to let the compiler know that it will alias this member - // and silence compilation warnings. - BOOST_THREAD_ATTRIBUTE_MAY_ALIAS thread_detail::atomic_int_type storage; - }; - - #define BOOST_ONCE_INIT {0} - - namespace thread_detail - { - inline atomic_type& get_atomic_storage(once_flag& flag) BOOST_NOEXCEPT - { - return reinterpret_cast< atomic_type& >(flag.storage); - } - - } - -#endif // BOOST_THREAD_PROVIDES_ONCE_CXX11 - -#if defined BOOST_THREAD_PROVIDES_INVOKE -#define BOOST_THREAD_INVOKE_RET_VOID detail::invoke -#define BOOST_THREAD_INVOKE_RET_VOID_CALL -#elif defined BOOST_THREAD_PROVIDES_INVOKE_RET -#define BOOST_THREAD_INVOKE_RET_VOID detail::invoke -#define BOOST_THREAD_INVOKE_RET_VOID_CALL -#else -#define BOOST_THREAD_INVOKE_RET_VOID boost::bind -#define BOOST_THREAD_INVOKE_RET_VOID_CALL () -#endif - - -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - - template - inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(ArgTypes)... args) - { - if (thread_detail::enter_once_region(flag)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID( - thread_detail::decay_copy(boost::forward(f)), - thread_detail::decay_copy(boost::forward(args))... - ) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH (...) - { - thread_detail::rollback_once_region(flag); - BOOST_RETHROW - } - BOOST_CATCH_END - thread_detail::commit_once_region(flag); - } - } -#else - template - inline void call_once(once_flag& flag, Function f) - { - if (thread_detail::enter_once_region(flag)) - { - BOOST_TRY - { - f(); - } - BOOST_CATCH (...) - { - thread_detail::rollback_once_region(flag); - BOOST_RETHROW - } - BOOST_CATCH_END - thread_detail::commit_once_region(flag); - } - } - - template - inline void call_once(once_flag& flag, Function f, T1 p1) - { - if (thread_detail::enter_once_region(flag)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID(f, p1) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH (...) - { - thread_detail::rollback_once_region(flag); - BOOST_RETHROW - } - BOOST_CATCH_END - thread_detail::commit_once_region(flag); - } - } - - template - inline void call_once(once_flag& flag, Function f, T1 p1, T2 p2) - { - if (thread_detail::enter_once_region(flag)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID(f, p1, p2) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH (...) - { - thread_detail::rollback_once_region(flag); - BOOST_RETHROW - } - BOOST_CATCH_END - thread_detail::commit_once_region(flag); - } - } - - template - inline void call_once(once_flag& flag, Function f, T1 p1, T2 p2, T3 p3) - { - if (thread_detail::enter_once_region(flag)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID(f, p1, p2, p3) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH (...) - { - thread_detail::rollback_once_region(flag); - BOOST_RETHROW - } - BOOST_CATCH_END - thread_detail::commit_once_region(flag); - } - } -#if !(defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5130)) - template - inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f) - { - if (thread_detail::enter_once_region(flag)) - { - BOOST_TRY - { - f(); - } - BOOST_CATCH (...) - { - thread_detail::rollback_once_region(flag); - BOOST_RETHROW - } - BOOST_CATCH_END - thread_detail::commit_once_region(flag); - } - } - - template - inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1) - { - if (thread_detail::enter_once_region(flag)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID( - thread_detail::decay_copy(boost::forward(f)), - thread_detail::decay_copy(boost::forward(p1)) - ) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH (...) - { - thread_detail::rollback_once_region(flag); - BOOST_RETHROW - } - BOOST_CATCH_END - thread_detail::commit_once_region(flag); - } - } - template - inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2) - { - if (thread_detail::enter_once_region(flag)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID( - thread_detail::decay_copy(boost::forward(f)), - thread_detail::decay_copy(boost::forward(p1)), - thread_detail::decay_copy(boost::forward(p2)) - ) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH (...) - { - thread_detail::rollback_once_region(flag); - BOOST_RETHROW - } - BOOST_CATCH_END - thread_detail::commit_once_region(flag); - } - } - template - inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2, BOOST_THREAD_RV_REF(T3) p3) - { - if (thread_detail::enter_once_region(flag)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID( - thread_detail::decay_copy(boost::forward(f)), - thread_detail::decay_copy(boost::forward(p1)), - thread_detail::decay_copy(boost::forward(p2)), - thread_detail::decay_copy(boost::forward(p3)) - ) BOOST_THREAD_INVOKE_RET_VOID_CALL; - - } - BOOST_CATCH (...) - { - thread_detail::rollback_once_region(flag); - BOOST_RETHROW - } - BOOST_CATCH_END - thread_detail::commit_once_region(flag); - } - } - -#endif // __SUNPRO_CC - -#endif -} - -#include - -#endif - diff --git a/libraries/boost/boost/thread/pthread/pthread_mutex_scoped_lock.hpp b/libraries/boost/boost/thread/pthread/pthread_mutex_scoped_lock.hpp deleted file mode 100644 index cdbf8c674..000000000 --- a/libraries/boost/boost/thread/pthread/pthread_mutex_scoped_lock.hpp +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef BOOST_PTHREAD_MUTEX_SCOPED_LOCK_HPP -#define BOOST_PTHREAD_MUTEX_SCOPED_LOCK_HPP -// (C) Copyright 2007-8 Anthony Williams -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include - -#include - -namespace boost -{ - namespace pthread - { - class pthread_mutex_scoped_lock - { - pthread_mutex_t* m; - bool locked; - public: - explicit pthread_mutex_scoped_lock(pthread_mutex_t* m_): - m(m_),locked(true) - { - BOOST_VERIFY(!pthread_mutex_lock(m)); - } - void unlock() - { - BOOST_VERIFY(!pthread_mutex_unlock(m)); - locked=false; - } - - ~pthread_mutex_scoped_lock() - { - if(locked) - { - unlock(); - } - } - - }; - - class pthread_mutex_scoped_unlock - { - pthread_mutex_t* m; - public: - explicit pthread_mutex_scoped_unlock(pthread_mutex_t* m_): - m(m_) - { - BOOST_VERIFY(!pthread_mutex_unlock(m)); - } - ~pthread_mutex_scoped_unlock() - { - BOOST_VERIFY(!pthread_mutex_lock(m)); - } - - }; - } -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/pthread/recursive_mutex.hpp b/libraries/boost/boost/thread/pthread/recursive_mutex.hpp deleted file mode 100644 index 4caae0b5d..000000000 --- a/libraries/boost/boost/thread/pthread/recursive_mutex.hpp +++ /dev/null @@ -1,404 +0,0 @@ -#ifndef BOOST_THREAD_PTHREAD_RECURSIVE_MUTEX_HPP -#define BOOST_THREAD_PTHREAD_RECURSIVE_MUTEX_HPP -// (C) Copyright 2007-8 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include -#if defined BOOST_THREAD_PROVIDES_NESTED_LOCKS -#include -#endif -#include -#include -#ifndef _WIN32 -#include -#endif -#include -#include -#include -#include -#ifdef BOOST_THREAD_USES_CHRONO -#include -#include -#endif -#include - -#if (defined _POSIX_TIMEOUTS && (_POSIX_TIMEOUTS-0)>=200112L) \ - || (defined __ANDROID__ && defined __ANDROID_API__ && __ANDROID_API__ >= 21) -#ifndef BOOST_PTHREAD_HAS_TIMEDLOCK -#define BOOST_PTHREAD_HAS_TIMEDLOCK -#endif -#endif - -#if defined BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE \ - || defined __ANDROID__ -#define BOOST_THREAD_HAS_PTHREAD_MUTEXATTR_SETTYPE -#endif - -#if defined BOOST_THREAD_HAS_PTHREAD_MUTEXATTR_SETTYPE && defined BOOST_PTHREAD_HAS_TIMEDLOCK -#define BOOST_USE_PTHREAD_RECURSIVE_TIMEDLOCK -#endif - -#include - -namespace boost -{ - class recursive_mutex - { - private: - pthread_mutex_t m; -#ifndef BOOST_THREAD_HAS_PTHREAD_MUTEXATTR_SETTYPE - pthread_cond_t cond; - bool is_locked; - pthread_t owner; - unsigned count; -#endif - public: - BOOST_THREAD_NO_COPYABLE(recursive_mutex) - recursive_mutex() - { -#ifdef BOOST_THREAD_HAS_PTHREAD_MUTEXATTR_SETTYPE - pthread_mutexattr_t attr; - - int const init_attr_res=pthread_mutexattr_init(&attr); - if(init_attr_res) - { - boost::throw_exception(thread_resource_error(init_attr_res, "boost:: recursive_mutex constructor failed in pthread_mutexattr_init")); - } - int const set_attr_res=pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE); - if(set_attr_res) - { - BOOST_VERIFY(!pthread_mutexattr_destroy(&attr)); - boost::throw_exception(thread_resource_error(set_attr_res, "boost:: recursive_mutex constructor failed in pthread_mutexattr_settype")); - } - - int const res=pthread_mutex_init(&m,&attr); - if(res) - { - BOOST_VERIFY(!pthread_mutexattr_destroy(&attr)); - boost::throw_exception(thread_resource_error(res, "boost:: recursive_mutex constructor failed in pthread_mutex_init")); - } - BOOST_VERIFY(!pthread_mutexattr_destroy(&attr)); -#else - int const res=pthread_mutex_init(&m,NULL); - if(res) - { - boost::throw_exception(thread_resource_error(res, "boost:: recursive_mutex constructor failed in pthread_mutex_init")); - } - int const res2=pthread_cond_init(&cond,NULL); - if(res2) - { - BOOST_VERIFY(!pthread_mutex_destroy(&m)); - boost::throw_exception(thread_resource_error(res2, "boost:: recursive_mutex constructor failed in pthread_cond_init")); - } - is_locked=false; - count=0; -#endif - } - ~recursive_mutex() - { - BOOST_VERIFY(!pthread_mutex_destroy(&m)); -#ifndef BOOST_THREAD_HAS_PTHREAD_MUTEXATTR_SETTYPE - BOOST_VERIFY(!pthread_cond_destroy(&cond)); -#endif - } - -#ifdef BOOST_THREAD_HAS_PTHREAD_MUTEXATTR_SETTYPE - void lock() - { - BOOST_VERIFY(!pthread_mutex_lock(&m)); - } - - void unlock() - { - BOOST_VERIFY(!pthread_mutex_unlock(&m)); - } - - bool try_lock() BOOST_NOEXCEPT - { - int const res=pthread_mutex_trylock(&m); - BOOST_ASSERT(!res || res==EBUSY); - return !res; - } -#define BOOST_THREAD_DEFINES_RECURSIVE_MUTEX_NATIVE_HANDLE - typedef pthread_mutex_t* native_handle_type; - native_handle_type native_handle() - { - return &m; - } - -#else - void lock() - { - boost::pthread::pthread_mutex_scoped_lock const local_lock(&m); - if(is_locked && pthread_equal(owner,pthread_self())) - { - ++count; - return; - } - - while(is_locked) - { - BOOST_VERIFY(!pthread_cond_wait(&cond,&m)); - } - is_locked=true; - ++count; - owner=pthread_self(); - } - - void unlock() - { - boost::pthread::pthread_mutex_scoped_lock const local_lock(&m); - if(!--count) - { - is_locked=false; - } - BOOST_VERIFY(!pthread_cond_signal(&cond)); - } - - bool try_lock() - { - boost::pthread::pthread_mutex_scoped_lock const local_lock(&m); - if(is_locked && !pthread_equal(owner,pthread_self())) - { - return false; - } - is_locked=true; - ++count; - owner=pthread_self(); - return true; - } - -#endif - -#if defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - typedef unique_lock scoped_lock; - typedef detail::try_lock_wrapper scoped_try_lock; -#endif - }; - - typedef recursive_mutex recursive_try_mutex; - - class recursive_timed_mutex - { - private: - pthread_mutex_t m; -#ifndef BOOST_USE_PTHREAD_RECURSIVE_TIMEDLOCK - pthread_cond_t cond; - bool is_locked; - pthread_t owner; - unsigned count; -#endif - public: - BOOST_THREAD_NO_COPYABLE(recursive_timed_mutex) - recursive_timed_mutex() - { -#ifdef BOOST_USE_PTHREAD_RECURSIVE_TIMEDLOCK - pthread_mutexattr_t attr; - - int const init_attr_res=pthread_mutexattr_init(&attr); - if(init_attr_res) - { - boost::throw_exception(thread_resource_error(init_attr_res, "boost:: recursive_timed_mutex constructor failed in pthread_mutexattr_init")); - } - int const set_attr_res=pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE); - if(set_attr_res) - { - boost::throw_exception(thread_resource_error(set_attr_res, "boost:: recursive_timed_mutex constructor failed in pthread_mutexattr_settype")); - } - - int const res=pthread_mutex_init(&m,&attr); - if(res) - { - BOOST_VERIFY(!pthread_mutexattr_destroy(&attr)); - boost::throw_exception(thread_resource_error(res, "boost:: recursive_timed_mutex constructor failed in pthread_mutex_init")); - } - BOOST_VERIFY(!pthread_mutexattr_destroy(&attr)); -#else - int const res=pthread_mutex_init(&m,NULL); - if(res) - { - boost::throw_exception(thread_resource_error(res, "boost:: recursive_timed_mutex constructor failed in pthread_mutex_init")); - } - int const res2=pthread_cond_init(&cond,NULL); - if(res2) - { - BOOST_VERIFY(!pthread_mutex_destroy(&m)); - boost::throw_exception(thread_resource_error(res2, "boost:: recursive_timed_mutex constructor failed in pthread_cond_init")); - } - is_locked=false; - count=0; -#endif - } - ~recursive_timed_mutex() - { - BOOST_VERIFY(!pthread_mutex_destroy(&m)); -#ifndef BOOST_USE_PTHREAD_RECURSIVE_TIMEDLOCK - BOOST_VERIFY(!pthread_cond_destroy(&cond)); -#endif - } - -#if defined BOOST_THREAD_USES_DATETIME - template - bool timed_lock(TimeDuration const & relative_time) - { - return timed_lock(get_system_time()+relative_time); - } -#endif - -#ifdef BOOST_USE_PTHREAD_RECURSIVE_TIMEDLOCK - void lock() - { - BOOST_VERIFY(!pthread_mutex_lock(&m)); - } - - void unlock() - { - BOOST_VERIFY(!pthread_mutex_unlock(&m)); - } - - bool try_lock() - { - int const res=pthread_mutex_trylock(&m); - BOOST_ASSERT(!res || res==EBUSY); - return !res; - } - private: - bool do_try_lock_until(struct timespec const &timeout) - { - int const res=pthread_mutex_timedlock(&m,&timeout); - BOOST_ASSERT(!res || res==ETIMEDOUT); - return !res; - } - - public: - -#else - void lock() - { - boost::pthread::pthread_mutex_scoped_lock const local_lock(&m); - if(is_locked && pthread_equal(owner,pthread_self())) - { - ++count; - return; - } - - while(is_locked) - { - BOOST_VERIFY(!pthread_cond_wait(&cond,&m)); - } - is_locked=true; - ++count; - owner=pthread_self(); - } - - void unlock() - { - boost::pthread::pthread_mutex_scoped_lock const local_lock(&m); - if(!--count) - { - is_locked=false; - } - BOOST_VERIFY(!pthread_cond_signal(&cond)); - } - - bool try_lock() BOOST_NOEXCEPT - { - boost::pthread::pthread_mutex_scoped_lock const local_lock(&m); - if(is_locked && !pthread_equal(owner,pthread_self())) - { - return false; - } - is_locked=true; - ++count; - owner=pthread_self(); - return true; - } - - private: - bool do_try_lock_until(struct timespec const &timeout) - { - boost::pthread::pthread_mutex_scoped_lock const local_lock(&m); - if(is_locked && pthread_equal(owner,pthread_self())) - { - ++count; - return true; - } - while(is_locked) - { - int const cond_res=pthread_cond_timedwait(&cond,&m,&timeout); - if(cond_res==ETIMEDOUT) - { - return false; - } - BOOST_ASSERT(!cond_res); - } - is_locked=true; - ++count; - owner=pthread_self(); - return true; - } - public: - -#endif - -#if defined BOOST_THREAD_USES_DATETIME - bool timed_lock(system_time const & abs_time) - { - struct timespec const ts=detail::to_timespec(abs_time); - return do_try_lock_until(ts); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_for(const chrono::duration& rel_time) - { - return try_lock_until(chrono::steady_clock::now() + rel_time); - } - template - bool try_lock_until(const chrono::time_point& t) - { - using namespace chrono; - system_clock::time_point s_now = system_clock::now(); - typename Clock::time_point c_now = Clock::now(); - return try_lock_until(s_now + ceil(t - c_now)); - } - template - bool try_lock_until(const chrono::time_point& t) - { - using namespace chrono; - typedef time_point nano_sys_tmpt; - return try_lock_until(nano_sys_tmpt(ceil(t.time_since_epoch()))); - } - bool try_lock_until(const chrono::time_point& tp) - { - //using namespace chrono; - chrono::nanoseconds d = tp.time_since_epoch(); - timespec ts = boost::detail::to_timespec(d); - return do_try_lock_until(ts); - } -#endif - -#define BOOST_THREAD_DEFINES_RECURSIVE_TIMED_MUTEX_NATIVE_HANDLE - typedef pthread_mutex_t* native_handle_type; - native_handle_type native_handle() - { - return &m; - } - -#if defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - typedef unique_lock scoped_timed_lock; - typedef detail::try_lock_wrapper scoped_try_lock; - typedef scoped_timed_lock scoped_lock; -#endif - }; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/pthread/shared_mutex.hpp b/libraries/boost/boost/thread/pthread/shared_mutex.hpp deleted file mode 100644 index b427b0f16..000000000 --- a/libraries/boost/boost/thread/pthread/shared_mutex.hpp +++ /dev/null @@ -1,716 +0,0 @@ -#ifndef BOOST_THREAD_PTHREAD_SHARED_MUTEX_HPP -#define BOOST_THREAD_PTHREAD_SHARED_MUTEX_HPP - -// (C) Copyright 2006-8 Anthony Williams -// (C) Copyright 2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include -#include -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS -#include -#endif -#ifdef BOOST_THREAD_USES_CHRONO -#include -#include -#endif -#include -#include - -#include - -namespace boost -{ - class shared_mutex - { - private: - class state_data - { - public: - state_data () : - shared_count(0), - exclusive(false), - upgrade(false), - exclusive_waiting_blocked(false) - {} - - void assert_free() const - { - BOOST_ASSERT( ! exclusive ); - BOOST_ASSERT( ! upgrade ); - BOOST_ASSERT( shared_count==0 ); - } - - void assert_locked() const - { - BOOST_ASSERT( exclusive ); - BOOST_ASSERT( shared_count==0 ); - BOOST_ASSERT( ! upgrade ); - } - - void assert_lock_shared () const - { - BOOST_ASSERT( ! exclusive ); - BOOST_ASSERT( shared_count>0 ); - //BOOST_ASSERT( (! upgrade) || (shared_count>1)); - // if upgraded there are at least 2 threads sharing the mutex, - // except when unlock_upgrade_and_lock has decreased the number of readers but has not taken yet exclusive ownership. - } - - void assert_lock_upgraded () const - { - BOOST_ASSERT( ! exclusive ); - BOOST_ASSERT( upgrade ); - BOOST_ASSERT( shared_count>0 ); - } - - void assert_lock_not_upgraded () const - { - BOOST_ASSERT( ! upgrade ); - } - - bool can_lock () const - { - return ! (shared_count || exclusive); - } - - void exclusive_blocked (bool blocked) - { - exclusive_waiting_blocked = blocked; - } - - void lock () - { - exclusive = true; - } - - void unlock () - { - exclusive = false; - exclusive_waiting_blocked = false; - } - - bool can_lock_shared () const - { - return ! (exclusive || exclusive_waiting_blocked); - } - - bool more_shared () const - { - return shared_count > 0 ; - } - unsigned get_shared_count () const - { - return shared_count ; - } - unsigned lock_shared () - { - return ++shared_count; - } - - - void unlock_shared () - { - --shared_count; - } - - bool unlock_shared_downgrades() - { - if (upgrade) { - upgrade=false; - exclusive=true; - return true; - } else { - exclusive_waiting_blocked=false; - return false; - } - } - - void lock_upgrade () - { - ++shared_count; - upgrade=true; - } - bool can_lock_upgrade () const - { - return ! (exclusive || exclusive_waiting_blocked || upgrade); - } - - void unlock_upgrade () - { - upgrade=false; - --shared_count; - } - - //private: - unsigned shared_count; - bool exclusive; - bool upgrade; - bool exclusive_waiting_blocked; - }; - - - - state_data state; - boost::mutex state_change; - boost::condition_variable shared_cond; - boost::condition_variable exclusive_cond; - boost::condition_variable upgrade_cond; - - void release_waiters() - { - exclusive_cond.notify_one(); - shared_cond.notify_all(); - } - - public: - - BOOST_THREAD_NO_COPYABLE(shared_mutex) - - shared_mutex() - { - } - - ~shared_mutex() - { - } - - void lock_shared() - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - while(!state.can_lock_shared()) - { - shared_cond.wait(lk); - } - state.lock_shared(); - } - - bool try_lock_shared() - { - boost::unique_lock lk(state_change); - - if(!state.can_lock_shared()) - { - return false; - } - state.lock_shared(); - return true; - } - -#if defined BOOST_THREAD_USES_DATETIME - bool timed_lock_shared(system_time const& timeout) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - - while(!state.can_lock_shared()) - { - if(!shared_cond.timed_wait(lk,timeout)) - { - return false; - } - } - state.lock_shared(); - return true; - } - - template - bool timed_lock_shared(TimeDuration const & relative_time) - { - return timed_lock_shared(get_system_time()+relative_time); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_shared_for(const chrono::duration& rel_time) - { - return try_lock_shared_until(chrono::steady_clock::now() + rel_time); - } - template - bool try_lock_shared_until(const chrono::time_point& abs_time) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - - while(!state.can_lock_shared()) - //while(state.exclusive || state.exclusive_waiting_blocked) - { - if(cv_status::timeout==shared_cond.wait_until(lk,abs_time)) - { - return false; - } - } - state.lock_shared(); - return true; - } -#endif - void unlock_shared() - { - boost::unique_lock lk(state_change); - state.assert_lock_shared(); - state.unlock_shared(); - if (! state.more_shared()) - { - if (state.upgrade) - { - // As there is a thread doing a unlock_upgrade_and_lock that is waiting for ! state.more_shared() - // avoid other threads to lock, lock_upgrade or lock_shared, so only this thread is notified. - state.upgrade=false; - state.exclusive=true; - //lk.unlock(); - upgrade_cond.notify_one(); - } - else - { - state.exclusive_waiting_blocked=false; - //lk.unlock(); - } - release_waiters(); - } - } - - void lock() - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - - while (state.shared_count || state.exclusive) - { - state.exclusive_waiting_blocked=true; - exclusive_cond.wait(lk); - } - state.exclusive=true; - } - -#if defined BOOST_THREAD_USES_DATETIME - bool timed_lock(system_time const& timeout) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - - while(state.shared_count || state.exclusive) - { - state.exclusive_waiting_blocked=true; - if(!exclusive_cond.timed_wait(lk,timeout)) - { - if(state.shared_count || state.exclusive) - { - state.exclusive_waiting_blocked=false; - release_waiters(); - return false; - } - break; - } - } - state.exclusive=true; - return true; - } - - template - bool timed_lock(TimeDuration const & relative_time) - { - return timed_lock(get_system_time()+relative_time); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_for(const chrono::duration& rel_time) - { - return try_lock_until(chrono::steady_clock::now() + rel_time); - } - template - bool try_lock_until(const chrono::time_point& abs_time) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - - while(state.shared_count || state.exclusive) - { - state.exclusive_waiting_blocked=true; - if(cv_status::timeout == exclusive_cond.wait_until(lk,abs_time)) - { - if(state.shared_count || state.exclusive) - { - state.exclusive_waiting_blocked=false; - release_waiters(); - return false; - } - break; - } - } - state.exclusive=true; - return true; - } -#endif - - bool try_lock() - { - boost::unique_lock lk(state_change); - - if(state.shared_count || state.exclusive) - { - return false; - } - else - { - state.exclusive=true; - return true; - } - - } - - void unlock() - { - boost::unique_lock lk(state_change); - state.assert_locked(); - state.exclusive=false; - state.exclusive_waiting_blocked=false; - state.assert_free(); - release_waiters(); - } - - void lock_upgrade() - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - while(state.exclusive || state.exclusive_waiting_blocked || state.upgrade) - { - shared_cond.wait(lk); - } - state.lock_shared(); - state.upgrade=true; - } - -#if defined BOOST_THREAD_USES_DATETIME - bool timed_lock_upgrade(system_time const& timeout) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - while(state.exclusive || state.exclusive_waiting_blocked || state.upgrade) - { - if(!shared_cond.timed_wait(lk,timeout)) - { - if(state.exclusive || state.exclusive_waiting_blocked || state.upgrade) - { - return false; - } - break; - } - } - state.lock_shared(); - state.upgrade=true; - return true; - } - - template - bool timed_lock_upgrade(TimeDuration const & relative_time) - { - return timed_lock_upgrade(get_system_time()+relative_time); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_upgrade_for(const chrono::duration& rel_time) - { - return try_lock_upgrade_until(chrono::steady_clock::now() + rel_time); - } - template - bool try_lock_upgrade_until(const chrono::time_point& abs_time) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - while(state.exclusive || state.exclusive_waiting_blocked || state.upgrade) - { - if(cv_status::timeout == shared_cond.wait_until(lk,abs_time)) - { - if(state.exclusive || state.exclusive_waiting_blocked || state.upgrade) - { - return false; - } - break; - } - } - state.lock_shared(); - state.upgrade=true; - return true; - } -#endif - bool try_lock_upgrade() - { - boost::unique_lock lk(state_change); - if(state.exclusive || state.exclusive_waiting_blocked || state.upgrade) - { - return false; - } - else - { - state.lock_shared(); - state.upgrade=true; - state.assert_lock_upgraded(); - return true; - } - } - - void unlock_upgrade() - { - boost::unique_lock lk(state_change); - //state.upgrade=false; - state.unlock_upgrade(); - if(! state.more_shared() ) - { - state.exclusive_waiting_blocked=false; - release_waiters(); - } else { - shared_cond.notify_all(); - } - } - - // Upgrade <-> Exclusive - void unlock_upgrade_and_lock() - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - state.assert_lock_upgraded(); - state.unlock_shared(); - while (state.more_shared()) - { - upgrade_cond.wait(lk); - } - state.upgrade=false; - state.exclusive=true; - state.assert_locked(); - } - - void unlock_and_lock_upgrade() - { - boost::unique_lock lk(state_change); - state.assert_locked(); - state.exclusive=false; - state.upgrade=true; - state.lock_shared(); - state.exclusive_waiting_blocked=false; - state.assert_lock_upgraded(); - release_waiters(); - } - - bool try_unlock_upgrade_and_lock() - { - boost::unique_lock lk(state_change); - state.assert_lock_upgraded(); - if( !state.exclusive - && !state.exclusive_waiting_blocked - && state.upgrade - && state.shared_count==1) - { - state.shared_count=0; - state.exclusive=true; - state.upgrade=false; - state.assert_locked(); - return true; - } - return false; - } -#ifdef BOOST_THREAD_USES_CHRONO - template - bool - try_unlock_upgrade_and_lock_for( - const chrono::duration& rel_time) - { - return try_unlock_upgrade_and_lock_until( - chrono::steady_clock::now() + rel_time); - } - template - bool - try_unlock_upgrade_and_lock_until( - const chrono::time_point& abs_time) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - state.assert_lock_upgraded(); - if (state.shared_count != 1) - { - for (;;) - { - cv_status status = shared_cond.wait_until(lk,abs_time); - if (state.shared_count == 1) - break; - if(status == cv_status::timeout) - return false; - } - } - state.upgrade=false; - state.exclusive=true; - state.exclusive_waiting_blocked=false; - state.shared_count=0; - return true; - } -#endif - - // Shared <-> Exclusive - void unlock_and_lock_shared() - { - boost::unique_lock lk(state_change); - state.assert_locked(); - state.exclusive=false; - state.lock_shared(); - state.exclusive_waiting_blocked=false; - release_waiters(); - } - -#ifdef BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS - bool try_unlock_shared_and_lock() - { - boost::unique_lock lk(state_change); - state.assert_lock_shared(); - if( !state.exclusive - && !state.exclusive_waiting_blocked - && !state.upgrade - && state.shared_count==1) - { - state.shared_count=0; - state.exclusive=true; - return true; - } - return false; - } -#ifdef BOOST_THREAD_USES_CHRONO - template - bool - try_unlock_shared_and_lock_for( - const chrono::duration& rel_time) - { - return try_unlock_shared_and_lock_until( - chrono::steady_clock::now() + rel_time); - } - template - bool - try_unlock_shared_and_lock_until( - const chrono::time_point& abs_time) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - state.assert_lock_shared(); - if (state.shared_count != 1) - { - for (;;) - { - cv_status status = shared_cond.wait_until(lk,abs_time); - if (state.shared_count == 1) - break; - if(status == cv_status::timeout) - return false; - } - } - state.upgrade=false; - state.exclusive=true; - state.exclusive_waiting_blocked=false; - state.shared_count=0; - return true; - } -#endif -#endif - - // Shared <-> Upgrade - void unlock_upgrade_and_lock_shared() - { - boost::unique_lock lk(state_change); - state.assert_lock_upgraded(); - state.upgrade=false; - state.exclusive_waiting_blocked=false; - release_waiters(); - } - -#ifdef BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS - bool try_unlock_shared_and_lock_upgrade() - { - boost::unique_lock lk(state_change); - state.assert_lock_shared(); - if( !state.exclusive - && !state.exclusive_waiting_blocked - && !state.upgrade - ) - { - state.upgrade=true; - return true; - } - return false; - } -#ifdef BOOST_THREAD_USES_CHRONO - template - bool - try_unlock_shared_and_lock_upgrade_for( - const chrono::duration& rel_time) - { - return try_unlock_shared_and_lock_upgrade_until( - chrono::steady_clock::now() + rel_time); - } - template - bool - try_unlock_shared_and_lock_upgrade_until( - const chrono::time_point& abs_time) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - state.assert_lock_shared(); - if( state.exclusive - || state.exclusive_waiting_blocked - || state.upgrade - ) - { - for (;;) - { - cv_status status = exclusive_cond.wait_until(lk,abs_time); - if( ! state.exclusive - && ! state.exclusive_waiting_blocked - && ! state.upgrade - ) - break; - if(status == cv_status::timeout) - return false; - } - } - state.upgrade=true; - return true; - } -#endif -#endif - }; - - typedef shared_mutex upgrade_mutex; -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/pthread/shared_mutex_assert.hpp b/libraries/boost/boost/thread/pthread/shared_mutex_assert.hpp deleted file mode 100644 index 186ab7984..000000000 --- a/libraries/boost/boost/thread/pthread/shared_mutex_assert.hpp +++ /dev/null @@ -1,724 +0,0 @@ -#ifndef BOOST_THREAD_PTHREAD_SHARED_MUTEX_HPP -#define BOOST_THREAD_PTHREAD_SHARED_MUTEX_HPP - -// (C) Copyright 2006-8 Anthony Williams -// (C) Copyright 2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include -#include -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS -#include -#endif -#ifdef BOOST_THREAD_USES_CHRONO -#include -#include -#endif -#include -#include - -#include - -namespace boost -{ - class shared_mutex - { - private: - class state_data - { - public: - state_data () : - shared_count(0), - exclusive(false), - upgrade(false), - exclusive_waiting_blocked(false) - {} - - void assert_free() const - { - BOOST_ASSERT( ! exclusive ); - BOOST_ASSERT( ! upgrade ); - BOOST_ASSERT( shared_count==0 ); - } - - void assert_locked() const - { - BOOST_ASSERT( exclusive ); - BOOST_ASSERT( shared_count==0 ); - BOOST_ASSERT( ! upgrade ); - } - - void assert_lock_shared () const - { - BOOST_ASSERT( ! exclusive ); - BOOST_ASSERT( shared_count>0 ); - //BOOST_ASSERT( (! upgrade) || (shared_count>1)); - // if upgraded there are at least 2 threads sharing the mutex, - // except when unlock_upgrade_and_lock has decreased the number of readers but has not taken yet exclusive ownership. - } - - void assert_lock_upgraded () const - { - BOOST_ASSERT( ! exclusive ); - BOOST_ASSERT( upgrade ); - BOOST_ASSERT( shared_count>0 ); - } - - void assert_lock_not_upgraded () const - { - BOOST_ASSERT( ! upgrade ); - } - - bool can_lock () const - { - return ! (shared_count || exclusive); - } - - void exclusive_blocked (bool blocked) - { - exclusive_waiting_blocked = blocked; - } - - void lock () - { - exclusive = true; - } - - void unlock () - { - exclusive = false; - exclusive_waiting_blocked = false; - } - - bool can_lock_shared () const - { - return ! (exclusive || exclusive_waiting_blocked); - } - - bool is_last_shared () const - { - return !shared_count ; - } - unsigned get_shared_count () const - { - return shared_count ; - } - unsigned lock_shared () - { - return ++shared_count; - } - - - void unlock_shared () - { - --shared_count; - } - - bool unlock_shared_downgrades() - { - if (upgrade) { - upgrade=false; - exclusive=true; - return true; - } else { - exclusive_waiting_blocked=false; - return false; - } - } - - void lock_upgrade () - { - lock_shared (); - upgrade=true; - } - bool can_lock_upgrade () const - { - return ! (exclusive || exclusive_waiting_blocked || upgrade); - } - - void unlock_upgrade () - { - upgrade=false; - unlock_shared(); - } - - //private: - unsigned shared_count; - bool exclusive; - bool upgrade; - bool exclusive_waiting_blocked; - }; - - - - state_data state; - boost::mutex state_change; - boost::condition_variable shared_cond; - boost::condition_variable exclusive_cond; - boost::condition_variable upgrade_cond; - - void release_waiters() - { - exclusive_cond.notify_one(); - shared_cond.notify_all(); - } - - public: - BOOST_THREAD_NO_COPYABLE(shared_mutex) - - shared_mutex() - { - } - - ~shared_mutex() - { - } - - void lock_shared() - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - - while(!state.can_lock_shared()) - { - shared_cond.wait(lk); - } - state.lock_shared(); - } - - bool try_lock_shared() - { - boost::unique_lock lk(state_change); - if(!state.can_lock_shared()) - { - return false; - } - else - { - state.lock_shared(); - return true; - } - } - -#if defined BOOST_THREAD_USES_DATETIME - bool timed_lock_shared(system_time const& timeout) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - - while(!state.can_lock_shared()) - { - if(!shared_cond.timed_wait(lk,timeout)) - { - return false; - } - } - state.lock_shared(); - return true; - } - - template - bool timed_lock_shared(TimeDuration const & relative_time) - { - return timed_lock_shared(get_system_time()+relative_time); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_shared_for(const chrono::duration& rel_time) - { - return try_lock_shared_until(chrono::steady_clock::now() + rel_time); - } - template - bool try_lock_shared_until(const chrono::time_point& abs_time) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - - while(!state.can_lock_shared()) - { - if(cv_status::timeout==shared_cond.wait_until(lk,abs_time)) - { - return false; - } - } - state.lock_shared(); - return true; - } -#endif - void unlock_shared() - { - boost::unique_lock lk(state_change); - state.assert_lock_shared(); - state.unlock_shared(); - if (state.get_shared_count () == 0) - { - if (state.unlock_shared_downgrades()) - { - lk.unlock(); - upgrade_cond.notify_one(); - } else { - lk.unlock(); - } - release_waiters(); - } - } - - void lock() - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - - while(!state.can_lock()) - { - state.exclusive_blocked(true); - exclusive_cond.wait(lk); - } - state.lock(); - } - -#if defined BOOST_THREAD_USES_DATETIME - bool timed_lock(system_time const& timeout) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - - while(!state.can_lock()) - { - state.exclusive_blocked(true); - if(!exclusive_cond.timed_wait(lk,timeout)) - { - if(!state.can_lock()) - { - state.exclusive_blocked(false); - release_waiters(); - return false; - } - break; - } - } - state.exclusive=true; - //state.lock(); - return true; - } - - template - bool timed_lock(TimeDuration const & relative_time) - { - return timed_lock(get_system_time()+relative_time); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_for(const chrono::duration& rel_time) - { - return try_lock_until(chrono::steady_clock::now() + rel_time); - } - template - bool try_lock_until(const chrono::time_point& abs_time) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - - while(!state.can_lock()) - { - state.exclusive_blocked(true); - if(cv_status::timeout == exclusive_cond.wait_until(lk,abs_time)) - { - if(!state.can_lock()) - { - state.exclusive_blocked(false); - release_waiters(); - return false; - } - break; - } - } - state.exclusive=true; - //state.lock(); - return true; - } -#endif - - bool try_lock() - { - boost::unique_lock lk(state_change); - - if(!state.can_lock()) - { - return false; - } - else - { - state.lock(); - return true; - } - - } - - void unlock() - { - boost::unique_lock lk(state_change); - state.assert_locked(); - state.unlock(); - state.assert_free(); - release_waiters(); - } - - void lock_upgrade() - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - while(!state.can_lock_upgrade()) - { - shared_cond.wait(lk); - } - state.lock_upgrade(); - } - -#if defined BOOST_THREAD_USES_DATETIME - bool timed_lock_upgrade(system_time const& timeout) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - while(!state.can_lock_upgrade()) - { - if(!shared_cond.timed_wait(lk,timeout)) - { - if(!state.can_lock_upgrade()) - { - return false; - } - break; - } - } - state.lock_upgrade(); - return true; - } - - template - bool timed_lock_upgrade(TimeDuration const & relative_time) - { - return timed_lock_upgrade(get_system_time()+relative_time); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_upgrade_for(const chrono::duration& rel_time) - { - return try_lock_upgrade_until(chrono::steady_clock::now() + rel_time); - } - template - bool try_lock_upgrade_until(const chrono::time_point& abs_time) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - while(!state.can_lock_upgrade()) - { - if(cv_status::timeout == shared_cond.wait_until(lk,abs_time)) - { - if(!state.can_lock_upgrade()) - { - return false; - } - break; - } - } - state.lock_upgrade(); - return true; - } -#endif - bool try_lock_upgrade() - { - boost::unique_lock lk(state_change); - if(!state.can_lock_upgrade()) - { - return false; - } - else - { - state.lock_upgrade(); - state.assert_lock_upgraded(); - return true; - } - } - - void unlock_upgrade() - { - boost::unique_lock lk(state_change); - state.assert_lock_upgraded(); - state.unlock_upgrade(); - state.assert_lock_not_upgraded (); - if(state.get_shared_count () == 0) - { - state.exclusive_blocked(false); - lk.unlock(); - release_waiters(); - } else { - lk.unlock(); - shared_cond.notify_all(); - } - } - - // Upgrade <-> Exclusive - void unlock_upgrade_and_lock() - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - state.assert_lock_upgraded(); - // assert state.get_shared_count() >=1 - while( - //! state.exclusive_waiting_blocked // Fixme: is this needed? - //&& - state.get_shared_count()!=1) - { - upgrade_cond.wait(lk); - } - state.unlock_upgrade(); - state.lock(); - state.assert_locked(); - } - - void unlock_and_lock_upgrade() - { - boost::unique_lock lk(state_change); - state.assert_locked(); - state.unlock(); - state.lock_upgrade(); - state.assert_lock_upgraded(); - release_waiters(); - } - - bool try_unlock_upgrade_and_lock() - { - boost::unique_lock lk(state_change); - state.assert_lock_upgraded(); - if( //!state.exclusive // this should be removed once the assertion work - ! state.exclusive_waiting_blocked // Fixme: why this is needed? - //&& state.upgrade // this should be removed once the assertion work - && state.get_shared_count()==1) - { - state.unlock_upgrade(); - state.lock(); - state.assert_locked(); - return true; - } - return false; - } -#ifdef BOOST_THREAD_USES_CHRONO - template - bool - try_unlock_upgrade_and_lock_for( - const chrono::duration& rel_time) - { - return try_unlock_upgrade_and_lock_until( - chrono::steady_clock::now() + rel_time); - } - template - bool - try_unlock_upgrade_and_lock_until( - const chrono::time_point& abs_time) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - state.assert_lock_upgraded(); - if (//state.exclusive // this should be removed once the assertion work - state.exclusive_waiting_blocked // Fixme: is this needed? - //|| ! state.upgrade // this should be removed once the assertion work - || state.get_shared_count() != 1) - { - for (;;) - { - //cv_status status = shared_cond.wait_until(lk,abs_time); - cv_status status = upgrade_cond.wait_until(lk,abs_time); - if (//!state.exclusive // this should be removed once the assertion work - ! state.exclusive_waiting_blocked // Fixme: is this needed? - //&& ! state.upgrade // this should be removed once the assertion work - && state.get_shared_count() == 1) - break; - if(status == cv_status::timeout) - return false; - } - } - state.unlock_upgrade(); - state.lock(); - return true; - } -#endif - - // Shared <-> Exclusive - void unlock_and_lock_shared() - { - boost::unique_lock lk(state_change); - state.assert_locked(); - state.unlock(); - state.lock_shared(); - release_waiters(); - } - -#ifdef BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS - bool try_unlock_shared_and_lock() - { - boost::unique_lock lk(state_change); - state.assert_lock_shared(); - if( //!state.exclusive // this should be removed once the assertion work - ! state.exclusive_waiting_blocked // Fixme: why this is needed? - //&& ! state.upgrade // Fixme: why this is needed if state.get_shared_count()==1? - && state.get_shared_count()==1) - { - state.unlock_shared(); - state.lock(); - return true; - } - return false; - } -#ifdef BOOST_THREAD_USES_CHRONO - template - bool - try_unlock_shared_and_lock_for( - const chrono::duration& rel_time) - { - return try_unlock_shared_and_lock_until( - chrono::steady_clock::now() + rel_time); - } - template - bool - try_unlock_shared_and_lock_until( - const chrono::time_point& abs_time) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - state.assert_lock_shared(); - if ( // !state.exclusive // this should be removed once the assertion work - state.exclusive_waiting_blocked // Fixme: is this needed? - //|| state.upgrade // Fixme: why this is needed if state.get_shared_count()==1? - || state.get_shared_count() != 1) - { - for (;;) - { - cv_status status = shared_cond.wait_until(lk,abs_time); - if ( //! state.exclusive // this should be removed once the assertion work - ! state.exclusive_waiting_blocked // Fixme: is this needed? - //&& ! state.upgrade - && state.get_shared_count() == 1) - break; - if(status == cv_status::timeout) - return false; - } - } - state.unlock_shared(); - state.lock(); - state.upgrade=false; // Is this absolutely needed? - state.exclusive_waiting_blocked=false; // Is this absolutely needed? - return true; - } -#endif -#endif - - // Shared <-> Upgrade - void unlock_upgrade_and_lock_shared() - { - boost::unique_lock lk(state_change); - state.assert_lock_upgraded(); - //state.unlock_upgrade(); - //state.lock_shared(); // less efficient - state.upgrade=false; - state.exclusive_waiting_blocked=false; // Is this absolutely needed? - release_waiters(); - } - -#ifdef BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS - bool try_unlock_shared_and_lock_upgrade() - { - boost::unique_lock lk(state_change); - state.assert_lock_shared(); - if( //! state.exclusive // this should be removed once the assertion work - ! state.exclusive_waiting_blocked // Fixme: is this needed? - && ! state.upgrade - ) - { - state.upgrade=true; - return true; - } - return false; - } -#ifdef BOOST_THREAD_USES_CHRONO - template - bool - try_unlock_shared_and_lock_upgrade_for( - const chrono::duration& rel_time) - { - return try_unlock_shared_and_lock_upgrade_until( - chrono::steady_clock::now() + rel_time); - } - template - bool - try_unlock_shared_and_lock_upgrade_until( - const chrono::time_point& abs_time) - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - boost::this_thread::disable_interruption do_not_disturb; -#endif - boost::unique_lock lk(state_change); - state.assert_lock_shared(); - if( //state.exclusive // this should be removed once the assertion work - state.exclusive_waiting_blocked // Fixme: is this needed? - || state.upgrade - ) - { - for (;;) - { - cv_status status = exclusive_cond.wait_until(lk,abs_time); - if( //! state.exclusive // this should be removed once the assertion work - ! state.exclusive_waiting_blocked // Fixme: is this needed? - && ! state.upgrade - ) - break; - if(status == cv_status::timeout) - return false; - } - } - //state.unlock_shared(); - //state.lock_upgrade(); // less efficient - state.upgrade=true; - return true; - } -#endif -#endif - }; - - typedef shared_mutex upgrade_mutex; -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/pthread/thread_data.hpp b/libraries/boost/boost/thread/pthread/thread_data.hpp deleted file mode 100644 index 458bcd542..000000000 --- a/libraries/boost/boost/thread/pthread/thread_data.hpp +++ /dev/null @@ -1,292 +0,0 @@ -#ifndef BOOST_THREAD_PTHREAD_THREAD_DATA_HPP -#define BOOST_THREAD_PTHREAD_THREAD_DATA_HPP -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#ifdef BOOST_THREAD_USES_CHRONO -#include -#endif - -#include -#include -#include - -#if defined(__ANDROID__) -# ifndef PAGE_SIZE -# define PAGE_SIZE 4096 -# endif -#endif - -#include -#include - -#include - -namespace boost -{ - class thread_attributes { - public: - thread_attributes() BOOST_NOEXCEPT { - int res = pthread_attr_init(&val_); - BOOST_VERIFY(!res && "pthread_attr_init failed"); - } - ~thread_attributes() { - int res = pthread_attr_destroy(&val_); - BOOST_VERIFY(!res && "pthread_attr_destroy failed"); - } - // stack - void set_stack_size(std::size_t size) BOOST_NOEXCEPT { - if (size==0) return; - std::size_t page_size = getpagesize(); -#ifdef PTHREAD_STACK_MIN - if (size func; - void* value; - - tss_data_node(boost::shared_ptr func_, - void* value_): - func(func_),value(value_) - {} - }; - - struct thread_data_base; - typedef boost::shared_ptr thread_data_ptr; - - struct BOOST_THREAD_DECL thread_data_base: - enable_shared_from_this - { - thread_data_ptr self; - pthread_t thread_handle; - boost::mutex data_mutex; - boost::condition_variable done_condition; - boost::mutex sleep_mutex; - boost::condition_variable sleep_condition; - bool done; - bool join_started; - bool joined; - boost::detail::thread_exit_callback_node* thread_exit_callbacks; - std::map tss_data; - -//#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - // These data must be at the end so that the access to the other fields doesn't change - // when BOOST_THREAD_PROVIDES_INTERRUPTIONS is defined. - // Another option is to have them always - pthread_mutex_t* cond_mutex; - pthread_cond_t* current_cond; -//#endif - typedef std::vector - //, hidden_allocator > - > notify_list_t; - notify_list_t notify; - - typedef std::vector > async_states_t; - async_states_t async_states_; - -//#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - // These data must be at the end so that the access to the other fields doesn't change - // when BOOST_THREAD_PROVIDES_INTERRUPTIONS is defined. - // Another option is to have them always - bool interrupt_enabled; - bool interrupt_requested; -//#endif - thread_data_base(): - thread_handle(0), - done(false),join_started(false),joined(false), - thread_exit_callbacks(0), -//#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - cond_mutex(0), - current_cond(0), -//#endif - notify(), - async_states_() -//#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - , interrupt_enabled(true) - , interrupt_requested(false) -//#endif - {} - virtual ~thread_data_base(); - - typedef pthread_t native_handle_type; - - virtual void run()=0; - virtual void notify_all_at_thread_exit(condition_variable* cv, mutex* m) - { - notify.push_back(std::pair(cv, m)); - } - - void make_ready_at_thread_exit(shared_ptr as) - { - async_states_.push_back(as); - } - - }; - - BOOST_THREAD_DECL thread_data_base* get_current_thread_data(); - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - class interruption_checker - { - thread_data_base* const thread_info; - pthread_mutex_t* m; - bool set; - - void check_for_interruption() - { -#ifndef BOOST_NO_EXCEPTIONS - if(thread_info->interrupt_requested) - { - thread_info->interrupt_requested=false; - throw thread_interrupted(); // BOOST_NO_EXCEPTIONS protected - } -#endif - } - - void operator=(interruption_checker&); - public: - explicit interruption_checker(pthread_mutex_t* cond_mutex,pthread_cond_t* cond): - thread_info(detail::get_current_thread_data()),m(cond_mutex), - set(thread_info && thread_info->interrupt_enabled) - { - if(set) - { - lock_guard guard(thread_info->data_mutex); - check_for_interruption(); - thread_info->cond_mutex=cond_mutex; - thread_info->current_cond=cond; - BOOST_VERIFY(!pthread_mutex_lock(m)); - } - else - { - BOOST_VERIFY(!pthread_mutex_lock(m)); - } - } - ~interruption_checker() - { - if(set) - { - BOOST_VERIFY(!pthread_mutex_unlock(m)); - lock_guard guard(thread_info->data_mutex); - thread_info->cond_mutex=NULL; - thread_info->current_cond=NULL; - } - else - { - BOOST_VERIFY(!pthread_mutex_unlock(m)); - } - } - }; -#endif - } - - namespace this_thread - { - namespace hidden - { - void BOOST_THREAD_DECL sleep_for(const timespec& ts); - void BOOST_THREAD_DECL sleep_until(const timespec& ts); - } - -#ifdef BOOST_THREAD_USES_CHRONO -#ifdef BOOST_THREAD_SLEEP_FOR_IS_STEADY - - inline - void BOOST_SYMBOL_VISIBLE sleep_for(const chrono::nanoseconds& ns) - { - return boost::this_thread::hidden::sleep_for(boost::detail::to_timespec(ns)); - } -#endif -#endif // BOOST_THREAD_USES_CHRONO - - namespace no_interruption_point - { - namespace hidden - { - void BOOST_THREAD_DECL sleep_for(const timespec& ts); - void BOOST_THREAD_DECL sleep_until(const timespec& ts); - } - - #ifdef BOOST_THREAD_USES_CHRONO - #ifdef BOOST_THREAD_SLEEP_FOR_IS_STEADY - - inline - void BOOST_SYMBOL_VISIBLE sleep_for(const chrono::nanoseconds& ns) - { - return boost::this_thread::no_interruption_point::hidden::sleep_for(boost::detail::to_timespec(ns)); - } - #endif - #endif // BOOST_THREAD_USES_CHRONO - - } // no_interruption_point - - void BOOST_THREAD_DECL yield() BOOST_NOEXCEPT; - -#if defined BOOST_THREAD_USES_DATETIME -#ifdef __DECXXX - /// Workaround of DECCXX issue of incorrect template substitution - template<> -#endif - inline void sleep(system_time const& abs_time) - { - return boost::this_thread::hidden::sleep_until(boost::detail::to_timespec(abs_time)); - } - - template - inline BOOST_SYMBOL_VISIBLE void sleep(TimeDuration const& rel_time) - { - this_thread::sleep(get_system_time()+rel_time); - } -#endif // BOOST_THREAD_USES_DATETIME - } // this_thread -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/pthread/thread_heap_alloc.hpp b/libraries/boost/boost/thread/pthread/thread_heap_alloc.hpp deleted file mode 100644 index 7828318f0..000000000 --- a/libraries/boost/boost/thread/pthread/thread_heap_alloc.hpp +++ /dev/null @@ -1,242 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2008 Anthony Williams -#ifndef THREAD_HEAP_ALLOC_PTHREAD_HPP -#define THREAD_HEAP_ALLOC_PTHREAD_HPP - -#include - -namespace boost -{ - namespace detail - { - template - inline T* heap_new() - { - return new T(); - } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template - inline T* heap_new(A1&& a1) - { - return new T(static_cast(a1)); - } - template - inline T* heap_new(A1&& a1,A2&& a2) - { - return new T(static_cast(a1),static_cast(a2)); - } - template - inline T* heap_new(A1&& a1,A2&& a2,A3&& a3) - { - return new T(static_cast(a1),static_cast(a2), - static_cast(a3)); - } - template - inline T* heap_new(A1&& a1,A2&& a2,A3&& a3,A4&& a4) - { - return new T(static_cast(a1),static_cast(a2), - static_cast(a3),static_cast(a4)); - } -#else - template - inline T* heap_new_impl(A1 a1) - { - return new T(a1); - } - template - inline T* heap_new_impl(A1 a1,A2 a2) - { - return new T(a1,a2); - } - template - inline T* heap_new_impl(A1 a1,A2 a2,A3 a3) - { - return new T(a1,a2,a3); - } - template - inline T* heap_new_impl(A1 a1,A2 a2,A3 a3,A4 a4) - { - return new T(a1,a2,a3,a4); - } - - template - inline T* heap_new(A1 const& a1) - { - return heap_new_impl(a1); - } - template - inline T* heap_new(A1& a1) - { - return heap_new_impl(a1); - } - - template - inline T* heap_new(A1 const& a1,A2 const& a2) - { - return heap_new_impl(a1,a2); - } - template - inline T* heap_new(A1& a1,A2 const& a2) - { - return heap_new_impl(a1,a2); - } - template - inline T* heap_new(A1 const& a1,A2& a2) - { - return heap_new_impl(a1,a2); - } - template - inline T* heap_new(A1& a1,A2& a2) - { - return heap_new_impl(a1,a2); - } - - template - inline T* heap_new(A1 const& a1,A2 const& a2,A3 const& a3) - { - return heap_new_impl(a1,a2,a3); - } - template - inline T* heap_new(A1& a1,A2 const& a2,A3 const& a3) - { - return heap_new_impl(a1,a2,a3); - } - template - inline T* heap_new(A1 const& a1,A2& a2,A3 const& a3) - { - return heap_new_impl(a1,a2,a3); - } - template - inline T* heap_new(A1& a1,A2& a2,A3 const& a3) - { - return heap_new_impl(a1,a2,a3); - } - - template - inline T* heap_new(A1 const& a1,A2 const& a2,A3& a3) - { - return heap_new_impl(a1,a2,a3); - } - template - inline T* heap_new(A1& a1,A2 const& a2,A3& a3) - { - return heap_new_impl(a1,a2,a3); - } - template - inline T* heap_new(A1 const& a1,A2& a2,A3& a3) - { - return heap_new_impl(a1,a2,a3); - } - template - inline T* heap_new(A1& a1,A2& a2,A3& a3) - { - return heap_new_impl(a1,a2,a3); - } - - template - inline T* heap_new(A1 const& a1,A2 const& a2,A3 const& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2 const& a2,A3 const& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1 const& a1,A2& a2,A3 const& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2& a2,A3 const& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - - template - inline T* heap_new(A1 const& a1,A2 const& a2,A3& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2 const& a2,A3& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1 const& a1,A2& a2,A3& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2& a2,A3& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1 const& a1,A2 const& a2,A3 const& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2 const& a2,A3 const& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1 const& a1,A2& a2,A3 const& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2& a2,A3 const& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - - template - inline T* heap_new(A1 const& a1,A2 const& a2,A3& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2 const& a2,A3& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1 const& a1,A2& a2,A3& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2& a2,A3& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - -#endif - template - inline void heap_delete(T* data) - { - delete data; - } - - template - struct do_heap_delete - { - void operator()(T* data) const - { - detail::heap_delete(data); - } - }; - } -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/pthread/timespec.hpp b/libraries/boost/boost/thread/pthread/timespec.hpp deleted file mode 100644 index 82f50f6ca..000000000 --- a/libraries/boost/boost/thread/pthread/timespec.hpp +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef BOOST_THREAD_PTHREAD_TIMESPEC_HPP -#define BOOST_THREAD_PTHREAD_TIMESPEC_HPP -// (C) Copyright 2007-8 Anthony Williams -// (C) Copyright 2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#if defined BOOST_THREAD_USES_DATETIME -#include -#endif -#include -#ifndef _WIN32 -#include -#endif -#ifdef BOOST_THREAD_USES_CHRONO -#include -#endif - -#if defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) -# define BOOST_THREAD_TIMESPEC_MAC_API -#include //for gettimeofday and timeval -#else -#include // for clock_gettime -#endif - -#include - -namespace boost -{ - namespace detail - { -#if defined BOOST_THREAD_USES_DATETIME - inline struct timespec to_timespec(boost::system_time const& abs_time) - { - struct timespec timeout = { 0,0}; - boost::posix_time::time_duration const time_since_epoch=abs_time-boost::posix_time::from_time_t(0); - - timeout.tv_sec=time_since_epoch.total_seconds(); - timeout.tv_nsec=(long)(time_since_epoch.fractional_seconds()*(1000000000l/time_since_epoch.ticks_per_second())); - return timeout; - } -#endif -#if defined BOOST_THREAD_USES_CHRONO - inline timespec to_timespec(chrono::nanoseconds const& ns) - { - struct timespec ts; - ts.tv_sec = static_cast(chrono::duration_cast(ns).count()); - ts.tv_nsec = static_cast((ns - chrono::duration_cast(ns)).count()); - return ts; - } - -#endif - - inline timespec to_timespec(boost::intmax_t const& ns) - { - boost::intmax_t s = ns / 1000000000l; - struct timespec ts; - ts.tv_sec = static_cast (s); - ts.tv_nsec = static_cast (ns - s * 1000000000l); - return ts; - } - inline boost::intmax_t to_nanoseconds_int_max(timespec const& ts) - { - return static_cast(ts.tv_sec) * 1000000000l + ts.tv_nsec; - } - inline bool timespec_ge_zero(timespec const& ts) - { - return (ts.tv_sec >= 0) || (ts.tv_nsec >= 0); - } - inline timespec timespec_now() - { - timespec ts; - -#if defined(BOOST_THREAD_TIMESPEC_MAC_API) - timeval tv; - ::gettimeofday(&tv, 0); - ts.tv_sec = tv.tv_sec; - ts.tv_nsec = tv.tv_usec * 1000; -#else - if ( ::clock_gettime( CLOCK_REALTIME, &ts ) ) - { - BOOST_ASSERT(0 && "Boost::Thread - Internal Error"); - } -#endif - return ts; - } - inline timespec timespec_zero() - { - timespec ts; - ts.tv_sec = 0; - ts.tv_nsec = 0; - return ts; - } - inline timespec timespec_plus(timespec const& lhs, timespec const& rhs) - { - return to_timespec(to_nanoseconds_int_max(lhs) + to_nanoseconds_int_max(rhs)); - } - inline timespec timespec_minus(timespec const& lhs, timespec const& rhs) - { - return to_timespec(to_nanoseconds_int_max(lhs) - to_nanoseconds_int_max(rhs)); - } - inline bool timespec_gt(timespec const& lhs, timespec const& rhs) - { - return to_nanoseconds_int_max(lhs) > to_nanoseconds_int_max(rhs); - } - inline bool timespec_ge(timespec const& lhs, timespec const& rhs) - { - return to_nanoseconds_int_max(lhs) >= to_nanoseconds_int_max(rhs); - } - - } -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/recursive_mutex.hpp b/libraries/boost/boost/thread/recursive_mutex.hpp deleted file mode 100644 index e716a190f..000000000 --- a/libraries/boost/boost/thread/recursive_mutex.hpp +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef BOOST_THREAD_RECURSIVE_MUTEX_HPP -#define BOOST_THREAD_RECURSIVE_MUTEX_HPP - -// recursive_mutex.hpp -// -// (C) Copyright 2007 Anthony Williams -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#if defined(BOOST_THREAD_PLATFORM_WIN32) -#include -#elif defined(BOOST_THREAD_PLATFORM_PTHREAD) -#include -#else -#error "Boost threads unavailable on this platform" -#endif - -#include - -namespace boost -{ - namespace sync - { - -#ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES - template<> - struct is_basic_lockable - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - template<> - struct is_lockable - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - template<> - struct is_basic_lockable - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - template<> - struct is_lockable - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; -#endif - - template<> - struct is_recursive_mutex_sur_parolle - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - template<> - struct is_recursive_mutex_sur_parolle - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - - } -} -#endif diff --git a/libraries/boost/boost/thread/reverse_lock.hpp b/libraries/boost/boost/thread/reverse_lock.hpp deleted file mode 100644 index 479c314bd..000000000 --- a/libraries/boost/boost/thread/reverse_lock.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2012 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_REVERSE_LOCK_HPP -#define BOOST_THREAD_REVERSE_LOCK_HPP -#include -#include -#include -#include -#include - -namespace boost -{ - - template - class reverse_lock - { - public: - typedef typename Lock::mutex_type mutex_type; - BOOST_THREAD_NO_COPYABLE(reverse_lock) - - explicit reverse_lock(Lock& m_) - : m(m_), mtx(0) - { - if (m.owns_lock()) - { - m.unlock(); - } - mtx=m.release(); - } - ~reverse_lock() - { - if (mtx) { - mtx->lock(); - m = BOOST_THREAD_MAKE_RV_REF(Lock(*mtx, adopt_lock)); - } - } - - private: - Lock& m; - mutex_type* mtx; - }; - - -#ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES - template - struct is_mutex_type > - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - -#endif - - -} - -#endif // header diff --git a/libraries/boost/boost/thread/scoped_thread.hpp b/libraries/boost/boost/thread/scoped_thread.hpp deleted file mode 100644 index c2da91972..000000000 --- a/libraries/boost/boost/thread/scoped_thread.hpp +++ /dev/null @@ -1,292 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2009-2012 Anthony Williams -// (C) Copyright 2012 Vicente J. Botet Escriba - -// Based on the Anthony's idea of scoped_thread in CCiA - -#ifndef BOOST_THREAD_SCOPED_THREAD_HPP -#define BOOST_THREAD_SCOPED_THREAD_HPP - -#include -#include -#include -#include -#include - -#include - -namespace boost -{ - - /** - * RAI @c thread wrapper adding a specific destroyer allowing to master what can be done at destruction time. - * - * CallableThread: A callable void(thread&) . - * The default is a join_if_joinable. - * - * thread std/boost::thread destructor terminates the program if the thread is not joinable. - * Having a wrapper that can join the thread before destroying it seems a natural need. - * - * Example: - * - * boost::strict_scoped_thread<> t((boost::thread(F))); - * - */ - template - class strict_scoped_thread - { - thread t_; - struct dummy; - public: - - BOOST_THREAD_NO_COPYABLE( strict_scoped_thread) /// non copyable - - /* - * - */ -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template ::type, thread>, void* >::type> - explicit strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(Args)... args) : - t_(boost::forward(f), boost::forward(args)...) {} -#else - template - explicit strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, - typename disable_if::type, thread>, void* >::type=0) : - t_(boost::forward(f)) {} - template - strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1) : - t_(boost::forward(f), boost::forward(a1)) {} - template - strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1, BOOST_THREAD_FWD_REF(A2) a2) : - t_(boost::forward(f), boost::forward(a1), boost::forward(a2)) {} - template - strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1, BOOST_THREAD_FWD_REF(A2) a2, BOOST_THREAD_FWD_REF(A3) a3) : - t_(boost::forward(f), boost::forward(a1), boost::forward(a2), boost::forward(a3)) {} -#endif - - /** - * Constructor from the thread to own. - * - * @param t: the thread to own. - * - * Effects: move the thread to own @c t. - */ - explicit strict_scoped_thread(BOOST_THREAD_RV_REF(thread) t) BOOST_NOEXCEPT : - t_(boost::move(t)) - { - } - - /** - * Destructor - * Effects: Call the CallableThread functor before destroying the owned thread. - * Remark: The CallableThread should not throw when joining the thread as the scoped variable is on a scope outside the thread function. - */ - ~strict_scoped_thread() - { - CallableThread on_destructor; - - on_destructor(t_); - } - - }; - - /** - * RAI @c thread wrapper adding a specific destroyer allowing to master what can be done at destruction time. - * - * CallableThread: A callable void(thread&) . - * The default is join_if_joinable. - * - * thread std::thread destructor terminates the program if the thread is not joinable. - * Having a wrapper that can join the thread before destroying it seems a natural need. - * - * Remark: @c scoped_thread is not a @c thread as @c thread is not designed to be derived from as a polymorphic type. - * Anyway @c scoped_thread can be used in most of the contexts a @c thread could be used as it has the - * same non-deprecated interface with the exception of the construction. - * - * Example: - * - * boost::scoped_thread<> t((boost::thread(F))); - * t.interrupt(); - * - */ - template - class scoped_thread - { - thread t_; - struct dummy; - public: - - typedef thread::id id; - - BOOST_THREAD_MOVABLE_ONLY( scoped_thread) /// Movable only - - /** - * Default Constructor. - * - * Effects: wraps a not-a-thread. - */ - scoped_thread() BOOST_NOEXCEPT: - t_() - { - } - - /** - * - */ - -#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) - template ::type, thread>, void* >::type> - explicit scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(Args)... args) : - t_(boost::forward(f), boost::forward(args)...) {} -#else - template - explicit scoped_thread(BOOST_THREAD_FWD_REF(F) f, - typename disable_if::type, thread>, void* >::type=0) : - t_(boost::forward(f)) {} - template - scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1) : - t_(boost::forward(f), boost::forward(a1)) {} - template - scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1, BOOST_THREAD_FWD_REF(A2) a2) : - t_(boost::forward(f), boost::forward(a1), boost::forward(a2)) {} - template - scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1, BOOST_THREAD_FWD_REF(A2) a2, BOOST_THREAD_FWD_REF(A3) a3) : - t_(boost::forward(f), boost::forward(a1), boost::forward(a2), boost::forward(a3)) {} - -#endif - /** - * Constructor from the thread to own. - * - * @param t: the thread to own. - * - * Effects: move the thread to own @c t. - */ - explicit scoped_thread(BOOST_THREAD_RV_REF(thread) t) BOOST_NOEXCEPT : - t_(boost::move(t)) - { - } - -// explicit operator thread() -// { -// return boost::move(t_); -// } - - /** - * Move constructor. - */ - scoped_thread(BOOST_RV_REF(scoped_thread) x) BOOST_NOEXCEPT : - t_(boost::move(BOOST_THREAD_RV(x).t_)) - {} - - /** - * Destructor - * - * Effects: Call the CallableThread functor before destroying the owned thread. - */ - ~scoped_thread() - { - CallableThread on_destructor; - - on_destructor(t_); - } - - /** - * Move assignment. - */ - scoped_thread& operator=(BOOST_RV_REF(scoped_thread) x) - { - CallableThread on_destructor; - - on_destructor(t_); - t_ = boost::move(BOOST_THREAD_RV(x).t_); - return *this; - } - - /** - * - */ - void swap(scoped_thread& x) BOOST_NOEXCEPT - { - t_.swap(x.t_); - } - - // forwarded thread functions - inline thread::id get_id() const BOOST_NOEXCEPT - { - return t_.get_id(); - } - - void detach() - { - t_.detach(); - } - - void join() - { - t_.join(); - } - -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_join_for(const chrono::duration& rel_time) - { - return t_.try_join_for(rel_time); - } - - template - bool try_join_until(const chrono::time_point& abs_time) - { - return t_.try_join_until(abs_time); - } -#endif - - thread::native_handle_type native_handle()BOOST_NOEXCEPT - { - return t_.native_handle(); - } - - bool joinable() const BOOST_NOEXCEPT - { - return t_.joinable(); - } - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - void interrupt() - { - t_.interrupt(); - } - - bool interruption_requested() const BOOST_NOEXCEPT - { - return t_.interruption_requested(); - } -#endif - - static unsigned hardware_concurrency() BOOST_NOEXCEPT - { - return thread::hardware_concurrency(); - } - -#ifdef BOOST_THREAD_PROVIDES_PHYSICAL_CONCURRENCY - static unsigned physical_concurrency() BOOST_NOEXCEPT - { - return thread::physical_concurrency(); - } -#endif - }; - - /** - * Effects: swaps the contents of two scoped threads. - */ - template - void swap(scoped_thread& lhs, scoped_thread& rhs) -BOOST_NOEXCEPT { - return lhs.swap(rhs); -} - -} -#include - -#endif diff --git a/libraries/boost/boost/thread/shared_lock_guard.hpp b/libraries/boost/boost/thread/shared_lock_guard.hpp deleted file mode 100644 index 97a6397c1..000000000 --- a/libraries/boost/boost/thread/shared_lock_guard.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2012 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_SHARED_LOCK_GUARD_HPP -#define BOOST_THREAD_SHARED_LOCK_GUARD_HPP -#include -//#include -#include -#include - -namespace boost -{ - - template - class shared_lock_guard - { - private: - SharedMutex& m; - - public: - typedef SharedMutex mutex_type; - BOOST_THREAD_NO_COPYABLE(shared_lock_guard) - explicit shared_lock_guard(SharedMutex& m_): - m(m_) - { - m.lock_shared(); - } - shared_lock_guard(SharedMutex& m_,adopt_lock_t): - m(m_) - {} - ~shared_lock_guard() - { - m.unlock_shared(); - } - }; - -#ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES - - template - struct is_mutex_type > - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - - -#endif - - -} - -#endif // header diff --git a/libraries/boost/boost/thread/shared_mutex.hpp b/libraries/boost/boost/thread/shared_mutex.hpp deleted file mode 100644 index ce5d6d1bf..000000000 --- a/libraries/boost/boost/thread/shared_mutex.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef BOOST_THREAD_SHARED_MUTEX_HPP -#define BOOST_THREAD_SHARED_MUTEX_HPP - -// shared_mutex.hpp -// -// (C) Copyright 2007 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#if defined(BOOST_THREAD_PLATFORM_WIN32) -#if defined(BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN) -#include -#else -#include -#endif -#elif defined(BOOST_THREAD_PLATFORM_PTHREAD) -//#include -#include -#else -#error "Boost threads unavailable on this platform" -#endif - -#include - -namespace boost -{ - typedef shared_mutex shared_timed_mutex; - namespace sync - { -#ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES - template<> - struct is_basic_lockable - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - template<> - struct is_lockable - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; -#endif - - } -} - -#endif diff --git a/libraries/boost/boost/thread/strict_lock.hpp b/libraries/boost/boost/thread/strict_lock.hpp deleted file mode 100644 index 93b7b1e71..000000000 --- a/libraries/boost/boost/thread/strict_lock.hpp +++ /dev/null @@ -1,235 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2008-2009,2012 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_STRICT_LOCK_HPP -#define BOOST_THREAD_STRICT_LOCK_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace boost -{ - - - //[strict_lock - template - class strict_lock - { - - BOOST_CONCEPT_ASSERT(( BasicLockable )); - public: - typedef Lockable mutex_type; - - // construct/copy/destroy: - - BOOST_THREAD_NO_COPYABLE( strict_lock) - - /** - * Constructor from a mutex reference. - * - * @param mtx the mutex to lock. - * - * __Effects: Stores a reference to the mutex to lock and locks it. - * __Throws: Any exception BasicMutex::lock() can throw. - */ - explicit strict_lock(mutex_type& mtx) : - mtx_(mtx) - { - mtx.lock(); - } /*< locks on construction >*/ - - -#if ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST - strict_lock(std::initializer_list > l_) : - mtx_(*(const_cast*>(l_.begin())->m)) - { - mtx_.lock(); - } -#endif - - /** - * Destructor - * - * __Effects: unlocks the stored mutex. - * - * __Throws - */ - ~strict_lock() - { - mtx_.unlock(); - } /*< unlocks on destruction >*/ - - - // observers - - /** - * @return the owned mutex. - */ - mutex_type* mutex() const BOOST_NOEXCEPT - { - return &mtx_; - } - - /** - * @return whether this lock is locking a mutex. - */ - bool owns_lock() const BOOST_NOEXCEPT - { - return true; - } - - /** - * @return whether this lock is locking that mutex. - */ - bool owns_lock(const mutex_type* l) const BOOST_NOEXCEPT - { - return l == mutex(); - } /*< strict locks specific function >*/ - - //BOOST_ADRESS_OF_DELETE(strict_lock) /*< disable aliasing >*/ - //BOOST_HEAP_ALLOCATION_DELETE(strict_lock) /*< disable heap allocation >*/ - - /*< no possibility to unlock >*/ - - private: - mutex_type& mtx_; - }; - //] - template - struct is_strict_lock_sur_parole > : true_type - { - }; - - /** - * A nested strict lock is a scoped lock guard ensuring the mutex is locked on its - * scope, by taking ownership of an nesting lock, locking the mutex on construction if not already locked - * and restoring the ownership to the nesting lock on destruction. - */ - //[nested_strict_lock - template - class nested_strict_lock - { - BOOST_CONCEPT_ASSERT(( BasicLock )); /*< The Lock must be a movable lock >*/ - public: - typedef typename Lock::mutex_type mutex_type; /*< Name the lockable type locked by Lock >*/ - - BOOST_THREAD_NO_COPYABLE( nested_strict_lock) - - /** - * Constructor from a nesting @c Lock. - * - * @param lk the nesting lock - * - * __Requires: lk.mutex() != null_ptr - * __Effects: Stores the reference to the lock parameter and takes ownership on it. - * If the lock doesn't owns the mutex @c mtx lock it. - * __Postconditions: @c owns_lock(lk.mutex()) - * __StrongException - * __Throws: - * - * - lock_error when BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED is defined and lk.mutex() == null_ptr - * - * - Any exception that @c lk.lock() can throw. - * - */ - explicit nested_strict_lock(Lock& lk) : - lk_(lk) /*< Store reference to lk >*/ - { - /*< Define BOOST_THREAD_DONT_CHECK_PRECONDITIONS if you don't want to check lk ownership >*/ - BOOST_THREAD_ASSERT_PRECONDITION( lk.mutex() != 0, - lock_error() - ); - if (!lk.owns_lock()) lk.lock(); /*< ensures it is locked >*/ - tmp_lk_ = move(lk); /*< Move ownership to temporary lk >*/ - } - -#if ! defined BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST - nested_strict_lock(std::initializer_list > l_) : - lk_(*(const_cast*>(l_.begin())->m)) - { - /*< Define BOOST_THREAD_DONT_CHECK_PRECONDITIONS if you don't want to check lk ownership >*/ - BOOST_THREAD_ASSERT_PRECONDITION( lk_.mutex() != 0, - lock_error() - ); - if (!lk_.owns_lock()) lk_.lock(); /*< ensures it is locked >*/ - tmp_lk_ = move(lk_); /*< Move ownership to temporary lk >*/ - } -#endif - - /** - * Destructor - * - * __Effects: Restores ownership to the nesting lock. - */ - ~nested_strict_lock()BOOST_NOEXCEPT - { - lk_ = move(tmp_lk_); /*< Move ownership to nesting lock >*/ - } - - // observers - /** - * return @c the owned mutex. - */ - mutex_type* mutex() const BOOST_NOEXCEPT - { - return tmp_lk_.mutex(); - } - - /** - * @return whether this lock is locking a mutex. - */ - bool owns_lock() const BOOST_NOEXCEPT - { - return true; - } - - /** - * @return whether if this lock is locking that mutex. - */ - bool owns_lock(mutex_type const* l) const BOOST_NOEXCEPT - { - return l == mutex(); - } - - //BOOST_ADRESS_OF_DELETE(nested_strict_lock) - //BOOST_HEAP_ALLOCATEION_DELETE(nested_strict_lock) - - private: - Lock& lk_; - Lock tmp_lk_; - }; - //] - - template - struct is_strict_lock_sur_parole > : true_type - { - }; - -#if ! defined BOOST_THREAD_NO_MAKE_STRICT_LOCK - template - strict_lock make_strict_lock(Lockable& mtx) - { - return { thread_detail::lockable_wrapper(mtx) }; - } - template - nested_strict_lock make_nested_strict_lock(Lock& lk) - { - return { thread_detail::lockable_wrapper(lk) }; - } -#endif -} -#include - -#endif diff --git a/libraries/boost/boost/thread/sync_bounded_queue.hpp b/libraries/boost/boost/thread/sync_bounded_queue.hpp deleted file mode 100644 index 2024d6602..000000000 --- a/libraries/boost/boost/thread/sync_bounded_queue.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef BOOST_THREAD_SYNC_BOUNDED_QUEUE_HPP -#define BOOST_THREAD_SYNC_BOUNDED_QUEUE_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2013-2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include - -#endif diff --git a/libraries/boost/boost/thread/sync_queue.hpp b/libraries/boost/boost/thread/sync_queue.hpp deleted file mode 100644 index 0d9334b47..000000000 --- a/libraries/boost/boost/thread/sync_queue.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef BOOST_THREAD_SYNC_QUEUE_HPP -#define BOOST_THREAD_SYNC_QUEUE_HPP - -////////////////////////////////////////////////////////////////////////////// -// -// (C) Copyright Vicente J. Botet Escriba 2013-2014. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/thread for documentation. -// -////////////////////////////////////////////////////////////////////////////// - -#include - -#endif diff --git a/libraries/boost/boost/thread/synchronized_value.hpp b/libraries/boost/boost/thread/synchronized_value.hpp deleted file mode 100644 index e16106304..000000000 --- a/libraries/boost/boost/thread/synchronized_value.hpp +++ /dev/null @@ -1,1068 +0,0 @@ -// (C) Copyright 2010 Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk -// (C) Copyright 2012 Vicente J. Botet Escriba -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -#ifndef BOOST_THREAD_SYNCHRONIZED_VALUE_HPP -#define BOOST_THREAD_SYNCHRONIZED_VALUE_HPP - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -//#include -//#if ! defined BOOST_NO_CXX11_HDR_TYPE_TRAITS -//#include -//#endif - -#if ! defined(BOOST_THREAD_NO_SYNCHRONIZE) -#include // todo change to once Boost.Tuple or Boost.Fusion provides Move semantics on C++98 compilers. -#include -#endif - -#include - -#include - -namespace boost -{ - - /** - * strict lock providing a const pointer access to the synchronized value type. - * - * @param T the value type. - * @param Lockable the mutex type protecting the value type. - */ - template - class const_strict_lock_ptr - { - public: - typedef T value_type; - typedef Lockable mutex_type; - protected: - - // this should be a strict_lock, but unique_lock is needed to be able to return it. - boost::unique_lock lk_; - T const& value_; - - public: - BOOST_THREAD_MOVABLE_ONLY( const_strict_lock_ptr ) - - /** - * @param value constant reference of the value to protect. - * @param mtx reference to the mutex used to protect the value. - * @effects locks the mutex @c mtx, stores a reference to it and to the value type @c value. - */ - const_strict_lock_ptr(T const& val, Lockable & mtx) : - lk_(mtx), value_(val) - { - } - const_strict_lock_ptr(T const& val, Lockable & mtx, adopt_lock_t tag) BOOST_NOEXCEPT : - lk_(mtx, tag), value_(val) - { - } - /** - * Move constructor. - * @effects takes ownership of the mutex owned by @c other, stores a reference to the mutex and the value type of @c other. - */ - const_strict_lock_ptr(BOOST_THREAD_RV_REF(const_strict_lock_ptr) other) BOOST_NOEXCEPT - : lk_(boost::move(BOOST_THREAD_RV(other).lk_)),value_(BOOST_THREAD_RV(other).value_) - { - } - - ~const_strict_lock_ptr() - { - } - - /** - * @return a constant pointer to the protected value - */ - const T* operator->() const - { - return &value_; - } - - /** - * @return a constant reference to the protected value - */ - const T& operator*() const - { - return value_; - } - - }; - - /** - * strict lock providing a pointer access to the synchronized value type. - * - * @param T the value type. - * @param Lockable the mutex type protecting the value type. - */ - template - class strict_lock_ptr : public const_strict_lock_ptr - { - typedef const_strict_lock_ptr base_type; - public: - BOOST_THREAD_MOVABLE_ONLY( strict_lock_ptr ) - - /** - * @param value reference of the value to protect. - * @param mtx reference to the mutex used to protect the value. - * @effects locks the mutex @c mtx, stores a reference to it and to the value type @c value. - */ - strict_lock_ptr(T & val, Lockable & mtx) : - base_type(val, mtx) - { - } - strict_lock_ptr(T & val, Lockable & mtx, adopt_lock_t tag) : - base_type(val, mtx, tag) - { - } - - /** - * Move constructor. - * @effects takes ownership of the mutex owned by @c other, stores a reference to the mutex and the value type of @c other. - */ - strict_lock_ptr(BOOST_THREAD_RV_REF(strict_lock_ptr) other) - : base_type(boost::move(static_cast(other))) - { - } - - ~strict_lock_ptr() - { - } - - /** - * @return a pointer to the protected value - */ - T* operator->() - { - return const_cast(&this->value_); - } - - /** - * @return a reference to the protected value - */ - T& operator*() - { - return const_cast(this->value_); - } - - }; - - template - struct synchronized_value_strict_lock_ptr - { - typedef strict_lock_ptr type; - }; - - template - struct synchronized_value_strict_lock_ptr - { - typedef const_strict_lock_ptr type; - }; - /** - * unique_lock providing a const pointer access to the synchronized value type. - * - * An object of type const_unique_lock_ptr is a unique_lock that provides a const pointer access to the synchronized value type. - * As unique_lock controls the ownership of a lockable object within a scope. - * Ownership of the lockable object may be acquired at construction or after construction, - * and may be transferred, after acquisition, to another const_unique_lock_ptr object. - * Objects of type const_unique_lock_ptr are not copyable but are movable. - * The behavior of a program is undefined if the mutex and the value type - * pointed do not exist for the entire remaining lifetime of the const_unique_lock_ptr object. - * The supplied Mutex type shall meet the BasicLockable requirements. - * - * @note const_unique_lock_ptr meets the Lockable requirements. - * If Lockable meets the TimedLockable requirements, const_unique_lock_ptr - * also meets the TimedLockable requirements. - * - * @param T the value type. - * @param Lockable the mutex type protecting the value type. - */ - template - class const_unique_lock_ptr : public unique_lock - { - typedef unique_lock base_type; - public: - typedef T value_type; - typedef Lockable mutex_type; - protected: - T const& value_; - - public: - BOOST_THREAD_MOVABLE_ONLY(const_unique_lock_ptr) - - /** - * @param value reference of the value to protect. - * @param mtx reference to the mutex used to protect the value. - * - * @requires If mutex_type is not a recursive mutex the calling thread does not own the mutex. - * - * @effects locks the mutex @c mtx, stores a reference to it and to the value type @c value. - */ - const_unique_lock_ptr(T const& val, Lockable & mtx) - : base_type(mtx), value_(val) - { - } - /** - * @param value reference of the value to protect. - * @param mtx reference to the mutex used to protect the value. - * @param tag of type adopt_lock_t used to differentiate the constructor. - * @requires The calling thread own the mutex. - * @effects stores a reference to it and to the value type @c value taking ownership. - */ - const_unique_lock_ptr(T const& val, Lockable & mtx, adopt_lock_t) BOOST_NOEXCEPT - : base_type(mtx, adopt_lock), value_(val) - { - } - /** - * @param value reference of the value to protect. - * @param mtx reference to the mutex used to protect the value. - * @param tag of type defer_lock_t used to differentiate the constructor. - * @effects stores a reference to it and to the value type @c value c. - */ - const_unique_lock_ptr(T const& val, Lockable & mtx, defer_lock_t) BOOST_NOEXCEPT - : base_type(mtx, defer_lock), value_(val) - { - } - /** - * @param value reference of the value to protect. - * @param mtx reference to the mutex used to protect the value. - * @param tag of type try_to_lock_t used to differentiate the constructor. - * @requires If mutex_type is not a recursive mutex the calling thread does not own the mutex. - * @effects try to lock the mutex @c mtx, stores a reference to it and to the value type @c value. - */ - const_unique_lock_ptr(T const& val, Lockable & mtx, try_to_lock_t) BOOST_NOEXCEPT - : base_type(mtx, try_to_lock), value_(val) - { - } - /** - * Move constructor. - * @effects takes ownership of the mutex owned by @c other, stores a reference to the mutex and the value type of @c other. - */ - const_unique_lock_ptr(BOOST_THREAD_RV_REF(const_unique_lock_ptr) other) BOOST_NOEXCEPT - : base_type(boost::move(static_cast(other))), value_(BOOST_THREAD_RV(other).value_) - { - } - - /** - * @effects If owns calls unlock() on the owned mutex. - */ - ~const_unique_lock_ptr() - { - } - - /** - * @return a constant pointer to the protected value - */ - const T* operator->() const - { - BOOST_ASSERT (this->owns_lock()); - return &value_; - } - - /** - * @return a constant reference to the protected value - */ - const T& operator*() const - { - BOOST_ASSERT (this->owns_lock()); - return value_; - } - - }; - - /** - * unique lock providing a pointer access to the synchronized value type. - * - * @param T the value type. - * @param Lockable the mutex type protecting the value type. - */ - template - class unique_lock_ptr : public const_unique_lock_ptr - { - typedef const_unique_lock_ptr base_type; - public: - typedef T value_type; - typedef Lockable mutex_type; - - BOOST_THREAD_MOVABLE_ONLY(unique_lock_ptr) - - /** - * @param value reference of the value to protect. - * @param mtx reference to the mutex used to protect the value. - * @effects locks the mutex @c mtx, stores a reference to it and to the value type @c value. - */ - unique_lock_ptr(T & val, Lockable & mtx) - : base_type(val, mtx) - { - } - /** - * @param value reference of the value to protect. - * @param mtx reference to the mutex used to protect the value. - * @param tag of type adopt_lock_t used to differentiate the constructor. - * @effects stores a reference to it and to the value type @c value taking ownership. - */ - unique_lock_ptr(T & value, Lockable & mtx, adopt_lock_t) BOOST_NOEXCEPT - : base_type(value, mtx, adopt_lock) - { - } - /** - * @param value reference of the value to protect. - * @param mtx reference to the mutex used to protect the value. - * @param tag of type defer_lock_t used to differentiate the constructor. - * @effects stores a reference to it and to the value type @c value c. - */ - unique_lock_ptr(T & value, Lockable & mtx, defer_lock_t) BOOST_NOEXCEPT - : base_type(value, mtx, defer_lock) - { - } - /** - * @param value reference of the value to protect. - * @param mtx reference to the mutex used to protect the value. - * @param tag of type try_to_lock_t used to differentiate the constructor. - * @effects try to lock the mutex @c mtx, stores a reference to it and to the value type @c value. - */ - unique_lock_ptr(T & value, Lockable & mtx, try_to_lock_t) BOOST_NOEXCEPT - : base_type(value, mtx, try_to_lock) - { - } - /** - * Move constructor. - * @effects takes ownership of the mutex owned by @c other, stores a reference to the mutex and the value type of @c other. - */ - unique_lock_ptr(BOOST_THREAD_RV_REF(unique_lock_ptr) other) BOOST_NOEXCEPT - : base_type(boost::move(static_cast(other))) - { - } - - ~unique_lock_ptr() - { - } - - /** - * @return a pointer to the protected value - */ - T* operator->() - { - BOOST_ASSERT (this->owns_lock()); - return const_cast(&this->value_); - } - - /** - * @return a reference to the protected value - */ - T& operator*() - { - BOOST_ASSERT (this->owns_lock()); - return const_cast(this->value_); - } - - - }; - - template - struct synchronized_value_unique_lock_ptr - { - typedef unique_lock_ptr type; - }; - - template - struct synchronized_value_unique_lock_ptr - { - typedef const_unique_lock_ptr type; - }; - /** - * cloaks a value type and the mutex used to protect it together. - * @param T the value type. - * @param Lockable the mutex type protecting the value type. - */ - template - class synchronized_value - { - -#if ! defined(BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS) -#if ! defined BOOST_NO_CXX11_VARIADIC_TEMPLATES - template - friend std::tuple::type ...> synchronize(SV& ...sv); -#else - template - friend std::tuple< - typename synchronized_value_strict_lock_ptr::type, - typename synchronized_value_strict_lock_ptr::type - > - synchronize(SV1& sv1, SV2& sv2); - template - friend std::tuple< - typename synchronized_value_strict_lock_ptr::type, - typename synchronized_value_strict_lock_ptr::type, - typename synchronized_value_strict_lock_ptr::type - > - synchronize(SV1& sv1, SV2& sv2, SV3& sv3); -#endif -#endif - - public: - typedef T value_type; - typedef Lockable mutex_type; - private: - T value_; - mutable mutex_type mtx_; - public: - // construction/destruction - /** - * Default constructor. - * - * @Requires: T is DefaultConstructible - */ - synchronized_value() - //BOOST_NOEXCEPT_IF(is_nothrow_default_constructible::value) - : value_() - { - } - - /** - * Constructor from copy constructible value. - * - * Requires: T is CopyConstructible - */ - synchronized_value(T const& other) - //BOOST_NOEXCEPT_IF(is_nothrow_copy_constructible::value) - : value_(other) - { - } - - /** - * Move Constructor. - * - * Requires: T is CopyMovable - */ - synchronized_value(BOOST_THREAD_RV_REF(T) other) - //BOOST_NOEXCEPT_IF(is_nothrow_move_constructible::value) - : value_(boost::move(other)) - { - } - - /** - * Constructor from value type. - * - * Requires: T is DefaultConstructible and Assignable - * Effects: Assigns the value on a scope protected by the mutex of the rhs. The mutex is not copied. - */ - synchronized_value(synchronized_value const& rhs) - { - strict_lock lk(rhs.mtx_); - value_ = rhs.value_; - } - - /** - * Move Constructor from movable value type - * - */ - synchronized_value(BOOST_THREAD_RV_REF(synchronized_value) other) - { - strict_lock lk(BOOST_THREAD_RV(other).mtx_); - value_= boost::move(BOOST_THREAD_RV(other).value_); - } - - // mutation - /** - * Assignment operator. - * - * Effects: Copies the underlying value on a scope protected by the two mutexes. - * The mutex is not copied. The locks are acquired using lock, so deadlock is avoided. - * For example, there is no problem if one thread assigns a = b and the other assigns b = a. - * - * Return: *this - */ - - synchronized_value& operator=(synchronized_value const& rhs) - { - if(&rhs != this) - { - // auto _ = make_unique_locks(mtx_, rhs.mtx_); - unique_lock lk1(mtx_, defer_lock); - unique_lock lk2(rhs.mtx_, defer_lock); - lock(lk1,lk2); - - value_ = rhs.value_; - } - return *this; - } - /** - * Assignment operator from a T const&. - * Effects: The operator copies the value on a scope protected by the mutex. - * Return: *this - */ - synchronized_value& operator=(value_type const& val) - { - { - strict_lock lk(mtx_); - value_ = val; - } - return *this; - } - - //observers - /** - * Explicit conversion to value type. - * - * Requires: T is CopyConstructible - * Return: A copy of the protected value obtained on a scope protected by the mutex. - * - */ - T get() const - { - strict_lock lk(mtx_); - return value_; - } - /** - * Explicit conversion to value type. - * - * Requires: T is CopyConstructible - * Return: A copy of the protected value obtained on a scope protected by the mutex. - * - */ -#if ! defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) - explicit operator T() const - { - return get(); - } -#endif - - /** - * value type getter. - * - * Return: A constant reference to the protected value. - * - * Note: Not thread safe - * - */ - T const& value() const - { - return value_; - } - /** - * mutex getter. - * - * Return: A constant reference to the protecting mutex. - * - * Note: Not thread safe - * - */ - mutex_type const& mutex() const - { - return mtx_; - } - /** - * Swap - * - * Effects: Swaps the data. Again, locks are acquired using lock(). The mutexes are not swapped. - * A swap method accepts a T& and swaps the data inside a critical section. - * This is by far the preferred method of changing the guarded datum wholesale because it keeps the lock only - * for a short time, thus lowering the pressure on the mutex. - */ - void swap(synchronized_value & rhs) - { - if (this == &rhs) { - return; - } - // auto _ = make_unique_locks(mtx_, rhs.mtx_); - unique_lock lk1(mtx_, defer_lock); - unique_lock lk2(rhs.mtx_, defer_lock); - lock(lk1,lk2); - boost::swap(value_, rhs.value_); - } - /** - * Swap with the underlying value type - * - * Effects: Swaps the data on a scope protected by the mutex. - */ - void swap(value_type & rhs) - { - strict_lock lk(mtx_); - boost::swap(value_, rhs); - } - - /** - * Essentially calling a method obj->foo(x, y, z) calls the method foo(x, y, z) inside a critical section as - * long-lived as the call itself. - */ - strict_lock_ptr operator->() - { - return BOOST_THREAD_MAKE_RV_REF((strict_lock_ptr(value_, mtx_))); - } - /** - * If the synchronized_value object involved is const-qualified, then you'll only be able to call const methods - * through operator->. So, for example, vec->push_back("xyz") won't work if vec were const-qualified. - * The locking mechanism capitalizes on the assumption that const methods don't modify their underlying data. - */ - const_strict_lock_ptr operator->() const - { - return BOOST_THREAD_MAKE_RV_REF((const_strict_lock_ptr(value_, mtx_))); - } - - /** - * Call function on a locked block. - * - * @requires fct(value_) is well formed. - * - * Example - * void fun(synchronized_value> & v) { - * v ( [](vector> & vec) - * { - * vec.push_back(42); - * assert(vec.back() == 42); - * } ); - * } - */ - template - inline - typename boost::result_of::type - operator()(BOOST_THREAD_RV_REF(F) fct) - { - strict_lock lk(mtx_); - return fct(value_); - } - template - inline - typename boost::result_of::type - operator()(BOOST_THREAD_RV_REF(F) fct) const - { - strict_lock lk(mtx_); - return fct(value_); - } - - -#if defined BOOST_NO_CXX11_RVALUE_REFERENCES - template - inline - typename boost::result_of::type - operator()(F const & fct) - { - strict_lock lk(mtx_); - return fct(value_); - } - template - inline - typename boost::result_of::type - operator()(F const & fct) const - { - strict_lock lk(mtx_); - return fct(value_); - } - - template - inline - R operator()(R(*fct)(value_type&)) - { - strict_lock lk(mtx_); - return fct(value_); - } - template - inline - R operator()(R(*fct)(value_type const&)) const - { - strict_lock lk(mtx_); - return fct(value_); - } -#endif - - - /** - * The synchronize() factory make easier to lock on a scope. - * As discussed, operator-> can only lock over the duration of a call, so it is insufficient for complex operations. - * With synchronize() you get to lock the object in a scoped and to directly access the object inside that scope. - * - * Example - * void fun(synchronized_value> & v) { - * auto&& vec=v.synchronize(); - * vec.push_back(42); - * assert(vec.back() == 42); - * } - */ - strict_lock_ptr synchronize() - { - return BOOST_THREAD_MAKE_RV_REF((strict_lock_ptr(value_, mtx_))); - } - const_strict_lock_ptr synchronize() const - { - return BOOST_THREAD_MAKE_RV_REF((const_strict_lock_ptr(value_, mtx_))); - } - - unique_lock_ptr unique_synchronize() - { - return BOOST_THREAD_MAKE_RV_REF((unique_lock_ptr(value_, mtx_))); - } - const_unique_lock_ptr unique_synchronize() const - { - return BOOST_THREAD_MAKE_RV_REF((const_unique_lock_ptr(value_, mtx_))); - } - unique_lock_ptr unique_synchronize(defer_lock_t tag) - { - return BOOST_THREAD_MAKE_RV_REF((unique_lock_ptr(value_, mtx_, tag))); - } - const_unique_lock_ptr unique_synchronize(defer_lock_t tag) const - { - return BOOST_THREAD_MAKE_RV_REF((const_unique_lock_ptr(value_, mtx_, tag))); - } - unique_lock_ptr defer_synchronize() BOOST_NOEXCEPT - { - return BOOST_THREAD_MAKE_RV_REF((unique_lock_ptr(value_, mtx_, defer_lock))); - } - const_unique_lock_ptr defer_synchronize() const BOOST_NOEXCEPT - { - return BOOST_THREAD_MAKE_RV_REF((const_unique_lock_ptr(value_, mtx_, defer_lock))); - } - unique_lock_ptr try_to_synchronize() BOOST_NOEXCEPT - { - return BOOST_THREAD_MAKE_RV_REF((unique_lock_ptr(value_, mtx_, try_to_lock))); - } - const_unique_lock_ptr try_to_synchronize() const BOOST_NOEXCEPT - { - return BOOST_THREAD_MAKE_RV_REF((const_unique_lock_ptr(value_, mtx_, try_to_lock))); - } - unique_lock_ptr adopt_synchronize() BOOST_NOEXCEPT - { - return BOOST_THREAD_MAKE_RV_REF((unique_lock_ptr(value_, mtx_, adopt_lock))); - } - const_unique_lock_ptr adopt_synchronize() const BOOST_NOEXCEPT - { - return BOOST_THREAD_MAKE_RV_REF((const_unique_lock_ptr(value_, mtx_, adopt_lock))); - } - - -#if ! defined __IBMCPP__ - private: -#endif - class deref_value - { - private: - friend class synchronized_value; - - boost::unique_lock lk_; - T& value_; - - explicit deref_value(synchronized_value& outer): - lk_(outer.mtx_),value_(outer.value_) - {} - - public: - BOOST_THREAD_MOVABLE_ONLY(deref_value) - - deref_value(BOOST_THREAD_RV_REF(deref_value) other): - lk_(boost::move(BOOST_THREAD_RV(other).lk_)),value_(BOOST_THREAD_RV(other).value_) - {} - operator T&() - { - return value_; - } - - deref_value& operator=(T const& newVal) - { - value_=newVal; - return *this; - } - }; - class const_deref_value - { - private: - friend class synchronized_value; - - boost::unique_lock lk_; - const T& value_; - - explicit const_deref_value(synchronized_value const& outer): - lk_(outer.mtx_), value_(outer.value_) - {} - - public: - BOOST_THREAD_MOVABLE_ONLY(const_deref_value) - - const_deref_value(BOOST_THREAD_RV_REF(const_deref_value) other): - lk_(boost::move(BOOST_THREAD_RV(other).lk_)), value_(BOOST_THREAD_RV(other).value_) - {} - - operator const T&() - { - return value_; - } - }; - - public: - deref_value operator*() - { - return BOOST_THREAD_MAKE_RV_REF(deref_value(*this)); - } - - const_deref_value operator*() const - { - return BOOST_THREAD_MAKE_RV_REF(const_deref_value(*this)); - } - - // io functions - /** - * @requires T is OutputStreamable - * @effects saves the value type on the output stream @c os. - */ - template - void save(OStream& os) const - { - strict_lock lk(mtx_); - os << value_; - } - /** - * @requires T is InputStreamable - * @effects loads the value type from the input stream @c is. - */ - template - void load(IStream& is) const - { - strict_lock lk(mtx_); - is >> value_; - } - - // relational operators - /** - * @requires T is EqualityComparable - * - */ - bool operator==(synchronized_value const& rhs) const - { - unique_lock lk1(mtx_, defer_lock); - unique_lock lk2(rhs.mtx_, defer_lock); - lock(lk1,lk2); - - return value_ == rhs.value_; - } - /** - * @requires T is LessThanComparable - * - */ - bool operator<(synchronized_value const& rhs) const - { - unique_lock lk1(mtx_, defer_lock); - unique_lock lk2(rhs.mtx_, defer_lock); - lock(lk1,lk2); - - return value_ < rhs.value_; - } - /** - * @requires T is GreaterThanComparable - * - */ - bool operator>(synchronized_value const& rhs) const - { - unique_lock lk1(mtx_, defer_lock); - unique_lock lk2(rhs.mtx_, defer_lock); - lock(lk1,lk2); - - return value_ > rhs.value_; - } - bool operator<=(synchronized_value const& rhs) const - { - unique_lock lk1(mtx_, defer_lock); - unique_lock lk2(rhs.mtx_, defer_lock); - lock(lk1,lk2); - - return value_ <= rhs.value_; - } - bool operator>=(synchronized_value const& rhs) const - { - unique_lock lk1(mtx_, defer_lock); - unique_lock lk2(rhs.mtx_, defer_lock); - lock(lk1,lk2); - - return value_ >= rhs.value_; - } - bool operator==(value_type const& rhs) const - { - unique_lock lk1(mtx_); - - return value_ == rhs; - } - bool operator!=(value_type const& rhs) const - { - unique_lock lk1(mtx_); - - return value_ != rhs; - } - bool operator<(value_type const& rhs) const - { - unique_lock lk1(mtx_); - - return value_ < rhs; - } - bool operator<=(value_type const& rhs) const - { - unique_lock lk1(mtx_); - - return value_ <= rhs; - } - bool operator>(value_type const& rhs) const - { - unique_lock lk1(mtx_); - - return value_ > rhs; - } - bool operator>=(value_type const& rhs) const - { - unique_lock lk1(mtx_); - - return value_ >= rhs; - } - - }; - - // Specialized algorithms - /** - * - */ - template - inline void swap(synchronized_value & lhs, synchronized_value & rhs) - { - lhs.swap(rhs); - } - template - inline void swap(synchronized_value & lhs, T & rhs) - { - lhs.swap(rhs); - } - template - inline void swap(T & lhs, synchronized_value & rhs) - { - rhs.swap(lhs); - } - - //Hash support - -// template struct hash; -// template -// struct hash >; - - // Comparison with T - template - bool operator!=(synchronized_value const&lhs, synchronized_value const& rhs) - { - return ! (lhs==rhs); - } - - template - bool operator==(T const& lhs, synchronized_value const&rhs) - { - return rhs==lhs; - } - template - bool operator!=(T const& lhs, synchronized_value const&rhs) - { - return rhs!=lhs; - } - template - bool operator<(T const& lhs, synchronized_value const&rhs) - { - return rhs>=lhs; - } - template - bool operator<=(T const& lhs, synchronized_value const&rhs) - { - return rhs>lhs; - } - template - bool operator>(T const& lhs, synchronized_value const&rhs) - { - return rhs<=lhs; - } - template - bool operator>=(T const& lhs, synchronized_value const&rhs) - { - return rhs - inline OStream& operator<<(OStream& os, synchronized_value const& rhs) - { - rhs.save(os); - return os; - } - template - inline IStream& operator>>(IStream& is, synchronized_value const& rhs) - { - rhs.load(is); - return is; - } - -#if ! defined(BOOST_THREAD_NO_SYNCHRONIZE) -#if ! defined BOOST_NO_CXX11_VARIADIC_TEMPLATES - - template - std::tuple::type ...> synchronize(SV& ...sv) - { - boost::lock(sv.mtx_ ...); - typedef std::tuple::type ...> t_type; - - return t_type(typename synchronized_value_strict_lock_ptr::type(sv.value_, sv.mtx_, adopt_lock) ...); - } -#else - - template - std::tuple< - typename synchronized_value_strict_lock_ptr::type, - typename synchronized_value_strict_lock_ptr::type - > - synchronize(SV1& sv1, SV2& sv2) - { - boost::lock(sv1.mtx_, sv2.mtx_); - typedef std::tuple< - typename synchronized_value_strict_lock_ptr::type, - typename synchronized_value_strict_lock_ptr::type - > t_type; - - return t_type( - typename synchronized_value_strict_lock_ptr::type(sv1.value_, sv1.mtx_, adopt_lock), - typename synchronized_value_strict_lock_ptr::type(sv2.value_, sv2.mtx_, adopt_lock) - ); - - } - template - std::tuple< - typename synchronized_value_strict_lock_ptr::type, - typename synchronized_value_strict_lock_ptr::type, - typename synchronized_value_strict_lock_ptr::type - > - synchronize(SV1& sv1, SV2& sv2, SV3& sv3) - { - boost::lock(sv1.mtx_, sv2.mtx_); - typedef std::tuple< - typename synchronized_value_strict_lock_ptr::type, - typename synchronized_value_strict_lock_ptr::type, - typename synchronized_value_strict_lock_ptr::type - > t_type; - - return t_type( - typename synchronized_value_strict_lock_ptr::type(sv1.value_, sv1.mtx_, adopt_lock), - typename synchronized_value_strict_lock_ptr::type(sv2.value_, sv2.mtx_, adopt_lock), - typename synchronized_value_strict_lock_ptr::type(sv3.value_, sv3.mtx_, adopt_lock) - ); - - } -#endif -#endif -} - -#include - -#endif // header diff --git a/libraries/boost/boost/thread/testable_mutex.hpp b/libraries/boost/boost/thread/testable_mutex.hpp deleted file mode 100644 index 3c87f9349..000000000 --- a/libraries/boost/boost/thread/testable_mutex.hpp +++ /dev/null @@ -1,152 +0,0 @@ -// (C) Copyright 2012 Vicente J. Botet Escriba -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -#ifndef BOOST_THREAD_TESTABLE_LOCKABLE_HPP -#define BOOST_THREAD_TESTABLE_LOCKABLE_HPP - -#include - -#include - -#include -#include - -#include - -namespace boost -{ - /** - * Based on Associate Mutexes with Data to Prevent Races, By Herb Sutter, May 13, 2010 - * http://www.drdobbs.com/windows/associate-mutexes-with-data-to-prevent-r/224701827?pgno=3 - * - * Make our mutex testable if it isn't already. - * - * Many mutex services (including boost::mutex) don't provide a way to ask, - * "Do I already hold a lock on this mutex?" - * Sometimes it is needed to know if a method like is_locked to be available. - * This wrapper associates an arbitrary lockable type with a thread id that stores the ID of the thread that - * currently holds the lockable. The thread id initially holds an invalid value that means no threads own the mutex. - * When we acquire a lock, we set the thread id; and when we release a lock, we reset it back to its default no id state. - * - */ - template - class testable_mutex - { - Lockable mtx_; - atomic id_; - public: - /// the type of the wrapped lockable - typedef Lockable lockable_type; - - /// Non copyable - BOOST_THREAD_NO_COPYABLE(testable_mutex) - - testable_mutex() : id_(thread::id()) {} - - void lock() - { - BOOST_ASSERT(! is_locked_by_this_thread()); - mtx_.lock(); - id_ = this_thread::get_id(); - } - - void unlock() - { - BOOST_ASSERT(is_locked_by_this_thread()); - id_ = thread::id(); - mtx_.unlock(); - } - - bool try_lock() - { - BOOST_ASSERT(! is_locked_by_this_thread()); - if (mtx_.try_lock()) - { - id_ = this_thread::get_id(); - return true; - } - else - { - return false; - } - } -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_for(const chrono::duration& rel_time) - { - BOOST_ASSERT(! is_locked_by_this_thread()); - if (mtx_.try_lock_for(rel_time)) - { - id_ = this_thread::get_id(); - return true; - } - else - { - return false; - } - } - template - bool try_lock_until(const chrono::time_point& abs_time) - { - BOOST_ASSERT(! is_locked_by_this_thread()); - if (mtx_.try_lock_until(abs_time)) - { - id_ = this_thread::get_id(); - return true; - } - else - { - return false; - } - } -#endif - - bool is_locked_by_this_thread() const - { - return this_thread::get_id() == id_; - } - bool is_locked() const - { - return ! (thread::id() == id_); - } - - thread::id get_id() const - { - return id_; - } - - // todo add the shared and upgrade mutex functions - }; - - template - struct is_testable_lockable : false_type - {}; - - template - struct is_testable_lockable > : true_type - {}; - -// /** -// * Overloaded function used to check if the mutex is locked when it is testable and do nothing otherwise. -// * -// * This function is used usually to assert the pre-condition when the function can only be called when the mutex -// * must be locked by the current thread. -// */ -// template -// bool is_locked_by_this_thread(testable_mutex const& mtx) -// { -// return mtx.is_locked(); -// } -// template -// bool is_locked_by_this_thread(Lockable const&) -// { -// return true; -// } -} - -#include - -#endif // header diff --git a/libraries/boost/boost/thread/thread.hpp b/libraries/boost/boost/thread/thread.hpp deleted file mode 100644 index 3e63b42aa..000000000 --- a/libraries/boost/boost/thread/thread.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef BOOST_THREAD_THREAD_HPP -#define BOOST_THREAD_THREAD_HPP - -// thread.hpp -// -// (C) Copyright 2007-8 Anthony Williams -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include - - -#endif diff --git a/libraries/boost/boost/thread/thread_functors.hpp b/libraries/boost/boost/thread/thread_functors.hpp deleted file mode 100644 index bba129f76..000000000 --- a/libraries/boost/boost/thread/thread_functors.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2009-2012 Anthony Williams -// (C) Copyright 2012 Vicente J. Botet Escriba - -// Based on the Anthony's idea of scoped_thread in CCiA - -#ifndef BOOST_THREAD_THREAD_FUNCTORS_HPP -#define BOOST_THREAD_THREAD_FUNCTORS_HPP - -#include -#include -#include -#include - -#include - -namespace boost -{ - - struct detach - { - void operator()(thread& t) - { - t.detach(); - } - }; - - struct join_if_joinable - { - void operator()(thread& t) - { - if (t.joinable()) - { - t.join(); - } - } - }; - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - struct interrupt_and_join_if_joinable - { - void operator()(thread& t) - { - if (t.joinable()) - { - t.interrupt(); - t.join(); - } - } - }; -#endif -} -#include - -#endif diff --git a/libraries/boost/boost/thread/thread_guard.hpp b/libraries/boost/boost/thread/thread_guard.hpp deleted file mode 100644 index 85157f101..000000000 --- a/libraries/boost/boost/thread/thread_guard.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2009-2012 Anthony Williams -// (C) Copyright 2012 Vicente J. Botet Escriba - -// Based on the Anthony's idea of thread_joiner in CCiA - -#ifndef BOOST_THREAD_THREAD_GUARD_HPP -#define BOOST_THREAD_THREAD_GUARD_HPP - -#include -#include -#include - -#include - -namespace boost -{ - - /** - * Non-copyable RAII scoped thread guard joiner which join the thread if joinable when destroyed. - */ - template - class thread_guard - { - thread& t_; - public: - BOOST_THREAD_NO_COPYABLE( thread_guard) - - explicit thread_guard(thread& t) : - t_(t) - { - } - ~thread_guard() - { - CallableThread on_destructor; - - on_destructor(t_); - } - }; - -} -#include - -#endif diff --git a/libraries/boost/boost/thread/thread_only.hpp b/libraries/boost/boost/thread/thread_only.hpp deleted file mode 100644 index 0d0c07061..000000000 --- a/libraries/boost/boost/thread/thread_only.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef BOOST_THREAD_THREAD_ONLY_HPP -#define BOOST_THREAD_THREAD_ONLY_HPP - -// thread.hpp -// -// (C) Copyright 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - -#if defined(BOOST_THREAD_PLATFORM_WIN32) -#include -#elif defined(BOOST_THREAD_PLATFORM_PTHREAD) -#include -#else -#error "Boost threads unavailable on this platform" -#endif - -#include -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS -#include -#endif -#include - - -#endif diff --git a/libraries/boost/boost/thread/thread_pool.hpp b/libraries/boost/boost/thread/thread_pool.hpp deleted file mode 100644 index 4d2dcbea3..000000000 --- a/libraries/boost/boost/thread/thread_pool.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/09 Vicente J. Botet Escriba -// Adapt to boost from CCIA C++11 implementation -// first implementation of a simple pool thread using a vector of threads and a sync_queue. - -#ifndef BOOST_THREAD_THREAD_POOL_HPP -#define BOOST_THREAD_THREAD_POOL_HPP - -#include - -#endif diff --git a/libraries/boost/boost/thread/thread_time.hpp b/libraries/boost/boost/thread/thread_time.hpp deleted file mode 100644 index ffdcf850f..000000000 --- a/libraries/boost/boost/thread/thread_time.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef BOOST_THREAD_TIME_HPP -#define BOOST_THREAD_TIME_HPP -// (C) Copyright 2007 Anthony Williams -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include - -namespace boost -{ - typedef boost::posix_time::ptime system_time; - - inline system_time get_system_time() - { -#if defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK) - return boost::date_time::microsec_clock::universal_time(); -#else // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK) - return boost::date_time::second_clock::universal_time(); -#endif // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK) - } - - namespace detail - { - inline system_time get_system_time_sentinel() - { - return system_time(boost::posix_time::pos_infin); - } - - inline unsigned long get_milliseconds_until(system_time const& target_time) - { - if(target_time.is_pos_infinity()) - { - return ~(unsigned long)0; - } - system_time const now=get_system_time(); - if(target_time<=now) - { - return 0; - } - return static_cast((target_time-now).total_milliseconds()+1); - } - - } - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/tss.hpp b/libraries/boost/boost/thread/tss.hpp deleted file mode 100644 index d798bef55..000000000 --- a/libraries/boost/boost/thread/tss.hpp +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef BOOST_THREAD_TSS_HPP -#define BOOST_THREAD_TSS_HPP -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007-8 Anthony Williams - -#include -#include -#include - -#include - -namespace boost -{ - namespace detail - { - struct tss_cleanup_function - { - virtual ~tss_cleanup_function() - {} - - virtual void operator()(void* data)=0; - }; - - BOOST_THREAD_DECL void set_tss_data(void const* key,boost::shared_ptr func,void* tss_data,bool cleanup_existing); - BOOST_THREAD_DECL void* get_tss_data(void const* key); - } - - template - class thread_specific_ptr - { - private: - thread_specific_ptr(thread_specific_ptr&); - thread_specific_ptr& operator=(thread_specific_ptr&); - - struct delete_data: - detail::tss_cleanup_function - { - void operator()(void* data) - { - delete static_cast(data); - } - }; - - struct run_custom_cleanup_function: - detail::tss_cleanup_function - { - void (*cleanup_function)(T*); - - explicit run_custom_cleanup_function(void (*cleanup_function_)(T*)): - cleanup_function(cleanup_function_) - {} - - void operator()(void* data) - { - cleanup_function(static_cast(data)); - } - }; - - - boost::shared_ptr cleanup; - - public: - typedef T element_type; - - thread_specific_ptr(): - cleanup(detail::heap_new(),detail::do_heap_delete()) - {} - explicit thread_specific_ptr(void (*func_)(T*)) - { - if(func_) - { - cleanup.reset(detail::heap_new(func_),detail::do_heap_delete()); - } - } - ~thread_specific_ptr() - { - detail::set_tss_data(this,boost::shared_ptr(),0,true); - } - - T* get() const - { - return static_cast(detail::get_tss_data(this)); - } - T* operator->() const - { - return get(); - } - typename boost::detail::sp_dereference< T >::type operator*() const - { - return *get(); - } - T* release() - { - T* const temp=get(); - detail::set_tss_data(this,boost::shared_ptr(),0,false); - return temp; - } - void reset(T* new_value=0) - { - T* const current_value=get(); - if(current_value!=new_value) - { - detail::set_tss_data(this,cleanup,new_value,true); - } - } - }; -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/user_scheduler.hpp b/libraries/boost/boost/thread/user_scheduler.hpp deleted file mode 100644 index c551d2171..000000000 --- a/libraries/boost/boost/thread/user_scheduler.hpp +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (C) 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// 2013/11 Vicente J. Botet Escriba -// first implementation of a simple serial scheduler. - -#ifndef BOOST_THREAD_USER_SCHEDULER_HPP -#define BOOST_THREAD_USER_SCHEDULER_HPP - -#include -#include -#include -#include -#include - -#include - -namespace boost -{ - - class user_scheduler - { - /// type-erasure to store the works to do - typedef thread_detail::work work; - - /// the thread safe work queue - sync_queue work_queue; - - public: - /** - * Effects: try to execute one task. - * Returns: whether a task has been executed. - * Throws: whatever the current task constructor throws or the task() throws. - */ - bool try_executing_one() - { - work task; - try - { - if (work_queue.try_pull(task) == queue_op_status::success) - { - task(); - return true; - } - return false; - } - catch (std::exception& ) - { - return false; - } - catch (...) - { - return false; - } - } - private: - /** - * Effects: schedule one task or yields - * Throws: whatever the current task constructor throws or the task() throws. - */ - void schedule_one_or_yield() - { - if ( ! try_executing_one()) - { - this_thread::yield(); - } - } - - - /** - * The main loop of the worker thread - */ - void worker_thread() - { - while (!closed()) - { - schedule_one_or_yield(); - } - while (try_executing_one()) - { - } - } - - public: - /// user_scheduler is not copyable. - BOOST_THREAD_NO_COPYABLE(user_scheduler) - - /** - * \b Effects: creates a thread pool that runs closures using one of its closure-executing methods. - * - * \b Throws: Whatever exception is thrown while initializing the needed resources. - */ - user_scheduler() - { - } - /** - * \b Effects: Destroys the thread pool. - * - * \b Synchronization: The completion of all the closures happen before the completion of the \c user_scheduler destructor. - */ - ~user_scheduler() - { - // signal to all the worker thread that there will be no more submissions. - close(); - } - - /** - * loop - */ - void loop() { worker_thread(); } - /** - * \b Effects: close the \c user_scheduler for submissions. - * The loop will work until there is no more closures to run. - */ - void close() - { - work_queue.close(); - } - - /** - * \b Returns: whether the pool is closed for submissions. - */ - bool closed() - { - return work_queue.closed(); - } - - /** - * \b Requires: \c Closure is a model of \c Callable(void()) and a model of \c CopyConstructible/MoveConstructible. - * - * \b Effects: The specified \c closure will be scheduled for execution at some point in the future. - * If invoked closure throws an exception the \c user_scheduler will call \c std::terminate, as is the case with threads. - * - * \b Synchronization: completion of \c closure on a particular thread happens before destruction of thread's thread local variables. - * - * \b Throws: \c sync_queue_is_closed if the thread pool is closed. - * Whatever exception that can be throw while storing the closure. - */ - -#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - template - void submit(Closure & closure) - { - work w ((closure)); - work_queue.push(boost::move(w)); - //work_queue.push(work(closure)); // todo check why this doesn't work - } -#endif - void submit(void (*closure)()) - { - work w ((closure)); - work_queue.push(boost::move(w)); - //work_queue.push(work(closure)); // todo check why this doesn't work - } - - template - void submit(BOOST_THREAD_RV_REF(Closure) closure) - { - work w =boost::move(closure); - work_queue.push(boost::move(w)); - //work_queue.push(work(boost::move(closure))); // todo check why this doesn't work - } - - /** - * \b Requires: This must be called from an scheduled task. - * - * \b Effects: reschedule functions until pred() - */ - template - bool reschedule_until(Pred const& pred) - { - do { - if ( ! try_executing_one()) - { - return false; - } - } while (! pred()); - return true; - } - /** - * run queued closures - */ - void run_queued_closures() - { - sync_queue::underlying_queue_type q = work_queue.underlying_queue(); - while (q.empty()) - { - work task = q.front(); - q.pop_front(); - task(); - } - } - - }; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/v2/shared_mutex.hpp b/libraries/boost/boost/thread/v2/shared_mutex.hpp deleted file mode 100644 index 5acab4d8c..000000000 --- a/libraries/boost/boost/thread/v2/shared_mutex.hpp +++ /dev/null @@ -1,1062 +0,0 @@ -#ifndef BOOST_THREAD_V2_SHARED_MUTEX_HPP -#define BOOST_THREAD_V2_SHARED_MUTEX_HPP - -// shared_mutex.hpp -// -// Copyright Howard Hinnant 2007-2010. -// Copyright Vicente J. Botet Escriba 2012. -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -/* - synopsis - -namespace boost -{ -namespace thread_v2 -{ - -class shared_mutex -{ -public: - - shared_mutex(); - ~shared_mutex(); - - shared_mutex(const shared_mutex&) = delete; - shared_mutex& operator=(const shared_mutex&) = delete; - - // Exclusive ownership - - void lock(); - bool try_lock(); - template - bool try_lock_for(const boost::chrono::duration& rel_time); - template - bool - try_lock_until( - const boost::chrono::time_point& abs_time); - void unlock(); - - // Shared ownership - - void lock_shared(); - bool try_lock_shared(); - template - bool - try_lock_shared_for(const boost::chrono::duration& rel_time); - template - bool - try_lock_shared_until( - const boost::chrono::time_point& abs_time); - void unlock_shared(); -}; - -class upgrade_mutex -{ -public: - - upgrade_mutex(); - ~upgrade_mutex(); - - upgrade_mutex(const upgrade_mutex&) = delete; - upgrade_mutex& operator=(const upgrade_mutex&) = delete; - - // Exclusive ownership - - void lock(); - bool try_lock(); - template - bool try_lock_for(const boost::chrono::duration& rel_time); - template - bool - try_lock_until( - const boost::chrono::time_point& abs_time); - void unlock(); - - // Shared ownership - - void lock_shared(); - bool try_lock_shared(); - template - bool - try_lock_shared_for(const boost::chrono::duration& rel_time); - template - bool - try_lock_shared_until( - const boost::chrono::time_point& abs_time); - void unlock_shared(); - - // Upgrade ownership - - void lock_upgrade(); - bool try_lock_upgrade(); - template - bool - try_lock_upgrade_for( - const boost::chrono::duration& rel_time); - template - bool - try_lock_upgrade_until( - const boost::chrono::time_point& abs_time); - void unlock_upgrade(); - - // Shared <-> Exclusive - - bool try_unlock_shared_and_lock(); - template - bool - try_unlock_shared_and_lock_for( - const boost::chrono::duration& rel_time); - template - bool - try_unlock_shared_and_lock_until( - const boost::chrono::time_point& abs_time); - void unlock_and_lock_shared(); - - // Shared <-> Upgrade - - bool try_unlock_shared_and_lock_upgrade(); - template - bool - try_unlock_shared_and_lock_upgrade_for( - const boost::chrono::duration& rel_time); - template - bool - try_unlock_shared_and_lock_upgrade_until( - const boost::chrono::time_point& abs_time); - void unlock_upgrade_and_lock_shared(); - - // Upgrade <-> Exclusive - - void unlock_upgrade_and_lock(); - bool try_unlock_upgrade_and_lock(); - template - bool - try_unlock_upgrade_and_lock_for( - const boost::chrono::duration& rel_time); - template - bool - try_unlock_upgrade_and_lock_until( - const boost::chrono::time_point& abs_time); - void unlock_and_lock_upgrade(); -}; - -} // thread_v2 -} // boost - - */ - -#include -#include -#include -#include -#include -#include -#include -#define BOOST_THREAD_INLINE inline - -namespace boost { - namespace thread_v2 { - - class shared_mutex - { - typedef ::boost::mutex mutex_t; - typedef ::boost::condition_variable cond_t; - typedef unsigned count_t; - - mutex_t mut_; - cond_t gate1_; - cond_t gate2_; - count_t state_; - - static const count_t write_entered_ = 1U << (sizeof(count_t)*CHAR_BIT - 1); - static const count_t n_readers_ = ~write_entered_; - - public: - BOOST_THREAD_INLINE shared_mutex(); - BOOST_THREAD_INLINE ~shared_mutex(); - -#ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS - shared_mutex(shared_mutex const&) = delete; - shared_mutex& operator=(shared_mutex const&) = delete; -#else // BOOST_NO_CXX11_DELETED_FUNCTIONS - private: - shared_mutex(shared_mutex const&); - shared_mutex& operator=(shared_mutex const&); - public: -#endif // BOOST_NO_CXX11_DELETED_FUNCTIONS - - // Exclusive ownership - - BOOST_THREAD_INLINE void lock(); - BOOST_THREAD_INLINE bool try_lock(); - template - bool try_lock_for(const boost::chrono::duration& rel_time) - { - return try_lock_until(boost::chrono::steady_clock::now() + rel_time); - } - template - bool - try_lock_until( - const boost::chrono::time_point& abs_time); - BOOST_THREAD_INLINE void unlock(); - - - // Shared ownership - - BOOST_THREAD_INLINE void lock_shared(); - BOOST_THREAD_INLINE bool try_lock_shared(); - template - bool - try_lock_shared_for(const boost::chrono::duration& rel_time) - { - return try_lock_shared_until(boost::chrono::steady_clock::now() + - rel_time); - } - template - bool - try_lock_shared_until( - const boost::chrono::time_point& abs_time); - BOOST_THREAD_INLINE void unlock_shared(); - -#if defined BOOST_THREAD_USES_DATETIME - bool timed_lock(system_time const& timeout); - template - bool timed_lock(TimeDuration const & relative_time) - { - return timed_lock(get_system_time()+relative_time); - } - bool timed_lock_shared(system_time const& timeout); - template - bool timed_lock_shared(TimeDuration const & relative_time) - { - return timed_lock_shared(get_system_time()+relative_time); - } -#endif - }; - - template - bool - shared_mutex::try_lock_until( - const boost::chrono::time_point& abs_time) - { - boost::unique_lock lk(mut_); - if (state_ & write_entered_) - { - while (true) - { - boost::cv_status status = gate1_.wait_until(lk, abs_time); - if ((state_ & write_entered_) == 0) - break; - if (status == boost::cv_status::timeout) - return false; - } - } - state_ |= write_entered_; - if (state_ & n_readers_) - { - while (true) - { - boost::cv_status status = gate2_.wait_until(lk, abs_time); - if ((state_ & n_readers_) == 0) - break; - if (status == boost::cv_status::timeout) - { - state_ &= ~write_entered_; - return false; - } - } - } - return true; - } - - template - bool - shared_mutex::try_lock_shared_until( - const boost::chrono::time_point& abs_time) - { - boost::unique_lock lk(mut_); - if ((state_ & write_entered_) || (state_ & n_readers_) == n_readers_) - { - while (true) - { - boost::cv_status status = gate1_.wait_until(lk, abs_time); - if ((state_ & write_entered_) == 0 && - (state_ & n_readers_) < n_readers_) - break; - if (status == boost::cv_status::timeout) - return false; - } - } - count_t num_readers = (state_ & n_readers_) + 1; - state_ &= ~n_readers_; - state_ |= num_readers; - return true; - } - -#if defined BOOST_THREAD_USES_DATETIME - bool shared_mutex::timed_lock(system_time const& abs_time) - { - boost::unique_lock lk(mut_); - if (state_ & write_entered_) - { - while (true) - { - bool status = gate1_.timed_wait(lk, abs_time); - if ((state_ & write_entered_) == 0) - break; - if (!status) - return false; - } - } - state_ |= write_entered_; - if (state_ & n_readers_) - { - while (true) - { - bool status = gate2_.timed_wait(lk, abs_time); - if ((state_ & n_readers_) == 0) - break; - if (!status) - { - state_ &= ~write_entered_; - return false; - } - } - } - return true; - } - bool shared_mutex::timed_lock_shared(system_time const& abs_time) - { - boost::unique_lock lk(mut_); - if (state_ & write_entered_) - { - while (true) - { - bool status = gate1_.timed_wait(lk, abs_time); - if ((state_ & write_entered_) == 0) - break; - if (!status ) - return false; - } - } - state_ |= write_entered_; - if (state_ & n_readers_) - { - while (true) - { - bool status = gate2_.timed_wait(lk, abs_time); - if ((state_ & n_readers_) == 0) - break; - if (!status) - { - state_ &= ~write_entered_; - return false; - } - } - } - return true; - } -#endif - class upgrade_mutex - { - typedef boost::mutex mutex_t; - typedef boost::condition_variable cond_t; - typedef unsigned count_t; - - mutex_t mut_; - cond_t gate1_; - cond_t gate2_; - count_t state_; - - static const unsigned write_entered_ = 1U << (sizeof(count_t)*CHAR_BIT - 1); - static const unsigned upgradable_entered_ = write_entered_ >> 1; - static const unsigned n_readers_ = ~(write_entered_ | upgradable_entered_); - - public: - - BOOST_THREAD_INLINE upgrade_mutex(); - BOOST_THREAD_INLINE ~upgrade_mutex(); - -#ifndef BOOST_CXX11_NO_DELETED_FUNCTIONS - upgrade_mutex(const upgrade_mutex&) = delete; - upgrade_mutex& operator=(const upgrade_mutex&) = delete; -#else // BOOST_CXX11_NO_DELETED_FUNCTIONS - private: - upgrade_mutex(const upgrade_mutex&); - upgrade_mutex& operator=(const upgrade_mutex&); - public: -#endif // BOOST_CXX11_NO_DELETED_FUNCTIONS - - // Exclusive ownership - - BOOST_THREAD_INLINE void lock(); - BOOST_THREAD_INLINE bool try_lock(); - template - bool try_lock_for(const boost::chrono::duration& rel_time) - { - return try_lock_until(boost::chrono::steady_clock::now() + rel_time); - } - template - bool - try_lock_until( - const boost::chrono::time_point& abs_time); - BOOST_THREAD_INLINE void unlock(); - - // Shared ownership - - BOOST_THREAD_INLINE void lock_shared(); - BOOST_THREAD_INLINE bool try_lock_shared(); - template - bool - try_lock_shared_for(const boost::chrono::duration& rel_time) - { - return try_lock_shared_until(boost::chrono::steady_clock::now() + - rel_time); - } - template - bool - try_lock_shared_until( - const boost::chrono::time_point& abs_time); - BOOST_THREAD_INLINE void unlock_shared(); - - // Upgrade ownership - - BOOST_THREAD_INLINE void lock_upgrade(); - BOOST_THREAD_INLINE bool try_lock_upgrade(); - template - bool - try_lock_upgrade_for( - const boost::chrono::duration& rel_time) - { - return try_lock_upgrade_until(boost::chrono::steady_clock::now() + - rel_time); - } - template - bool - try_lock_upgrade_until( - const boost::chrono::time_point& abs_time); - BOOST_THREAD_INLINE void unlock_upgrade(); - - // Shared <-> Exclusive - - BOOST_THREAD_INLINE bool try_unlock_shared_and_lock(); - template - bool - try_unlock_shared_and_lock_for( - const boost::chrono::duration& rel_time) - { - return try_unlock_shared_and_lock_until( - boost::chrono::steady_clock::now() + rel_time); - } - template - bool - try_unlock_shared_and_lock_until( - const boost::chrono::time_point& abs_time); - BOOST_THREAD_INLINE void unlock_and_lock_shared(); - - // Shared <-> Upgrade - - BOOST_THREAD_INLINE bool try_unlock_shared_and_lock_upgrade(); - template - bool - try_unlock_shared_and_lock_upgrade_for( - const boost::chrono::duration& rel_time) - { - return try_unlock_shared_and_lock_upgrade_until( - boost::chrono::steady_clock::now() + rel_time); - } - template - bool - try_unlock_shared_and_lock_upgrade_until( - const boost::chrono::time_point& abs_time); - BOOST_THREAD_INLINE void unlock_upgrade_and_lock_shared(); - - // Upgrade <-> Exclusive - - BOOST_THREAD_INLINE void unlock_upgrade_and_lock(); - BOOST_THREAD_INLINE bool try_unlock_upgrade_and_lock(); - template - bool - try_unlock_upgrade_and_lock_for( - const boost::chrono::duration& rel_time) - { - return try_unlock_upgrade_and_lock_until( - boost::chrono::steady_clock::now() + rel_time); - } - template - bool - try_unlock_upgrade_and_lock_until( - const boost::chrono::time_point& abs_time); - BOOST_THREAD_INLINE void unlock_and_lock_upgrade(); - -#if defined BOOST_THREAD_USES_DATETIME - inline bool timed_lock(system_time const& abs_time); - template - bool timed_lock(TimeDuration const & relative_time) - { - return timed_lock(get_system_time()+relative_time); - } - inline bool timed_lock_shared(system_time const& abs_time); - template - bool timed_lock_shared(TimeDuration const & relative_time) - { - return timed_lock_shared(get_system_time()+relative_time); - } - inline bool timed_lock_upgrade(system_time const& abs_time); - template - bool timed_lock_upgrade(TimeDuration const & relative_time) - { - return timed_lock_upgrade(get_system_time()+relative_time); - } -#endif - - }; - - template - bool - upgrade_mutex::try_lock_until( - const boost::chrono::time_point& abs_time) - { - boost::unique_lock lk(mut_); - if (state_ & (write_entered_ | upgradable_entered_)) - { - while (true) - { - boost::cv_status status = gate1_.wait_until(lk, abs_time); - if ((state_ & (write_entered_ | upgradable_entered_)) == 0) - break; - if (status == boost::cv_status::timeout) - return false; - } - } - state_ |= write_entered_; - if (state_ & n_readers_) - { - while (true) - { - boost::cv_status status = gate2_.wait_until(lk, abs_time); - if ((state_ & n_readers_) == 0) - break; - if (status == boost::cv_status::timeout) - { - state_ &= ~write_entered_; - return false; - } - } - } - return true; - } - - template - bool - upgrade_mutex::try_lock_shared_until( - const boost::chrono::time_point& abs_time) - { - boost::unique_lock lk(mut_); - if ((state_ & write_entered_) || (state_ & n_readers_) == n_readers_) - { - while (true) - { - boost::cv_status status = gate1_.wait_until(lk, abs_time); - if ((state_ & write_entered_) == 0 && - (state_ & n_readers_) < n_readers_) - break; - if (status == boost::cv_status::timeout) - return false; - } - } - count_t num_readers = (state_ & n_readers_) + 1; - state_ &= ~n_readers_; - state_ |= num_readers; - return true; - } - - template - bool - upgrade_mutex::try_lock_upgrade_until( - const boost::chrono::time_point& abs_time) - { - boost::unique_lock lk(mut_); - if ((state_ & (write_entered_ | upgradable_entered_)) || - (state_ & n_readers_) == n_readers_) - { - while (true) - { - boost::cv_status status = gate1_.wait_until(lk, abs_time); - if ((state_ & (write_entered_ | upgradable_entered_)) == 0 && - (state_ & n_readers_) < n_readers_) - break; - if (status == boost::cv_status::timeout) - return false; - } - } - count_t num_readers = (state_ & n_readers_) + 1; - state_ &= ~n_readers_; - state_ |= upgradable_entered_ | num_readers; - return true; - } - -#if defined BOOST_THREAD_USES_DATETIME - bool upgrade_mutex::timed_lock(system_time const& abs_time) - { - boost::unique_lock lk(mut_); - if (state_ & (write_entered_ | upgradable_entered_)) - { - while (true) - { - bool status = gate1_.timed_wait(lk, abs_time); - if ((state_ & (write_entered_ | upgradable_entered_)) == 0) - break; - if (!status) - return false; - } - } - state_ |= write_entered_; - if (state_ & n_readers_) - { - while (true) - { - bool status = gate2_.timed_wait(lk, abs_time); - if ((state_ & n_readers_) == 0) - break; - if (!status) - { - state_ &= ~write_entered_; - return false; - } - } - } - return true; - } - bool upgrade_mutex::timed_lock_shared(system_time const& abs_time) - { - boost::unique_lock lk(mut_); - if ((state_ & write_entered_) || (state_ & n_readers_) == n_readers_) - { - while (true) - { - bool status = gate1_.timed_wait(lk, abs_time); - if ((state_ & write_entered_) == 0 && - (state_ & n_readers_) < n_readers_) - break; - if (!status) - return false; - } - } - count_t num_readers = (state_ & n_readers_) + 1; - state_ &= ~n_readers_; - state_ |= num_readers; - return true; - } - bool upgrade_mutex::timed_lock_upgrade(system_time const& abs_time) - { - boost::unique_lock lk(mut_); - if ((state_ & (write_entered_ | upgradable_entered_)) || - (state_ & n_readers_) == n_readers_) - { - while (true) - { - bool status = gate1_.timed_wait(lk, abs_time); - if ((state_ & (write_entered_ | upgradable_entered_)) == 0 && - (state_ & n_readers_) < n_readers_) - break; - if (!status) - return false; - } - } - count_t num_readers = (state_ & n_readers_) + 1; - state_ &= ~n_readers_; - state_ |= upgradable_entered_ | num_readers; - return true; - } - -#endif - template - bool - upgrade_mutex::try_unlock_shared_and_lock_until( - const boost::chrono::time_point& abs_time) - { - boost::unique_lock lk(mut_); - if (state_ != 1) - { - while (true) - { - boost::cv_status status = gate2_.wait_until(lk, abs_time); - if (state_ == 1) - break; - if (status == boost::cv_status::timeout) - return false; - } - } - state_ = write_entered_; - return true; - } - - template - bool - upgrade_mutex::try_unlock_shared_and_lock_upgrade_until( - const boost::chrono::time_point& abs_time) - { - boost::unique_lock lk(mut_); - if ((state_ & (write_entered_ | upgradable_entered_)) != 0) - { - while (true) - { - boost::cv_status status = gate2_.wait_until(lk, abs_time); - if ((state_ & (write_entered_ | upgradable_entered_)) == 0) - break; - if (status == boost::cv_status::timeout) - return false; - } - } - state_ |= upgradable_entered_; - return true; - } - - template - bool - upgrade_mutex::try_unlock_upgrade_and_lock_until( - const boost::chrono::time_point& abs_time) - { - boost::unique_lock lk(mut_); - if ((state_ & n_readers_) != 1) - { - while (true) - { - boost::cv_status status = gate2_.wait_until(lk, abs_time); - if ((state_ & n_readers_) == 1) - break; - if (status == boost::cv_status::timeout) - return false; - } - } - state_ = write_entered_; - return true; - } - - ////// - // shared_mutex - - shared_mutex::shared_mutex() - : state_(0) - { - } - - shared_mutex::~shared_mutex() - { - boost::lock_guard _(mut_); - } - - // Exclusive ownership - - void - shared_mutex::lock() - { - boost::unique_lock lk(mut_); - while (state_ & write_entered_) - gate1_.wait(lk); - state_ |= write_entered_; - while (state_ & n_readers_) - gate2_.wait(lk); - } - - bool - shared_mutex::try_lock() - { - boost::unique_lock lk(mut_); - if (state_ == 0) - { - state_ = write_entered_; - return true; - } - return false; - } - - void - shared_mutex::unlock() - { - boost::lock_guard _(mut_); - state_ = 0; - gate1_.notify_all(); - } - - // Shared ownership - - void - shared_mutex::lock_shared() - { - boost::unique_lock lk(mut_); - while ((state_ & write_entered_) || (state_ & n_readers_) == n_readers_) - gate1_.wait(lk); - count_t num_readers = (state_ & n_readers_) + 1; - state_ &= ~n_readers_; - state_ |= num_readers; - } - - bool - shared_mutex::try_lock_shared() - { - boost::unique_lock lk(mut_); - count_t num_readers = state_ & n_readers_; - if (!(state_ & write_entered_) && num_readers != n_readers_) - { - ++num_readers; - state_ &= ~n_readers_; - state_ |= num_readers; - return true; - } - return false; - } - - void - shared_mutex::unlock_shared() - { - boost::lock_guard _(mut_); - count_t num_readers = (state_ & n_readers_) - 1; - state_ &= ~n_readers_; - state_ |= num_readers; - if (state_ & write_entered_) - { - if (num_readers == 0) - gate2_.notify_one(); - } - else - { - if (num_readers == n_readers_ - 1) - gate1_.notify_one(); - } - } - - // upgrade_mutex - - upgrade_mutex::upgrade_mutex() - : gate1_(), - gate2_(), - state_(0) - { - } - - upgrade_mutex::~upgrade_mutex() - { - boost::lock_guard _(mut_); - } - - // Exclusive ownership - - void - upgrade_mutex::lock() - { - boost::unique_lock lk(mut_); - while (state_ & (write_entered_ | upgradable_entered_)) - gate1_.wait(lk); - state_ |= write_entered_; - while (state_ & n_readers_) - gate2_.wait(lk); - } - - bool - upgrade_mutex::try_lock() - { - boost::unique_lock lk(mut_); - if (state_ == 0) - { - state_ = write_entered_; - return true; - } - return false; - } - - void - upgrade_mutex::unlock() - { - boost::lock_guard _(mut_); - state_ = 0; - gate1_.notify_all(); - } - - // Shared ownership - - void - upgrade_mutex::lock_shared() - { - boost::unique_lock lk(mut_); - while ((state_ & write_entered_) || (state_ & n_readers_) == n_readers_) - gate1_.wait(lk); - count_t num_readers = (state_ & n_readers_) + 1; - state_ &= ~n_readers_; - state_ |= num_readers; - } - - bool - upgrade_mutex::try_lock_shared() - { - boost::unique_lock lk(mut_); - count_t num_readers = state_ & n_readers_; - if (!(state_ & write_entered_) && num_readers != n_readers_) - { - ++num_readers; - state_ &= ~n_readers_; - state_ |= num_readers; - return true; - } - return false; - } - - void - upgrade_mutex::unlock_shared() - { - boost::lock_guard _(mut_); - count_t num_readers = (state_ & n_readers_) - 1; - state_ &= ~n_readers_; - state_ |= num_readers; - if (state_ & write_entered_) - { - if (num_readers == 0) - gate2_.notify_one(); - } - else - { - if (num_readers == n_readers_ - 1) - gate1_.notify_one(); - } - } - - // Upgrade ownership - - void - upgrade_mutex::lock_upgrade() - { - boost::unique_lock lk(mut_); - while ((state_ & (write_entered_ | upgradable_entered_)) || - (state_ & n_readers_) == n_readers_) - gate1_.wait(lk); - count_t num_readers = (state_ & n_readers_) + 1; - state_ &= ~n_readers_; - state_ |= upgradable_entered_ | num_readers; - } - - bool - upgrade_mutex::try_lock_upgrade() - { - boost::unique_lock lk(mut_); - count_t num_readers = state_ & n_readers_; - if (!(state_ & (write_entered_ | upgradable_entered_)) - && num_readers != n_readers_) - { - ++num_readers; - state_ &= ~n_readers_; - state_ |= upgradable_entered_ | num_readers; - return true; - } - return false; - } - - void - upgrade_mutex::unlock_upgrade() - { - { - boost::lock_guard _(mut_); - count_t num_readers = (state_ & n_readers_) - 1; - state_ &= ~(upgradable_entered_ | n_readers_); - state_ |= num_readers; - } - gate1_.notify_all(); - } - - // Shared <-> Exclusive - - bool - upgrade_mutex::try_unlock_shared_and_lock() - { - boost::unique_lock lk(mut_); - if (state_ == 1) - { - state_ = write_entered_; - return true; - } - return false; - } - - void - upgrade_mutex::unlock_and_lock_shared() - { - { - boost::lock_guard _(mut_); - state_ = 1; - } - gate1_.notify_all(); - } - - // Shared <-> Upgrade - - bool - upgrade_mutex::try_unlock_shared_and_lock_upgrade() - { - boost::unique_lock lk(mut_); - if (!(state_ & (write_entered_ | upgradable_entered_))) - { - state_ |= upgradable_entered_; - return true; - } - return false; - } - - void - upgrade_mutex::unlock_upgrade_and_lock_shared() - { - { - boost::lock_guard _(mut_); - state_ &= ~upgradable_entered_; - } - gate1_.notify_all(); - } - - // Upgrade <-> Exclusive - - void - upgrade_mutex::unlock_upgrade_and_lock() - { - boost::unique_lock lk(mut_); - count_t num_readers = (state_ & n_readers_) - 1; - state_ &= ~(upgradable_entered_ | n_readers_); - state_ |= write_entered_ | num_readers; - while (state_ & n_readers_) - gate2_.wait(lk); - } - - bool - upgrade_mutex::try_unlock_upgrade_and_lock() - { - boost::unique_lock lk(mut_); - if (state_ == (upgradable_entered_ | 1)) - { - state_ = write_entered_; - return true; - } - return false; - } - - void - upgrade_mutex::unlock_and_lock_upgrade() - { - { - boost::lock_guard _(mut_); - state_ = upgradable_entered_ | 1; - } - gate1_.notify_all(); - } - - } // thread_v2 -} // boost - -namespace boost { - //using thread_v2::shared_mutex; - using thread_v2::upgrade_mutex; - typedef thread_v2::upgrade_mutex shared_mutex; -} - -#endif diff --git a/libraries/boost/boost/thread/v2/thread.hpp b/libraries/boost/boost/thread/v2/thread.hpp deleted file mode 100644 index 53560610e..000000000 --- a/libraries/boost/boost/thread/v2/thread.hpp +++ /dev/null @@ -1,155 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2011 Vicente J. Botet Escriba - -#ifndef BOOST_THREAD_V2_THREAD_HPP -#define BOOST_THREAD_V2_THREAD_HPP - -#include -#ifdef BOOST_THREAD_USES_CHRONO -#include -#include -#endif -#include -#include - -namespace boost -{ - namespace this_thread - { - namespace no_interruption_point - { -#ifdef BOOST_THREAD_USES_CHRONO - - template - void sleep_until(const chrono::time_point& t) - { - using namespace chrono; - mutex mut; - condition_variable cv; - unique_lock lk(mut); - while (Clock::now() < t) - cv.wait_until(lk, t); - } - -#ifdef BOOST_THREAD_SLEEP_FOR_IS_STEADY - - template - void sleep_for(const chrono::duration& d) - { - using namespace chrono; - if (d > duration::zero()) - { - duration Max = nanoseconds::max BOOST_PREVENT_MACRO_SUBSTITUTION (); - nanoseconds ns; - if (d < Max) - { - ns = duration_cast(d); - if (ns < d) - ++ns; - } - else - ns = nanoseconds:: max BOOST_PREVENT_MACRO_SUBSTITUTION (); - sleep_for(ns); - } - } - - template - inline BOOST_SYMBOL_VISIBLE - void sleep_until(const chrono::time_point& t) - { - using namespace chrono; - sleep_for(t - steady_clock::now()); - } -#else - template - void sleep_for(const chrono::duration& d) - { - using namespace chrono; - if (d > duration::zero()) - { - steady_clock::time_point c_timeout = steady_clock::now() + ceil(d); - sleep_until(c_timeout); - } - } - -#endif - -#endif - } -#ifdef BOOST_THREAD_USES_CHRONO - - template - void sleep_until(const chrono::time_point& t) - { - using namespace chrono; - mutex mut; - condition_variable cv; - unique_lock lk(mut); - while (Clock::now() < t) - cv.wait_until(lk, t); - } - -#if defined BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC && defined BOOST_CHRONO_HAS_CLOCK_STEADY - template - void sleep_for(const chrono::duration& d) - { - using namespace chrono; - if (d > duration::zero()) - { - steady_clock::time_point c_timeout = steady_clock::now() + ceil(d); - sleep_until(c_timeout); - } - } - -#elif defined BOOST_THREAD_SLEEP_FOR_IS_STEADY - - template - void sleep_for(const chrono::duration& d) - { - using namespace chrono; - if (d > duration::zero()) - { - duration Max = nanoseconds::max BOOST_PREVENT_MACRO_SUBSTITUTION (); - nanoseconds ns; - if (d < Max) - { - ns = duration_cast(d); - if (ns < d) - ++ns; - } - else - ns = nanoseconds:: max BOOST_PREVENT_MACRO_SUBSTITUTION (); - sleep_for(ns); - } - } - - template - inline BOOST_SYMBOL_VISIBLE - void sleep_until(const chrono::time_point& t) - { - using namespace chrono; - sleep_for(t - steady_clock::now()); - } -#else - template - void sleep_for(const chrono::duration& d) - { - using namespace chrono; - if (d > duration::zero()) - { - //system_clock::time_point c_timeout = time_point_cast(system_clock::now() + ceil(d)); - system_clock::time_point c_timeout = system_clock::now() + ceil(d); - sleep_until(c_timeout); - } - } - -#endif - -#endif - } -} - - -#endif diff --git a/libraries/boost/boost/thread/win32/basic_recursive_mutex.hpp b/libraries/boost/boost/thread/win32/basic_recursive_mutex.hpp deleted file mode 100644 index cfdfa043a..000000000 --- a/libraries/boost/boost/thread/win32/basic_recursive_mutex.hpp +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef BOOST_BASIC_RECURSIVE_MUTEX_WIN32_HPP -#define BOOST_BASIC_RECURSIVE_MUTEX_WIN32_HPP - -// basic_recursive_mutex.hpp -// -// (C) Copyright 2006-8 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#ifdef BOOST_THREAD_USES_CHRONO -#include -#include -#endif - -#include - -namespace boost -{ - namespace detail - { - template - struct basic_recursive_mutex_impl - { - long recursion_count; - long locking_thread_id; - underlying_mutex_type mutex; - - void initialize() - { - recursion_count=0; - locking_thread_id=0; - mutex.initialize(); - } - - void destroy() - { - mutex.destroy(); - } - - bool try_lock() BOOST_NOEXCEPT - { - long const current_thread_id=win32::GetCurrentThreadId(); - return try_recursive_lock(current_thread_id) || try_basic_lock(current_thread_id); - } - - void lock() - { - long const current_thread_id=win32::GetCurrentThreadId(); - if(!try_recursive_lock(current_thread_id)) - { - mutex.lock(); - BOOST_INTERLOCKED_EXCHANGE(&locking_thread_id,current_thread_id); - recursion_count=1; - } - } -#if defined BOOST_THREAD_USES_DATETIME - bool timed_lock(::boost::system_time const& target) - { - long const current_thread_id=win32::GetCurrentThreadId(); - return try_recursive_lock(current_thread_id) || try_timed_lock(current_thread_id,target); - } - template - bool timed_lock(Duration const& timeout) - { - return timed_lock(get_system_time()+timeout); - } -#endif - -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_for(const chrono::duration& rel_time) - { - long const current_thread_id=win32::GetCurrentThreadId(); - return try_recursive_lock(current_thread_id) || try_timed_lock_for(current_thread_id,rel_time); - } - template - bool try_lock_until(const chrono::time_point& t) - { - long const current_thread_id=win32::GetCurrentThreadId(); - return try_recursive_lock(current_thread_id) || try_timed_lock_until(current_thread_id,t); - } -#endif - void unlock() - { - if(!--recursion_count) - { - BOOST_INTERLOCKED_EXCHANGE(&locking_thread_id,0); - mutex.unlock(); - } - } - - private: - bool try_recursive_lock(long current_thread_id) BOOST_NOEXCEPT - { - if(::boost::detail::interlocked_read_acquire(&locking_thread_id)==current_thread_id) - { - ++recursion_count; - return true; - } - return false; - } - - bool try_basic_lock(long current_thread_id) BOOST_NOEXCEPT - { - if(mutex.try_lock()) - { - BOOST_INTERLOCKED_EXCHANGE(&locking_thread_id,current_thread_id); - recursion_count=1; - return true; - } - return false; - } - -#if defined BOOST_THREAD_USES_DATETIME - bool try_timed_lock(long current_thread_id,::boost::system_time const& target) - { - if(mutex.timed_lock(target)) - { - BOOST_INTERLOCKED_EXCHANGE(&locking_thread_id,current_thread_id); - recursion_count=1; - return true; - } - return false; - } -#endif - template - bool try_timed_lock_until(long current_thread_id,TP const& target) - { - if(mutex.try_lock_until(target)) - { - BOOST_INTERLOCKED_EXCHANGE(&locking_thread_id,current_thread_id); - recursion_count=1; - return true; - } - return false; - } - template - bool try_timed_lock_for(long current_thread_id,D const& target) - { - if(mutex.try_lock_for(target)) - { - BOOST_INTERLOCKED_EXCHANGE(&locking_thread_id,current_thread_id); - recursion_count=1; - return true; - } - return false; - } - }; - - typedef basic_recursive_mutex_impl basic_recursive_mutex; - typedef basic_recursive_mutex_impl basic_recursive_timed_mutex; - } -} - -#define BOOST_BASIC_RECURSIVE_MUTEX_INITIALIZER {0} - -#include - -#endif diff --git a/libraries/boost/boost/thread/win32/basic_timed_mutex.hpp b/libraries/boost/boost/thread/win32/basic_timed_mutex.hpp deleted file mode 100644 index d20c6589e..000000000 --- a/libraries/boost/boost/thread/win32/basic_timed_mutex.hpp +++ /dev/null @@ -1,279 +0,0 @@ -#ifndef BOOST_BASIC_TIMED_MUTEX_WIN32_HPP -#define BOOST_BASIC_TIMED_MUTEX_WIN32_HPP - -// basic_timed_mutex_win32.hpp -// -// (C) Copyright 2006-8 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include -#include -#if defined BOOST_THREAD_USES_DATETIME -#include -#endif -#include -#ifdef BOOST_THREAD_USES_CHRONO -#include -#include -#endif -#include - -namespace boost -{ - namespace detail - { - struct basic_timed_mutex - { - BOOST_STATIC_CONSTANT(unsigned char,lock_flag_bit=31); - BOOST_STATIC_CONSTANT(unsigned char,event_set_flag_bit=30); - BOOST_STATIC_CONSTANT(long,lock_flag_value=1< - bool timed_lock(Duration const& timeout) - { - return timed_lock(get_system_time()+timeout); - } - - bool timed_lock(boost::xtime const& timeout) - { - return timed_lock(system_time(timeout)); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_for(const chrono::duration& rel_time) - { - return try_lock_until(chrono::steady_clock::now() + rel_time); - } - template - bool try_lock_until(const chrono::time_point& t) - { - using namespace chrono; - system_clock::time_point s_now = system_clock::now(); - typename Clock::time_point c_now = Clock::now(); - return try_lock_until(s_now + ceil(t - c_now)); - } - template - bool try_lock_until(const chrono::time_point& t) - { - using namespace chrono; - typedef time_point sys_tmpt; - return try_lock_until(sys_tmpt(chrono::ceil(t.time_since_epoch()))); - } - bool try_lock_until(const chrono::time_point& tp) - { - if(try_lock()) - { - return true; - } - long old_count=active_count; - mark_waiting_and_try_lock(old_count); - - if(old_count&lock_flag_value) - { - bool lock_acquired=false; - void* const sem=get_event(); - - do - { - chrono::time_point now = chrono::system_clock::now(); - if (tp<=now) { - BOOST_INTERLOCKED_DECREMENT(&active_count); - return false; - } - chrono::milliseconds rel_time= chrono::ceil(tp-now); - - if(win32::WaitForSingleObjectEx(sem,static_cast(rel_time.count()),0)!=0) - { - BOOST_INTERLOCKED_DECREMENT(&active_count); - return false; - } - clear_waiting_and_try_lock(old_count); - lock_acquired=!(old_count&lock_flag_value); - } - while(!lock_acquired); - } - return true; - } -#endif - - void unlock() - { - long const offset=lock_flag_value; - long const old_count=BOOST_INTERLOCKED_EXCHANGE_ADD(&active_count,lock_flag_value); - if(!(old_count&event_set_flag_value) && (old_count>offset)) - { - if(!win32::interlocked_bit_test_and_set(&active_count,event_set_flag_bit)) - { - win32::SetEvent(get_event()); - } - } - } - - private: - void* get_event() - { - void* current_event=::boost::detail::interlocked_read_acquire(&event); - - if(!current_event) - { - void* const new_event=win32::create_anonymous_event(win32::auto_reset_event,win32::event_initially_reset); -#ifdef BOOST_MSVC -#pragma warning(push) -#pragma warning(disable:4311) -#pragma warning(disable:4312) -#endif - void* const old_event=BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&event,new_event,0); -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif - if(old_event!=0) - { - win32::CloseHandle(new_event); - return old_event; - } - else - { - return new_event; - } - } - return current_event; - } - - }; - - } -} - -#define BOOST_BASIC_TIMED_MUTEX_INITIALIZER {0} - -#include - -#endif diff --git a/libraries/boost/boost/thread/win32/condition_variable.hpp b/libraries/boost/boost/thread/win32/condition_variable.hpp deleted file mode 100644 index 23e9e4448..000000000 --- a/libraries/boost/boost/thread/win32/condition_variable.hpp +++ /dev/null @@ -1,567 +0,0 @@ -#ifndef BOOST_THREAD_CONDITION_VARIABLE_WIN32_HPP -#define BOOST_THREAD_CONDITION_VARIABLE_WIN32_HPP -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007-8 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - -#include -#include -#include -#include -#include -#if defined BOOST_THREAD_USES_DATETIME -#include -#endif -#include -#include -#include -#include - -#include -#include - -#ifdef BOOST_THREAD_USES_CHRONO -#include -#include -#endif - -#include -#include -#include - -#include - -namespace boost -{ - namespace detail - { - class basic_cv_list_entry; - void intrusive_ptr_add_ref(basic_cv_list_entry * p); - void intrusive_ptr_release(basic_cv_list_entry * p); - - class basic_cv_list_entry - { - private: - detail::win32::handle_manager semaphore; - detail::win32::handle_manager wake_sem; - long waiters; - bool notified; - long references; - - public: - BOOST_THREAD_NO_COPYABLE(basic_cv_list_entry) - explicit basic_cv_list_entry(detail::win32::handle_manager const& wake_sem_): - semaphore(detail::win32::create_anonymous_semaphore(0,LONG_MAX)), - wake_sem(wake_sem_.duplicate()), - waiters(1),notified(false),references(0) - {} - - static bool no_waiters(boost::intrusive_ptr const& entry) - { - return !detail::interlocked_read_acquire(&entry->waiters); - } - - void add_waiter() - { - BOOST_INTERLOCKED_INCREMENT(&waiters); - } - - void remove_waiter() - { - BOOST_INTERLOCKED_DECREMENT(&waiters); - } - - void release(unsigned count_to_release) - { - notified=true; - detail::win32::ReleaseSemaphore(semaphore,count_to_release,0); - } - - void release_waiters() - { - release(detail::interlocked_read_acquire(&waiters)); - } - - bool is_notified() const - { - return notified; - } - - bool wait(timeout abs_time) - { - return this_thread::interruptible_wait(semaphore,abs_time); - } - - bool woken() - { - unsigned long const woken_result=detail::win32::WaitForSingleObjectEx(wake_sem,0,0); - BOOST_ASSERT((woken_result==detail::win32::timeout) || (woken_result==0)); - return woken_result==0; - } - - friend void intrusive_ptr_add_ref(basic_cv_list_entry * p); - friend void intrusive_ptr_release(basic_cv_list_entry * p); - }; - - inline void intrusive_ptr_add_ref(basic_cv_list_entry * p) - { - BOOST_INTERLOCKED_INCREMENT(&p->references); - } - - inline void intrusive_ptr_release(basic_cv_list_entry * p) - { - if(!BOOST_INTERLOCKED_DECREMENT(&p->references)) - { - delete p; - } - } - - class basic_condition_variable - { - boost::mutex internal_mutex; - long total_count; - unsigned active_generation_count; - - typedef basic_cv_list_entry list_entry; - - typedef boost::intrusive_ptr entry_ptr; - typedef std::vector generation_list; - - generation_list generations; - detail::win32::handle_manager wake_sem; - - void wake_waiters(long count_to_wake) - { - detail::interlocked_write_release(&total_count,total_count-count_to_wake); - detail::win32::ReleaseSemaphore(wake_sem,count_to_wake,0); - } - - template - struct relocker - { - BOOST_THREAD_NO_COPYABLE(relocker) - lock_type& lock; - bool unlocked; - - relocker(lock_type& lock_): - lock(lock_),unlocked(false) - {} - void unlock() - { - lock.unlock(); - unlocked=true; - } - ~relocker() - { - if(unlocked) - { - lock.lock(); - } - - } - }; - - - entry_ptr get_wait_entry() - { - boost::lock_guard internal_lock(internal_mutex); - - if(!wake_sem) - { - wake_sem=detail::win32::create_anonymous_semaphore(0,LONG_MAX); - BOOST_ASSERT(wake_sem); - } - - detail::interlocked_write_release(&total_count,total_count+1); - if(generations.empty() || generations.back()->is_notified()) - { - entry_ptr new_entry(new list_entry(wake_sem)); - generations.push_back(new_entry); - return new_entry; - } - else - { - generations.back()->add_waiter(); - return generations.back(); - } - } - - struct entry_manager - { - entry_ptr const entry; - boost::mutex& internal_mutex; - - BOOST_THREAD_NO_COPYABLE(entry_manager) - entry_manager(entry_ptr const& entry_, boost::mutex& mutex_): - entry(entry_), internal_mutex(mutex_) - {} - - ~entry_manager() - { - boost::lock_guard internal_lock(internal_mutex); - entry->remove_waiter(); - } - - list_entry* operator->() - { - return entry.get(); - } - }; - - - protected: - template - bool do_wait(lock_type& lock,timeout abs_time) - { - relocker locker(lock); - - entry_manager entry(get_wait_entry(), internal_mutex); - - locker.unlock(); - - bool woken=false; - while(!woken) - { - if(!entry->wait(abs_time)) - { - return false; - } - - woken=entry->woken(); - } - return woken; - } - - template - bool do_wait(lock_type& m,timeout const& abs_time,predicate_type pred) - { - while (!pred()) - { - if(!do_wait(m, abs_time)) - return pred(); - } - return true; - } - - basic_condition_variable(const basic_condition_variable& other); - basic_condition_variable& operator=(const basic_condition_variable& other); - - public: - basic_condition_variable(): - total_count(0),active_generation_count(0),wake_sem(0) - {} - - ~basic_condition_variable() - {} - - void notify_one() BOOST_NOEXCEPT - { - if(detail::interlocked_read_acquire(&total_count)) - { - boost::lock_guard internal_lock(internal_mutex); - if(!total_count) - { - return; - } - wake_waiters(1); - - for(generation_list::iterator it=generations.begin(), - end=generations.end(); - it!=end;++it) - { - (*it)->release(1); - } - generations.erase(std::remove_if(generations.begin(),generations.end(),&basic_cv_list_entry::no_waiters),generations.end()); - } - } - - void notify_all() BOOST_NOEXCEPT - { - if(detail::interlocked_read_acquire(&total_count)) - { - boost::lock_guard internal_lock(internal_mutex); - if(!total_count) - { - return; - } - wake_waiters(total_count); - for(generation_list::iterator it=generations.begin(), - end=generations.end(); - it!=end;++it) - { - (*it)->release_waiters(); - } - generations.clear(); - wake_sem=detail::win32::handle(0); - } - } - - }; - } - - class condition_variable: - private detail::basic_condition_variable - { - public: - BOOST_THREAD_NO_COPYABLE(condition_variable) - condition_variable() - {} - - using detail::basic_condition_variable::notify_one; - using detail::basic_condition_variable::notify_all; - - void wait(unique_lock& m) - { - do_wait(m,detail::timeout::sentinel()); - } - - template - void wait(unique_lock& m,predicate_type pred) - { - while(!pred()) wait(m); - } - - -#if defined BOOST_THREAD_USES_DATETIME - bool timed_wait(unique_lock& m,boost::system_time const& abs_time) - { - return do_wait(m,abs_time); - } - - bool timed_wait(unique_lock& m,boost::xtime const& abs_time) - { - return do_wait(m,system_time(abs_time)); - } - template - bool timed_wait(unique_lock& m,duration_type const& wait_duration) - { - if (wait_duration.is_pos_infinity()) - { - wait(m); // or do_wait(m,detail::timeout::sentinel()); - return true; - } - if (wait_duration.is_special()) - { - return true; - } - return do_wait(m,wait_duration.total_milliseconds()); - } - - template - bool timed_wait(unique_lock& m,boost::system_time const& abs_time,predicate_type pred) - { - return do_wait(m,abs_time,pred); - } - template - bool timed_wait(unique_lock& m,boost::xtime const& abs_time,predicate_type pred) - { - return do_wait(m,system_time(abs_time),pred); - } - template - bool timed_wait(unique_lock& m,duration_type const& wait_duration,predicate_type pred) - { - if (wait_duration.is_pos_infinity()) - { - while (!pred()) - { - wait(m); // or do_wait(m,detail::timeout::sentinel()); - } - return true; - } - if (wait_duration.is_special()) - { - return pred(); - } - return do_wait(m,wait_duration.total_milliseconds(),pred); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - - template - cv_status - wait_until( - unique_lock& lock, - const chrono::time_point& t) - { - using namespace chrono; - chrono::time_point now = Clock::now(); - if (t<=now) { - return cv_status::timeout; - } - do_wait(lock, ceil(t-now).count()); - return Clock::now() < t ? cv_status::no_timeout : - cv_status::timeout; - } - - template - cv_status - wait_for( - unique_lock& lock, - const chrono::duration& d) - { - using namespace chrono; - if (d<=chrono::duration::zero()) { - return cv_status::timeout; - } - - steady_clock::time_point c_now = steady_clock::now(); - do_wait(lock, ceil(d).count()); - return steady_clock::now() - c_now < d ? cv_status::no_timeout : - cv_status::timeout; - } - - template - bool - wait_until( - unique_lock& lock, - const chrono::time_point& t, - Predicate pred) - { - while (!pred()) - { - if (wait_until(lock, t) == cv_status::timeout) - return pred(); - } - return true; - } - template - bool - wait_for( - unique_lock& lock, - const chrono::duration& d, - Predicate pred) - { - return wait_until(lock, chrono::steady_clock::now() + d, boost::move(pred)); - } -#endif - }; - - class condition_variable_any: - private detail::basic_condition_variable - { - public: - BOOST_THREAD_NO_COPYABLE(condition_variable_any) - condition_variable_any() - {} - - using detail::basic_condition_variable::notify_one; - using detail::basic_condition_variable::notify_all; - - template - void wait(lock_type& m) - { - do_wait(m,detail::timeout::sentinel()); - } - - template - void wait(lock_type& m,predicate_type pred) - { - while(!pred()) wait(m); - } - -#if defined BOOST_THREAD_USES_DATETIME - template - bool timed_wait(lock_type& m,boost::system_time const& abs_time) - { - return do_wait(m,abs_time); - } - - template - bool timed_wait(lock_type& m,boost::xtime const& abs_time) - { - return do_wait(m,system_time(abs_time)); - } - - template - bool timed_wait(lock_type& m,duration_type const& wait_duration) - { - return do_wait(m,wait_duration.total_milliseconds()); - } - - template - bool timed_wait(lock_type& m,boost::system_time const& abs_time,predicate_type pred) - { - return do_wait(m,abs_time,pred); - } - - template - bool timed_wait(lock_type& m,boost::xtime const& abs_time,predicate_type pred) - { - return do_wait(m,system_time(abs_time),pred); - } - - template - bool timed_wait(lock_type& m,duration_type const& wait_duration,predicate_type pred) - { - return do_wait(m,wait_duration.total_milliseconds(),pred); - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - - template - cv_status - wait_until( - lock_type& lock, - const chrono::time_point& t) - { - using namespace chrono; - chrono::time_point now = Clock::now(); - if (t<=now) { - return cv_status::timeout; - } - do_wait(lock, ceil(t-now).count()); - return Clock::now() < t ? cv_status::no_timeout : - cv_status::timeout; - } - - template - cv_status - wait_for( - lock_type& lock, - const chrono::duration& d) - { - using namespace chrono; - if (d<=chrono::duration::zero()) { - return cv_status::timeout; - } - steady_clock::time_point c_now = steady_clock::now(); - do_wait(lock, ceil(d).count()); - return steady_clock::now() - c_now < d ? cv_status::no_timeout : - cv_status::timeout; - } - - template - bool - wait_until( - lock_type& lock, - const chrono::time_point& t, - Predicate pred) - { - while (!pred()) - { - if (wait_until(lock, t) == cv_status::timeout) - return pred(); - } - return true; - } - - template - bool - wait_for( - lock_type& lock, - const chrono::duration& d, - Predicate pred) - { - return wait_until(lock, chrono::steady_clock::now() + d, boost::move(pred)); - } -#endif - }; - - BOOST_THREAD_DECL void notify_all_at_thread_exit(condition_variable& cond, unique_lock lk); -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/win32/interlocked_read.hpp b/libraries/boost/boost/thread/win32/interlocked_read.hpp deleted file mode 100644 index 2ad3fe901..000000000 --- a/libraries/boost/boost/thread/win32/interlocked_read.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef BOOST_THREAD_DETAIL_INTERLOCKED_READ_WIN32_HPP -#define BOOST_THREAD_DETAIL_INTERLOCKED_READ_WIN32_HPP - -// interlocked_read_win32.hpp -// -// (C) Copyright 2005-8 Anthony Williams -// (C) Copyright 2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include - -#include - -#ifdef BOOST_MSVC - -namespace boost -{ - namespace detail - { - // Since VS2005 volatile reads always acquire - inline long interlocked_read_acquire(long volatile* x) BOOST_NOEXCEPT - { - long const res=*x; - return res; - } - inline void* interlocked_read_acquire(void* volatile* x) BOOST_NOEXCEPT - { - void* const res=*x; - return res; - } - - // Since VS2005 volatile writes always release - inline void interlocked_write_release(long volatile* x,long value) BOOST_NOEXCEPT - { - *x=value; - } - inline void interlocked_write_release(void* volatile* x,void* value) BOOST_NOEXCEPT - { - *x=value; - } - } -} - -#else - -namespace boost -{ - namespace detail - { - inline long interlocked_read_acquire(long volatile* x) BOOST_NOEXCEPT - { - return BOOST_INTERLOCKED_COMPARE_EXCHANGE(x,0,0); - } - inline void* interlocked_read_acquire(void* volatile* x) BOOST_NOEXCEPT - { - return BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(x,0,0); - } - inline void interlocked_write_release(long volatile* x,long value) BOOST_NOEXCEPT - { - BOOST_INTERLOCKED_EXCHANGE(x,value); - } - inline void interlocked_write_release(void* volatile* x,void* value) BOOST_NOEXCEPT - { - BOOST_INTERLOCKED_EXCHANGE_POINTER(x,value); - } - } -} - -#endif - -#include - -#endif diff --git a/libraries/boost/boost/thread/win32/mfc_thread_init.hpp b/libraries/boost/boost/thread/win32/mfc_thread_init.hpp deleted file mode 100644 index e866f8949..000000000 --- a/libraries/boost/boost/thread/win32/mfc_thread_init.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef BOOST_THREAD_WIN32_MFC_THREAD_INIT_HPP -#define BOOST_THREAD_WIN32_MFC_THREAD_INIT_HPP -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2008 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - - -// check if we use MFC -#ifdef _AFXDLL -# if defined(_AFXEXT) - -// can't use ExtRawDllMain from afxdllx.h as it also defines the symbol _pRawDllMain -extern "C" -inline BOOL WINAPI ExtRawDllMain(HINSTANCE, DWORD dwReason, LPVOID) -{ - if (dwReason == DLL_PROCESS_ATTACH) - { - // save critical data pointers before running the constructors - AFX_MODULE_STATE* pModuleState = AfxGetModuleState(); - pModuleState->m_pClassInit = pModuleState->m_classList; - pModuleState->m_pFactoryInit = pModuleState->m_factoryList; - pModuleState->m_classList.m_pHead = NULL; - pModuleState->m_factoryList.m_pHead = NULL; - } - return TRUE; // ok -} - -extern "C" __declspec(selectany) BOOL (WINAPI * const _pRawDllMainOrig)(HANDLE, DWORD, LPVOID) = &ExtRawDllMain; - -# elif defined(_USRDLL) - -extern "C" BOOL WINAPI RawDllMain(HANDLE, DWORD dwReason, LPVOID); -extern "C" __declspec(selectany) BOOL (WINAPI * const _pRawDllMainOrig)(HANDLE, DWORD, LPVOID) = &RawDllMain; - -# endif -#endif - -#endif diff --git a/libraries/boost/boost/thread/win32/mutex.hpp b/libraries/boost/boost/thread/win32/mutex.hpp deleted file mode 100644 index 01544784b..000000000 --- a/libraries/boost/boost/thread/win32/mutex.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef BOOST_THREAD_WIN32_MUTEX_HPP -#define BOOST_THREAD_WIN32_MUTEX_HPP -// (C) Copyright 2005-7 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#if defined BOOST_THREAD_PROVIDES_NESTED_LOCKS -#include -#endif -#include - -#include - -namespace boost -{ - namespace detail - { - typedef ::boost::detail::basic_timed_mutex underlying_mutex; - } - - class mutex: - public ::boost::detail::underlying_mutex - { - public: - BOOST_THREAD_NO_COPYABLE(mutex) - mutex() - { - initialize(); - } - ~mutex() - { - destroy(); - } - -#if defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - typedef unique_lock scoped_lock; - typedef detail::try_lock_wrapper scoped_try_lock; -#endif - }; - - typedef mutex try_mutex; - - class timed_mutex: - public ::boost::detail::basic_timed_mutex - { - public: - BOOST_THREAD_NO_COPYABLE(timed_mutex) - timed_mutex() - { - initialize(); - } - - ~timed_mutex() - { - destroy(); - } - -#if defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - typedef unique_lock scoped_timed_lock; - typedef detail::try_lock_wrapper scoped_try_lock; - typedef scoped_timed_lock scoped_lock; -#endif - }; -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/win32/once.hpp b/libraries/boost/boost/thread/win32/once.hpp deleted file mode 100644 index 24eb0f29d..000000000 --- a/libraries/boost/boost/thread/win32/once.hpp +++ /dev/null @@ -1,1087 +0,0 @@ -#ifndef BOOST_THREAD_WIN32_ONCE_HPP -#define BOOST_THREAD_WIN32_ONCE_HPP - -// once.hpp -// -// (C) Copyright 2005-7 Anthony Williams -// (C) Copyright 2005 John Maddock -// (C) Copyright 2011-2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#ifdef BOOST_NO_STDC_NAMESPACE -namespace std -{ - using ::memcpy; - using ::ptrdiff_t; -} -#endif - -namespace boost -{ - struct once_flag; - namespace detail - { - struct once_context; - - inline bool enter_once_region(once_flag& flag, once_context& ctx) BOOST_NOEXCEPT; - inline void commit_once_region(once_flag& flag, once_context& ctx) BOOST_NOEXCEPT; - inline void rollback_once_region(once_flag& flag, once_context& ctx) BOOST_NOEXCEPT; - } - -#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11 - - struct once_flag - { - BOOST_THREAD_NO_COPYABLE(once_flag) - BOOST_CONSTEXPR once_flag() BOOST_NOEXCEPT - : status(0), count(0) - {} - long status; - long count; - private: - friend inline bool enter_once_region(once_flag& flag, detail::once_context& ctx) BOOST_NOEXCEPT; - friend inline void commit_once_region(once_flag& flag, detail::once_context& ctx) BOOST_NOEXCEPT; - friend inline void rollback_once_region(once_flag& flag, detail::once_context& ctx) BOOST_NOEXCEPT; - }; - -#define BOOST_ONCE_INIT once_flag() -#else // BOOST_THREAD_PROVIDES_ONCE_CXX11 - - struct once_flag - { - long status; - long count; - }; - -#define BOOST_ONCE_INIT {0,0} -#endif // BOOST_THREAD_PROVIDES_ONCE_CXX11 - -#if defined BOOST_THREAD_PROVIDES_INVOKE -#define BOOST_THREAD_INVOKE_RET_VOID detail::invoke -#define BOOST_THREAD_INVOKE_RET_VOID_CALL -#elif defined BOOST_THREAD_PROVIDES_INVOKE_RET -#define BOOST_THREAD_INVOKE_RET_VOID detail::invoke -#define BOOST_THREAD_INVOKE_RET_VOID_CALL -#else -#define BOOST_THREAD_INVOKE_RET_VOID boost::bind -#define BOOST_THREAD_INVOKE_RET_VOID_CALL () -#endif - - namespace detail - { -#ifdef BOOST_NO_ANSI_APIS - typedef wchar_t once_char_type; -#else - typedef char once_char_type; -#endif - unsigned const once_mutex_name_fixed_length=54; - unsigned const once_mutex_name_length=once_mutex_name_fixed_length+ - sizeof(void*)*2+sizeof(unsigned long)*2+1; - - template - void int_to_string(I p, once_char_type* buf) - { - for(unsigned i=0; i < sizeof(I)*2; ++i,++buf) - { -#ifdef BOOST_NO_ANSI_APIS - once_char_type const a=L'A'; -#else - once_char_type const a='A'; -#endif - *buf = a + static_cast((p >> (i*4)) & 0x0f); - } - *buf = 0; - } - - inline void name_once_mutex(once_char_type* mutex_name,void* flag_address) - { -#ifdef BOOST_NO_ANSI_APIS - static const once_char_type fixed_mutex_name[]=L"Local\\{C15730E2-145C-4c5e-B005-3BC753F42475}-once-flag"; -#else - static const once_char_type fixed_mutex_name[]="Local\\{C15730E2-145C-4c5e-B005-3BC753F42475}-once-flag"; -#endif - BOOST_STATIC_ASSERT(sizeof(fixed_mutex_name) == - (sizeof(once_char_type)*(once_mutex_name_fixed_length+1))); - - std::memcpy(mutex_name,fixed_mutex_name,sizeof(fixed_mutex_name)); - detail::int_to_string(reinterpret_cast(flag_address), - mutex_name + once_mutex_name_fixed_length); - detail::int_to_string(win32::GetCurrentProcessId(), - mutex_name + once_mutex_name_fixed_length + sizeof(void*)*2); - } - - inline void* open_once_event(once_char_type* mutex_name,void* flag_address) - { - if(!*mutex_name) - { - name_once_mutex(mutex_name,flag_address); - } - -#ifdef BOOST_NO_ANSI_APIS - return ::boost::detail::win32::OpenEventW( -#else - return ::boost::detail::win32::OpenEventA( -#endif - ::boost::detail::win32::synchronize | - ::boost::detail::win32::event_modify_state, - false, - mutex_name); - } - - inline void* create_once_event(once_char_type* mutex_name,void* flag_address) - { - if(!*mutex_name) - { - name_once_mutex(mutex_name,flag_address); - } - - return ::boost::detail::win32::create_event( - mutex_name, - ::boost::detail::win32::manual_reset_event, - ::boost::detail::win32::event_initially_reset); - } - - struct once_context { - long const function_complete_flag_value; - long const running_value; - bool counted; - detail::win32::handle_manager event_handle; - detail::once_char_type mutex_name[once_mutex_name_length]; - once_context() : - function_complete_flag_value(0xc15730e2), - running_value(0x7f0725e3), - counted(false) - { - mutex_name[0]=0; - } - }; - enum once_action {try_, break_, continue_}; - - inline bool enter_once_region(once_flag& flag, once_context& ctx) BOOST_NOEXCEPT - { - long status=BOOST_INTERLOCKED_COMPARE_EXCHANGE(&flag.status,ctx.running_value,0); - if(!status) - { - if(!ctx.event_handle) - { - ctx.event_handle=detail::open_once_event(ctx.mutex_name,&flag); - } - if(ctx.event_handle) - { - ::boost::detail::win32::ResetEvent(ctx.event_handle); - } - return true; - } - return false; - } - inline void commit_once_region(once_flag& flag, once_context& ctx) BOOST_NOEXCEPT - { - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - } - BOOST_INTERLOCKED_EXCHANGE(&flag.status,ctx.function_complete_flag_value); - if(!ctx.event_handle && - (::boost::detail::interlocked_read_acquire(&flag.count)>1)) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - } - if(ctx.event_handle) - { - ::boost::detail::win32::SetEvent(ctx.event_handle); - } - } - inline void rollback_once_region(once_flag& flag, once_context& ctx) BOOST_NOEXCEPT - { - BOOST_INTERLOCKED_EXCHANGE(&flag.status,0); - if(!ctx.event_handle) - { - ctx.event_handle=detail::open_once_event(ctx.mutex_name,&flag); - } - if(ctx.event_handle) - { - ::boost::detail::win32::SetEvent(ctx.event_handle); - } - } - } - -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) -//#if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR) - inline void call_once(once_flag& flag, void (*f)()) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - f(); - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite, 0)); - } - } -//#endif - template - inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - f(); - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - template - inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(A) a, BOOST_THREAD_RV_REF(ArgTypes)... args) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID( - thread_detail::decay_copy(boost::forward(f)), - thread_detail::decay_copy(boost::forward(a)), - thread_detail::decay_copy(boost::forward(args))... - ) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } -#else -#if ! defined(BOOST_MSVC) && ! defined(BOOST_INTEL) - template - void call_once(once_flag& flag,Function f) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - f(); - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - template - void call_once(once_flag& flag,Function f, T1 p1) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID(f,p1) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - template - void call_once(once_flag& flag,Function f, T1 p1, T2 p2) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID(f,p1,p2) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - template - void call_once(once_flag& flag,Function f, T1 p1, T2 p2, T3 p3) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID(f,p1,p2,p3) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } -#elif defined BOOST_NO_CXX11_RVALUE_REFERENCES - - template - void call_once(once_flag& flag,Function const&f) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - f(); - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - template - void call_once(once_flag& flag,Function const&f, T1 const&p1) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID(f,p1) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - template - void call_once(once_flag& flag,Function const&f, T1 const&p1, T2 const&p2) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID(f,p1,p2) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - template - void call_once(once_flag& flag,Function const&f, T1 const&p1, T2 const&p2, T3 const&p3) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID(f,p1,p2,p3) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } -#endif -#if 1 -#if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR) - inline void call_once(once_flag& flag, void (*f)()) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - f(); - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - template - void call_once(once_flag& flag,void (*f)(BOOST_THREAD_RV_REF(T1)), BOOST_THREAD_RV_REF(T1) p1) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - f( - thread_detail::decay_copy(boost::forward(p1)) - ); - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - template - void call_once(once_flag& flag,void (*f)(BOOST_THREAD_RV_REF(T1),BOOST_THREAD_RV_REF(T2)), BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - f( - thread_detail::decay_copy(boost::forward(p1)), - thread_detail::decay_copy(boost::forward(p2)) - ); - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - template - void call_once(once_flag& flag,void (*f)(BOOST_THREAD_RV_REF(T1),BOOST_THREAD_RV_REF(T2)), BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2, BOOST_THREAD_RV_REF(T3) p3) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - f( - thread_detail::decay_copy(boost::forward(p1)), - thread_detail::decay_copy(boost::forward(p2)), - thread_detail::decay_copy(boost::forward(p3)) - ); - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } -#endif - template - void call_once(once_flag& flag,BOOST_THREAD_RV_REF(Function) f) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - f(); - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - - template - void call_once(once_flag& flag,BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID( - thread_detail::decay_copy(boost::forward(f)), - thread_detail::decay_copy(boost::forward(p1)) - ) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - template - void call_once(once_flag& flag,BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID( - thread_detail::decay_copy(boost::forward(f)), - thread_detail::decay_copy(boost::forward(p1)), - thread_detail::decay_copy(boost::forward(p2)) - ) BOOST_THREAD_INVOKE_RET_VOID_CALL; - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - template - void call_once(once_flag& flag,BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1, BOOST_THREAD_RV_REF(T2) p2, BOOST_THREAD_RV_REF(T3) p3) - { - // Try for a quick win: if the procedure has already been called - // just skip through: - detail::once_context ctx; - while(::boost::detail::interlocked_read_acquire(&flag.status) - !=ctx.function_complete_flag_value) - { - if(detail::enter_once_region(flag, ctx)) - { - BOOST_TRY - { - BOOST_THREAD_INVOKE_RET_VOID( - thread_detail::decay_copy(boost::forward(f)), - thread_detail::decay_copy(boost::forward(p1)), - thread_detail::decay_copy(boost::forward(p2)), - thread_detail::decay_copy(boost::forward(p3)) - ) BOOST_THREAD_INVOKE_RET_VOID_CALL; - - } - BOOST_CATCH(...) - { - detail::rollback_once_region(flag, ctx); - BOOST_RETHROW - } - BOOST_CATCH_END - detail::commit_once_region(flag, ctx); - break; - } - if(!ctx.counted) - { - BOOST_INTERLOCKED_INCREMENT(&flag.count); - ctx.counted=true; - long status=::boost::detail::interlocked_read_acquire(&flag.status); - if(status==ctx.function_complete_flag_value) - { - break; - } - if(!ctx.event_handle) - { - ctx.event_handle=detail::create_once_event(ctx.mutex_name,&flag); - continue; - } - } - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( - ctx.event_handle,::boost::detail::win32::infinite,0)); - } - } - -#endif -#endif -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/win32/recursive_mutex.hpp b/libraries/boost/boost/thread/win32/recursive_mutex.hpp deleted file mode 100644 index 1f0f7f5e5..000000000 --- a/libraries/boost/boost/thread/win32/recursive_mutex.hpp +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef BOOST_RECURSIVE_MUTEX_WIN32_HPP -#define BOOST_RECURSIVE_MUTEX_WIN32_HPP - -// recursive_mutex.hpp -// -// (C) Copyright 2006-7 Anthony Williams -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - - -#include -#include -#include -#if defined BOOST_THREAD_PROVIDES_NESTED_LOCKS -#include -#endif - -#include - -namespace boost -{ - class recursive_mutex: - public ::boost::detail::basic_recursive_mutex - { - public: - BOOST_THREAD_NO_COPYABLE(recursive_mutex) - recursive_mutex() - { - ::boost::detail::basic_recursive_mutex::initialize(); - } - ~recursive_mutex() - { - ::boost::detail::basic_recursive_mutex::destroy(); - } - -#if defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - typedef unique_lock scoped_lock; - typedef detail::try_lock_wrapper scoped_try_lock; -#endif - }; - - typedef recursive_mutex recursive_try_mutex; - - class recursive_timed_mutex: - public ::boost::detail::basic_recursive_timed_mutex - { - public: - BOOST_THREAD_NO_COPYABLE(recursive_timed_mutex) - recursive_timed_mutex() - { - ::boost::detail::basic_recursive_timed_mutex::initialize(); - } - ~recursive_timed_mutex() - { - ::boost::detail::basic_recursive_timed_mutex::destroy(); - } - -#if defined BOOST_THREAD_PROVIDES_NESTED_LOCKS - typedef unique_lock scoped_timed_lock; - typedef detail::try_lock_wrapper scoped_try_lock; - typedef scoped_timed_lock scoped_lock; -#endif - }; -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/win32/shared_mutex.hpp b/libraries/boost/boost/thread/win32/shared_mutex.hpp deleted file mode 100644 index b7822d114..000000000 --- a/libraries/boost/boost/thread/win32/shared_mutex.hpp +++ /dev/null @@ -1,903 +0,0 @@ -#ifndef BOOST_THREAD_WIN32_SHARED_MUTEX_HPP -#define BOOST_THREAD_WIN32_SHARED_MUTEX_HPP - -// (C) Copyright 2006-8 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include -#include -#include -#include -#ifdef BOOST_THREAD_USES_CHRONO -#include -#include -#endif -#include - -#include - -namespace boost -{ - class shared_mutex - { - private: - struct state_data - { - unsigned shared_count:11, - shared_waiting:11, - exclusive:1, - upgrade:1, - exclusive_waiting:7, - exclusive_waiting_blocked:1; - - friend bool operator==(state_data const& lhs,state_data const& rhs) - { - return *reinterpret_cast(&lhs)==*reinterpret_cast(&rhs); - } - }; - - - template - T interlocked_compare_exchange(T* target,T new_value,T comparand) - { - BOOST_STATIC_ASSERT(sizeof(T)==sizeof(long)); - long const res=BOOST_INTERLOCKED_COMPARE_EXCHANGE(reinterpret_cast(target), - *reinterpret_cast(&new_value), - *reinterpret_cast(&comparand)); - return *reinterpret_cast(&res); - } - - enum - { - unlock_sem = 0, - exclusive_sem = 1 - }; - - state_data state; - detail::win32::handle semaphores[2]; - detail::win32::handle upgrade_sem; - - void release_waiters(state_data old_state) - { - if(old_state.exclusive_waiting) - { - BOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[exclusive_sem],1,0)!=0); - } - - if(old_state.shared_waiting || old_state.exclusive_waiting) - { - BOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[unlock_sem],old_state.shared_waiting + (old_state.exclusive_waiting?1:0),0)!=0); - } - } - void release_shared_waiters(state_data old_state) - { - if(old_state.shared_waiting || old_state.exclusive_waiting) - { - BOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[unlock_sem],old_state.shared_waiting + (old_state.exclusive_waiting?1:0),0)!=0); - } - } - - public: - BOOST_THREAD_NO_COPYABLE(shared_mutex) - shared_mutex() - { - semaphores[unlock_sem]=detail::win32::create_anonymous_semaphore(0,LONG_MAX); - semaphores[exclusive_sem]=detail::win32::create_anonymous_semaphore_nothrow(0,LONG_MAX); - if (!semaphores[exclusive_sem]) - { - detail::win32::release_semaphore(semaphores[unlock_sem],LONG_MAX); - boost::throw_exception(thread_resource_error()); - } - upgrade_sem=detail::win32::create_anonymous_semaphore_nothrow(0,LONG_MAX); - if (!upgrade_sem) - { - detail::win32::release_semaphore(semaphores[unlock_sem],LONG_MAX); - detail::win32::release_semaphore(semaphores[exclusive_sem],LONG_MAX); - boost::throw_exception(thread_resource_error()); - } - state_data state_={0,0,0,0,0,0}; - state=state_; - } - - ~shared_mutex() - { - detail::win32::CloseHandle(upgrade_sem); - detail::win32::CloseHandle(semaphores[unlock_sem]); - detail::win32::CloseHandle(semaphores[exclusive_sem]); - } - - bool try_lock_shared() - { - state_data old_state=state; - for(;;) - { - state_data new_state=old_state; - if(!new_state.exclusive && !new_state.exclusive_waiting_blocked) - { - ++new_state.shared_count; - if(!new_state.shared_count) - { - return false; - } - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - return !(old_state.exclusive| old_state.exclusive_waiting_blocked); - } - - void lock_shared() - { - -#if defined BOOST_THREAD_USES_DATETIME - BOOST_VERIFY(timed_lock_shared(::boost::detail::get_system_time_sentinel())); -#else - BOOST_VERIFY(try_lock_shared_until(chrono::steady_clock::now())); -#endif - } - -#if defined BOOST_THREAD_USES_DATETIME - template - bool timed_lock_shared(TimeDuration const & relative_time) - { - return timed_lock_shared(get_system_time()+relative_time); - } - bool timed_lock_shared(boost::system_time const& wait_until) - { - for(;;) - { - state_data old_state=state; - for(;;) - { - state_data new_state=old_state; - if(new_state.exclusive || new_state.exclusive_waiting_blocked) - { - ++new_state.shared_waiting; - if(!new_state.shared_waiting) - { - boost::throw_exception(boost::lock_error()); - } - } - else - { - ++new_state.shared_count; - if(!new_state.shared_count) - { - boost::throw_exception(boost::lock_error()); - } - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - - if(!(old_state.exclusive| old_state.exclusive_waiting_blocked)) - { - return true; - } - - unsigned long const res=detail::win32::WaitForSingleObjectEx(semaphores[unlock_sem],::boost::detail::get_milliseconds_until(wait_until), 0); - if(res==detail::win32::timeout) - { - for(;;) - { - state_data new_state=old_state; - if(new_state.exclusive || new_state.exclusive_waiting_blocked) - { - if(new_state.shared_waiting) - { - --new_state.shared_waiting; - } - } - else - { - ++new_state.shared_count; - if(!new_state.shared_count) - { - return false; - } - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - - if(!(old_state.exclusive| old_state.exclusive_waiting_blocked)) - { - return true; - } - return false; - } - - BOOST_ASSERT(res==0); - } - } -#endif - -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_shared_for(const chrono::duration& rel_time) - { - return try_lock_shared_until(chrono::steady_clock::now() + rel_time); - } - template - bool try_lock_shared_until(const chrono::time_point& t) - { - using namespace chrono; - system_clock::time_point s_now = system_clock::now(); - typename Clock::time_point c_now = Clock::now(); - return try_lock_shared_until(s_now + ceil(t - c_now)); - } - template - bool try_lock_shared_until(const chrono::time_point& t) - { - using namespace chrono; - typedef time_point sys_tmpt; - return try_lock_shared_until(sys_tmpt(chrono::ceil(t.time_since_epoch()))); - } - bool try_lock_shared_until(const chrono::time_point& tp) - { - for(;;) - { - state_data old_state=state; - for(;;) - { - state_data new_state=old_state; - if(new_state.exclusive || new_state.exclusive_waiting_blocked) - { - ++new_state.shared_waiting; - if(!new_state.shared_waiting) - { - boost::throw_exception(boost::lock_error()); - } - } - else - { - ++new_state.shared_count; - if(!new_state.shared_count) - { - boost::throw_exception(boost::lock_error()); - } - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - - if(!(old_state.exclusive| old_state.exclusive_waiting_blocked)) - { - return true; - } - - chrono::system_clock::time_point n = chrono::system_clock::now(); - unsigned long res; - if (tp>n) { - chrono::milliseconds rel_time= chrono::ceil(tp-n); - res=detail::win32::WaitForSingleObjectEx(semaphores[unlock_sem], - static_cast(rel_time.count()), 0); - } else { - res=detail::win32::timeout; - } - if(res==detail::win32::timeout) - { - for(;;) - { - state_data new_state=old_state; - if(new_state.exclusive || new_state.exclusive_waiting_blocked) - { - if(new_state.shared_waiting) - { - --new_state.shared_waiting; - } - } - else - { - ++new_state.shared_count; - if(!new_state.shared_count) - { - return false; - } - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - - if(!(old_state.exclusive| old_state.exclusive_waiting_blocked)) - { - return true; - } - return false; - } - - BOOST_ASSERT(res==0); - } - } -#endif - - void unlock_shared() - { - state_data old_state=state; - for(;;) - { - state_data new_state=old_state; - bool const last_reader=!--new_state.shared_count; - - if(last_reader) - { - if(new_state.upgrade) - { - new_state.upgrade=false; - new_state.exclusive=true; - } - else - { - if(new_state.exclusive_waiting) - { - --new_state.exclusive_waiting; - new_state.exclusive_waiting_blocked=false; - } - new_state.shared_waiting=0; - } - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - if(last_reader) - { - if(old_state.upgrade) - { - BOOST_VERIFY(detail::win32::ReleaseSemaphore(upgrade_sem,1,0)!=0); - } - else - { - release_waiters(old_state); - } - } - break; - } - old_state=current_state; - } - } - - void lock() - { - -#if defined BOOST_THREAD_USES_DATETIME - BOOST_VERIFY(timed_lock(::boost::detail::get_system_time_sentinel())); -#else - BOOST_VERIFY(try_lock_until(chrono::steady_clock::now())); -#endif - } - -#if defined BOOST_THREAD_USES_DATETIME - template - bool timed_lock(TimeDuration const & relative_time) - { - return timed_lock(get_system_time()+relative_time); - } -#endif - - bool try_lock() - { - state_data old_state=state; - for(;;) - { - state_data new_state=old_state; - if(new_state.shared_count || new_state.exclusive) - { - return false; - } - else - { - new_state.exclusive=true; - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - return true; - } - - -#if defined BOOST_THREAD_USES_DATETIME - bool timed_lock(boost::system_time const& wait_until) - { - for(;;) - { - state_data old_state=state; - - for(;;) - { - state_data new_state=old_state; - if(new_state.shared_count || new_state.exclusive) - { - ++new_state.exclusive_waiting; - if(!new_state.exclusive_waiting) - { - boost::throw_exception(boost::lock_error()); - } - - new_state.exclusive_waiting_blocked=true; - } - else - { - new_state.exclusive=true; - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - - if(!old_state.shared_count && !old_state.exclusive) - { - return true; - } - #ifndef UNDER_CE - const bool wait_all = true; - #else - const bool wait_all = false; - #endif - unsigned long const wait_res=detail::win32::WaitForMultipleObjectsEx(2,semaphores,wait_all,::boost::detail::get_milliseconds_until(wait_until), 0); - if(wait_res==detail::win32::timeout) - { - for(;;) - { - bool must_notify = false; - state_data new_state=old_state; - if(new_state.shared_count || new_state.exclusive) - { - if(new_state.exclusive_waiting) - { - if(!--new_state.exclusive_waiting) - { - new_state.exclusive_waiting_blocked=false; - must_notify = true; - } - } - } - else - { - new_state.exclusive=true; - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if (must_notify) - { - BOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[unlock_sem],1,0)!=0); - } - - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - if(!old_state.shared_count && !old_state.exclusive) - { - return true; - } - return false; - } - BOOST_ASSERT(wait_res<2); - } - } -#endif -#ifdef BOOST_THREAD_USES_CHRONO - template - bool try_lock_for(const chrono::duration& rel_time) - { - return try_lock_until(chrono::steady_clock::now() + rel_time); - } - template - bool try_lock_until(const chrono::time_point& t) - { - using namespace chrono; - system_clock::time_point s_now = system_clock::now(); - typename Clock::time_point c_now = Clock::now(); - return try_lock_until(s_now + ceil(t - c_now)); - } - template - bool try_lock_until(const chrono::time_point& t) - { - using namespace chrono; - typedef time_point sys_tmpt; - return try_lock_until(sys_tmpt(chrono::ceil(t.time_since_epoch()))); - } - bool try_lock_until(const chrono::time_point& tp) - { - for(;;) - { - state_data old_state=state; - - for(;;) - { - state_data new_state=old_state; - if(new_state.shared_count || new_state.exclusive) - { - ++new_state.exclusive_waiting; - if(!new_state.exclusive_waiting) - { - boost::throw_exception(boost::lock_error()); - } - - new_state.exclusive_waiting_blocked=true; - } - else - { - new_state.exclusive=true; - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - - if(!old_state.shared_count && !old_state.exclusive) - { - return true; - } - #ifndef UNDER_CE - const bool wait_all = true; - #else - const bool wait_all = false; - #endif - - chrono::system_clock::time_point n = chrono::system_clock::now(); - unsigned long wait_res; - if (tp>n) { - chrono::milliseconds rel_time= chrono::ceil(tp-chrono::system_clock::now()); - wait_res=detail::win32::WaitForMultipleObjectsEx(2,semaphores,wait_all, - static_cast(rel_time.count()), 0); - } else { - wait_res=detail::win32::timeout; - } - if(wait_res==detail::win32::timeout) - { - for(;;) - { - bool must_notify = false; - state_data new_state=old_state; - if(new_state.shared_count || new_state.exclusive) - { - if(new_state.exclusive_waiting) - { - if(!--new_state.exclusive_waiting) - { - new_state.exclusive_waiting_blocked=false; - must_notify = true; - } - } - } - else - { - new_state.exclusive=true; - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if (must_notify) - { - BOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[unlock_sem],1,0)!=0); - } - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - if(!old_state.shared_count && !old_state.exclusive) - { - return true; - } - return false; - } - BOOST_ASSERT(wait_res<2); - } - } -#endif - - void unlock() - { - state_data old_state=state; - for(;;) - { - state_data new_state=old_state; - new_state.exclusive=false; - if(new_state.exclusive_waiting) - { - --new_state.exclusive_waiting; - new_state.exclusive_waiting_blocked=false; - } - new_state.shared_waiting=0; - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - release_waiters(old_state); - } - - void lock_upgrade() - { - for(;;) - { - state_data old_state=state; - for(;;) - { - state_data new_state=old_state; - if(new_state.exclusive || new_state.exclusive_waiting_blocked || new_state.upgrade) - { - ++new_state.shared_waiting; - if(!new_state.shared_waiting) - { - boost::throw_exception(boost::lock_error()); - } - } - else - { - ++new_state.shared_count; - if(!new_state.shared_count) - { - boost::throw_exception(boost::lock_error()); - } - new_state.upgrade=true; - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - - if(!(old_state.exclusive|| old_state.exclusive_waiting_blocked|| old_state.upgrade)) - { - return; - } - - BOOST_VERIFY(!detail::win32::WaitForSingleObjectEx(semaphores[unlock_sem],detail::win32::infinite, 0)); - } - } - - bool try_lock_upgrade() - { - state_data old_state=state; - for(;;) - { - state_data new_state=old_state; - if(new_state.exclusive || new_state.exclusive_waiting_blocked || new_state.upgrade) - { - return false; - } - else - { - ++new_state.shared_count; - if(!new_state.shared_count) - { - return false; - } - new_state.upgrade=true; - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - return true; - } - - void unlock_upgrade() - { - state_data old_state=state; - for(;;) - { - state_data new_state=old_state; - new_state.upgrade=false; - bool const last_reader=!--new_state.shared_count; - - new_state.shared_waiting=0; - if(last_reader) - { - if(new_state.exclusive_waiting) - { - --new_state.exclusive_waiting; - new_state.exclusive_waiting_blocked=false; - } - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - if(last_reader) - { - release_waiters(old_state); - } - else { - release_shared_waiters(old_state); - } - // #7720 - //else { - // release_waiters(old_state); - //} - break; - } - old_state=current_state; - } - } - - void unlock_upgrade_and_lock() - { - state_data old_state=state; - for(;;) - { - state_data new_state=old_state; - bool const last_reader=!--new_state.shared_count; - - if(last_reader) - { - new_state.upgrade=false; - new_state.exclusive=true; - } - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - if(!last_reader) - { - BOOST_VERIFY(!detail::win32::WaitForSingleObjectEx(upgrade_sem,detail::win32::infinite, 0)); - } - break; - } - old_state=current_state; - } - } - - void unlock_and_lock_upgrade() - { - state_data old_state=state; - for(;;) - { - state_data new_state=old_state; - new_state.exclusive=false; - new_state.upgrade=true; - ++new_state.shared_count; - if(new_state.exclusive_waiting) - { - --new_state.exclusive_waiting; - new_state.exclusive_waiting_blocked=false; - } - new_state.shared_waiting=0; - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - release_waiters(old_state); - } -// bool try_unlock_upgrade_and_lock() -// { -// return false; -// } -//#ifdef BOOST_THREAD_USES_CHRONO -// template -// bool -// try_unlock_upgrade_and_lock_for( -// const chrono::duration& rel_time) -// { -// return try_unlock_upgrade_and_lock_until( -// chrono::steady_clock::now() + rel_time); -// } -// template -// bool -// try_unlock_upgrade_and_lock_until( -// const chrono::time_point& abs_time) -// { -// return false; -// } -//#endif - - void unlock_and_lock_shared() - { - state_data old_state=state; - for(;;) - { - state_data new_state=old_state; - new_state.exclusive=false; - ++new_state.shared_count; - if(new_state.exclusive_waiting) - { - --new_state.exclusive_waiting; - new_state.exclusive_waiting_blocked=false; - } - new_state.shared_waiting=0; - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - release_waiters(old_state); - } - void unlock_upgrade_and_lock_shared() - { - state_data old_state=state; - for(;;) - { - state_data new_state=old_state; - new_state.upgrade=false; - if(new_state.exclusive_waiting) - { - --new_state.exclusive_waiting; - new_state.exclusive_waiting_blocked=false; - } - new_state.shared_waiting=0; - - state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); - if(current_state==old_state) - { - break; - } - old_state=current_state; - } - release_waiters(old_state); - } - - }; - typedef shared_mutex upgrade_mutex; - -} - -#include - -#endif diff --git a/libraries/boost/boost/thread/win32/thread_data.hpp b/libraries/boost/boost/thread/win32/thread_data.hpp deleted file mode 100644 index 005f3ba50..000000000 --- a/libraries/boost/boost/thread/win32/thread_data.hpp +++ /dev/null @@ -1,328 +0,0 @@ -#ifndef BOOST_THREAD_PTHREAD_THREAD_DATA_HPP -#define BOOST_THREAD_PTHREAD_THREAD_DATA_HPP -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2008 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba - -#include -#include -#include -#include - -#include - -#include -#ifdef BOOST_THREAD_USES_CHRONO -#include -#endif - -#include -#include -#include - -#include - -#ifdef BOOST_MSVC -#pragma warning(push) -#pragma warning(disable:4251) -#endif - -namespace boost -{ - class condition_variable; - class mutex; - - class thread_attributes { - public: - thread_attributes() BOOST_NOEXCEPT { - val_.stack_size = 0; - //val_.lpThreadAttributes=0; - } - ~thread_attributes() { - } - // stack size - void set_stack_size(std::size_t size) BOOST_NOEXCEPT { - val_.stack_size = size; - } - - std::size_t get_stack_size() const BOOST_NOEXCEPT { - return val_.stack_size; - } - - //void set_security(LPSECURITY_ATTRIBUTES lpThreadAttributes) - //{ - // val_.lpThreadAttributes=lpThreadAttributes; - //} - //LPSECURITY_ATTRIBUTES get_security() - //{ - // return val_.lpThreadAttributes; - //} - - struct win_attrs { - std::size_t stack_size; - //LPSECURITY_ATTRIBUTES lpThreadAttributes; - }; - typedef win_attrs native_handle_type; - native_handle_type* native_handle() {return &val_;} - const native_handle_type* native_handle() const {return &val_;} - - private: - win_attrs val_; - }; - - namespace detail - { - struct shared_state_base; - struct tss_cleanup_function; - struct thread_exit_callback_node; - struct tss_data_node - { - boost::shared_ptr func; - void* value; - - tss_data_node(boost::shared_ptr func_, - void* value_): - func(func_),value(value_) - {} - }; - - struct thread_data_base; - void intrusive_ptr_add_ref(thread_data_base * p); - void intrusive_ptr_release(thread_data_base * p); - - struct BOOST_THREAD_DECL thread_data_base - { - long count; - - // Win32 threading APIs are not available in store apps so - // use abstraction on top of Windows::System::Threading. -#if BOOST_PLAT_WINDOWS_RUNTIME - detail::win32::scoped_winrt_thread thread_handle; -#else - detail::win32::handle_manager thread_handle; -#endif - - boost::detail::thread_exit_callback_node* thread_exit_callbacks; - unsigned id; - std::map tss_data; - typedef std::vector - //, hidden_allocator > - > notify_list_t; - notify_list_t notify; - - typedef std::vector > async_states_t; - async_states_t async_states_; -//#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - // These data must be at the end so that the access to the other fields doesn't change - // when BOOST_THREAD_PROVIDES_INTERRUPTIONS is defined - // Another option is to have them always - detail::win32::handle_manager interruption_handle; - bool interruption_enabled; -//#endif - - thread_data_base(): - count(0), - thread_handle(), - thread_exit_callbacks(0), - id(0), - tss_data(), - notify(), - async_states_() -//#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - , interruption_handle(create_anonymous_event(detail::win32::manual_reset_event,detail::win32::event_initially_reset)) - , interruption_enabled(true) -//#endif - {} - virtual ~thread_data_base(); - - friend void intrusive_ptr_add_ref(thread_data_base * p) - { - BOOST_INTERLOCKED_INCREMENT(&p->count); - } - - friend void intrusive_ptr_release(thread_data_base * p) - { - if(!BOOST_INTERLOCKED_DECREMENT(&p->count)) - { - detail::heap_delete(p); - } - } - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - void interrupt() - { - BOOST_VERIFY(detail::win32::SetEvent(interruption_handle)!=0); - } -#endif - typedef detail::win32::handle native_handle_type; - - virtual void run()=0; - - virtual void notify_all_at_thread_exit(condition_variable* cv, mutex* m) - { - notify.push_back(std::pair(cv, m)); - } - - void make_ready_at_thread_exit(shared_ptr as) - { - async_states_.push_back(as); - } - - }; - BOOST_THREAD_DECL thread_data_base* get_current_thread_data(); - - typedef boost::intrusive_ptr thread_data_ptr; - - struct BOOST_SYMBOL_VISIBLE timeout - { - win32::ticks_type start; - uintmax_t milliseconds; - bool relative; - boost::system_time abs_time; - - static unsigned long const max_non_infinite_wait=0xfffffffe; - - timeout(uintmax_t milliseconds_): - start(win32::GetTickCount64_()()), - milliseconds(milliseconds_), - relative(true) - //, - // abs_time(boost::get_system_time()) - {} - - timeout(boost::system_time const& abs_time_): - start(win32::GetTickCount64_()()), - milliseconds(0), - relative(false), - abs_time(abs_time_) - {} - - struct BOOST_SYMBOL_VISIBLE remaining_time - { - bool more; - unsigned long milliseconds; - - remaining_time(uintmax_t remaining): - more(remaining>max_non_infinite_wait), - milliseconds(more?max_non_infinite_wait:(unsigned long)remaining) - {} - }; - - remaining_time remaining_milliseconds() const - { - if(is_sentinel()) - { - return remaining_time(win32::infinite); - } - else if(relative) - { - win32::ticks_type const now=win32::GetTickCount64_()(); - win32::ticks_type const elapsed=now-start; - return remaining_time((elapsed - inline BOOST_SYMBOL_VISIBLE void sleep(TimeDuration const& rel_time) - { - interruptible_wait(detail::pin_to_zero(rel_time.total_milliseconds())); - } - inline BOOST_SYMBOL_VISIBLE void sleep(system_time const& abs_time) - { - interruptible_wait(abs_time); - } -// #11322 sleep_for() nanoseconds overload will always return too early on windows -//#ifdef BOOST_THREAD_USES_CHRONO -// inline void BOOST_SYMBOL_VISIBLE sleep_for(const chrono::nanoseconds& ns) -// { -// interruptible_wait(chrono::duration_cast(ns).count()); -// } -//#endif - namespace no_interruption_point - { - bool BOOST_THREAD_DECL non_interruptible_wait(detail::win32::handle handle_to_wait_for,detail::timeout target_time); - inline void non_interruptible_wait(uintmax_t milliseconds) - { - non_interruptible_wait(detail::win32::invalid_handle_value,milliseconds); - } - inline BOOST_SYMBOL_VISIBLE void non_interruptible_wait(system_time const& abs_time) - { - non_interruptible_wait(detail::win32::invalid_handle_value,abs_time); - } - template - inline BOOST_SYMBOL_VISIBLE void sleep(TimeDuration const& rel_time) - { - non_interruptible_wait(detail::pin_to_zero(rel_time.total_milliseconds())); - } - inline BOOST_SYMBOL_VISIBLE void sleep(system_time const& abs_time) - { - non_interruptible_wait(abs_time); - } -// #11322 sleep_for() nanoseconds overload will always return too early on windows -//#ifdef BOOST_THREAD_USES_CHRONO -// inline void BOOST_SYMBOL_VISIBLE sleep_for(const chrono::nanoseconds& ns) -// { -// non_interruptible_wait(chrono::duration_cast(ns).count()); -// } -//#endif - } - } - -} - -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif - -#include - -#endif diff --git a/libraries/boost/boost/thread/win32/thread_heap_alloc.hpp b/libraries/boost/boost/thread/win32/thread_heap_alloc.hpp deleted file mode 100644 index 610fe3263..000000000 --- a/libraries/boost/boost/thread/win32/thread_heap_alloc.hpp +++ /dev/null @@ -1,409 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007 Anthony Williams -#ifndef THREAD_HEAP_ALLOC_HPP -#define THREAD_HEAP_ALLOC_HPP -#include -#include -#include -#include -#include -#include -#include - -#if defined( BOOST_USE_WINDOWS_H ) -# include - -namespace boost -{ - namespace detail - { - namespace win32 - { - using ::GetProcessHeap; - using ::HeapAlloc; - using ::HeapFree; - } - } -} - -#else - -# ifdef HeapAlloc -# undef HeapAlloc -# endif - -namespace boost -{ - namespace detail - { - namespace win32 - { - extern "C" - { - __declspec(dllimport) handle __stdcall GetProcessHeap(); - __declspec(dllimport) void* __stdcall HeapAlloc(handle,unsigned long,ulong_ptr); - __declspec(dllimport) int __stdcall HeapFree(handle,unsigned long,void*); - } - } - } -} - -#endif - -#include - -namespace boost -{ - namespace detail - { - inline void* allocate_raw_heap_memory(unsigned size) - { - void* const heap_memory=detail::win32::HeapAlloc(detail::win32::GetProcessHeap(),0,size); - if(!heap_memory) - { - boost::throw_exception(std::bad_alloc()); - } - return heap_memory; - } - - inline void free_raw_heap_memory(void* heap_memory) - { - BOOST_VERIFY(detail::win32::HeapFree(detail::win32::GetProcessHeap(),0,heap_memory)!=0); - } - - template - inline T* heap_new() - { - void* const heap_memory=allocate_raw_heap_memory(sizeof(T)); - BOOST_TRY - { - T* const data=new (heap_memory) T(); - return data; - } - BOOST_CATCH(...) - { - free_raw_heap_memory(heap_memory); - BOOST_RETHROW - } - BOOST_CATCH_END - } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - template - inline T* heap_new(A1&& a1) - { - void* const heap_memory=allocate_raw_heap_memory(sizeof(T)); - BOOST_TRY - { - T* const data=new (heap_memory) T(static_cast(a1)); - return data; - } - BOOST_CATCH(...) - { - free_raw_heap_memory(heap_memory); - BOOST_RETHROW - } - BOOST_CATCH_END - } - template - inline T* heap_new(A1&& a1,A2&& a2) - { - void* const heap_memory=allocate_raw_heap_memory(sizeof(T)); - BOOST_TRY - { - T* const data=new (heap_memory) T(static_cast(a1),static_cast(a2)); - return data; - } - BOOST_CATCH(...) - { - free_raw_heap_memory(heap_memory); - BOOST_RETHROW - } - BOOST_CATCH_END - } - template - inline T* heap_new(A1&& a1,A2&& a2,A3&& a3) - { - void* const heap_memory=allocate_raw_heap_memory(sizeof(T)); - BOOST_TRY - { - T* const data=new (heap_memory) T(static_cast(a1),static_cast(a2), - static_cast(a3)); - return data; - } - BOOST_CATCH(...) - { - free_raw_heap_memory(heap_memory); - BOOST_RETHROW - } - BOOST_CATCH_END - } - template - inline T* heap_new(A1&& a1,A2&& a2,A3&& a3,A4&& a4) - { - void* const heap_memory=allocate_raw_heap_memory(sizeof(T)); - BOOST_TRY - { - T* const data=new (heap_memory) T(static_cast(a1),static_cast(a2), - static_cast(a3),static_cast(a4)); - return data; - } - BOOST_CATCH(...) - { - free_raw_heap_memory(heap_memory); - BOOST_RETHROW - } - BOOST_CATCH_END - } -#else - template - inline T* heap_new_impl(A1 a1) - { - void* const heap_memory=allocate_raw_heap_memory(sizeof(T)); - BOOST_TRY - { - T* const data=new (heap_memory) T(a1); - return data; - } - BOOST_CATCH(...) - { - free_raw_heap_memory(heap_memory); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - template - inline T* heap_new_impl(A1 a1,A2 a2) - { - void* const heap_memory=allocate_raw_heap_memory(sizeof(T)); - BOOST_TRY - { - T* const data=new (heap_memory) T(a1,a2); - return data; - } - BOOST_CATCH(...) - { - free_raw_heap_memory(heap_memory); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - template - inline T* heap_new_impl(A1 a1,A2 a2,A3 a3) - { - void* const heap_memory=allocate_raw_heap_memory(sizeof(T)); - BOOST_TRY - { - T* const data=new (heap_memory) T(a1,a2,a3); - return data; - } - BOOST_CATCH(...) - { - free_raw_heap_memory(heap_memory); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - template - inline T* heap_new_impl(A1 a1,A2 a2,A3 a3,A4 a4) - { - void* const heap_memory=allocate_raw_heap_memory(sizeof(T)); - BOOST_TRY - { - T* const data=new (heap_memory) T(a1,a2,a3,a4); - return data; - } - BOOST_CATCH(...) - { - free_raw_heap_memory(heap_memory); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - - template - inline T* heap_new(A1 const& a1) - { - return heap_new_impl(a1); - } - template - inline T* heap_new(A1& a1) - { - return heap_new_impl(a1); - } - - template - inline T* heap_new(A1 const& a1,A2 const& a2) - { - return heap_new_impl(a1,a2); - } - template - inline T* heap_new(A1& a1,A2 const& a2) - { - return heap_new_impl(a1,a2); - } - template - inline T* heap_new(A1 const& a1,A2& a2) - { - return heap_new_impl(a1,a2); - } - template - inline T* heap_new(A1& a1,A2& a2) - { - return heap_new_impl(a1,a2); - } - - template - inline T* heap_new(A1 const& a1,A2 const& a2,A3 const& a3) - { - return heap_new_impl(a1,a2,a3); - } - template - inline T* heap_new(A1& a1,A2 const& a2,A3 const& a3) - { - return heap_new_impl(a1,a2,a3); - } - template - inline T* heap_new(A1 const& a1,A2& a2,A3 const& a3) - { - return heap_new_impl(a1,a2,a3); - } - template - inline T* heap_new(A1& a1,A2& a2,A3 const& a3) - { - return heap_new_impl(a1,a2,a3); - } - - template - inline T* heap_new(A1 const& a1,A2 const& a2,A3& a3) - { - return heap_new_impl(a1,a2,a3); - } - template - inline T* heap_new(A1& a1,A2 const& a2,A3& a3) - { - return heap_new_impl(a1,a2,a3); - } - template - inline T* heap_new(A1 const& a1,A2& a2,A3& a3) - { - return heap_new_impl(a1,a2,a3); - } - template - inline T* heap_new(A1& a1,A2& a2,A3& a3) - { - return heap_new_impl(a1,a2,a3); - } - - template - inline T* heap_new(A1 const& a1,A2 const& a2,A3 const& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2 const& a2,A3 const& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1 const& a1,A2& a2,A3 const& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2& a2,A3 const& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - - template - inline T* heap_new(A1 const& a1,A2 const& a2,A3& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2 const& a2,A3& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1 const& a1,A2& a2,A3& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2& a2,A3& a3,A4 const& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1 const& a1,A2 const& a2,A3 const& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2 const& a2,A3 const& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1 const& a1,A2& a2,A3 const& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2& a2,A3 const& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - - template - inline T* heap_new(A1 const& a1,A2 const& a2,A3& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2 const& a2,A3& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1 const& a1,A2& a2,A3& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - template - inline T* heap_new(A1& a1,A2& a2,A3& a3,A4& a4) - { - return heap_new_impl(a1,a2,a3,a4); - } - -#endif - template - inline void heap_delete(T* data) - { - data->~T(); - free_raw_heap_memory(data); - } - - template - struct do_heap_delete - { - void operator()(T* data) const - { - detail::heap_delete(data); - } - }; - } -} - -#include - - -#endif diff --git a/libraries/boost/boost/thread/win32/thread_primitives.hpp b/libraries/boost/boost/thread/win32/thread_primitives.hpp deleted file mode 100644 index c9e279faa..000000000 --- a/libraries/boost/boost/thread/win32/thread_primitives.hpp +++ /dev/null @@ -1,670 +0,0 @@ -#ifndef BOOST_WIN32_THREAD_PRIMITIVES_HPP -#define BOOST_WIN32_THREAD_PRIMITIVES_HPP - -// win32_thread_primitives.hpp -// -// (C) Copyright 2005-7 Anthony Williams -// (C) Copyright 2007 David Deakins -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include -#include -#include -#include -#include -//#include -#include - -#if BOOST_PLAT_WINDOWS_RUNTIME -#include -#endif - -#if defined( BOOST_USE_WINDOWS_H ) -# include - -namespace boost -{ - namespace detail - { - namespace win32 - { - typedef HANDLE handle; - typedef SYSTEM_INFO system_info; - typedef unsigned __int64 ticks_type; - typedef FARPROC farproc_t; - unsigned const infinite=INFINITE; - unsigned const timeout=WAIT_TIMEOUT; - handle const invalid_handle_value=INVALID_HANDLE_VALUE; - unsigned const event_modify_state=EVENT_MODIFY_STATE; - unsigned const synchronize=SYNCHRONIZE; - unsigned const wait_abandoned=WAIT_ABANDONED; - unsigned const create_event_initial_set = 0x00000002; - unsigned const create_event_manual_reset = 0x00000001; - unsigned const event_all_access = EVENT_ALL_ACCESS; - unsigned const semaphore_all_access = SEMAPHORE_ALL_ACCESS; - - -# ifdef BOOST_NO_ANSI_APIS -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_VISTA - using ::CreateMutexW; - using ::CreateEventW; - using ::CreateSemaphoreW; -# else - using ::CreateMutexExW; - using ::CreateEventExW; - using ::CreateSemaphoreExW; -# endif - using ::OpenEventW; - using ::GetModuleHandleW; -# else - using ::CreateMutexA; - using ::CreateEventA; - using ::OpenEventA; - using ::CreateSemaphoreA; - using ::GetModuleHandleA; -# endif -#if BOOST_PLAT_WINDOWS_RUNTIME - using ::GetNativeSystemInfo; - using ::GetTickCount64; -#else - using ::GetSystemInfo; - using ::GetTickCount; -#endif - using ::CloseHandle; - using ::ReleaseMutex; - using ::ReleaseSemaphore; - using ::SetEvent; - using ::ResetEvent; - using ::WaitForMultipleObjectsEx; - using ::WaitForSingleObjectEx; - using ::GetCurrentProcessId; - using ::GetCurrentThreadId; - using ::GetCurrentThread; - using ::GetCurrentProcess; - using ::DuplicateHandle; -#if !BOOST_PLAT_WINDOWS_RUNTIME - using ::SleepEx; - using ::Sleep; - using ::QueueUserAPC; - using ::GetProcAddress; -#endif - } - } -} -#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) - -# ifdef UNDER_CE -# ifndef WINAPI -# ifndef _WIN32_WCE_EMULATION -# define WINAPI __cdecl // Note this doesn't match the desktop definition -# else -# define WINAPI __stdcall -# endif -# endif - -# ifdef __cplusplus -extern "C" { -# endif -typedef int BOOL; -typedef unsigned long DWORD; -typedef void* HANDLE; -# include -# ifdef __cplusplus -} -# endif -# endif - -# ifdef __cplusplus -extern "C" { -# endif -struct _SYSTEM_INFO; -# ifdef __cplusplus -} -#endif - -namespace boost -{ - namespace detail - { - namespace win32 - { -# ifdef _WIN64 - typedef unsigned __int64 ulong_ptr; -# else - typedef unsigned long ulong_ptr; -# endif - typedef void* handle; - typedef _SYSTEM_INFO system_info; - typedef unsigned __int64 ticks_type; - typedef int (__stdcall *farproc_t)(); - unsigned const infinite=~0U; - unsigned const timeout=258U; - handle const invalid_handle_value=(handle)(-1); - unsigned const event_modify_state=2; - unsigned const synchronize=0x100000u; - unsigned const wait_abandoned=0x00000080u; - unsigned const create_event_initial_set = 0x00000002; - unsigned const create_event_manual_reset = 0x00000001; - unsigned const event_all_access = 0x1F0003; - unsigned const semaphore_all_access = 0x1F0003; - - extern "C" - { - struct _SECURITY_ATTRIBUTES; -# ifdef BOOST_NO_ANSI_APIS -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_VISTA - __declspec(dllimport) void* __stdcall CreateMutexW(_SECURITY_ATTRIBUTES*,int,wchar_t const*); - __declspec(dllimport) void* __stdcall CreateSemaphoreW(_SECURITY_ATTRIBUTES*,long,long,wchar_t const*); - __declspec(dllimport) void* __stdcall CreateEventW(_SECURITY_ATTRIBUTES*,int,int,wchar_t const*); -# else - __declspec(dllimport) void* __stdcall CreateMutexExW(_SECURITY_ATTRIBUTES*,wchar_t const*,unsigned long,unsigned long); - __declspec(dllimport) void* __stdcall CreateEventExW(_SECURITY_ATTRIBUTES*,wchar_t const*,unsigned long,unsigned long); - __declspec(dllimport) void* __stdcall CreateSemaphoreExW(_SECURITY_ATTRIBUTES*,long,long,wchar_t const*,unsigned long,unsigned long); -# endif - __declspec(dllimport) void* __stdcall OpenEventW(unsigned long,int,wchar_t const*); - __declspec(dllimport) void* __stdcall GetModuleHandleW(wchar_t const*); -# else - __declspec(dllimport) void* __stdcall CreateMutexA(_SECURITY_ATTRIBUTES*,int,char const*); - __declspec(dllimport) void* __stdcall CreateSemaphoreA(_SECURITY_ATTRIBUTES*,long,long,char const*); - __declspec(dllimport) void* __stdcall CreateEventA(_SECURITY_ATTRIBUTES*,int,int,char const*); - __declspec(dllimport) void* __stdcall OpenEventA(unsigned long,int,char const*); - __declspec(dllimport) void* __stdcall GetModuleHandleA(char const*); -# endif -#if BOOST_PLAT_WINDOWS_RUNTIME - __declspec(dllimport) void __stdcall GetNativeSystemInfo(_SYSTEM_INFO*); - __declspec(dllimport) ticks_type __stdcall GetTickCount64(); -#else - __declspec(dllimport) void __stdcall GetSystemInfo(_SYSTEM_INFO*); - __declspec(dllimport) unsigned long __stdcall GetTickCount(); -#endif - __declspec(dllimport) int __stdcall CloseHandle(void*); - __declspec(dllimport) int __stdcall ReleaseMutex(void*); - __declspec(dllimport) unsigned long __stdcall WaitForSingleObjectEx(void*,unsigned long,int); - __declspec(dllimport) unsigned long __stdcall WaitForMultipleObjectsEx(unsigned long nCount,void* const * lpHandles,int bWaitAll,unsigned long dwMilliseconds,int bAlertable); - __declspec(dllimport) int __stdcall ReleaseSemaphore(void*,long,long*); - __declspec(dllimport) int __stdcall DuplicateHandle(void*,void*,void*,void**,unsigned long,int,unsigned long); -#if !BOOST_PLAT_WINDOWS_RUNTIME - __declspec(dllimport) unsigned long __stdcall SleepEx(unsigned long,int); - __declspec(dllimport) void __stdcall Sleep(unsigned long); - typedef void (__stdcall *queue_user_apc_callback_function)(ulong_ptr); - __declspec(dllimport) unsigned long __stdcall QueueUserAPC(queue_user_apc_callback_function,void*,ulong_ptr); - __declspec(dllimport) farproc_t __stdcall GetProcAddress(void *, const char *); -#endif - -# ifndef UNDER_CE - __declspec(dllimport) unsigned long __stdcall GetCurrentProcessId(); - __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(); - __declspec(dllimport) void* __stdcall GetCurrentThread(); - __declspec(dllimport) void* __stdcall GetCurrentProcess(); - __declspec(dllimport) int __stdcall SetEvent(void*); - __declspec(dllimport) int __stdcall ResetEvent(void*); -# else - using ::GetCurrentProcessId; - using ::GetCurrentThreadId; - using ::GetCurrentThread; - using ::GetCurrentProcess; - using ::SetEvent; - using ::ResetEvent; -# endif - } - } - } -} -#else -# error "Win32 functions not available" -#endif - -#include - -namespace boost -{ - namespace detail - { - namespace win32 - { - namespace detail { typedef ticks_type (__stdcall *gettickcount64_t)(); } -#if !BOOST_PLAT_WINDOWS_RUNTIME - extern "C" - { -#ifdef _MSC_VER - long _InterlockedCompareExchange(long volatile *, long, long); -#pragma intrinsic(_InterlockedCompareExchange) -#elif defined(__MINGW64_VERSION_MAJOR) - long _InterlockedCompareExchange(long volatile *, long, long); -#else - // Mingw doesn't provide intrinsics -#define _InterlockedCompareExchange InterlockedCompareExchange -#endif - } - // Borrowed from https://stackoverflow.com/questions/8211820/userland-interrupt-timer-access-such-as-via-kequeryinterrupttime-or-similar - inline ticks_type __stdcall GetTickCount64emulation() - { - static volatile long count = 0xFFFFFFFF; - unsigned long previous_count, current_tick32, previous_count_zone, current_tick32_zone; - ticks_type current_tick64; - - previous_count = (unsigned long) _InterlockedCompareExchange(&count, 0, 0); - current_tick32 = GetTickCount(); - - if(previous_count == 0xFFFFFFFF) - { - // count has never been written - unsigned long initial_count; - initial_count = current_tick32 >> 28; - previous_count = (unsigned long) _InterlockedCompareExchange(&count, initial_count, 0xFFFFFFFF); - - current_tick64 = initial_count; - current_tick64 <<= 28; - current_tick64 += current_tick32 & 0x0FFFFFFF; - return current_tick64; - } - - previous_count_zone = previous_count & 15; - current_tick32_zone = current_tick32 >> 28; - - if(current_tick32_zone == previous_count_zone) - { - // The top four bits of the 32-bit tick count haven't changed since count was last written. - current_tick64 = previous_count; - current_tick64 <<= 28; - current_tick64 += current_tick32 & 0x0FFFFFFF; - return current_tick64; - } - - if(current_tick32_zone == previous_count_zone + 1 || (current_tick32_zone == 0 && previous_count_zone == 15)) - { - // The top four bits of the 32-bit tick count have been incremented since count was last written. - _InterlockedCompareExchange(&count, previous_count + 1, previous_count); - current_tick64 = previous_count + 1; - current_tick64 <<= 28; - current_tick64 += current_tick32 & 0x0FFFFFFF; - return current_tick64; - } - - // Oops, we weren't called often enough, we're stuck - return 0xFFFFFFFF; - } -#else -#endif - inline detail::gettickcount64_t GetTickCount64_() - { - static detail::gettickcount64_t gettickcount64impl; - if(gettickcount64impl) - return gettickcount64impl; - - // GetTickCount and GetModuleHandle are not allowed in the Windows Runtime, - // and kernel32 isn't used in Windows Phone. -#if BOOST_PLAT_WINDOWS_RUNTIME - gettickcount64impl = &GetTickCount64; -#else - farproc_t addr=GetProcAddress( -#if !defined(BOOST_NO_ANSI_APIS) - GetModuleHandleA("KERNEL32.DLL"), -#else - GetModuleHandleW(L"KERNEL32.DLL"), -#endif - "GetTickCount64"); - if(addr) - gettickcount64impl=(detail::gettickcount64_t) addr; - else - gettickcount64impl=&GetTickCount64emulation; -#endif - return gettickcount64impl; - } - - enum event_type - { - auto_reset_event=false, - manual_reset_event=true - }; - - enum initial_event_state - { - event_initially_reset=false, - event_initially_set=true - }; - - inline handle create_event( -#if !defined(BOOST_NO_ANSI_APIS) - const char *mutex_name, -#else - const wchar_t *mutex_name, -#endif - event_type type, - initial_event_state state) - { -#if !defined(BOOST_NO_ANSI_APIS) - handle const res = win32::CreateEventA(0, type, state, mutex_name); -#elif BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_VISTA - handle const res = win32::CreateEventW(0, type, state, mutex_name); -#else - handle const res = win32::CreateEventExW( - 0, - mutex_name, - type ? create_event_manual_reset : 0 | state ? create_event_initial_set : 0, - event_all_access); -#endif - return res; - } - - inline handle create_anonymous_event(event_type type,initial_event_state state) - { - handle const res = create_event(0, type, state); - if(!res) - { - boost::throw_exception(thread_resource_error()); - } - return res; - } - - inline handle create_anonymous_semaphore_nothrow(long initial_count,long max_count) - { -#if !defined(BOOST_NO_ANSI_APIS) - handle const res=win32::CreateSemaphoreA(0,initial_count,max_count,0); -#else -#if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_VISTA - handle const res=win32::CreateSemaphoreEx(0,initial_count,max_count,0,0); -#else - handle const res=win32::CreateSemaphoreExW(0,initial_count,max_count,0,0,semaphore_all_access); -#endif -#endif - return res; - } - - inline handle create_anonymous_semaphore(long initial_count,long max_count) - { - handle const res=create_anonymous_semaphore_nothrow(initial_count,max_count); - if(!res) - { - boost::throw_exception(thread_resource_error()); - } - return res; - } - - inline handle duplicate_handle(handle source) - { - handle const current_process=GetCurrentProcess(); - long const same_access_flag=2; - handle new_handle=0; - bool const success=DuplicateHandle(current_process,source,current_process,&new_handle,0,false,same_access_flag)!=0; - if(!success) - { - boost::throw_exception(thread_resource_error()); - } - return new_handle; - } - - inline void release_semaphore(handle semaphore,long count) - { - BOOST_VERIFY(ReleaseSemaphore(semaphore,count,0)!=0); - } - - inline void get_system_info(system_info *info) - { -#if BOOST_PLAT_WINDOWS_RUNTIME - win32::GetNativeSystemInfo(info); -#else - win32::GetSystemInfo(info); -#endif - } - - inline void sleep(unsigned long milliseconds) - { - if(milliseconds == 0) - { -#if BOOST_PLAT_WINDOWS_RUNTIME - std::this_thread::yield(); -#else - ::boost::detail::win32::Sleep(0); -#endif - } - else - { -#if BOOST_PLAT_WINDOWS_RUNTIME - ::boost::detail::win32::WaitForSingleObjectEx(::boost::detail::win32::GetCurrentThread(), milliseconds, 0); -#else - ::boost::detail::win32::Sleep(milliseconds); -#endif - } - } - -#if BOOST_PLAT_WINDOWS_RUNTIME - class BOOST_THREAD_DECL scoped_winrt_thread - { - public: - scoped_winrt_thread() : m_completionHandle(invalid_handle_value) - {} - - ~scoped_winrt_thread() - { - if (m_completionHandle != ::boost::detail::win32::invalid_handle_value) - { - CloseHandle(m_completionHandle); - } - } - - typedef unsigned(__stdcall * thread_func)(void *); - bool start(thread_func address, void *parameter, unsigned int *thrdId); - - handle waitable_handle() const - { - BOOST_ASSERT(m_completionHandle != ::boost::detail::win32::invalid_handle_value); - return m_completionHandle; - } - - private: - handle m_completionHandle; - }; -#endif - class BOOST_THREAD_DECL handle_manager - { - private: - handle handle_to_manage; - handle_manager(handle_manager&); - handle_manager& operator=(handle_manager&); - - void cleanup() - { - if(handle_to_manage && handle_to_manage!=invalid_handle_value) - { - BOOST_VERIFY(CloseHandle(handle_to_manage)); - } - } - - public: - explicit handle_manager(handle handle_to_manage_): - handle_to_manage(handle_to_manage_) - {} - handle_manager(): - handle_to_manage(0) - {} - - handle_manager& operator=(handle new_handle) - { - cleanup(); - handle_to_manage=new_handle; - return *this; - } - - operator handle() const - { - return handle_to_manage; - } - - handle duplicate() const - { - return duplicate_handle(handle_to_manage); - } - - void swap(handle_manager& other) - { - std::swap(handle_to_manage,other.handle_to_manage); - } - - handle release() - { - handle const res=handle_to_manage; - handle_to_manage=0; - return res; - } - - bool operator!() const - { - return !handle_to_manage; - } - - ~handle_manager() - { - cleanup(); - } - }; - } - } -} - -#if defined(BOOST_MSVC) && (_MSC_VER>=1400) && !defined(UNDER_CE) - -namespace boost -{ - namespace detail - { - namespace win32 - { -#if _MSC_VER==1400 - extern "C" unsigned char _interlockedbittestandset(long *a,long b); - extern "C" unsigned char _interlockedbittestandreset(long *a,long b); -#else - extern "C" unsigned char _interlockedbittestandset(volatile long *a,long b); - extern "C" unsigned char _interlockedbittestandreset(volatile long *a,long b); -#endif - -#pragma intrinsic(_interlockedbittestandset) -#pragma intrinsic(_interlockedbittestandreset) - - inline bool interlocked_bit_test_and_set(long* x,long bit) - { - return _interlockedbittestandset(x,bit)!=0; - } - - inline bool interlocked_bit_test_and_reset(long* x,long bit) - { - return _interlockedbittestandreset(x,bit)!=0; - } - - } - } -} -#define BOOST_THREAD_BTS_DEFINED -#elif (defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN)) && defined(_M_IX86) -namespace boost -{ - namespace detail - { - namespace win32 - { - inline bool interlocked_bit_test_and_set(long* x,long bit) - { -#ifndef BOOST_INTEL_CXX_VERSION - __asm { - mov eax,bit; - mov edx,x; - lock bts [edx],eax; - setc al; - }; -#else - bool ret; - __asm { - mov eax,bit - mov edx,x - lock bts [edx],eax - setc al - mov ret, al - }; - return ret; - -#endif - } - - inline bool interlocked_bit_test_and_reset(long* x,long bit) - { -#ifndef BOOST_INTEL_CXX_VERSION - __asm { - mov eax,bit; - mov edx,x; - lock btr [edx],eax; - setc al; - }; -#else - bool ret; - __asm { - mov eax,bit - mov edx,x - lock btr [edx],eax - setc al - mov ret, al - }; - return ret; - -#endif - } - - } - } -} -#define BOOST_THREAD_BTS_DEFINED -#endif - -#ifndef BOOST_THREAD_BTS_DEFINED - -namespace boost -{ - namespace detail - { - namespace win32 - { - inline bool interlocked_bit_test_and_set(long* x,long bit) - { - long const value=1< - -#endif diff --git a/libraries/boost/boost/thread/with_lock_guard.hpp b/libraries/boost/boost/thread/with_lock_guard.hpp deleted file mode 100644 index 5d99b36f2..000000000 --- a/libraries/boost/boost/thread/with_lock_guard.hpp +++ /dev/null @@ -1,234 +0,0 @@ -// (C) Copyright 2013 Ruslan Baratov -// Copyright (C) 2014 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See www.boost.org/libs/thread for documentation. - -#ifndef BOOST_THREAD_WITH_LOCK_GUARD_HPP -#define BOOST_THREAD_WITH_LOCK_GUARD_HPP - -#include -#include -//#include - -namespace boost { - -#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \ - !defined(BOOST_NO_CXX11_DECLTYPE) && \ - !defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) - -/** - * Utility to run functions in scope protected by mutex. - * - * Examples: - * - * int func(int, int&); - * boost::mutex m; - * int a; - * int result = boost::with_lock_guard(m, func, 1, boost::ref(a)); - * - * // using boost::bind - * int result = boost::with_lock_guard( - * m, boost::bind(func, 2, boost::ref(a)) - * ); - * - * // using lambda - * int a; - * int result = boost::with_lock_guard( - * m, - * [&a](int x) { - * a = 3; - * return x + 4; - * }, - * 5 - * ); - */ -template -typename boost::result_of::type with_lock_guard( - Lockable& m, - BOOST_FWD_REF(Function) func, - BOOST_FWD_REF(Args)... args -) //-> decltype(func(boost::forward(args)...)) -{ - boost::lock_guard lock(m); - return func(boost::forward(args)...); -} - -#else - -// Workaround versions for compilers without c++11 variadic templates support. -// (function arguments limit: 4) -// (for lambda support define BOOST_RESULT_OF_USE_DECLTYPE may be needed) - -template -typename boost::result_of::type with_lock_guard( - Lockable& m, - BOOST_FWD_REF(Func) func -) { - boost::lock_guard lock(m); - return func(); -} - -template -typename boost::result_of::type with_lock_guard( - Lockable& m, - BOOST_FWD_REF(Func) func, - BOOST_FWD_REF(Arg) arg -) { - boost::lock_guard lock(m); - return func( - boost::forward(arg) - ); -} - -template -typename boost::result_of::type with_lock_guard( - Lockable& m, - BOOST_FWD_REF(Func) func, - BOOST_FWD_REF(Arg1) arg1, - BOOST_FWD_REF(Arg2) arg2 -) { - boost::lock_guard lock(m); - return func( - boost::forward(arg1), - boost::forward(arg2) - ); -} - -template -typename boost::result_of::type with_lock_guard( - Lockable& m, - BOOST_FWD_REF(Func) func, - BOOST_FWD_REF(Arg1) arg1, - BOOST_FWD_REF(Arg2) arg2, - BOOST_FWD_REF(Arg3) arg3 -) { - boost::lock_guard lock(m); - return func( - boost::forward(arg1), - boost::forward(arg2), - boost::forward(arg3) - ); -} - -template < - class Lockable, class Func, class Arg1, class Arg2, class Arg3, class Arg4 -> -typename boost::result_of::type with_lock_guard( - Lockable& m, - BOOST_FWD_REF(Func) func, - BOOST_FWD_REF(Arg1) arg1, - BOOST_FWD_REF(Arg2) arg2, - BOOST_FWD_REF(Arg3) arg3, - BOOST_FWD_REF(Arg4) arg4 -) { - boost::lock_guard lock(m); - return func( - boost::forward(arg1), - boost::forward(arg2), - boost::forward(arg3), - boost::forward(arg4) - ); -} - -// overloads for function pointer -// (if argument is not function pointer, static assert will trigger) -template -typename boost::result_of< - typename boost::add_pointer::type() ->::type with_lock_guard( - Lockable& m, - Func* func -) { - BOOST_STATIC_ASSERT(boost::is_function::value); - - boost::lock_guard lock(m); - return func(); -} - -template -typename boost::result_of< - typename boost::add_pointer::type(Arg) ->::type with_lock_guard( - Lockable& m, - Func* func, - BOOST_FWD_REF(Arg) arg -) { - BOOST_STATIC_ASSERT(boost::is_function::value); - - boost::lock_guard lock(m); - return func( - boost::forward(arg) - ); -} - -template -typename boost::result_of< - typename boost::add_pointer::type(Arg1, Arg2) ->::type with_lock_guard( - Lockable& m, - Func* func, - BOOST_FWD_REF(Arg1) arg1, - BOOST_FWD_REF(Arg2) arg2 -) { - BOOST_STATIC_ASSERT(boost::is_function::value); - - boost::lock_guard lock(m); - return func( - boost::forward(arg1), - boost::forward(arg2) - ); -} - -template -typename boost::result_of< - typename boost::add_pointer::type(Arg1, Arg2, Arg3) ->::type with_lock_guard( - Lockable& m, - Func* func, - BOOST_FWD_REF(Arg1) arg1, - BOOST_FWD_REF(Arg2) arg2, - BOOST_FWD_REF(Arg3) arg3 -) { - BOOST_STATIC_ASSERT(boost::is_function::value); - - boost::lock_guard lock(m); - return func( - boost::forward(arg1), - boost::forward(arg2), - boost::forward(arg3) - ); -} - -template < - class Lockable, class Func, class Arg1, class Arg2, class Arg3, class Arg4 -> -typename boost::result_of< - typename boost::add_pointer::type(Arg1, Arg2, Arg3, Arg4) ->::type with_lock_guard( - Lockable& m, - Func* func, - BOOST_FWD_REF(Arg1) arg1, - BOOST_FWD_REF(Arg2) arg2, - BOOST_FWD_REF(Arg3) arg3, - BOOST_FWD_REF(Arg4) arg4 -) { - BOOST_STATIC_ASSERT(boost::is_function::value); - - boost::lock_guard lock(m); - return func( - boost::forward(arg1), - boost::forward(arg2), - boost::forward(arg3), - boost::forward(arg4) - ); -} - -#endif - -} // namespace boost - -#endif // BOOST_THREAD_WITH_LOCK_GUARD_HPP - diff --git a/libraries/boost/boost/thread/xtime.hpp b/libraries/boost/boost/thread/xtime.hpp deleted file mode 100644 index 9c6a35964..000000000 --- a/libraries/boost/boost/thread/xtime.hpp +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2001-2003 -// William E. Kempf -// Copyright (C) 2007-8 Anthony Williams -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_XTIME_WEK070601_HPP -#define BOOST_XTIME_WEK070601_HPP - -#include -#if defined BOOST_THREAD_USES_DATETIME - -#include -#include -#include - -#include - -namespace boost { - -enum xtime_clock_types -{ - TIME_UTC_=1 -// TIME_TAI, -// TIME_MONOTONIC, -// TIME_PROCESS, -// TIME_THREAD, -// TIME_LOCAL, -// TIME_SYNC, -// TIME_RESOLUTION -}; - -struct xtime -{ -#if defined(BOOST_NO_INT64_T) - typedef int_fast32_t xtime_sec_t; //INT_FAST32_MIN <= sec <= INT_FAST32_MAX -#else - typedef int_fast64_t xtime_sec_t; //INT_FAST64_MIN <= sec <= INT_FAST64_MAX -#endif - - typedef int_fast32_t xtime_nsec_t; //0 <= xtime.nsec < NANOSECONDS_PER_SECOND - - xtime_sec_t sec; - xtime_nsec_t nsec; - - operator system_time() const - { - return boost::posix_time::from_time_t(0)+ - boost::posix_time::seconds(static_cast(sec))+ -#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS - boost::posix_time::nanoseconds(nsec); -#else - boost::posix_time::microseconds((nsec+500)/1000); -#endif - } - -}; - -inline xtime get_xtime(boost::system_time const& abs_time) -{ - xtime res; - boost::posix_time::time_duration const time_since_epoch=abs_time-boost::posix_time::from_time_t(0); - - res.sec=static_cast(time_since_epoch.total_seconds()); - res.nsec=static_cast(time_since_epoch.fractional_seconds()*(1000000000/time_since_epoch.ticks_per_second())); - return res; -} - -inline int xtime_get(struct xtime* xtp, int clock_type) -{ - if (clock_type == TIME_UTC_) - { - *xtp=get_xtime(get_system_time()); - return clock_type; - } - return 0; -} - - -inline int xtime_cmp(const xtime& xt1, const xtime& xt2) -{ - if (xt1.sec == xt2.sec) - return (int)(xt1.nsec - xt2.nsec); - else - return (xt1.sec > xt2.sec) ? 1 : -1; -} - -} // namespace boost - -#include -#endif -#endif //BOOST_XTIME_WEK070601_HPP diff --git a/libraries/boost/libs/system/src/error_code.cpp b/libraries/boost/libs/system/src/error_code.cpp deleted file mode 100644 index aa628ab30..000000000 --- a/libraries/boost/libs/system/src/error_code.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// error_code support implementation file ----------------------------------// - -// Copyright Beman Dawes 2002, 2006 - -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See library home page at http://www.boost.org/libs/system - -//----------------------------------------------------------------------------// - -// define BOOST_SYSTEM_SOURCE so that knows -// the library is being built (possibly exporting rather than importing code) -#define BOOST_SYSTEM_SOURCE - -#include - -#ifndef BOOST_ERROR_CODE_HEADER_ONLY -#include -#endif diff --git a/libraries/boost/libs/thread/src/future.cpp b/libraries/boost/libs/thread/src/future.cpp deleted file mode 100644 index 4aeac94a1..000000000 --- a/libraries/boost/libs/thread/src/future.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// (C) Copyright 2012 Vicente J. Botet Escriba -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#ifndef BOOST_NO_EXCEPTIONS - - -#include -#include - -namespace boost -{ - - namespace thread_detail - { - - class future_error_category : - public boost::system::error_category - { - public: - virtual const char* name() const BOOST_NOEXCEPT; - virtual std::string message(int ev) const; - }; - - const char* - future_error_category::name() const BOOST_NOEXCEPT - { - return "future"; - } - - std::string - future_error_category::message(int ev) const - { - switch (BOOST_SCOPED_ENUM_NATIVE(future_errc)(ev)) - { - case future_errc::broken_promise: - return std::string("The associated promise has been destructed prior " - "to the associated state becoming ready."); - case future_errc::future_already_retrieved: - return std::string("The future has already been retrieved from " - "the promise or packaged_task."); - case future_errc::promise_already_satisfied: - return std::string("The state of the promise has already been set."); - case future_errc::no_state: - return std::string("Operation not permitted on an object without " - "an associated state."); - } - return std::string("unspecified future_errc value\n"); - } - future_error_category future_error_category_var; - } - - BOOST_THREAD_DECL - const system::error_category& - future_category() BOOST_NOEXCEPT - { - return thread_detail::future_error_category_var; - } - -} -#endif - diff --git a/libraries/boost/libs/thread/src/pthread/once.cpp b/libraries/boost/libs/thread/src/pthread/once.cpp deleted file mode 100644 index 2395cff6d..000000000 --- a/libraries/boost/libs/thread/src/pthread/once.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2007 Anthony Williams -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#ifdef BOOST_THREAD_ONCE_ATOMIC -#include "./once_atomic.cpp" -#else -#define __STDC_CONSTANT_MACROS -#include -#include -#include -#include -#include -#include -#include -#include // memcmp. -namespace boost -{ - namespace thread_detail - { - BOOST_THREAD_DECL uintmax_atomic_t once_global_epoch=BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_MAX_C; - BOOST_THREAD_DECL pthread_mutex_t once_epoch_mutex=PTHREAD_MUTEX_INITIALIZER; - BOOST_THREAD_DECL pthread_cond_t once_epoch_cv = PTHREAD_COND_INITIALIZER; - - namespace - { - pthread_key_t epoch_tss_key; - pthread_once_t epoch_tss_key_flag=PTHREAD_ONCE_INIT; - - extern "C" - { - static void delete_epoch_tss_data(void* data) - { - free(data); - } - - static void create_epoch_tss_key() - { - BOOST_VERIFY(!pthread_key_create(&epoch_tss_key,delete_epoch_tss_data)); - } - } - -#if defined BOOST_THREAD_PATCH - const pthread_once_t pthread_once_init_value=PTHREAD_ONCE_INIT; - struct BOOST_THREAD_DECL delete_epoch_tss_key_on_dlclose_t - { - delete_epoch_tss_key_on_dlclose_t() - { - } - ~delete_epoch_tss_key_on_dlclose_t() - { - if(memcmp(&epoch_tss_key_flag, &pthread_once_init_value, sizeof(pthread_once_t))) - { - void* data = pthread_getspecific(epoch_tss_key); - if (data) - delete_epoch_tss_data(data); - pthread_key_delete(epoch_tss_key); - } - } - }; - delete_epoch_tss_key_on_dlclose_t delete_epoch_tss_key_on_dlclose; -#endif - } - - uintmax_atomic_t& get_once_per_thread_epoch() - { - BOOST_VERIFY(!pthread_once(&epoch_tss_key_flag,create_epoch_tss_key)); - void* data=pthread_getspecific(epoch_tss_key); - if(!data) - { - data=malloc(sizeof(thread_detail::uintmax_atomic_t)); - if(!data) BOOST_THROW_EXCEPTION(std::bad_alloc()); - BOOST_VERIFY(!pthread_setspecific(epoch_tss_key,data)); - *static_cast(data)=BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_MAX_C; - } - return *static_cast(data); - } - } - -} -#endif // diff --git a/libraries/boost/libs/thread/src/pthread/once_atomic.cpp b/libraries/boost/libs/thread/src/pthread/once_atomic.cpp deleted file mode 100644 index b7ee1dc5b..000000000 --- a/libraries/boost/libs/thread/src/pthread/once_atomic.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// (C) Copyright 2013 Andrey Semashev -// (C) Copyright 2013 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -//#define __STDC_CONSTANT_MACROS -#include -#include -#include -#include -#include -#include -#include -#include - -namespace boost -{ - namespace thread_detail - { - - enum flag_states - { - uninitialized, in_progress, initialized - }; - - -#ifndef BOOST_THREAD_PROVIDES_ONCE_CXX11 - BOOST_STATIC_ASSERT_MSG(sizeof(atomic_int_type) == sizeof(atomic_type), "Boost.Thread: unsupported platform"); -#endif - - static pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER; - static pthread_cond_t once_cv = PTHREAD_COND_INITIALIZER; - - BOOST_THREAD_DECL bool enter_once_region(once_flag& flag) BOOST_NOEXCEPT - { - atomic_type& f = get_atomic_storage(flag); - if (f.load(memory_order_acquire) != initialized) - { - pthread::pthread_mutex_scoped_lock lk(&once_mutex); - if (f.load(memory_order_acquire) != initialized) - { - while (true) - { - atomic_int_type expected = uninitialized; - if (f.compare_exchange_strong(expected, in_progress, memory_order_acq_rel, memory_order_acquire)) - { - // We have set the flag to in_progress - return true; - } - else if (expected == initialized) - { - // Another thread managed to complete the initialization - return false; - } - else - { - // Wait until the initialization is complete - //pthread::pthread_mutex_scoped_lock lk(&once_mutex); - BOOST_VERIFY(!pthread_cond_wait(&once_cv, &once_mutex)); - } - } - } - } - return false; - } - - BOOST_THREAD_DECL void commit_once_region(once_flag& flag) BOOST_NOEXCEPT - { - atomic_type& f = get_atomic_storage(flag); - { - pthread::pthread_mutex_scoped_lock lk(&once_mutex); - f.store(initialized, memory_order_release); - } - BOOST_VERIFY(!pthread_cond_broadcast(&once_cv)); - } - - BOOST_THREAD_DECL void rollback_once_region(once_flag& flag) BOOST_NOEXCEPT - { - atomic_type& f = get_atomic_storage(flag); - { - pthread::pthread_mutex_scoped_lock lk(&once_mutex); - f.store(uninitialized, memory_order_release); - } - BOOST_VERIFY(!pthread_cond_broadcast(&once_cv)); - } - - } // namespace thread_detail - -} // namespace boost diff --git a/libraries/boost/libs/thread/src/pthread/thread.cpp b/libraries/boost/libs/thread/src/pthread/thread.cpp deleted file mode 100644 index 12c3cf960..000000000 --- a/libraries/boost/libs/thread/src/pthread/thread.cpp +++ /dev/null @@ -1,846 +0,0 @@ -// Copyright (C) 2001-2003 -// William E. Kempf -// Copyright (C) 2007-8 Anthony Williams -// (C) Copyright 2011-2012 Vicente J. Botet Escriba -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include - -#include -#if defined BOOST_THREAD_USES_DATETIME -#include -#endif -#include -#include -#include -#include -#include - -#ifdef __GLIBC__ -#include -#elif defined(__APPLE__) || defined(__FreeBSD__) -#include -#include -#elif defined BOOST_HAS_UNISTD_H -#include -#endif - -#include -#include -#include - -#include -#include -#include -#include -#include // memcmp. - -namespace boost -{ - namespace detail - { - thread_data_base::~thread_data_base() - { - for (notify_list_t::iterator i = notify.begin(), e = notify.end(); - i != e; ++i) - { - i->second->unlock(); - i->first->notify_all(); - } - for (async_states_t::iterator i = async_states_.begin(), e = async_states_.end(); - i != e; ++i) - { - (*i)->make_ready(); - } - } - - struct thread_exit_callback_node - { - boost::detail::thread_exit_function_base* func; - thread_exit_callback_node* next; - - thread_exit_callback_node(boost::detail::thread_exit_function_base* func_, - thread_exit_callback_node* next_): - func(func_),next(next_) - {} - }; - - namespace - { -#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11 - boost::once_flag current_thread_tls_init_flag; -#else - boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT; -#endif - pthread_key_t current_thread_tls_key; - - extern "C" - { - static void tls_destructor(void* data) - { - //boost::detail::thread_data_base* thread_info=static_cast(data); - boost::detail::thread_data_ptr thread_info = static_cast(data)->shared_from_this(); - - if(thread_info) - { - while(!thread_info->tss_data.empty() || thread_info->thread_exit_callbacks) - { - - while(thread_info->thread_exit_callbacks) - { - detail::thread_exit_callback_node* const current_node=thread_info->thread_exit_callbacks; - thread_info->thread_exit_callbacks=current_node->next; - if(current_node->func) - { - (*current_node->func)(); - delete current_node->func; - } - delete current_node; - } - while (!thread_info->tss_data.empty()) - { - std::map::iterator current - = thread_info->tss_data.begin(); - if(current->second.func && (current->second.value!=0)) - { - (*current->second.func)(current->second.value); - } - thread_info->tss_data.erase(current); - } - } - thread_info->self.reset(); - } - } - } - -#if defined BOOST_THREAD_PATCH - struct delete_current_thread_tls_key_on_dlclose_t - { - delete_current_thread_tls_key_on_dlclose_t() - { - } - ~delete_current_thread_tls_key_on_dlclose_t() - { - const boost::once_flag uninitialized = BOOST_ONCE_INIT; - if (memcmp(¤t_thread_tls_init_flag, &uninitialized, sizeof(boost::once_flag))) - { - void* data = pthread_getspecific(current_thread_tls_key); - if (data) - tls_destructor(data); - pthread_key_delete(current_thread_tls_key); - } - } - }; - delete_current_thread_tls_key_on_dlclose_t delete_current_thread_tls_key_on_dlclose; -#endif - void create_current_thread_tls_key() - { - BOOST_VERIFY(!pthread_key_create(¤t_thread_tls_key,&tls_destructor)); - } - } - - boost::detail::thread_data_base* get_current_thread_data() - { - boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key); - return (boost::detail::thread_data_base*)pthread_getspecific(current_thread_tls_key); - } - - void set_current_thread_data(detail::thread_data_base* new_data) - { - boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key); - BOOST_VERIFY(!pthread_setspecific(current_thread_tls_key,new_data)); - } - } - - namespace - { - extern "C" - { - static void* thread_proxy(void* param) - { - //boost::detail::thread_data_ptr thread_info = static_cast(param)->self; - boost::detail::thread_data_ptr thread_info = static_cast(param)->shared_from_this(); - thread_info->self.reset(); - detail::set_current_thread_data(thread_info.get()); -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - BOOST_TRY - { -#endif - thread_info->run(); -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - - } - BOOST_CATCH (thread_interrupted const&) - { - } -// Removed as it stops the debugger identifying the cause of the exception -// Unhandled exceptions still cause the application to terminate -// BOOST_CATCH(...) -// { -// throw; -// -// std::terminate(); -// } - BOOST_CATCH_END -#endif - detail::tls_destructor(thread_info.get()); - detail::set_current_thread_data(0); - boost::lock_guard lock(thread_info->data_mutex); - thread_info->done=true; - thread_info->done_condition.notify_all(); - - return 0; - } - } - } - namespace detail - { - struct externally_launched_thread: - detail::thread_data_base - { - externally_launched_thread() - { -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - interrupt_enabled=false; -#endif - } - ~externally_launched_thread() { - BOOST_ASSERT(notify.empty()); - notify.clear(); - BOOST_ASSERT(async_states_.empty()); - async_states_.clear(); - } - void run() - {} - void notify_all_at_thread_exit(condition_variable*, mutex*) - {} - - private: - externally_launched_thread(externally_launched_thread&); - void operator=(externally_launched_thread&); - }; - - thread_data_base* make_external_thread_data() - { - thread_data_base* const me(detail::heap_new()); - me->self.reset(me); - set_current_thread_data(me); - return me; - } - - - thread_data_base* get_or_make_current_thread_data() - { - thread_data_base* current_thread_data(get_current_thread_data()); - if(!current_thread_data) - { - current_thread_data=make_external_thread_data(); - } - return current_thread_data; - } - - } - - - thread::thread() BOOST_NOEXCEPT - {} - - bool thread::start_thread_noexcept() - { - thread_info->self=thread_info; - int const res = pthread_create(&thread_info->thread_handle, 0, &thread_proxy, thread_info.get()); - if (res != 0) - { - thread_info->self.reset(); - return false; - } - return true; - } - - bool thread::start_thread_noexcept(const attributes& attr) - { - thread_info->self=thread_info; - const attributes::native_handle_type* h = attr.native_handle(); - int res = pthread_create(&thread_info->thread_handle, h, &thread_proxy, thread_info.get()); - if (res != 0) - { - thread_info->self.reset(); - return false; - } - int detached_state; - res = pthread_attr_getdetachstate(h, &detached_state); - if (res != 0) - { - thread_info->self.reset(); - return false; - } - if (PTHREAD_CREATE_DETACHED==detached_state) - { - detail::thread_data_ptr local_thread_info; - thread_info.swap(local_thread_info); - - if(local_thread_info) - { - //lock_guard lock(local_thread_info->data_mutex); - if(!local_thread_info->join_started) - { - //BOOST_VERIFY(!pthread_detach(local_thread_info->thread_handle)); - local_thread_info->join_started=true; - local_thread_info->joined=true; - } - } - } - return true; - } - - - - detail::thread_data_ptr thread::get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const - { - return thread_info; - } - - bool thread::join_noexcept() - { - detail::thread_data_ptr const local_thread_info=(get_thread_info)(); - if(local_thread_info) - { - bool do_join=false; - - { - unique_lock lock(local_thread_info->data_mutex); - while(!local_thread_info->done) - { - local_thread_info->done_condition.wait(lock); - } - do_join=!local_thread_info->join_started; - - if(do_join) - { - local_thread_info->join_started=true; - } - else - { - while(!local_thread_info->joined) - { - local_thread_info->done_condition.wait(lock); - } - } - } - if(do_join) - { - void* result=0; - BOOST_VERIFY(!pthread_join(local_thread_info->thread_handle,&result)); - lock_guard lock(local_thread_info->data_mutex); - local_thread_info->joined=true; - local_thread_info->done_condition.notify_all(); - } - - if(thread_info==local_thread_info) - { - thread_info.reset(); - } - return true; - } - else - { - return false; - } - } - - bool thread::do_try_join_until_noexcept(struct timespec const &timeout, bool& res) - { - detail::thread_data_ptr const local_thread_info=(get_thread_info)(); - if(local_thread_info) - { - bool do_join=false; - - { - unique_lock lock(local_thread_info->data_mutex); - while(!local_thread_info->done) - { - if(!local_thread_info->done_condition.do_wait_until(lock,timeout)) - { - res=false; - return true; - } - } - do_join=!local_thread_info->join_started; - - if(do_join) - { - local_thread_info->join_started=true; - } - else - { - while(!local_thread_info->joined) - { - local_thread_info->done_condition.wait(lock); - } - } - } - if(do_join) - { - void* result=0; - BOOST_VERIFY(!pthread_join(local_thread_info->thread_handle,&result)); - lock_guard lock(local_thread_info->data_mutex); - local_thread_info->joined=true; - local_thread_info->done_condition.notify_all(); - } - - if(thread_info==local_thread_info) - { - thread_info.reset(); - } - res=true; - return true; - } - else - { - return false; - } - } - - bool thread::joinable() const BOOST_NOEXCEPT - { - return (get_thread_info)()?true:false; - } - - - void thread::detach() - { - detail::thread_data_ptr local_thread_info; - thread_info.swap(local_thread_info); - - if(local_thread_info) - { - lock_guard lock(local_thread_info->data_mutex); - if(!local_thread_info->join_started) - { - BOOST_VERIFY(!pthread_detach(local_thread_info->thread_handle)); - local_thread_info->join_started=true; - local_thread_info->joined=true; - } - } - } - - namespace this_thread - { - namespace no_interruption_point - { - namespace hidden - { - void BOOST_THREAD_DECL sleep_for(const timespec& ts) - { - - if (boost::detail::timespec_ge(ts, boost::detail::timespec_zero())) - { - - # if defined(BOOST_HAS_PTHREAD_DELAY_NP) - # if defined(__IBMCPP__) || defined(_AIX) - BOOST_VERIFY(!pthread_delay_np(const_cast(&ts))); - # else - BOOST_VERIFY(!pthread_delay_np(&ts)); - # endif - # elif defined(BOOST_HAS_NANOSLEEP) - // nanosleep takes a timespec that is an offset, not - // an absolute time. - nanosleep(&ts, 0); - # else - mutex mx; - unique_lock lock(mx); - condition_variable cond; - cond.do_wait_for(lock, ts); - # endif - } - } - - void BOOST_THREAD_DECL sleep_until(const timespec& ts) - { - timespec now = boost::detail::timespec_now(); - if (boost::detail::timespec_gt(ts, now)) - { - for (int foo=0; foo < 5; ++foo) - { - - # if defined(BOOST_HAS_PTHREAD_DELAY_NP) - timespec d = boost::detail::timespec_minus(ts, now); - BOOST_VERIFY(!pthread_delay_np(&d)); - # elif defined(BOOST_HAS_NANOSLEEP) - // nanosleep takes a timespec that is an offset, not - // an absolute time. - timespec d = boost::detail::timespec_minus(ts, now); - nanosleep(&d, 0); - # else - mutex mx; - unique_lock lock(mx); - condition_variable cond; - cond.do_wait_until(lock, ts); - # endif - timespec now2 = boost::detail::timespec_now(); - if (boost::detail::timespec_ge(now2, ts)) - { - return; - } - } - } - } - - } - } - namespace hidden - { - void BOOST_THREAD_DECL sleep_for(const timespec& ts) - { - boost::detail::thread_data_base* const thread_info=boost::detail::get_current_thread_data(); - - if(thread_info) - { - unique_lock lk(thread_info->sleep_mutex); - while( thread_info->sleep_condition.do_wait_for(lk,ts)) {} - } - else - { - boost::this_thread::no_interruption_point::hidden::sleep_for(ts); - } - } - - void BOOST_THREAD_DECL sleep_until(const timespec& ts) - { - boost::detail::thread_data_base* const thread_info=boost::detail::get_current_thread_data(); - - if(thread_info) - { - unique_lock lk(thread_info->sleep_mutex); - while(thread_info->sleep_condition.do_wait_until(lk,ts)) {} - } - else - { - boost::this_thread::no_interruption_point::hidden::sleep_until(ts); - } - } - } // hidden - } // this_thread - - namespace this_thread - { - void yield() BOOST_NOEXCEPT - { -# if defined(BOOST_HAS_SCHED_YIELD) - BOOST_VERIFY(!sched_yield()); -# elif defined(BOOST_HAS_PTHREAD_YIELD) - BOOST_VERIFY(!pthread_yield()); -//# elif defined BOOST_THREAD_USES_DATETIME -// xtime xt; -// xtime_get(&xt, TIME_UTC_); -// sleep(xt); -// sleep_for(chrono::milliseconds(0)); -# else -#error - timespec ts; - ts.tv_sec= 0; - ts.tv_nsec= 0; - hidden::sleep_for(ts); -# endif - } - } - unsigned thread::hardware_concurrency() BOOST_NOEXCEPT - { -#if defined(PTW32_VERSION) || defined(__hpux) - return pthread_num_processors_np(); -#elif defined(__APPLE__) || defined(__FreeBSD__) - int count; - size_t size=sizeof(count); - return sysctlbyname("hw.ncpu",&count,&size,NULL,0)?0:count; -#elif defined(BOOST_HAS_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN) - int const count=sysconf(_SC_NPROCESSORS_ONLN); - return (count>0)?count:0; -#elif defined(__GLIBC__) - return get_nprocs(); -#else - return 0; -#endif - } - - unsigned thread::physical_concurrency() BOOST_NOEXCEPT - { -#ifdef __linux__ - try { - using namespace std; - - ifstream proc_cpuinfo ("/proc/cpuinfo"); - - const string physical_id("physical id"), core_id("core id"); - - typedef std::pair core_entry; // [physical ID, core id] - - std::set cores; - - core_entry current_core_entry; - - string line; - while ( getline(proc_cpuinfo, line) ) { - if (line.empty()) - continue; - - vector key_val(2); - boost::split(key_val, line, boost::is_any_of(":")); - - if (key_val.size() != 2) - return hardware_concurrency(); - - string key = key_val[0]; - string value = key_val[1]; - boost::trim(key); - boost::trim(value); - - if (key == physical_id) { - current_core_entry.first = boost::lexical_cast(value); - continue; - } - - if (key == core_id) { - current_core_entry.second = boost::lexical_cast(value); - cores.insert(current_core_entry); - continue; - } - } - // Fall back to hardware_concurrency() in case - // /proc/cpuinfo is formatted differently than we expect. - return cores.size() != 0 ? cores.size() : hardware_concurrency(); - } catch(...) { - return hardware_concurrency(); - } -#elif defined(__APPLE__) - int count; - size_t size=sizeof(count); - return sysctlbyname("hw.physicalcpu",&count,&size,NULL,0)?0:count; -#else - return hardware_concurrency(); -#endif - } - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - void thread::interrupt() - { - detail::thread_data_ptr const local_thread_info=(get_thread_info)(); - if(local_thread_info) - { - lock_guard lk(local_thread_info->data_mutex); - local_thread_info->interrupt_requested=true; - if(local_thread_info->current_cond) - { - boost::pthread::pthread_mutex_scoped_lock internal_lock(local_thread_info->cond_mutex); - BOOST_VERIFY(!pthread_cond_broadcast(local_thread_info->current_cond)); - } - } - } - - bool thread::interruption_requested() const BOOST_NOEXCEPT - { - detail::thread_data_ptr const local_thread_info=(get_thread_info)(); - if(local_thread_info) - { - lock_guard lk(local_thread_info->data_mutex); - return local_thread_info->interrupt_requested; - } - else - { - return false; - } - } -#endif - - thread::native_handle_type thread::native_handle() - { - detail::thread_data_ptr const local_thread_info=(get_thread_info)(); - if(local_thread_info) - { - lock_guard lk(local_thread_info->data_mutex); - return local_thread_info->thread_handle; - } - else - { - return pthread_t(); - } - } - - - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - namespace this_thread - { - void interruption_point() - { -#ifndef BOOST_NO_EXCEPTIONS - boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data(); - if(thread_info && thread_info->interrupt_enabled) - { - lock_guard lg(thread_info->data_mutex); - if(thread_info->interrupt_requested) - { - thread_info->interrupt_requested=false; - throw thread_interrupted(); - } - } -#endif - } - - bool interruption_enabled() BOOST_NOEXCEPT - { - boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data(); - return thread_info && thread_info->interrupt_enabled; - } - - bool interruption_requested() BOOST_NOEXCEPT - { - boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data(); - if(!thread_info) - { - return false; - } - else - { - lock_guard lg(thread_info->data_mutex); - return thread_info->interrupt_requested; - } - } - - disable_interruption::disable_interruption() BOOST_NOEXCEPT: - interruption_was_enabled(interruption_enabled()) - { - if(interruption_was_enabled) - { - detail::get_current_thread_data()->interrupt_enabled=false; - } - } - - disable_interruption::~disable_interruption() BOOST_NOEXCEPT - { - if(detail::get_current_thread_data()) - { - detail::get_current_thread_data()->interrupt_enabled=interruption_was_enabled; - } - } - - restore_interruption::restore_interruption(disable_interruption& d) BOOST_NOEXCEPT - { - if(d.interruption_was_enabled) - { - detail::get_current_thread_data()->interrupt_enabled=true; - } - } - - restore_interruption::~restore_interruption() BOOST_NOEXCEPT - { - if(detail::get_current_thread_data()) - { - detail::get_current_thread_data()->interrupt_enabled=false; - } - } - } -#endif - - namespace detail - { - void add_thread_exit_function(thread_exit_function_base* func) - { - detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); - thread_exit_callback_node* const new_node= - heap_new(func,current_thread_data->thread_exit_callbacks); - current_thread_data->thread_exit_callbacks=new_node; - } - - tss_data_node* find_tss_data(void const* key) - { - detail::thread_data_base* const current_thread_data(get_current_thread_data()); - if(current_thread_data) - { - std::map::iterator current_node= - current_thread_data->tss_data.find(key); - if(current_node!=current_thread_data->tss_data.end()) - { - return ¤t_node->second; - } - } - return 0; - } - - void* get_tss_data(void const* key) - { - if(tss_data_node* const current_node=find_tss_data(key)) - { - return current_node->value; - } - return 0; - } - - void add_new_tss_node(void const* key, - boost::shared_ptr func, - void* tss_data) - { - detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); - current_thread_data->tss_data.insert(std::make_pair(key,tss_data_node(func,tss_data))); - } - - void erase_tss_node(void const* key) - { - detail::thread_data_base* const current_thread_data(get_current_thread_data()); - if(current_thread_data) - { - current_thread_data->tss_data.erase(key); - } - } - - void set_tss_data(void const* key, - boost::shared_ptr func, - void* tss_data,bool cleanup_existing) - { - if(tss_data_node* const current_node=find_tss_data(key)) - { - if(cleanup_existing && current_node->func && (current_node->value!=0)) - { - (*current_node->func)(current_node->value); - } - if(func || (tss_data!=0)) - { - current_node->func=func; - current_node->value=tss_data; - } - else - { - erase_tss_node(key); - } - } - else if(func || (tss_data!=0)) - { - add_new_tss_node(key,func,tss_data); - } - } - } - - BOOST_THREAD_DECL void notify_all_at_thread_exit(condition_variable& cond, unique_lock lk) - { - detail::thread_data_base* const current_thread_data(detail::get_current_thread_data()); - if(current_thread_data) - { - current_thread_data->notify_all_at_thread_exit(&cond, lk.release()); - } - } -namespace detail { - - void BOOST_THREAD_DECL make_ready_at_thread_exit(shared_ptr as) - { - detail::thread_data_base* const current_thread_data(detail::get_current_thread_data()); - if(current_thread_data) - { - current_thread_data->make_ready_at_thread_exit(as); - } - } -} - - - -} diff --git a/libraries/boost/libs/thread/src/tss_null.cpp b/libraries/boost/libs/thread/src/tss_null.cpp deleted file mode 100644 index b5029f199..000000000 --- a/libraries/boost/libs/thread/src/tss_null.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// (C) Copyright Michael Glassford 2004. -// (C) Copyright 2007 Anthony Williams -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include - -#if defined(BOOST_HAS_WINTHREADS) && (defined(BOOST_THREAD_BUILD_LIB) || defined(BOOST_THREAD_TEST) || defined(UNDER_CE)) && (!defined(_MSC_VER) || defined(UNDER_CE)) - -namespace boost -{ - /* - This file is a "null" implementation of tss cleanup; it's - purpose is to to eliminate link errors in cases - where it is known that tss cleanup is not needed. - */ - - void tss_cleanup_implemented(void) - { - /* - This function's sole purpose is to cause a link error in cases where - automatic tss cleanup is not implemented by Boost.Threads as a - reminder that user code is responsible for calling the necessary - functions at the appropriate times (and for implementing an a - tss_cleanup_implemented() function to eliminate the linker's - missing symbol error). - - If Boost.Threads later implements automatic tss cleanup in cases - where it currently doesn't (which is the plan), the duplicate - symbol error will warn the user that their custom solution is no - longer needed and can be removed. - */ - } - -} - -#endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB) && !defined(_MSC_VER) diff --git a/libraries/boost/libs/thread/src/win32/thread.cpp b/libraries/boost/libs/thread/src/win32/thread.cpp deleted file mode 100644 index 7e2c21bc0..000000000 --- a/libraries/boost/libs/thread/src/win32/thread.cpp +++ /dev/null @@ -1,1043 +0,0 @@ -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// (C) Copyright 2007 Anthony Williams -// (C) Copyright 2007 David Deakins -// (C) Copyright 2011-2013 Vicente J. Botet Escriba - -//#define BOOST_THREAD_VERSION 3 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if defined BOOST_THREAD_USES_DATETIME -#include -#include -#endif -#include -#include -#include -#ifndef UNDER_CE -#include -#endif -#include -#include -#include - -#if BOOST_PLAT_WINDOWS_RUNTIME -#include -#include -#include -#include -#include -#include -#include -#include -#pragma comment(lib, "runtimeobject.lib") -#endif - -namespace boost -{ - namespace detail - { - thread_data_base::~thread_data_base() - { - for (notify_list_t::iterator i = notify.begin(), e = notify.end(); - i != e; ++i) - { - i->second->unlock(); - i->first->notify_all(); - } - for (async_states_t::iterator i = async_states_.begin(), e = async_states_.end(); - i != e; ++i) - { - (*i)->make_ready(); - } - } - } - - namespace - { -#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11 - boost::once_flag current_thread_tls_init_flag; -#else - boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT; -#endif -#if defined(UNDER_CE) - // Windows CE does not define the TLS_OUT_OF_INDEXES constant. -#define TLS_OUT_OF_INDEXES 0xFFFFFFFF -#endif -#if !BOOST_PLAT_WINDOWS_RUNTIME - DWORD current_thread_tls_key=TLS_OUT_OF_INDEXES; -#else - __declspec(thread) boost::detail::thread_data_base* current_thread_data_base; -#endif - - void create_current_thread_tls_key() - { - tss_cleanup_implemented(); // if anyone uses TSS, we need the cleanup linked in -#if !BOOST_PLAT_WINDOWS_RUNTIME - current_thread_tls_key=TlsAlloc(); - BOOST_ASSERT(current_thread_tls_key!=TLS_OUT_OF_INDEXES); -#endif - } - - void cleanup_tls_key() - { -#if !BOOST_PLAT_WINDOWS_RUNTIME - if(current_thread_tls_key!=TLS_OUT_OF_INDEXES) - { - TlsFree(current_thread_tls_key); - current_thread_tls_key=TLS_OUT_OF_INDEXES; - } -#endif - } - - void set_current_thread_data(detail::thread_data_base* new_data) - { - boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key); -#if BOOST_PLAT_WINDOWS_RUNTIME - current_thread_data_base = new_data; -#else - if (current_thread_tls_key != TLS_OUT_OF_INDEXES) - { - BOOST_VERIFY(TlsSetValue(current_thread_tls_key, new_data)); - } - else - { - BOOST_VERIFY(false); - //boost::throw_exception(thread_resource_error()); - } -#endif - } - } - - namespace detail - { - thread_data_base* get_current_thread_data() - { -#if BOOST_PLAT_WINDOWS_RUNTIME - return current_thread_data_base; -#else - if (current_thread_tls_key == TLS_OUT_OF_INDEXES) - { - return 0; - } - return (detail::thread_data_base*)TlsGetValue(current_thread_tls_key); -#endif - } - } - - namespace - { -#ifndef BOOST_HAS_THREADEX -// Windows CE doesn't define _beginthreadex - - struct ThreadProxyData - { - typedef unsigned (__stdcall* func)(void*); - func start_address_; - void* arglist_; - ThreadProxyData(func start_address,void* arglist) : start_address_(start_address), arglist_(arglist) {} - }; - - DWORD WINAPI ThreadProxy(LPVOID args) - { - boost::csbl::unique_ptr data(reinterpret_cast(args)); - DWORD ret=data->start_address_(data->arglist_); - return ret; - } - - //typedef void* uintptr_t; - - inline uintptr_t _beginthreadex(void* security, unsigned stack_size, unsigned (__stdcall* start_address)(void*), - void* arglist, unsigned initflag, unsigned* thrdaddr) - { - DWORD threadID; - ThreadProxyData* data = new ThreadProxyData(start_address,arglist); - HANDLE hthread=CreateThread(static_cast(security),stack_size,ThreadProxy, - data,initflag,&threadID); - if (hthread==0) { - delete data; - return 0; - } - *thrdaddr=threadID; - return reinterpret_cast(hthread); - } - -#endif - - } - - namespace detail - { - struct thread_exit_callback_node - { - boost::detail::thread_exit_function_base* func; - thread_exit_callback_node* next; - - thread_exit_callback_node(boost::detail::thread_exit_function_base* func_, - thread_exit_callback_node* next_): - func(func_),next(next_) - {} - }; - - } - -#if BOOST_PLAT_WINDOWS_RUNTIME - namespace detail - { - std::atomic_uint threadCount; - - bool win32::scoped_winrt_thread::start(thread_func address, void *parameter, unsigned int *thrdId) - { - Microsoft::WRL::ComPtr threadPoolFactory; - HRESULT hr = ::Windows::Foundation::GetActivationFactory( - Microsoft::WRL::Wrappers::HStringReference(RuntimeClass_Windows_System_Threading_ThreadPool).Get(), - &threadPoolFactory); - if (hr != S_OK) - { - return false; - } - - // Create event for tracking work item completion. - *thrdId = ++threadCount; - handle completionHandle = CreateEventExW(NULL, NULL, 0, EVENT_ALL_ACCESS); - if (!completionHandle) - { - return false; - } - m_completionHandle = completionHandle; - - // Create new work item. - Microsoft::WRL::ComPtr workItem = - Microsoft::WRL::Callback, ABI::Windows::System::Threading::IWorkItemHandler, Microsoft::WRL::FtmBase>> - ([address, parameter, completionHandle](ABI::Windows::Foundation::IAsyncAction *) - { - // Add a reference since we need to access the completionHandle after the thread_start_function. - // This is to handle cases where detach() was called and run_thread_exit_callbacks() would end - // up closing the handle. - ::boost::detail::thread_data_base* const thread_info(reinterpret_cast<::boost::detail::thread_data_base*>(parameter)); - intrusive_ptr_add_ref(thread_info); - - __try - { - address(parameter); - } - __finally - { - SetEvent(completionHandle); - intrusive_ptr_release(thread_info); - } - return S_OK; - }); - - // Schedule work item on the threadpool. - Microsoft::WRL::ComPtr asyncAction; - hr = threadPoolFactory->RunWithPriorityAndOptionsAsync( - workItem.Get(), - ABI::Windows::System::Threading::WorkItemPriority_Normal, - ABI::Windows::System::Threading::WorkItemOptions_TimeSliced, - &asyncAction); - return hr == S_OK; - } - } -#endif - - namespace - { - void run_thread_exit_callbacks() - { - detail::thread_data_ptr current_thread_data(detail::get_current_thread_data(),false); - if(current_thread_data) - { - while(! current_thread_data->tss_data.empty() || current_thread_data->thread_exit_callbacks) - { - while(current_thread_data->thread_exit_callbacks) - { - detail::thread_exit_callback_node* const current_node=current_thread_data->thread_exit_callbacks; - current_thread_data->thread_exit_callbacks=current_node->next; - if(current_node->func) - { - (*current_node->func)(); - boost::detail::heap_delete(current_node->func); - } - boost::detail::heap_delete(current_node); - } - while (!current_thread_data->tss_data.empty()) - { - std::map::iterator current - = current_thread_data->tss_data.begin(); - if(current->second.func && (current->second.value!=0)) - { - (*current->second.func)(current->second.value); - } - current_thread_data->tss_data.erase(current); - } - } - set_current_thread_data(0); - } - } - - unsigned __stdcall thread_start_function(void* param) - { - detail::thread_data_base* const thread_info(reinterpret_cast(param)); - set_current_thread_data(thread_info); -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - BOOST_TRY - { -#endif - thread_info->run(); -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - } - BOOST_CATCH(thread_interrupted const&) - { - } -// Removed as it stops the debugger identifying the cause of the exception -// Unhandled exceptions still cause the application to terminate -// BOOST_CATCH(...) -// { -// std::terminate(); -// } - BOOST_CATCH_END -#endif - run_thread_exit_callbacks(); - return 0; - } - } - - thread::thread() BOOST_NOEXCEPT - {} - - bool thread::start_thread_noexcept() - { -#if BOOST_PLAT_WINDOWS_RUNTIME - intrusive_ptr_add_ref(thread_info.get()); - if (!thread_info->thread_handle.start(&thread_start_function, thread_info.get(), &thread_info->id)) - { - intrusive_ptr_release(thread_info.get()); -// boost::throw_exception(thread_resource_error()); - return false; - } - return true; -#else - uintptr_t const new_thread=_beginthreadex(0,0,&thread_start_function,thread_info.get(),CREATE_SUSPENDED,&thread_info->id); - if(!new_thread) - { - return false; -// boost::throw_exception(thread_resource_error()); - } - intrusive_ptr_add_ref(thread_info.get()); - thread_info->thread_handle=(detail::win32::handle)(new_thread); - ResumeThread(thread_info->thread_handle); - return true; -#endif - } - - bool thread::start_thread_noexcept(const attributes& attr) - { -#if BOOST_PLAT_WINDOWS_RUNTIME - // Stack size isn't supported with Windows Runtime. - attr; - return start_thread_noexcept(); -#else - //uintptr_t const new_thread=_beginthreadex(attr.get_security(),attr.get_stack_size(),&thread_start_function,thread_info.get(),CREATE_SUSPENDED,&thread_info->id); - uintptr_t const new_thread=_beginthreadex(0,static_cast(attr.get_stack_size()),&thread_start_function,thread_info.get(),CREATE_SUSPENDED,&thread_info->id); - if(!new_thread) - { - return false; -// boost::throw_exception(thread_resource_error()); - } - intrusive_ptr_add_ref(thread_info.get()); - thread_info->thread_handle=(detail::win32::handle)(new_thread); - ResumeThread(thread_info->thread_handle); - return true; -#endif - } - - thread::thread(detail::thread_data_ptr data): - thread_info(data) - {} - - namespace - { - struct externally_launched_thread: - detail::thread_data_base - { - externally_launched_thread() - { - ++count; -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - interruption_enabled=false; -#endif - } - ~externally_launched_thread() { - BOOST_ASSERT(notify.empty()); - notify.clear(); - BOOST_ASSERT(async_states_.empty()); - async_states_.clear(); - } - - void run() - {} - void notify_all_at_thread_exit(condition_variable*, mutex*) - {} - - private: - externally_launched_thread(externally_launched_thread&); - void operator=(externally_launched_thread&); - }; - - void make_external_thread_data() - { - externally_launched_thread* me=detail::heap_new(); - BOOST_TRY - { - set_current_thread_data(me); - } - BOOST_CATCH(...) - { - detail::heap_delete(me); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - detail::thread_data_base* get_or_make_current_thread_data() - { - detail::thread_data_base* current_thread_data(detail::get_current_thread_data()); - if(!current_thread_data) - { - make_external_thread_data(); - current_thread_data=detail::get_current_thread_data(); - } - return current_thread_data; - } - } - - thread::id thread::get_id() const BOOST_NOEXCEPT - { -#if defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID - detail::thread_data_ptr local_thread_info=(get_thread_info)(); - if(!local_thread_info) - { - return 0; - } - return local_thread_info->id; -#else - return thread::id((get_thread_info)()); -#endif - } - - bool thread::joinable() const BOOST_NOEXCEPT - { - detail::thread_data_ptr local_thread_info = (get_thread_info)(); - if(!local_thread_info) - { - return false; - } - return true; - } - bool thread::join_noexcept() - { - detail::thread_data_ptr local_thread_info=(get_thread_info)(); - if(local_thread_info) - { - this_thread::interruptible_wait(this->native_handle(),detail::timeout::sentinel()); - release_handle(); - return true; - } - else - { - return false; - } - } - -#if defined BOOST_THREAD_USES_DATETIME - bool thread::timed_join(boost::system_time const& wait_until) - { - return do_try_join_until(boost::detail::get_milliseconds_until(wait_until)); - } -#endif - bool thread::do_try_join_until_noexcept(uintmax_t milli, bool& res) - { - detail::thread_data_ptr local_thread_info=(get_thread_info)(); - if(local_thread_info) - { - if(!this_thread::interruptible_wait(this->native_handle(),milli)) - { - res=false; - return true; - } - release_handle(); - res=true; - return true; - } - else - { - return false; - } - } - - void thread::detach() - { - release_handle(); - } - - void thread::release_handle() - { - thread_info=0; - } - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - void thread::interrupt() - { - detail::thread_data_ptr local_thread_info=(get_thread_info)(); - if(local_thread_info) - { - local_thread_info->interrupt(); - } - } - - bool thread::interruption_requested() const BOOST_NOEXCEPT - { - detail::thread_data_ptr local_thread_info=(get_thread_info)(); - return local_thread_info.get() && (detail::win32::WaitForSingleObjectEx(local_thread_info->interruption_handle,0,0)==0); - } - -#endif - - unsigned thread::hardware_concurrency() BOOST_NOEXCEPT - { - detail::win32::system_info info; - detail::win32::get_system_info(&info); - return info.dwNumberOfProcessors; - } - - unsigned thread::physical_concurrency() BOOST_NOEXCEPT - { - // a bit too strict: Windows XP with SP3 would be sufficient -#if BOOST_PLAT_WINDOWS_RUNTIME \ - || ( BOOST_USE_WINAPI_VERSION <= BOOST_WINAPI_VERSION_WINXP ) \ - || ( ( defined(__MINGW32__) && !defined(__MINGW64__) ) && _WIN32_WINNT < 0x0600) - return 0; -#else - unsigned cores = 0; - DWORD size = 0; - - GetLogicalProcessorInformation(NULL, &size); - if (ERROR_INSUFFICIENT_BUFFER != GetLastError()) - return 0; - - std::vector buffer(size); - if (GetLogicalProcessorInformation(&buffer.front(), &size) == FALSE) - return 0; - - const size_t Elements = size / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); - - for (size_t i = 0; i < Elements; ++i) { - if (buffer[i].Relationship == RelationProcessorCore) - ++cores; - } - return cores; -#endif - } - - thread::native_handle_type thread::native_handle() - { - detail::thread_data_ptr local_thread_info=(get_thread_info)(); - if(!local_thread_info) - { - return detail::win32::invalid_handle_value; - } -#if BOOST_PLAT_WINDOWS_RUNTIME - // There is no 'real' Win32 handle so we return a handle that at least can be waited on. - return local_thread_info->thread_handle.waitable_handle(); -#else - return (detail::win32::handle)local_thread_info->thread_handle; -#endif - } - - detail::thread_data_ptr thread::get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const - { - return thread_info; - } - - namespace this_thread - { - namespace - { - LARGE_INTEGER get_due_time(detail::timeout const& target_time) - { - LARGE_INTEGER due_time={{0,0}}; - if(target_time.relative) - { - detail::win32::ticks_type const elapsed_milliseconds=detail::win32::GetTickCount64_()()-target_time.start; - LONGLONG const remaining_milliseconds=(target_time.milliseconds-elapsed_milliseconds); - LONGLONG const hundred_nanoseconds_in_one_millisecond=10000; - - if(remaining_milliseconds>0) - { - due_time.QuadPart=-(remaining_milliseconds*hundred_nanoseconds_in_one_millisecond); - } - } - else - { - SYSTEMTIME target_system_time={0,0,0,0,0,0,0,0}; - target_system_time.wYear=target_time.abs_time.date().year(); - target_system_time.wMonth=target_time.abs_time.date().month(); - target_system_time.wDay=target_time.abs_time.date().day(); - target_system_time.wHour=(WORD)target_time.abs_time.time_of_day().hours(); - target_system_time.wMinute=(WORD)target_time.abs_time.time_of_day().minutes(); - target_system_time.wSecond=(WORD)target_time.abs_time.time_of_day().seconds(); - - if(!SystemTimeToFileTime(&target_system_time,((FILETIME*)&due_time))) - { - due_time.QuadPart=0; - } - else - { - long const hundred_nanoseconds_in_one_second=10000000; - posix_time::time_duration::tick_type const ticks_per_second= - target_time.abs_time.time_of_day().ticks_per_second(); - if(ticks_per_second>hundred_nanoseconds_in_one_second) - { - posix_time::time_duration::tick_type const - ticks_per_hundred_nanoseconds= - ticks_per_second/hundred_nanoseconds_in_one_second; - due_time.QuadPart+= - target_time.abs_time.time_of_day().fractional_seconds()/ - ticks_per_hundred_nanoseconds; - } - else - { - due_time.QuadPart+= - target_time.abs_time.time_of_day().fractional_seconds()* - (hundred_nanoseconds_in_one_second/ticks_per_second); - } - } - } - return due_time; - } - } - -#ifndef UNDER_CE -#if !BOOST_PLAT_WINDOWS_RUNTIME - namespace detail_ - { - typedef struct _REASON_CONTEXT { - ULONG Version; - DWORD Flags; - union { - LPWSTR SimpleReasonString; - struct { - HMODULE LocalizedReasonModule; - ULONG LocalizedReasonId; - ULONG ReasonStringCount; - LPWSTR *ReasonStrings; - } Detailed; - } Reason; - } REASON_CONTEXT, *PREASON_CONTEXT; - //static REASON_CONTEXT default_reason_context={0/*POWER_REQUEST_CONTEXT_VERSION*/, 0x00000001/*POWER_REQUEST_CONTEXT_SIMPLE_STRING*/, (LPWSTR)L"generic"}; - typedef BOOL (WINAPI *setwaitabletimerex_t)(HANDLE, const LARGE_INTEGER *, LONG, PTIMERAPCROUTINE, LPVOID, PREASON_CONTEXT, ULONG); - static inline BOOL WINAPI SetWaitableTimerEx_emulation(HANDLE hTimer, const LARGE_INTEGER *lpDueTime, LONG lPeriod, PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext, ULONG TolerableDelay) - { - return SetWaitableTimer(hTimer, lpDueTime, lPeriod, pfnCompletionRoutine, lpArgToCompletionRoutine, FALSE); - } -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 6387) // MSVC sanitiser warns that GetModuleHandleA() might fail -#endif - static inline setwaitabletimerex_t SetWaitableTimerEx() - { - static setwaitabletimerex_t setwaitabletimerex_impl; - if(setwaitabletimerex_impl) - return setwaitabletimerex_impl; - void (*addr)()=(void (*)()) GetProcAddress( -#if !defined(BOOST_NO_ANSI_APIS) - GetModuleHandleA("KERNEL32.DLL"), -#else - GetModuleHandleW(L"KERNEL32.DLL"), -#endif - "SetWaitableTimerEx"); - if(addr) - setwaitabletimerex_impl=(setwaitabletimerex_t) addr; - else - setwaitabletimerex_impl=&SetWaitableTimerEx_emulation; - return setwaitabletimerex_impl; - } -#ifdef _MSC_VER -#pragma warning(pop) -#endif - } -#endif -#endif - bool interruptible_wait(detail::win32::handle handle_to_wait_for,detail::timeout target_time) - { - detail::win32::handle handles[4]={0}; - unsigned handle_count=0; - unsigned wait_handle_index=~0U; -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - unsigned interruption_index=~0U; -#endif - unsigned timeout_index=~0U; - if(handle_to_wait_for!=detail::win32::invalid_handle_value) - { - wait_handle_index=handle_count; - handles[handle_count++]=handle_to_wait_for; - } -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - if(detail::get_current_thread_data() && detail::get_current_thread_data()->interruption_enabled) - { - interruption_index=handle_count; - handles[handle_count++]=detail::get_current_thread_data()->interruption_handle; - } -#endif - detail::win32::handle_manager timer_handle; - -#ifndef UNDER_CE -#if !BOOST_PLAT_WINDOWS_RUNTIME - // Preferentially use coalescing timers for better power consumption and timer accuracy - if(!target_time.is_sentinel()) - { - detail::timeout::remaining_time const time_left=target_time.remaining_milliseconds(); - timer_handle=CreateWaitableTimer(NULL,false,NULL); - if(timer_handle!=0) - { - ULONG tolerable=32; // Empirical testing shows Windows ignores this when <= 26 - if(time_left.milliseconds/20>tolerable) // 5% - tolerable=time_left.milliseconds/20; - LARGE_INTEGER due_time=get_due_time(target_time); - //bool const set_time_succeeded=detail_::SetWaitableTimerEx()(timer_handle,&due_time,0,0,0,&detail_::default_reason_context,tolerable)!=0; - bool const set_time_succeeded=detail_::SetWaitableTimerEx()(timer_handle,&due_time,0,0,0,NULL,tolerable)!=0; - if(set_time_succeeded) - { - timeout_index=handle_count; - handles[handle_count++]=timer_handle; - } - } - } -#endif -#endif - - bool const using_timer=timeout_index!=~0u; - detail::timeout::remaining_time time_left(0); - - do - { - if(!using_timer) - { - time_left=target_time.remaining_milliseconds(); - } - - if(handle_count) - { - unsigned long const notified_index=detail::win32::WaitForMultipleObjectsEx(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds, 0); - if(notified_indexinterruption_handle); - throw thread_interrupted(); - } -#endif - else if(notified_index==timeout_index) - { - return false; - } - } - } - else - { - detail::win32::sleep(time_left.milliseconds); - } - if(target_time.relative) - { - target_time.milliseconds-=detail::timeout::max_non_infinite_wait; - } - } - while(time_left.more); - return false; - } - - namespace no_interruption_point - { - bool non_interruptible_wait(detail::win32::handle handle_to_wait_for,detail::timeout target_time) - { - detail::win32::handle handles[3]={0}; - unsigned handle_count=0; - unsigned wait_handle_index=~0U; - unsigned timeout_index=~0U; - if(handle_to_wait_for!=detail::win32::invalid_handle_value) - { - wait_handle_index=handle_count; - handles[handle_count++]=handle_to_wait_for; - } - detail::win32::handle_manager timer_handle; - -#ifndef UNDER_CE -#if !BOOST_PLAT_WINDOWS_RUNTIME - // Preferentially use coalescing timers for better power consumption and timer accuracy - if(!target_time.is_sentinel()) - { - detail::timeout::remaining_time const time_left=target_time.remaining_milliseconds(); - timer_handle=CreateWaitableTimer(NULL,false,NULL); - if(timer_handle!=0) - { - ULONG tolerable=32; // Empirical testing shows Windows ignores this when <= 26 - if(time_left.milliseconds/20>tolerable) // 5% - tolerable=time_left.milliseconds/20; - LARGE_INTEGER due_time=get_due_time(target_time); - //bool const set_time_succeeded=detail_::SetWaitableTimerEx()(timer_handle,&due_time,0,0,0,&detail_::default_reason_context,tolerable)!=0; - bool const set_time_succeeded=detail_::SetWaitableTimerEx()(timer_handle,&due_time,0,0,0,NULL,tolerable)!=0; - if(set_time_succeeded) - { - timeout_index=handle_count; - handles[handle_count++]=timer_handle; - } - } - } -#endif -#endif - - bool const using_timer=timeout_index!=~0u; - detail::timeout::remaining_time time_left(0); - - do - { - if(!using_timer) - { - time_left=target_time.remaining_milliseconds(); - } - - if(handle_count) - { - unsigned long const notified_index=detail::win32::WaitForMultipleObjectsEx(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds, 0); - if(notified_indexid; - } -#endif - return detail::win32::GetCurrentThreadId(); -#else - return thread::id(get_or_make_current_thread_data()); -#endif - } - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - void interruption_point() - { - if(interruption_enabled() && interruption_requested()) - { - detail::win32::ResetEvent(detail::get_current_thread_data()->interruption_handle); - throw thread_interrupted(); - } - } - - bool interruption_enabled() BOOST_NOEXCEPT - { - return detail::get_current_thread_data() && detail::get_current_thread_data()->interruption_enabled; - } - - bool interruption_requested() BOOST_NOEXCEPT - { - return detail::get_current_thread_data() && (detail::win32::WaitForSingleObjectEx(detail::get_current_thread_data()->interruption_handle,0,0)==0); - } -#endif - - void yield() BOOST_NOEXCEPT - { - detail::win32::sleep(0); - } - -#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS - disable_interruption::disable_interruption() BOOST_NOEXCEPT: - interruption_was_enabled(interruption_enabled()) - { - if(interruption_was_enabled) - { - detail::get_current_thread_data()->interruption_enabled=false; - } - } - - disable_interruption::~disable_interruption() BOOST_NOEXCEPT - { - if(detail::get_current_thread_data()) - { - detail::get_current_thread_data()->interruption_enabled=interruption_was_enabled; - } - } - - restore_interruption::restore_interruption(disable_interruption& d) BOOST_NOEXCEPT - { - if(d.interruption_was_enabled) - { - detail::get_current_thread_data()->interruption_enabled=true; - } - } - - restore_interruption::~restore_interruption() BOOST_NOEXCEPT - { - if(detail::get_current_thread_data()) - { - detail::get_current_thread_data()->interruption_enabled=false; - } - } -#endif - } - - namespace detail - { - void add_thread_exit_function(thread_exit_function_base* func) - { - detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); - thread_exit_callback_node* const new_node= - heap_new( - func,current_thread_data->thread_exit_callbacks); - current_thread_data->thread_exit_callbacks=new_node; - } - - tss_data_node* find_tss_data(void const* key) - { - detail::thread_data_base* const current_thread_data(get_current_thread_data()); - if(current_thread_data) - { - std::map::iterator current_node= - current_thread_data->tss_data.find(key); - if(current_node!=current_thread_data->tss_data.end()) - { - return ¤t_node->second; - } - } - return NULL; - } - - void* get_tss_data(void const* key) - { - if(tss_data_node* const current_node=find_tss_data(key)) - { - return current_node->value; - } - return NULL; - } - - void add_new_tss_node(void const* key, - boost::shared_ptr func, - void* tss_data) - { - detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); - current_thread_data->tss_data.insert(std::make_pair(key,tss_data_node(func,tss_data))); - } - - void erase_tss_node(void const* key) - { - detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); - current_thread_data->tss_data.erase(key); - } - - void set_tss_data(void const* key, - boost::shared_ptr func, - void* tss_data,bool cleanup_existing) - { - if(tss_data_node* const current_node=find_tss_data(key)) - { - if(cleanup_existing && current_node->func && (current_node->value!=0)) - { - (*current_node->func)(current_node->value); - } - if(func || (tss_data!=0)) - { - current_node->func=func; - current_node->value=tss_data; - } - else - { - erase_tss_node(key); - } - } - else if(func || (tss_data!=0)) - { - add_new_tss_node(key,func,tss_data); - } - } - } - - BOOST_THREAD_DECL void __cdecl on_process_enter() - {} - - BOOST_THREAD_DECL void __cdecl on_thread_enter() - {} - - BOOST_THREAD_DECL void __cdecl on_process_exit() - { - boost::cleanup_tls_key(); - } - - BOOST_THREAD_DECL void __cdecl on_thread_exit() - { - boost::run_thread_exit_callbacks(); - } - - BOOST_THREAD_DECL void notify_all_at_thread_exit(condition_variable& cond, unique_lock lk) - { - detail::thread_data_base* const current_thread_data(detail::get_current_thread_data()); - if(current_thread_data) - { - current_thread_data->notify_all_at_thread_exit(&cond, lk.release()); - } - } -//namespace detail { -// -// void BOOST_THREAD_DECL make_ready_at_thread_exit(shared_ptr as) -// { -// detail::thread_data_base* const current_thread_data(detail::get_current_thread_data()); -// if(current_thread_data) -// { -// current_thread_data->make_ready_at_thread_exit(as); -// } -// } -//} -} - diff --git a/libraries/boost/libs/thread/src/win32/tss_dll.cpp b/libraries/boost/libs/thread/src/win32/tss_dll.cpp deleted file mode 100644 index cd71933c1..000000000 --- a/libraries/boost/libs/thread/src/win32/tss_dll.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// (C) Copyright Michael Glassford 2004. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include - - -#if defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL) - - #include - - #include - - #if defined(__BORLANDC__) - extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) - #elif defined(_WIN32_WCE) - extern "C" BOOL WINAPI DllMain(HANDLE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) - #else - extern "C" BOOL WINAPI DllMain(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) - #endif - { - switch(dwReason) - { - case DLL_PROCESS_ATTACH: - { - boost::on_process_enter(); - boost::on_thread_enter(); - break; - } - - case DLL_THREAD_ATTACH: - { - boost::on_thread_enter(); - break; - } - - case DLL_THREAD_DETACH: - { - boost::on_thread_exit(); - break; - } - - case DLL_PROCESS_DETACH: - { - boost::on_thread_exit(); - boost::on_process_exit(); - break; - } - } - - return TRUE; - } - -namespace boost -{ - void tss_cleanup_implemented() - { - /* - This function's sole purpose is to cause a link error in cases where - automatic tss cleanup is not implemented by Boost.Threads as a - reminder that user code is responsible for calling the necessary - functions at the appropriate times (and for implementing an a - tss_cleanup_implemented() function to eliminate the linker's - missing symbol error). - - If Boost.Threads later implements automatic tss cleanup in cases - where it currently doesn't (which is the plan), the duplicate - symbol error will warn the user that their custom solution is no - longer needed and can be removed. - */ - } -} - -#else //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL) - -#ifdef _MSC_VER -// Prevent LNK4221 warning with link=static -namespace boost { namespace link_static_warning_inhibit { - extern __declspec(dllexport) void foo() { } -} } -#endif - -#endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL) diff --git a/libraries/boost/libs/thread/src/win32/tss_pe.cpp b/libraries/boost/libs/thread/src/win32/tss_pe.cpp deleted file mode 100644 index 841f98b87..000000000 --- a/libraries/boost/libs/thread/src/win32/tss_pe.cpp +++ /dev/null @@ -1,325 +0,0 @@ -// $Id$ -// (C) Copyright Aaron W. LaFramboise, Roland Schwarz, Michael Glassford 2004. -// (C) Copyright 2007 Roland Schwarz -// (C) Copyright 2007 Anthony Williams -// (C) Copyright 2007 David Deakins -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include - -#if defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB) - -#if (defined(__MINGW32__) && !defined(_WIN64)) || defined(__MINGW64__) || (__MINGW64_VERSION_MAJOR) - -#include - -#include - -#include - -namespace boost -{ - void tss_cleanup_implemented() {} -} - -namespace { - void NTAPI on_tls_callback(void* , DWORD dwReason, PVOID ) - { - switch (dwReason) - { - case DLL_THREAD_DETACH: - { - boost::on_thread_exit(); - break; - } - } - } -} - -#if defined(__MINGW64__) || (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION >3) || \ - ((__MINGW32_MAJOR_VERSION==3) && (__MINGW32_MINOR_VERSION>=18)) -extern "C" -{ - PIMAGE_TLS_CALLBACK __crt_xl_tls_callback__ __attribute__ ((section(".CRT$XLB"))) = on_tls_callback; -} -#else -extern "C" { - - void (* after_ctors )() __attribute__((section(".ctors"))) = boost::on_process_enter; - void (* before_dtors)() __attribute__((section(".dtors"))) = boost::on_thread_exit; - void (* after_dtors )() __attribute__((section(".dtors.zzz"))) = boost::on_process_exit; - - ULONG __tls_index__ = 0; - char __tls_end__ __attribute__((section(".tls$zzz"))) = 0; - char __tls_start__ __attribute__((section(".tls"))) = 0; - - - PIMAGE_TLS_CALLBACK __crt_xl_start__ __attribute__ ((section(".CRT$XLA"))) = 0; - PIMAGE_TLS_CALLBACK __crt_xl_end__ __attribute__ ((section(".CRT$XLZ"))) = 0; -} -extern "C" const IMAGE_TLS_DIRECTORY32 _tls_used __attribute__ ((section(".rdata$T"))) = -{ - (DWORD) &__tls_start__, - (DWORD) &__tls_end__, - (DWORD) &__tls_index__, - (DWORD) (&__crt_xl_start__+1), - (DWORD) 0, - (DWORD) 0 -}; -#endif - - -#elif defined(_MSC_VER) && !defined(UNDER_CE) - - #include - - #include - - #include - - -// _pRawDllMainOrig can be defined by including boost/thread/win32/mfc_thread_init.hpp -// into your dll; it ensures that MFC-Dll-initialization will be done properly -// The following code is adapted from the MFC-Dll-init code -/* - * _pRawDllMainOrig MUST be an extern const variable, which will be aliased to - * _pDefaultRawDllMainOrig if no real user definition is present, thanks to the - * alternatename directive. - */ - -// work at least with _MSC_VER 1500 (MSVC++ 9.0, VS 2008) -#if (_MSC_VER >= 1500) - -extern "C" { -extern BOOL (WINAPI * const _pRawDllMainOrig)(HANDLE, DWORD, LPVOID); -extern BOOL (WINAPI * const _pDefaultRawDllMainOrig)(HANDLE, DWORD, LPVOID) = NULL; -#if defined (_M_IX86) -#pragma comment(linker, "/alternatename:__pRawDllMainOrig=__pDefaultRawDllMainOrig") -#elif defined (_M_X64) || defined (_M_ARM) -#pragma comment(linker, "/alternatename:_pRawDllMainOrig=_pDefaultRawDllMainOrig") -#else /* defined (_M_X64) || defined (_M_ARM) */ -#error Unsupported platform -#endif /* defined (_M_X64) || defined (_M_ARM) */ -} - -#endif - - - - - //Definitions required by implementation - - #if (_MSC_VER < 1300) || (_MSC_VER > 1900) // 1300 == VC++ 7.0, 1900 == VC++ 14.0 - typedef void (__cdecl *_PVFV)(); - #define INIRETSUCCESS - #define PVAPI void __cdecl - #else - typedef int (__cdecl *_PVFV)(); - #define INIRETSUCCESS 0 - #define PVAPI int __cdecl - #endif - - typedef void (NTAPI* _TLSCB)(HINSTANCE, DWORD, PVOID); - - //Symbols for connection to the runtime environment - - extern "C" - { - extern DWORD _tls_used; //the tls directory (located in .rdata segment) - extern _TLSCB __xl_a[], __xl_z[]; //tls initializers */ - } - - namespace - { - //Forward declarations - - static PVAPI on_tls_prepare(); - static PVAPI on_process_init(); - static PVAPI on_process_term(); - static void NTAPI on_tls_callback(HINSTANCE, DWORD, PVOID); - - //The .CRT$Xxx information is taken from Codeguru: - //http://www.codeguru.com/Cpp/misc/misc/threadsprocesses/article.php/c6945__2/ - -#if (_MSC_VER >= 1400) -#pragma section(".CRT$XIU",long,read) -#pragma section(".CRT$XCU",long,read) -#pragma section(".CRT$XTU",long,read) -#pragma section(".CRT$XLC",long,read) - __declspec(allocate(".CRT$XLC")) _TLSCB __xl_ca=on_tls_callback; - __declspec(allocate(".CRT$XIU"))_PVFV p_tls_prepare = on_tls_prepare; - __declspec(allocate(".CRT$XCU"))_PVFV p_process_init = on_process_init; - __declspec(allocate(".CRT$XTU"))_PVFV p_process_term = on_process_term; -#else - #if (_MSC_VER >= 1300) // 1300 == VC++ 7.0 - # pragma data_seg(push, old_seg) - #endif - //Callback to run tls glue code first. - //I don't think it is necessary to run it - //at .CRT$XIB level, since we are only - //interested in thread detachement. But - //this could be changed easily if required. - - #pragma data_seg(".CRT$XIU") - static _PVFV p_tls_prepare = on_tls_prepare; - #pragma data_seg() - - //Callback after all global ctors. - - #pragma data_seg(".CRT$XCU") - static _PVFV p_process_init = on_process_init; - #pragma data_seg() - - //Callback for tls notifications. - - #pragma data_seg(".CRT$XLB") - _TLSCB p_thread_callback = on_tls_callback; - #pragma data_seg() - //Callback for termination. - - #pragma data_seg(".CRT$XTU") - static _PVFV p_process_term = on_process_term; - #pragma data_seg() - #if (_MSC_VER >= 1300) // 1300 == VC++ 7.0 - # pragma data_seg(pop, old_seg) - #endif -#endif - -#ifdef BOOST_MSVC -#pragma warning(push) -#pragma warning(disable:4189) -#endif - - PVAPI on_tls_prepare() - { - //The following line has an important side effect: - //if the TLS directory is not already there, it will - //be created by the linker. In other words, it forces a tls - //directory to be generated by the linker even when static tls - //(i.e. __declspec(thread)) is not used. - //The volatile should prevent the optimizer - //from removing the reference. - - DWORD volatile dw = _tls_used; - - #if (_MSC_VER < 1300) // 1300 == VC++ 7.0 - _TLSCB* pfbegin = __xl_a; - _TLSCB* pfend = __xl_z; - _TLSCB* pfdst = pfbegin; - //pfdst = (_TLSCB*)_tls_used.AddressOfCallBacks; - - //The following loop will merge the address pointers - //into a contiguous area, since the tlssup code seems - //to require this (at least on MSVC 6) - - while (pfbegin < pfend) - { - if (*pfbegin != 0) - { - *pfdst = *pfbegin; - ++pfdst; - } - ++pfbegin; - } - - *pfdst = 0; - #endif - - return INIRETSUCCESS; - } -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif - - PVAPI on_process_init() - { - //Schedule on_thread_exit() to be called for the main - //thread before destructors of global objects have been - //called. - - //It will not be run when 'quick' exiting the - //library; however, this is the standard behaviour - //for destructors of global objects, so that - //shouldn't be a problem. - - atexit(boost::on_thread_exit); - - //Call Boost process entry callback here - - boost::on_process_enter(); - - return INIRETSUCCESS; - } - - PVAPI on_process_term() - { - boost::on_process_exit(); - return INIRETSUCCESS; - } - - void NTAPI on_tls_callback(HINSTANCE /*h*/, DWORD dwReason, PVOID /*pv*/) - { - switch (dwReason) - { - case DLL_THREAD_DETACH: - boost::on_thread_exit(); - break; - } - } - -#if (_MSC_VER >= 1500) - BOOL WINAPI dll_callback(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved) -#else - BOOL WINAPI dll_callback(HANDLE, DWORD dwReason, LPVOID) -#endif - { - switch (dwReason) - { - case DLL_THREAD_DETACH: - boost::on_thread_exit(); - break; - case DLL_PROCESS_DETACH: - boost::on_process_exit(); - break; - } - -#if (_MSC_VER >= 1500) - if( _pRawDllMainOrig ) - { - return _pRawDllMainOrig(hInstance, dwReason, lpReserved); - } -#endif - return true; - } - } //namespace - -extern "C" -{ - extern BOOL (WINAPI * const _pRawDllMain)(HANDLE, DWORD, LPVOID)=&dll_callback; -} -namespace boost -{ - void tss_cleanup_implemented() - { - /* - This function's sole purpose is to cause a link error in cases where - automatic tss cleanup is not implemented by Boost.Threads as a - reminder that user code is responsible for calling the necessary - functions at the appropriate times (and for implementing an a - tss_cleanup_implemented() function to eliminate the linker's - missing symbol error). - - If Boost.Threads later implements automatic tss cleanup in cases - where it currently doesn't (which is the plan), the duplicate - symbol error will warn the user that their custom solution is no - longer needed and can be removed. - */ - } -} - -#endif //defined(_MSC_VER) && !defined(UNDER_CE) - -#endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB) diff --git a/unix/config/ax_boost_thread.m4 b/unix/config/ax_boost_thread.m4 deleted file mode 100644 index 79e12cdb4..000000000 --- a/unix/config/ax_boost_thread.m4 +++ /dev/null @@ -1,149 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_boost_thread.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_BOOST_THREAD -# -# DESCRIPTION -# -# Test for Thread library from the Boost C++ libraries. The macro requires -# a preceding call to AX_BOOST_BASE. Further documentation is available at -# . -# -# This macro calls: -# -# AC_SUBST(BOOST_THREAD_LIB) -# -# And sets: -# -# HAVE_BOOST_THREAD -# -# LICENSE -# -# Copyright (c) 2009 Thomas Porschberg -# Copyright (c) 2009 Michael Tindal -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 27 - -AC_DEFUN([AX_BOOST_THREAD], -[ - AC_ARG_WITH([boost-thread], - AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@], - [use the Thread library from boost - it is possible to specify a certain library for the linker - e.g. --with-boost-thread=boost_thread-gcc-mt ]), - [ - if test "$withval" = "no"; then - want_boost="no" - elif test "$withval" = "yes"; then - want_boost="yes" - ax_boost_user_thread_lib="" - else - want_boost="yes" - ax_boost_user_thread_lib="$withval" - fi - ], - [want_boost="yes"] - ) - - if test "x$want_boost" = "xyes"; then - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_BUILD]) - CPPFLAGS_SAVED="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - - LDFLAGS_SAVED="$LDFLAGS" - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_CACHE_CHECK(whether the Boost::Thread library is available, - ax_cv_boost_thread, - [AC_LANG_PUSH([C++]) - CXXFLAGS_SAVE=$CXXFLAGS - - if test "x$host_os" = "xsolaris" ; then - CXXFLAGS="-pthreads $CXXFLAGS" - elif test "x$host_os" = "xmingw32" ; then - CXXFLAGS="-mthreads $CXXFLAGS" - else - CXXFLAGS="-pthread $CXXFLAGS" - fi - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], - [[boost::thread_group thrds; - return 0;]])], - ax_cv_boost_thread=yes, ax_cv_boost_thread=no) - CXXFLAGS=$CXXFLAGS_SAVE - AC_LANG_POP([C++]) - ]) - if test "x$ax_cv_boost_thread" = "xyes"; then - if test "x$host_os" = "xsolaris" ; then - BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS" - elif test "x$host_os" = "xmingw32" ; then - BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS" - else - BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS" - fi - - AC_SUBST(BOOST_CPPFLAGS) - - AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Thread library is available]) - BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` - - LDFLAGS_SAVE=$LDFLAGS - case "x$host_os" in - *bsd* ) - LDFLAGS="-pthread $LDFLAGS" - break; - ;; - esac - if test "x$ax_boost_user_thread_lib" = "x"; then - for libextension in `ls -r $BOOSTLIBDIR/libboost_thread* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'`; do - ax_lib=${libextension} - AC_CHECK_LIB($ax_lib, exit, - [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], - [link_thread="no"]) - done - if test "x$link_thread" != "xyes"; then - for libextension in `ls -r $BOOSTLIBDIR/boost_thread* 2>/dev/null | sed 's,.*/,,' | sed 's,\..*,,'`; do - ax_lib=${libextension} - AC_CHECK_LIB($ax_lib, exit, - [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], - [link_thread="no"]) - done - fi - - else - for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do - AC_CHECK_LIB($ax_lib, exit, - [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], - [link_thread="no"]) - done - - fi - if test "x$ax_lib" = "x"; then - AC_MSG_ERROR(Could not find a version of the library!) - fi - if test "x$link_thread" = "xno"; then - AC_MSG_ERROR(Could not link against $ax_lib !) - else - case "x$host_os" in - *bsd* ) - BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS" - break; - ;; - esac - - fi - fi - - CPPFLAGS="$CPPFLAGS_SAVED" - LDFLAGS="$LDFLAGS_SAVED" - fi -]) diff --git a/windows/vs2015/boost_date_time.vcxproj b/windows/vs2015/boost_date_time.vcxproj deleted file mode 100644 index 67383acd5..000000000 --- a/windows/vs2015/boost_date_time.vcxproj +++ /dev/null @@ -1,288 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - Release-SSE2 - Win32 - - - Release-SSE2 - x64 - - - Release-AVX - Win32 - - - Release-AVX - x64 - - - - - - - - - {35A2DC31-84BC-4F7A-9C93-1D072432AD79} - boost_date_time - - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - false - true - Unicode - v140 - - - StaticLibrary - false - true - Unicode - v140 - - - StaticLibrary - false - true - Unicode - v140 - - - StaticLibrary - false - true - Unicode - v140 - - - v140 - - - v140 - - - - - - - - - - - - - - - - - - - - - - - - - - bin32\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_date_time32d - - - bin64\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_date_time64d - - - bin32\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_date_time32 - - - bin64\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_date_time64 - - - bin32\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_date_time32-sse2 - - - bin64\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - lib$(ProjectName)$(ConfigTag) - - - - - - Level3 - Disabled - WIN32;WIN32_LEAN_AND_MEAN;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_HAS_ITERATOR_DEBUGGING=0;BOOST_DATE_TIME_STATIC_LINK;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - ProgramDatabase - Default - MultiThreadedDebug - false - true - true - - - Windows - true - - - - - - - Level3 - Disabled - WIN32;WIN32_LEAN_AND_MEAN;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_HAS_ITERATOR_DEBUGGING=0;BOOST_DATE_TIME_STATIC_LINK;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - ProgramDatabase - Default - MultiThreadedDebug - false - true - true - false - true - - - Windows - true - - - - - Level3 - - - Full - false - true - WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;BOOST_DATE_TIME_STATIC_LINK;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - AnySuitable - Speed - MultiThreaded - false - true - true - - - Windows - true - true - true - - - - - Level3 - - - Full - false - true - WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;BOOST_DATE_TIME_STATIC_LINK;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - AnySuitable - Speed - MultiThreaded - false - true - true - - - Windows - true - true - true - - - - - Level3 - - - Full - false - true - WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;BOOST_DATE_TIME_STATIC_LINK;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - AnySuitable - Speed - MultiThreaded - false - true - StreamingSIMDExtensions2 - true - - - Windows - true - true - true - - - - - Level3 - - - Full - false - true - WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;BOOST_DATE_TIME_STATIC_LINK;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - AnySuitable - Speed - MultiThreaded - false - true - true - - - Windows - true - true - true - - - - - - \ No newline at end of file diff --git a/windows/vs2015/boost_date_time.vcxproj.filters b/windows/vs2015/boost_date_time.vcxproj.filters deleted file mode 100644 index 78a75a5f5..000000000 --- a/windows/vs2015/boost_date_time.vcxproj.filters +++ /dev/null @@ -1,26 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - - - - - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/windows/vs2015/boost_system.vcxproj b/windows/vs2015/boost_system.vcxproj deleted file mode 100644 index 038e20442..000000000 --- a/windows/vs2015/boost_system.vcxproj +++ /dev/null @@ -1,286 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - Release-SSE2 - Win32 - - - Release-SSE2 - x64 - - - Release-AVX - Win32 - - - Release-AVX - x64 - - - - - - - {D870A978-8130-4D1D-9FB2-3EE2028D2C50} - boost_system - - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - false - true - Unicode - v140 - - - StaticLibrary - false - true - Unicode - v140 - - - StaticLibrary - false - true - Unicode - v140 - - - StaticLibrary - false - true - Unicode - v140 - - - v140 - - - v140 - - - - - - - - - - - - - - - - - - - - - - - - - - bin32\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_system32d - - - bin64\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_system64d - - - bin32\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_system32 - - - bin64\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_system64 - - - bin32\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_system32-sse2 - - - bin64\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - lib$(ProjectName)$(ConfigTag) - - - - - - Level3 - Disabled - WIN32;WIN32_LEAN_AND_MEAN;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_HAS_ITERATOR_DEBUGGING=0;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - ProgramDatabase - Default - MultiThreadedDebug - false - true - true - - - Windows - true - - - - - - - Level3 - Disabled - WIN32;WIN32_LEAN_AND_MEAN;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_HAS_ITERATOR_DEBUGGING=0;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - ProgramDatabase - Default - MultiThreadedDebug - false - true - true - false - true - - - Windows - true - - - - - Level3 - - - Full - false - true - WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - AnySuitable - Speed - MultiThreaded - false - true - true - - - Windows - true - true - true - - - - - Level3 - - - Full - false - true - WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - AnySuitable - Speed - MultiThreaded - false - true - true - - - Windows - true - true - true - - - - - Level3 - - - Full - false - true - WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - AnySuitable - Speed - MultiThreaded - false - true - StreamingSIMDExtensions2 - true - - - Windows - true - true - true - - - - - Level3 - - - Full - false - true - WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - AnySuitable - Speed - MultiThreaded - false - true - true - - - Windows - true - true - true - - - - - - \ No newline at end of file diff --git a/windows/vs2015/boost_system.vcxproj.filters b/windows/vs2015/boost_system.vcxproj.filters deleted file mode 100644 index 833f7fb68..000000000 --- a/windows/vs2015/boost_system.vcxproj.filters +++ /dev/null @@ -1,20 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - - - - - - - Source Files - - - \ No newline at end of file diff --git a/windows/vs2015/boost_thread.vcxproj b/windows/vs2015/boost_thread.vcxproj deleted file mode 100644 index 385737821..000000000 --- a/windows/vs2015/boost_thread.vcxproj +++ /dev/null @@ -1,295 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - Release-SSE2 - Win32 - - - Release-SSE2 - x64 - - - Release-AVX - Win32 - - - Release-AVX - x64 - - - - - - - - - - {10B193D4-E27B-4438-A825-BFB3D2B4C74D} - boost_thread - - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - true - Unicode - v140 - - - StaticLibrary - false - true - Unicode - v140 - - - StaticLibrary - false - true - Unicode - v140 - - - StaticLibrary - false - true - Unicode - v140 - - - StaticLibrary - false - true - Unicode - v140 - - - v140 - - - v140 - - - - - - - - - - - - - - - - - - - - - - - - - - bin32\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_thread32d - - - bin64\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_thread64d - - - bin32\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_thread32 - - - bin64\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_thread64 - - - bin32\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - libboost_thread32-sse2 - - - bin64\lib\ - build\$(ProjectName)\$(Platform)\$(Configuration)\ - lib$(ProjectName)$(ConfigTag) - - - - - - Level3 - Disabled - WIN32;WIN32_LEAN_AND_MEAN;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_HAS_ITERATOR_DEBUGGING=0;BOOST_THREAD_BUILD_LIB=1;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - ProgramDatabase - Default - MultiThreadedDebug - false - true - true - 4005 - - - Windows - true - - - - - - - Level3 - Disabled - WIN32;WIN32_LEAN_AND_MEAN;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_HAS_ITERATOR_DEBUGGING=0;BOOST_THREAD_BUILD_LIB=1;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - ProgramDatabase - Default - MultiThreadedDebug - false - true - true - false - true - 4005 - - - Windows - true - - - - - Level3 - - - Full - false - true - WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;BOOST_THREAD_BUILD_LIB=1;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - AnySuitable - Speed - MultiThreaded - false - true - true - 4005 - - - Windows - true - true - true - - - - - Level3 - - - Full - false - true - WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;BOOST_THREAD_BUILD_LIB=1;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - AnySuitable - Speed - MultiThreaded - false - true - true - 4005 - - - Windows - true - true - true - - - - - Level3 - - - Full - false - true - WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;BOOST_THREAD_BUILD_LIB=1;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - AnySuitable - Speed - MultiThreaded - false - true - StreamingSIMDExtensions2 - true - 4005 - - - Windows - true - true - true - - - - - Level3 - - - Full - false - true - WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;BOOST_THREAD_BUILD_LIB=1;BOOST_ALL_NO_LIB;%(PreprocessorDefinitions) - ..\..\libraries\boost;%(AdditionalIncludeDirectories) - AnySuitable - Speed - MultiThreaded - false - true - true - 4005 - - - Windows - true - true - true - - - - - - \ No newline at end of file diff --git a/windows/vs2015/boost_thread.vcxproj.filters b/windows/vs2015/boost_thread.vcxproj.filters deleted file mode 100644 index 052d6d2d2..000000000 --- a/windows/vs2015/boost_thread.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {cb1a2c20-bc9c-42c3-a1d2-0c0d88873162} - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - - - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/windows/vs2015/povray.sln b/windows/vs2015/povray.sln index 9b3ecf49a..30637a996 100644 --- a/windows/vs2015/povray.sln +++ b/windows/vs2015/povray.sln @@ -32,12 +32,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "povbase", "povbase.vcxproj" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "povfrontend", "povfrontend.vcxproj", "{C6D9B754-11EB-4FC3-8683-593BFD58C904}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Boost Libraries", "Boost Libraries", "{31AFDB3C-8769-49DF-9C9E-2013E194D983}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boost_thread", "boost_thread.vcxproj", "{10B193D4-E27B-4438-A825-BFB3D2B4C74D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boost_date_time", "boost_date_time.vcxproj", "{35A2DC31-84BC-4F7A-9C93-1D072432AD79}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OpenEXR Libraries", "OpenEXR Libraries", "{30F7FB89-B9D5-473E-A14D-6A00700C1EA9}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenEXR IlmImf", "openexr_IlmImf.vcxproj", "{7DF42126-D237-41D3-9ABE-A3ACC8BAC56E}" @@ -62,8 +56,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "povms", "povms.vcxproj", "{ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "povplatform", "povplatform.vcxproj", "{0C227B07-1830-4C5B-8D4E-2DEFFFD2792D}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boost_system", "boost_system.vcxproj", "{D870A978-8130-4D1D-9FB2-3EE2028D2C50}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "povvm", "povvm.vcxproj", "{E7A73E97-7106-4D4A-98BA-AA43FBD19DB4}" EndProject Global @@ -226,22 +218,6 @@ Global {C6D9B754-11EB-4FC3-8683-593BFD58C904}.Release-SSE2|Win32.ActiveCfg = Release-SSE2|Win32 {C6D9B754-11EB-4FC3-8683-593BFD58C904}.Release-SSE2|Win32.Build.0 = Release-SSE2|Win32 {C6D9B754-11EB-4FC3-8683-593BFD58C904}.Release-SSE2|x64.ActiveCfg = Release|x64 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Debug|Win32.ActiveCfg = Debug|Win32 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Debug|x64.ActiveCfg = Debug|x64 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release|Win32.ActiveCfg = Release|Win32 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release|x64.ActiveCfg = Release|x64 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release-AVX|Win32.ActiveCfg = Release|Win32 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release-AVX|x64.ActiveCfg = Release-AVX|x64 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release-SSE2|Win32.ActiveCfg = Release-SSE2|Win32 - {10B193D4-E27B-4438-A825-BFB3D2B4C74D}.Release-SSE2|x64.ActiveCfg = Release|x64 - {35A2DC31-84BC-4F7A-9C93-1D072432AD79}.Debug|Win32.ActiveCfg = Debug|Win32 - {35A2DC31-84BC-4F7A-9C93-1D072432AD79}.Debug|x64.ActiveCfg = Debug|x64 - {35A2DC31-84BC-4F7A-9C93-1D072432AD79}.Release|Win32.ActiveCfg = Release|Win32 - {35A2DC31-84BC-4F7A-9C93-1D072432AD79}.Release|x64.ActiveCfg = Release|x64 - {35A2DC31-84BC-4F7A-9C93-1D072432AD79}.Release-AVX|Win32.ActiveCfg = Release|Win32 - {35A2DC31-84BC-4F7A-9C93-1D072432AD79}.Release-AVX|x64.ActiveCfg = Release-AVX|x64 - {35A2DC31-84BC-4F7A-9C93-1D072432AD79}.Release-SSE2|Win32.ActiveCfg = Release-SSE2|Win32 - {35A2DC31-84BC-4F7A-9C93-1D072432AD79}.Release-SSE2|x64.ActiveCfg = Release|x64 {7DF42126-D237-41D3-9ABE-A3ACC8BAC56E}.Debug|Win32.ActiveCfg = Debug|Win32 {7DF42126-D237-41D3-9ABE-A3ACC8BAC56E}.Debug|Win32.Build.0 = Debug|Win32 {7DF42126-D237-41D3-9ABE-A3ACC8BAC56E}.Debug|x64.ActiveCfg = Debug|x64 @@ -390,20 +366,6 @@ Global {0C227B07-1830-4C5B-8D4E-2DEFFFD2792D}.Release-SSE2|Win32.ActiveCfg = Release-SSE2|Win32 {0C227B07-1830-4C5B-8D4E-2DEFFFD2792D}.Release-SSE2|Win32.Build.0 = Release-SSE2|Win32 {0C227B07-1830-4C5B-8D4E-2DEFFFD2792D}.Release-SSE2|x64.ActiveCfg = Release|x64 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Debug|Win32.ActiveCfg = Debug|Win32 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Debug|Win32.Build.0 = Debug|Win32 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Debug|x64.ActiveCfg = Debug|x64 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Debug|x64.Build.0 = Debug|x64 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Release|Win32.ActiveCfg = Release|Win32 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Release|Win32.Build.0 = Release|Win32 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Release|x64.ActiveCfg = Release|x64 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Release|x64.Build.0 = Release|x64 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Release-AVX|Win32.ActiveCfg = Release|Win32 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Release-AVX|x64.ActiveCfg = Release-AVX|x64 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Release-AVX|x64.Build.0 = Release-AVX|x64 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Release-SSE2|Win32.ActiveCfg = Release-SSE2|Win32 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Release-SSE2|Win32.Build.0 = Release-SSE2|Win32 - {D870A978-8130-4D1D-9FB2-3EE2028D2C50}.Release-SSE2|x64.ActiveCfg = Release|x64 {E7A73E97-7106-4D4A-98BA-AA43FBD19DB4}.Debug|Win32.ActiveCfg = Debug|Win32 {E7A73E97-7106-4D4A-98BA-AA43FBD19DB4}.Debug|Win32.Build.0 = Debug|Win32 {E7A73E97-7106-4D4A-98BA-AA43FBD19DB4}.Debug|x64.ActiveCfg = Debug|x64 @@ -434,8 +396,6 @@ Global {C6D9B754-11EB-4FC3-8683-593B53E9AD1F} = {5319B36D-2906-4EAF-B623-B7C04F3CC2AD} {C6D9B754-11EB-4FC3-8683-593B2377D043} = {5319B36D-2906-4EAF-B623-B7C04F3CC2AD} {C6D9B754-11EB-4FC3-8683-593BFD58C904} = {5319B36D-2906-4EAF-B623-B7C04F3CC2AD} - {10B193D4-E27B-4438-A825-BFB3D2B4C74D} = {31AFDB3C-8769-49DF-9C9E-2013E194D983} - {35A2DC31-84BC-4F7A-9C93-1D072432AD79} = {31AFDB3C-8769-49DF-9C9E-2013E194D983} {7DF42126-D237-41D3-9ABE-A3ACC8BAC56E} = {30F7FB89-B9D5-473E-A14D-6A00700C1EA9} {C46B9A53-86D8-4B7F-AB15-B2C04518A195} = {30F7FB89-B9D5-473E-A14D-6A00700C1EA9} {76ADDB29-9C6A-442C-9BA9-764C050F75DD} = {30F7FB89-B9D5-473E-A14D-6A00700C1EA9} @@ -447,7 +407,6 @@ Global {F0304A28-E1C7-4F4F-BE1F-DF57936C9664} = {5319B36D-2906-4EAF-B623-B7C04F3CC2AD} {B1E68128-84D7-4525-A3C1-E6C1077F2239} = {5319B36D-2906-4EAF-B623-B7C04F3CC2AD} {0C227B07-1830-4C5B-8D4E-2DEFFFD2792D} = {5319B36D-2906-4EAF-B623-B7C04F3CC2AD} - {D870A978-8130-4D1D-9FB2-3EE2028D2C50} = {31AFDB3C-8769-49DF-9C9E-2013E194D983} {E7A73E97-7106-4D4A-98BA-AA43FBD19DB4} = {5319B36D-2906-4EAF-B623-B7C04F3CC2AD} EndGlobalSection EndGlobal diff --git a/windows/vs2015/tests.vcxproj b/windows/vs2015/tests.vcxproj index bdbe343e0..421a3c9b3 100644 --- a/windows/vs2015/tests.vcxproj +++ b/windows/vs2015/tests.vcxproj @@ -278,9 +278,6 @@ - - {d870a978-8130-4d1d-9fb2-3ee2028d2c50} - {c6d9b754-11eb-4fc3-8683-593b53e9ad1f} From 162aa58a385f322dd8f8fa6d2f0ed44f58a92c54 Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Tue, 19 Feb 2019 00:09:05 +0100 Subject: [PATCH 12/13] Fix broken Mac OS X build. --- source/backend/control/scene.cpp | 1 - source/backend/control/scene.h | 4 ++-- source/backend/povray.cpp | 1 - source/backend/povray.h | 3 +-- source/backend/scene/view.cpp | 1 - source/backend/scene/view.h | 3 +-- source/backend/support/task.cpp | 1 - source/backend/support/task.h | 2 +- source/base/base_fwd.h | 8 -------- vfe/vfesession.cpp | 2 -- vfe/vfesession.h | 3 +-- 11 files changed, 6 insertions(+), 23 deletions(-) diff --git a/source/backend/control/scene.cpp b/source/backend/control/scene.cpp index c8376f9c4..25a4624b0 100644 --- a/source/backend/control/scene.cpp +++ b/source/backend/control/scene.cpp @@ -42,7 +42,6 @@ // C++ standard header files #include #include -#include // Boost header files #include diff --git a/source/backend/control/scene.h b/source/backend/control/scene.h index 6288c2c3a..10ecf57ba 100644 --- a/source/backend/control/scene.h +++ b/source/backend/control/scene.h @@ -45,11 +45,11 @@ // C++ standard header files #include -// not required for `std::thread` because we forward-declare it in `base/base_fwd.h` +#include #include // POV-Ray header files (base module) -#include "base/base_fwd.h" +// (none at the moment) // POV-Ray header files (core module) #include "core/core_fwd.h" diff --git a/source/backend/povray.cpp b/source/backend/povray.cpp index dc0e1a299..de8848b64 100644 --- a/source/backend/povray.cpp +++ b/source/backend/povray.cpp @@ -41,7 +41,6 @@ // C++ standard header files #include -#include // Boost header files #include diff --git a/source/backend/povray.h b/source/backend/povray.h index f60fb43b0..dfee9cea9 100644 --- a/source/backend/povray.h +++ b/source/backend/povray.h @@ -49,13 +49,12 @@ // (none at the moment) // C++ standard header files -// not required for `std::thread` because we forward-declare it in `base/base_fwd.h` +#include // Boost header files #include // POV-Ray header files (base module) -#include "base/base_fwd.h" #include "base/version_info.h" // POV-Ray header files (backend module) diff --git a/source/backend/scene/view.cpp b/source/backend/scene/view.cpp index 8500f8a23..bc40c7f05 100644 --- a/source/backend/scene/view.cpp +++ b/source/backend/scene/view.cpp @@ -42,7 +42,6 @@ // C++ standard header files #include #include -#include // Boost header files #include diff --git a/source/backend/scene/view.h b/source/backend/scene/view.h index a2b5931cc..a1b7d81cb 100644 --- a/source/backend/scene/view.h +++ b/source/backend/scene/view.h @@ -47,11 +47,10 @@ #include #include #include -// not required for `std::thread` because we forward-declare it in `base/base_fwd.h` +#include #include // POV-Ray header files (base module) -#include "base/base_fwd.h" #include "base/types.h" // TODO - only appears to be pulled in for POVRect - can we avoid this? // POV-Ray header files (core module) diff --git a/source/backend/support/task.cpp b/source/backend/support/task.cpp index 72c3065a3..90296980c 100644 --- a/source/backend/support/task.cpp +++ b/source/backend/support/task.cpp @@ -41,7 +41,6 @@ // C++ standard header files #include -#include // Boost header files #include diff --git a/source/backend/support/task.h b/source/backend/support/task.h index 6fec0194b..cf0916b55 100644 --- a/source/backend/support/task.h +++ b/source/backend/support/task.h @@ -45,7 +45,7 @@ // C++ standard header files #include #include -// not required for `std::thread` because we forward-declare it in `base/base_fwd.h` +#include // Boost header files #include diff --git a/source/base/base_fwd.h b/source/base/base_fwd.h index 37622eea9..c71b98949 100644 --- a/source/base/base_fwd.h +++ b/source/base/base_fwd.h @@ -40,14 +40,6 @@ /// @note /// This file should not pull in any POV-Ray header whatsoever. -// Forward-declare the standard library's thread type, rather than pulling in -// ``, and all the other headers it might want in turn. -namespace std -{ -class thread; -} -// end of namespace std - namespace pov_base { diff --git a/vfe/vfesession.cpp b/vfe/vfesession.cpp index 8d8ccb72f..83e6eca09 100644 --- a/vfe/vfesession.cpp +++ b/vfe/vfesession.cpp @@ -42,8 +42,6 @@ #include "vfe.h" -#include - #include #include "backend/povray.h" diff --git a/vfe/vfesession.h b/vfe/vfesession.h index f46cfb672..634bcd68f 100644 --- a/vfe/vfesession.h +++ b/vfe/vfesession.h @@ -43,13 +43,12 @@ #include #include #include -// not required for `std::thread` because we forward-declare it in `base/base_fwd.h` +#include #include #include #include -#include "base/base_fwd.h" #include "base/stringutilities.h" #include "frontend/simplefrontend.h" From 29a10823a7451388098565bc2c753fc72c478775 Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Tue, 19 Feb 2019 01:21:00 +0100 Subject: [PATCH 13/13] Fix another Mac OS X build error. --- vfe/unix/unixconsole.cpp | 42 ++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/vfe/unix/unixconsole.cpp b/vfe/unix/unixconsole.cpp index 5b492d7e3..26305e500 100644 --- a/vfe/unix/unixconsole.cpp +++ b/vfe/unix/unixconsole.cpp @@ -93,7 +93,7 @@ static bool gCancelRender = false; // for handling asynchronous (external) signals static int gSignalNumber = 0; static std::mutex gSignalMutex; -static bool gTerminateSignalHandler = false; +static volatile bool gTerminateSignalHandler = false; // TODO FIXME - This way to handle signals seems rather wonky, as it is subject @@ -114,9 +114,13 @@ static void SignalHandler (void) while(!gTerminateSignalHandler) { // Wait till a signal is caught. +#ifdef HAVE_SIGTIMEDWAIT signum = sigtimedwait(&sigset, nullptr, &timeout); if (signum == -1) continue; // Error. Presumably timed out; check whether to end the task. +#else + (void)sigwait(&sigset, &signum); +#endif // Got a signal. std::lock_guard lock(gSignalMutex); @@ -423,6 +427,25 @@ static void CleanupBenchmark(vfeUnixSession *session, std::string& ini, std::str session->DeleteTemporaryFile(SysToUCS2String(pov.c_str())); } +static void TerminateSignalHandler(std::thread* sigthread) +{ + gTerminateSignalHandler = true; +#ifdef HAVE_SIGTIMEDWAIT + // `std::thread`s must be `join`ed or `detach`ed before destruction, + // otherwise their destructor causes ungraceful termination of the entire + // program. + sigthread->join(); +#else + // `std::thread`s must be `join`ed or `detach`ed before destruction, + // otherwise their destructor causes ungraceful termination of the entire + // program. `join` is not an option because we can't reliably make the + // thread terminate itself, so we must trust the OS that it will kill any + // `detach`ed threads when their parent process exits. + // TODO - This is a hackish solution. + sigthread->detach(); +#endif +} + int main (int argc, char **argv) { vfeUnixSession *session; @@ -499,8 +522,7 @@ int main (int argc, char **argv) PrintStatus (session) ; // TODO: general usage display (not yet in core code) session->GetUnixOptions()->PrintOptions(); - gTerminateSignalHandler = true; - sigthread->join(); + TerminateSignalHandler(sigthread); delete sigthread; delete session; return RETURN_OK; @@ -509,8 +531,7 @@ int main (int argc, char **argv) { session->Shutdown() ; PrintVersion(); - gTerminateSignalHandler = true; - sigthread->join(); + TerminateSignalHandler(sigthread); delete sigthread; delete session; return RETURN_OK; @@ -519,8 +540,7 @@ int main (int argc, char **argv) { session->Shutdown(); PrintGeneration(); - gTerminateSignalHandler = true; - sigthread->join(); + TerminateSignalHandler(sigthread); delete sigthread; delete session; return RETURN_OK; @@ -533,8 +553,7 @@ int main (int argc, char **argv) else { session->Shutdown(); - gTerminateSignalHandler = true; - sigthread->join(); + TerminateSignalHandler(sigthread); delete sigthread; delete session; return retval; @@ -578,7 +597,7 @@ int main (int argc, char **argv) session->PauseWhenDone(true); // main render loop - session->SetEventMask(stBackendStateChanged); // immediatly notify this event + session->SetEventMask(stBackendStateChanged); // immediately notify this event while (((flags = session->GetStatus(true, 200)) & stRenderShutdown) == 0) { ProcessSignal(); @@ -635,8 +654,7 @@ int main (int argc, char **argv) retval = gCancelRender ? RETURN_USER_ABORT : RETURN_ERROR; session->Shutdown(); PrintStatus (session); - gTerminateSignalHandler = true; - sigthread->join(); + TerminateSignalHandler(sigthread); delete sigthread; delete session;