Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
   Copyright (c) 2014 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy of this software
   and associated documentation files (the "Software"), to deal in the Software without restriction,
   including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef SINGLETON_H_
#define SINGLETON_H_

namespace Divide {

template<typename T>
class Singleton {
public :
    inline static T& getOrCreateInstance() {
        if (!_instance) {
            _instance = new T;
        }

        return *_instance;
    }

    inline static bool hasInstance() {
        return _instance != nullptr;
    }

    inline static T& getInstance() {
        return *_instance;
    }

    inline static void createInstance() {
        if (!_instance) {
            _instance = new T;
        }
    }

    inline static void destroyInstance() {
        if (_instance) {
            delete _instance;
            _instance = nullptr;
        }
    }

protected :
    Singleton() 
    {
    }

    virtual ~Singleton() 
    {
    }

private:
	Singleton(Singleton&) = delete;
	void operator =(Singleton&) = delete;

private :
    /// C++11 standard assures a static instance should be thread safe:
    /// "if control enters the declaration concurrently while the variable is being initialized,
    /// the concurrent execution shall wait for completion of the initialization."
    static T* _instance;
};

template<typename T> T* Singleton<T>::_instance = 0;

#define DEFINE_SINGLETON(class_name) \
    class class_name : public Singleton<class_name> { \
        friend class Singleton<class_name>;

#define DEFINE_SINGLETON_EXT1(class_name, base_class) \
    class class_name : public Singleton<class_name> , public base_class{ \
        friend class Singleton<class_name>;

#define DEFINE_SINGLETON_EXT2(class_name, base_class1, base_class2) \
    class class_name : public Singleton<class_name> , public base_class1, public base_class2{ \
        friend class Singleton<class_name>;

#define END_SINGLETON };

}; //namespace Divide

#endif // SINGLETON_H

Commits for Divide-Framework/trunk/Source Code/Core/Headers/Singleton.h

Diff revisions: vs.
Revision Author Commited Message
331 Diff Diff IonutCava picture IonutCava Sat 06 Dec, 2014 20:53:45 +0000

[Ionut]
- Limited line length to 132 characters to improve readability and diff-comparisons
- Refactored memory allocation/deallocation functions
- Fixed a few compatibility issues with HashMap.h
- Fixed a bug in GPU Skinning shaders (cast a float to int)

326 Diff Diff IonutCava picture IonutCava Tue 30 Sep, 2014 21:11:32 +0000

[Ionut]
- Fixed more memory leaks
- Simplified Task interface and timing System
- Improved compatibility between Boost, STL and EASTL with random combinations of vectors, strings and maps
- Simplified Light class by removing the “slot” member
- Random optimizations

324 Diff Diff IonutCava picture IonutCava Sun 14 Sep, 2014 14:01:39 +0000

[Ionut]
- New memory management system (no custom allocators in this commit)
— Memory tracer to detect memory leaks on shutdown (from: https://www.relisoft.com/book/tech/9new.html)
— SAFE_DELETE_XYZ are now inline template functions not macros
— ASSERTION system now supports logging and message boxes and continue on error configurable for each build type
— Fixed a lot of memory leaks detected by the new system (some still remain)

- Added SRGB support (part 1)
— Albedo textures are loaded as SRGB (make sure resources are SRGB)
— Shaders output gamma corrected colors
— Moved terrain textures back to 2 array system (albedo and normal maps, albedo maps using a SRGB sampler)

- Sky is now loaded via the ResourceCache system
- Added include safeguards in shader atoms

318 Diff Diff IonutCava picture IonutCava Sat 30 Aug, 2014 17:35:53 +0000

[Ionut]
- Wrapped the entire code in a “Divide” namespace
- VertexBuffers now call “shrink_to_fit” on all internal data storage
- Improved some vector performance by preferring “emplace_back” instead of “push_back” + proepr usage of reserve / resize
- Wrapped OIS specific types and classes in Divide::Input namespace
- Added the messageBox.layout file (forgot it in the previous few commits)

294 Diff Diff k1ngp1n picture k1ngp1n Wed 30 Jul, 2014 20:19:14 +0000

[Ionut]
- More nVidia compatibility fixes (lighting shaders with textures still fail to compile):
— NS_GLIM compatibility fix (set ELEMENT_ARRAY_BUFFER to 0 in glimBatchData’s VAO on creation when setting attrib pointers)

  • Could improve NS_GLIM performance a lot by caching some buffers instead of re-creating them every time a batch is generated, but it’s suppose to be used only for debugging, so low prio*

- Removed interpolation factor from FrameEvent struct. Only using interpolation factor stored in GFXDevice instance
- Fixed the close button (added GLFW close callback)
- More code style improvements (no new comments yet)

249 Diff Diff k1ngp1n picture k1ngp1n Mon 31 Mar, 2014 20:42:31 +0000

[Ionut] [[BR]]
- Migrated to platform toolset v100 [[BR]]
- Updated boost to 1.55 [[BR]]
- Moved from “NULL” to “nullptr” [[BR]]
- DevIL is now linked dynamically [[BR]]

224 Diff Diff k1ngp1n picture k1ngp1n Thu 09 Jan, 2014 21:30:55 +0000

[Ionut] [[BR]]
- More work and bugfixes with the branch reintegration [[BR]]
- Fixed GPU performance queries [[BR]]
- Fixed some FBO creation issues with multisampled textures [[BR]]
- Current issues: [[BR]]
— Terrain rendering not working on AMD [[BR]]
— Reflections not working on AMD & nVidia [[BR]]
— Grass rendering using TRIANGLE_STRIPS not complete yet [[BR]]

221 Diff Diff k1ngp1n picture k1ngp1n Wed 08 Jan, 2014 18:50:02 +0000

[Ionut] [[BR]]
- Merged branch “Shadows And Animations” back into trunk [[BR]]
- Added DoxygenGUI project file [[BR]]

  • Buggy *
178 Diff Diff k1ngp1n picture k1ngp1n Sat 16 Nov, 2013 16:42:20 +0000

[Ionut][[BR]]
- Path generation between 2 points using a specified NavMesh (Part 1 / 3 - “Base Code”) [[BR]]

170 k1ngp1n picture k1ngp1n Sun 03 Nov, 2013 17:24:57 +0000

-Moved hardware related code to a separate project [[BR]]
-More work on post-processing: [[BR]]
— HDR rendering is working, but final tonemapping needs more work [[BR]]
-Important changes in BloomPreRenderOperator.cpp, PostFX.cpp and glFrameBufferObject.cpp [[BR]]
-Trailing and leading whitespace cleanups [[BR]]