8c9cdb65ad46f0cf94536bf08c717bf57fbef4d5
[TDDC76_proj.git] /
1 ////////////////////////////////////////////////////////////
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
23 ////////////////////////////////////////////////////////////
24
25 #ifndef SFML_NONCOPYABLE_HPP
26 #define SFML_NONCOPYABLE_HPP
27
28 ////////////////////////////////////////////////////////////
29 // Headers
30 ////////////////////////////////////////////////////////////
31 #include <SFML/System/Export.hpp>
32
33
34 namespace sf
35 {
36 ////////////////////////////////////////////////////////////
37 /// \brief Utility class that makes any derived
38 /// class non-copyable
39 ///
40 ////////////////////////////////////////////////////////////
41 class SFML_SYSTEM_API NonCopyable
42 {
43 protected :
44
45 ////////////////////////////////////////////////////////////
46 /// \brief Default constructor
47 ///
48 /// Because this class has a copy constructor, the compiler
49 /// will not automatically generate the default constructor.
50 /// That's why we must define it explicitely.
51 ///
52 ////////////////////////////////////////////////////////////
53 NonCopyable() {}
54
55 private :
56
57 ////////////////////////////////////////////////////////////
58 /// \brief Disabled copy constructor
59 ///
60 /// By making the copy constructor private, the compiler will
61 /// trigger an error if anyone outside tries to use it.
62 /// To prevent NonCopyable or friend classes from using it,
63 /// we also give no definition, so that the linker will
64 /// produce an error if the first protection was inefficient.
65 ///
66 ////////////////////////////////////////////////////////////
67 NonCopyable(const NonCopyable&);
68
69 ////////////////////////////////////////////////////////////
70 /// \brief Disabled assignment operator
71 ///
72 /// By making the assignment operator private, the compiler will
73 /// trigger an error if anyone outside tries to use it.
74 /// To prevent NonCopyable or friend classes from using it,
75 /// we also give no definition, so that the linker will
76 /// produce an error if the first protection was inefficient.
77 ///
78 ////////////////////////////////////////////////////////////
79 NonCopyable& operator =(const NonCopyable&);
80 };
81
82 } // namespace sf
83
84
85 #endif // SFML_NONCOPYABLE_HPP
86
87
88 ////////////////////////////////////////////////////////////
89 /// \class sf::NonCopyable
90 /// \ingroup system
91 ///
92 /// This class makes its instances non-copyable, by explicitely
93 /// disabling its copy constructor and its assignment operator.
94 ///
95 /// To create a non-copyable class, simply inherit from
96 /// sf::NonCopyable.
97 ///
98 /// The type of inheritance (public or private) doesn't matter,
99 /// the copy constructor and assignment operator are declared private
100 /// in sf::NonCopyable so they will end up being inaccessible in both
101 /// cases. Thus you can use a shorter syntax for inheriting from it
102 /// (see below).
103 ///
104 /// Usage example:
105 /// \code
106 /// class MyNonCopyableClass : sf::NonCopyable
107 /// {
108 /// ...
109 /// };
110 /// \endcode
111 ///
112 /// Deciding whether the instances of a class can be copied
113 /// or not is a very important design choice. You are strongly
114 /// encouraged to think about it before writing a class,
115 /// and to use sf::NonCopyable when necessary to prevent
116 /// many potential future errors when using it. This is also
117 /// a very important indication to users of your class.
118 ///
119 ////////////////////////////////////////////////////////////