yapf.hpp

Go to the documentation of this file.
00001 /* $Id: yapf.hpp 15609 2009-03-04 08:02:16Z peter1138 $ */
00002 
00005 #ifndef  YAPF_HPP
00006 #define  YAPF_HPP
00007 
00008 #include "../openttd.h"
00009 #include "../vehicle_base.h"
00010 #include "../road_map.h"
00011 #include "../tunnel_map.h"
00012 #include "../bridge_map.h"
00013 #include "../tunnelbridge_map.h"
00014 #include "../bridge.h"
00015 #include "../station_base.h"
00016 #include "../station_map.h"
00017 #include "../tile_cmd.h"
00018 #include "../landscape.h"
00019 #include "yapf.h"
00020 #include "../pathfind.h"
00021 #include "../waypoint.h"
00022 #include "../debug.h"
00023 #include "../settings_type.h"
00024 #include "../tunnelbridge.h"
00025 
00026 extern uint64 ottd_rdtsc();
00027 
00028 #include <limits.h>
00029 #include <new>
00030 
00031 #if defined(_WIN32) || defined(_WIN64)
00032 #  include <windows.h>
00033 #else
00034 #  include <time.h>
00035 #endif
00036 
00037 struct CPerformanceTimer
00038 {
00039   int64    m_start;
00040   int64    m_acc;
00041 
00042   CPerformanceTimer() : m_start(0), m_acc(0) {}
00043 
00044   FORCEINLINE void Start()
00045   {
00046     m_start = QueryTime();
00047   }
00048 
00049   FORCEINLINE void Stop()
00050   {
00051     m_acc += QueryTime() - m_start;
00052   }
00053 
00054   FORCEINLINE int Get(int64 coef)
00055   {
00056     return (int)(m_acc * coef / QueryFrequency());
00057   }
00058 
00059   FORCEINLINE int64 QueryTime()
00060   {
00061     return ottd_rdtsc();
00062   }
00063 
00064   FORCEINLINE int64 QueryFrequency()
00065   {
00066     return ((int64)2200 * 1000000);
00067   }
00068 };
00069 
00070 struct CPerfStartReal
00071 {
00072   CPerformanceTimer *m_pperf;
00073 
00074   FORCEINLINE CPerfStartReal(CPerformanceTimer& perf) : m_pperf(&perf)
00075   {
00076     if (m_pperf != NULL) m_pperf->Start();
00077   }
00078 
00079   FORCEINLINE ~CPerfStartReal()
00080   {
00081     Stop();
00082   }
00083 
00084   FORCEINLINE void Stop()
00085   {
00086     if (m_pperf != NULL) {
00087       m_pperf->Stop();
00088       m_pperf = NULL;
00089     }
00090   }
00091 };
00092 
00093 struct CPerfStartFake
00094 {
00095   FORCEINLINE CPerfStartFake(CPerformanceTimer& perf) {}
00096   FORCEINLINE ~CPerfStartFake() {}
00097   FORCEINLINE void Stop() {}
00098 };
00099 
00100 typedef CPerfStartFake CPerfStart;
00101 
00102 
00103 //#undef FORCEINLINE
00104 //#define FORCEINLINE inline
00105 
00106 #include "../misc/crc32.hpp"
00107 #include "../misc/blob.hpp"
00108 #include "../misc/str.hpp"
00109 #include "../misc/fixedsizearray.hpp"
00110 #include "../misc/array.hpp"
00111 #include "../misc/hashtable.hpp"
00112 #include "../misc/binaryheap.hpp"
00113 #include "../misc/dbg_helpers.h"
00114 #include "nodelist.hpp"
00115 #include "follow_track.hpp"
00116 #include "yapf_base.hpp"
00117 #include "yapf_node.hpp"
00118 #include "yapf_common.hpp"
00119 #include "yapf_costbase.hpp"
00120 #include "yapf_costcache.hpp"
00121 
00122 
00123 #endif /* YAPF_HPP */

Generated on Thu Sep 24 19:35:08 2009 for OpenTTD by  doxygen 1.5.6