Browse Source

fix name clash with <time.h>

Kolja Strohm 1 week ago
parent
commit
744fd4fb3a
9 changed files with 97 additions and 99 deletions
  1. 7 6
      DX9GraphicsApi.cpp
  2. 4 7
      File.cpp
  3. 2 2
      Framework.vcxproj
  4. 2 2
      Framework.vcxproj.filters
  5. 1 1
      Logging.cpp
  6. 3 4
      RenderThread.cpp
  7. 14 18
      Screen.cpp
  8. 28 37
      Timer.cpp
  9. 36 22
      Timer.h

+ 7 - 6
DX9GraphicsApi.cpp

@@ -1,14 +1,14 @@
 #include <d3d9.h>
 
-#include "Image.h"
+#include "Camera3D.h"
 #include "DLLRegister.h"
-#include "Window.h"
 #include "Globals.h"
 #include "GraphicsApi.h"
-#include "Camera3D.h"
+#include "Image.h"
 #include "Texture.h"
+#include "Timer.h"
+#include "Window.h"
 #include "World3D.h"
-#include "Time.h"
 
 using namespace Framework;
 
@@ -88,7 +88,8 @@ void DirectX9::initialize(
     d3dpp.BackBufferHeight = this->backBufferSize.y;
     d3dpp.BackBufferWidth = this->backBufferSize.x;
 
-    uiImage->newImage(this->backBufferSize.x, this->backBufferSize.y, 0xFF000000);
+    uiImage->newImage(
+        this->backBufferSize.x, this->backBufferSize.y, 0xFF000000);
 
     HRESULT result = pDirect3D->CreateDevice(D3DADAPTER_DEFAULT,
         D3DDEVTYPE_HAL,
@@ -215,7 +216,7 @@ void DirectX9::presentFrame()
     int* bgBuff = uiImage->getBuffer();
     int tmpBr = sizeof(D3DCOLOR) * uiImage->getWidth();
     for (int y = 0, pitch = 0, bry = 0; y < uiImage->getHeight();
-         ++y, pitch += backRect->Pitch, bry += uiImage->getWidth())
+        ++y, pitch += backRect->Pitch, bry += uiImage->getWidth())
         memcpy(&((BYTE*)backRect->pBits)[pitch], (void*)&(bgBuff[bry]), tmpBr);
     // Beende Image
     result = pBackBuffer->UnlockRect();

+ 4 - 7
File.cpp

@@ -2,7 +2,7 @@
 
 #include "Key.h"
 #include "Text.h"
-#include "Time.h"
+#include "Timer.h"
 #ifdef WIN32
 #    include <direct.h>
 #    include <Shlwapi.h>
@@ -607,8 +607,7 @@ bool Framework::FileRemove(Text* pfad) // Deletes the specified file
     return ret;
 }
 
-bool Framework::FileRename(
-    Text* pfad_alt, Text* pfad_neu) // Renames the file
+bool Framework::FileRename(Text* pfad_alt, Text* pfad_neu) // Renames the file
 {
     bool ret = FileRename(pfad_alt->getText(), pfad_neu->getText());
     pfad_alt->release();
@@ -623,16 +622,14 @@ bool Framework::FileExists(Text* pfad) // Checks if the file exists
     return ret;
 }
 
-bool Framework::FileIsDirectory(
-    Text* pfad) // checks if the path is a directory
+bool Framework::FileIsDirectory(Text* pfad) // checks if the path is a directory
 {
     bool ret = FileIsDirectory(pfad->getText());
     pfad->release();
     return ret;
 }
 
-bool Framework::FilePathCreate(
-    const char* pfad) // Creates a file in the path
+bool Framework::FilePathCreate(const char* pfad) // Creates a file in the path
 {
     Text pf = pfad;
     bool erst = 1;

+ 2 - 2
Framework.vcxproj

@@ -305,7 +305,7 @@ copy "x64\Release\Framework.dll" "..\..\Spiele Platform\SMP\Fertig\x64\framework
     <ClInclude Include="Vec2.h" />
     <ClInclude Include="Vec3.h" />
     <ClInclude Include="Drawing3D.h" />
-    <ClInclude Include="Time.h" />
+    <ClInclude Include="Timer.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="AbstractElement.cpp" />
@@ -395,7 +395,7 @@ copy "x64\Release\Framework.dll" "..\..\Spiele Platform\SMP\Fertig\x64\framework
     <ClCompile Include="TextField.cpp" />
     <ClCompile Include="Thread.cpp" />
     <ClCompile Include="ToolTip.cpp" />
-    <ClCompile Include="Time.cpp" />
+    <ClCompile Include="Timer.cpp" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />

+ 2 - 2
Framework.vcxproj.filters

@@ -160,7 +160,7 @@
     <ClInclude Include="main.h">
       <Filter>Framework</Filter>
     </ClInclude>
-    <ClInclude Include="Time.h">
+    <ClInclude Include="Timer.h">
       <Filter>Framework</Filter>
     </ClInclude>
     <ClInclude Include="File.h">
@@ -621,7 +621,7 @@
     <ClCompile Include="UIInitialization.cpp">
       <Filter>Framework</Filter>
     </ClCompile>
-    <ClCompile Include="Time.cpp">
+    <ClCompile Include="Timer.cpp">
       <Filter>Framework</Filter>
     </ClCompile>
     <ClCompile Include="Model3DCollection.cpp">

+ 1 - 1
Logging.cpp

@@ -4,7 +4,7 @@
 
 #include "File.h"
 #include "Globals.h"
-#include "Time.h"
+#include "Timer.h"
 
 using namespace Framework;
 using namespace Framework::Logging;

+ 3 - 4
RenderThread.cpp

@@ -2,9 +2,9 @@
 
 #include <iostream>
 
-#include "Screen.h"
 #include "Logging.h"
-#include "Time.h"
+#include "Screen.h"
+#include "Timer.h"
 
 using namespace Framework;
 
@@ -64,8 +64,7 @@ void RenderTh::thread() // Render loop
         if (screen && !pause)
         {
             if (renderFunktion)
-                renderFunktion(
-                    renderParameter, this, screen->zRenderImage());
+                renderFunktion(renderParameter, this, screen->zRenderImage());
             screen->render();
             val++;
             if (tickFunktion) tickFunktion(tickParameter, this, renderTickTime);

+ 14 - 18
Screen.cpp

@@ -2,27 +2,27 @@
 
 #include <iostream>
 
-#include "Image.h"
+#include "Drawing.h"
 #include "File.h"
-#include "Window.h"
 #include "Globals.h"
 #include "GraphicsApi.h"
+#include "Image.h"
 #include "Logging.h"
 #include "Mat3.h"
-#include "MouseEvent.h"
 #include "Model3D.h"
+#include "MouseEvent.h"
 #include "Text.h"
+#include "Timer.h"
 #include "ToolTip.h"
-#include "Drawing.h"
-#include "Time.h"
+#include "Window.h"
 #ifdef WIN32
 #    include <d3d11.h>
 #    include <d3d9.h>
 #    include <D3Dcompiler.h>
 #    include <DirectXMath.h>
 
-#    include "comdef.h"
 #    include "Camera3D.h"
+#    include "comdef.h"
 #endif
 
 using namespace Framework;
@@ -100,13 +100,13 @@ void Screen::update()
 }
 
 void Screen::setTestRend(
-bool tr) // specifies whether to check for updates before rendering
+    bool tr) // specifies whether to check for updates before rendering
 {
     testRend = tr;
 }
 
 void Screen::setRenderDrawables(
-bool rO) // specifies whether drawings are rendered
+    bool rO) // specifies whether drawings are rendered
 {
     lock();
     renderDrawables = rO;
@@ -115,7 +115,7 @@ bool rO) // specifies whether drawings are rendered
 }
 
 void Screen::setOnTop(
-bool onTop) // specifies whether the onTop drawing is rendered
+    bool onTop) // specifies whether the onTop drawing is rendered
 {
     renderOnTop = onTop;
     rend = 1;
@@ -208,7 +208,7 @@ void Screen::tick(double tickval)
 }
 
 void Screen::setBackBufferSize(
-int Width, int height) // sets the size of the back buffer
+    int Width, int height) // sets the size of the back buffer
 {
     lock();
     api->setBackBufferSize(Vec2<int>(Width, height));
@@ -258,8 +258,7 @@ void Screen::doMouseEvent(MouseEvent& me) // sends mouse event
     unlock();
 }
 
-void Screen::doKeyboardEvent(
-KeyboardEvent& te) // sends keyboard event
+void Screen::doKeyboardEvent(KeyboardEvent& te) // sends keyboard event
 {
     lock();
     if (!renderOnTop)
@@ -294,8 +293,7 @@ Image* Screen::zRenderImage() const
     return api->zUIRenderImage();
 }
 
-ArrayIterator<Drawable*>
-Screen::getMembers() const // returns the drawings
+ArrayIterator<Drawable*> Screen::getMembers() const // returns the drawings
 {
     return members->begin();
 }
@@ -324,8 +322,7 @@ void Screen::waitForRendering() const // waits for the render function
     }
 }
 
-double Screen::getRenderZeit()
-const // returns how many seconds rendering takes
+double Screen::getRenderZeit() const // returns how many seconds rendering takes
 {
     return renderTime->getSekunden();
 }
@@ -570,8 +567,7 @@ void Screen3D::doMouseEvent(MouseEvent& me) // sends mouse event
     }
 }
 
-void Screen3D::doKeyboardEvent(
-KeyboardEvent& te) // sends keyboard event
+void Screen3D::doKeyboardEvent(KeyboardEvent& te) // sends keyboard event
 {
     if (handleUserInputsOnTick)
     {

+ 28 - 37
Time.cpp → Timer.cpp

@@ -1,4 +1,4 @@
-#include "Time.h"
+#include "Timer.h"
 
 #include <ctime>
 #include <time.h>
@@ -126,8 +126,8 @@ int Clock::setClock(int stunde, int minute, int sekunde)
 }
 
 int Clock::setClock(
-const char* format, const char* zeit) // format examples: "H:i:s", "H-i-s"
-                                      // (H=hour,i=minute,s=second)
+    const char* format, const char* zeit) // format examples: "H:i:s", "H-i-s"
+                                          // (H=hour,i=minute,s=second)
 {
     int flen = textLength(format);
     char* ende = 0;
@@ -345,7 +345,7 @@ int Clock::getSekunde() const // returns the second
 }
 
 Text* Clock::getClock(
-const char* format) const // returns the time formatted as text
+    const char* format) const // returns the time formatted as text
 {
     Text* ret = new Text("");
     int flen = textLength(format);
@@ -370,8 +370,7 @@ const char* format) const // returns the time formatted as text
     return ret;
 }
 
-bool Clock::isEqual(
-Clock* zeit) const // checks if the time equals zeit
+bool Clock::isEqual(Clock* zeit) const // checks if the time equals zeit
 {
     bool ret = stunde == zeit->getStunde() && minute == zeit->getMinute()
             && sekunde == zeit->getSekunde();
@@ -425,26 +424,23 @@ bool Clock::isEqual(int stunde, int minute, int sekunde) const
         && this->sekunde == sekunde;
 }
 
-bool Clock::hourEqual(
-int stunde) const // checks if the hour equals stunde
+bool Clock::hourEqual(int stunde) const // checks if the hour equals stunde
 {
     return this->stunde == stunde;
 }
 
-bool Clock::minuteEqual(
-int minute) const // checks if the minute equals minute
+bool Clock::minuteEqual(int minute) const // checks if the minute equals minute
 {
     return this->minute == minute;
 }
 
 bool Clock::secondEqual(
-int sekunde) const // checks if the second equals sekunde
+    int sekunde) const // checks if the second equals sekunde
 {
     return this->sekunde == sekunde;
 }
 
-bool Clock::isSmaller(
-Clock* zeit) const // checks if the time is less than zeit
+bool Clock::isSmaller(Clock* zeit) const // checks if the time is less than zeit
 {
     bool ret
         = isSmaller(zeit->getStunde(), zeit->getMinute(), zeit->getSekunde());
@@ -516,7 +512,7 @@ bool Clock::isSmaller(const char* format, Text* zeit) const
 }
 
 bool Clock::isLater(
-Clock* zeit) const // checks if the time is greater than zeit
+    Clock* zeit) const // checks if the time is greater than zeit
 {
     bool ret
         = isLater(zeit->getStunde(), zeit->getMinute(), zeit->getSekunde());
@@ -672,8 +668,8 @@ void Date::setDate(int jahr, int monat, int tag)
 }
 
 void Date::setDate(const char* format,
-const char*
-    datum) // format examples: "Y:m:d", "Y-m-d" (Y=year,m=month,d=day)
+    const char*
+        datum) // format examples: "Y:m:d", "Y-m-d" (Y=year,m=month,d=day)
 {
     int flen = textLength(format);
     char* ende = 0;
@@ -889,7 +885,7 @@ int Date::getTag() const // returns the day
 }
 
 Text* Date::getDate(
-const char* format) const // returns the date formatted as text
+    const char* format) const // returns the date formatted as text
 {
     Text* ret = new Text("");
     int flen = textLength(format);
@@ -914,8 +910,7 @@ const char* format) const // returns the date formatted as text
     return ret;
 }
 
-bool Date::isEqual(
-Date* datum) const // checks if the date equals datum
+bool Date::isEqual(Date* datum) const // checks if the date equals datum
 {
     bool ret = jahr == datum->getJahr() && monat == datum->getMonat()
             && tag == datum->getTag();
@@ -973,8 +968,7 @@ bool Date::yearEqual(int jahr) const // checks if the year equals jahr
     return this->jahr == jahr;
 }
 
-bool Date::monthEqual(
-int monat) const // checks if the month equals monat
+bool Date::monthEqual(int monat) const // checks if the month equals monat
 {
     return this->monat == monat;
 }
@@ -984,8 +978,7 @@ bool Date::dayEqual(int tag) const // checks if the day equals tag
     return this->tag == tag;
 }
 
-bool Date::isSmaller(
-Date* datum) const // checks if the date is less than datum
+bool Date::isSmaller(Date* datum) const // checks if the date is less than datum
 {
     bool ret = isSmaller(datum->getJahr(), datum->getMonat(), datum->getTag());
     datum->release();
@@ -1056,7 +1049,7 @@ bool Date::isSmaller(const char* format, Text* datum) const
 }
 
 bool Date::isLater(
-Date* datum) const // checks if the date is greater than datum
+    Date* datum) const // checks if the date is greater than datum
 {
     bool ret = isLater(datum->getJahr(), datum->getMonat(), datum->getTag());
     datum->release();
@@ -1167,8 +1160,8 @@ void Time::setTime(
 }
 
 void Time::setTime(const char* format,
-const char* zeit) // format examples: "Y:m:d H-i-s", "Y-m-d H:i:s"
-                  // (Y=year,m=month,d=day,H=hour,i=minute,s=second)
+    const char* zeit) // format examples: "Y:m:d H-i-s", "Y-m-d H:i:s"
+                      // (Y=year,m=month,d=day,H=hour,i=minute,s=second)
 {
     int y = datum->getJahr();
     int m = datum->getMonat();
@@ -1468,7 +1461,7 @@ void Time::minusSecond(__int64 sekunde) // subtracts sekunde seconds
 
 // constant
 Text* Time::getTime(
-const char* format) const // returns the time formatted as text
+    const char* format) const // returns the time formatted as text
 {
     Text* ret = new Text("");
     int flen = textLength(format);
@@ -1508,8 +1501,8 @@ const char* format) const // returns the time formatted as text
 
 bool Time::isEqual(Time* zeit) const // checks if the time equals zeit
 {
-    bool ret = datum->isEqual(zeit->getDate())
-            && uhrzeit->isEqual(zeit->getClock());
+    bool ret
+        = datum->isEqual(zeit->getDate()) && uhrzeit->isEqual(zeit->getClock());
     zeit->release();
     return ret;
 }
@@ -1601,8 +1594,7 @@ Clock* Time::zClock() const
     return uhrzeit;
 }
 
-bool Time::isSmaller(
-Time* zeit) const // checks if the time is less than zeit
+bool Time::isSmaller(Time* zeit) const // checks if the time is less than zeit
 {
     if (datum->isSmaller(zeit->getDate()))
     {
@@ -1715,8 +1707,7 @@ bool Time::isSmaller(const char* format, Text* zeit) const
     return ret;
 }
 
-bool Time::isLater(
-Time* zeit) const // checks if the time is greater than zeit
+bool Time::isLater(Time* zeit) const // checks if the time is greater than zeit
 {
     if (datum->isLater(zeit->getDate()))
     {
@@ -1864,14 +1855,14 @@ double Timer::getSekunden() const // returns the second difference between
     return messung;
 }
 
-double Timer::getMinuten()
-const // returns the minute difference between start and end of the measurement
+double Timer::getMinuten() const // returns the minute difference between start
+                                 // and end of the measurement
 {
     return messung / 60;
 }
 
-double Timer::getStunden()
-const // returns the hour difference between start and end of the measurement
+double Timer::getStunden() const // returns the hour difference between start
+                                 // and end of the measurement
 {
     return messung / 3600;
 }

+ 36 - 22
Time.h → Timer.h

@@ -1,17 +1,15 @@
 #ifndef Time_H
 #define Time_H
 
-#include <time.h>
-
 #include "OperatingSystem.h"
 #include "ReferenceCounter.h"
 
 namespace Framework
 {
-    class Text;       //! Text.h
-    class Clock;    //! From this file
-    class Date;      //! From this file
-    class Time;       //! From this file
+    class Text;  //! Text.h
+    class Clock; //! From this file
+    class Date;  //! From this file
+    class Time;  //! From this file
     class Timer; //! From this file
 
     //! This class stores a time of day in the form of hours, minutes and
@@ -359,34 +357,41 @@ namespace Framework
         //! \param tag The day to add.
         //! Example: ( 1.1.2000 ).plusDay( 32 ); new date: 2.2.2000
         DLLEXPORT void plusDay(int tag);
-        //! Subtracts the given date from the current date and stores the result.
+        //! Subtracts the given date from the current date and stores the
+        //! result.
         //! \param datum The date to subtract.
         //! Example: ( 2.12.1996 ).minusDate( ( 1.1.1 ) ); new date: 1.11.1995
         DLLEXPORT void minusDate(Date* datum);
-        //! Subtracts the given date from the current date and stores the result.
-        //! \param jahr The year to subtract. \param monat The month to subtract.
+        //! Subtracts the given date from the current date and stores the
+        //! result.
+        //! \param jahr The year to subtract. \param monat The month to
+        //! subtract.
         //! \param tag The day to subtract.
         //! Example: ( 2.12.1996 ).minusDate( 1, 1, 1 ); new date: 1.11.1995
         DLLEXPORT void minusDate(int jahr, int monat, int tag);
-        //! Subtracts the given date from the current date and stores the result.
+        //! Subtracts the given date from the current date and stores the
+        //! result.
         //! \param format A string specifying the format of the
         //! date in (datum). y=year, m=month, d=day.
         //! \param datum A string containing the date to subtract.
         //! Example: ( 2.12.1996 ).minusDate( "d.m.y", "1.1.1" );
         //! new date: 1.11.1995
         DLLEXPORT void minusDate(const char* format, const char* datum);
-        //! Subtracts the given date from the current date and stores the result.
+        //! Subtracts the given date from the current date and stores the
+        //! result.
         //! \param format A string specifying the format of the
         //! date in (datum). y=year, m=month, d=day.
         //! \param datum A Text object containing the date to subtract.
         //! Example: ( 2.12.1996 ).minusDate( "d.m.y", new Text(
         //! "1.1.1" ) ); new date: 1.11.1995
         DLLEXPORT void minusDate(const char* format, Text* datum);
-        //! Subtracts the given year from the current date and stores the result.
+        //! Subtracts the given year from the current date and stores the
+        //! result.
         //! \param jahr The year to subtract.
         //! Example: ( 1.11.1996 ).minusYear( 1 ); new date: 1.11.1995
         DLLEXPORT void minusYear(int jahr);
-        //! Subtracts the given month from the current date and stores the result.
+        //! Subtracts the given month from the current date and stores the
+        //! result.
         //! \param monat The month to subtract.
         //! Example: ( 1.12.1996 ).minusMonth( 13 ); new date: 1.11.1995
         DLLEXPORT void minusMonth(int monat);
@@ -425,7 +430,8 @@ namespace Framework
         //! A Text object containing the date to check.
         //! \return (true) if the given date matches the stored one.
         //! (false) otherwise.
-        //! Example: ( 1.11.1995 ).isEqual( "y-m-d", new Text( "1995-11-1" ) ); return: true
+        //! Example: ( 1.11.1995 ).isEqual( "y-m-d", new Text( "1995-11-1" ) );
+        //! return: true
         DLLEXPORT bool isEqual(const char* format, Text* datum) const;
         //! Checks if the date equals the given date.
         //! \param jahr The year of the date to check.
@@ -470,7 +476,8 @@ namespace Framework
         //! A string containing the date to check. \return
         //! (true) if the stored date is before the given one.
         //! (false) otherwise.
-        //! Example: ( 1.11.1995 ).isSmaller( "y, m, d", "2016, 1, 23" ); return true
+        //! Example: ( 1.11.1995 ).isSmaller( "y, m, d", "2016, 1, 23" ); return
+        //! true
         DLLEXPORT bool isSmaller(const char* format, const char* datum) const;
         //! Checks if the stored date is less than the given one.
         //! \param format A string specifying the format of the
@@ -478,7 +485,8 @@ namespace Framework
         //! A Text object containing the date to check.
         //! \return (true) if the stored date is before the given one.
         //! (false) otherwise.
-        //! Example: ( 1.11.1995 ).isSmaller( "y, m, d", new Text( "2016, 1, 23" ) ); return true
+        //! Example: ( 1.11.1995 ).isSmaller( "y, m, d", new Text( "2016, 1, 23"
+        //! ) ); return true
         DLLEXPORT bool isSmaller(const char* format, Text* datum) const;
         //! Checks if the stored date is greater than the given one.
         //! \param datum The date to check.
@@ -500,7 +508,8 @@ namespace Framework
         //! A string containing the date to check. \return
         //! (true) if the stored date is after the given one.
         //! (false) otherwise.
-        //! Example: ( 1.11.1995 ).isLater( "y, m, d", "2016, 1, 23" ); return false
+        //! Example: ( 1.11.1995 ).isLater( "y, m, d", "2016, 1, 23" ); return
+        //! false
         DLLEXPORT bool isLater(const char* format, const char* datum) const;
         //! Checks if the stored date is greater than the given one.
         //! \param format A string specifying the format of the
@@ -508,7 +517,8 @@ namespace Framework
         //! A Text object containing the date to check.
         //! \return (true) if the stored date is after the given one.
         //! (false) otherwise.
-        //! Example: ( 1.11.1995 ).isLater( "y, m, d", new Text( "2016, 1, 23" ) ); return true
+        //! Example: ( 1.11.1995 ).isLater( "y, m, d", new Text( "2016, 1, 23" )
+        //! ); return true
         DLLEXPORT bool isLater(const char* format, Text* datum) const;
     };
 
@@ -691,13 +701,17 @@ namespace Framework
             int stunde,
             int minute,
             int sekunde) const;
-        //! Returns the object storing the date with increased reference counter.
+        //! Returns the object storing the date with increased reference
+        //! counter.
         DLLEXPORT Date* getDate() const;
-        //! Returns the object storing the date without increased reference counter.
+        //! Returns the object storing the date without increased reference
+        //! counter.
         DLLEXPORT Date* zDate() const;
-        //! Returns the object storing the time of day with increased reference counter.
+        //! Returns the object storing the time of day with increased reference
+        //! counter.
         DLLEXPORT Clock* getClock() const;
-        //! Returns the object storing the time of day without increased reference counter.
+        //! Returns the object storing the time of day without increased
+        //! reference counter.
         DLLEXPORT Clock* zClock() const;
         //! Checks if the stored time is less than the given time.
         //! \param zeit The time to check. \return (true)