Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/libraries/src/util/CMakeLists.txt @ 5640

Last change on this file since 5640 was 5640, checked in by landauf, 15 years ago

Added a new utility "ScopedSingleton". A ScopedSingleton has a scope which is represented by a Scope template. ScopedSingletons are allowed to exist (= get created automatically after the first call to getInstance()) as soon as at least one instance of the corresponding Scope exists. If all those instances of Scope are deleted, the corresponding ScopedSingletons are destroyed too.

This allows us to create Singletons (for example the QuestManager) which may exist in a plugin and still get created and destroyed in parallel with GSLevel (or whatever Scope you like). All we have to do is to create and destroy one instance of Scope in GSLevel (or whoever defines the Scope). Therefore we don't have to link the singleton into GSLevel which is quite handy if we want to build independent plugins.

Btw, this can be expanded to other constructs, not just singletons. Just inherit from ScopeListener to get the full load of features.

(Note to Reto: I had to add a "ScopeManager" which ensures static linkage of the scope counters and listeners. Otherwise we'd end up with different counts in each library which is quite bad. Maybe you have a better idea? Or maybe you want to make the ScopeManager a singleton too? ;))

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1 #
2 #             ORXONOX - the hottest 3D action shooter ever to exist
3 #                             > www.orxonox.net <
4 #
5 #        This program is free software; you can redistribute it and/or
6 #         modify it under the terms of the GNU General Public License
7 #        as published by the Free Software Foundation; either version 2
8 #            of the License, or (at your option) any later version.
9 #
10 #       This program is distributed in the hope that it will be useful,
11 #        but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #                 GNU General Public License for more details.
14 #
15 #   You should have received a copy of the GNU General Public License along
16 #      with this program; if not, write to the Free Software Foundation,
17 #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 #
19
20SET_SOURCE_FILES(UTIL_SRC_FILES
21  Clipboard.cc
22  CRC32.cc
23  Exception.cc
24  ExprParser.cc
25  Math.cc
26  MultiType.cc
27  OutputBuffer.cc
28  OutputHandler.cc
29  Scope.cc
30  SignalHandler.cc
31  Sleep.cc
32  StringUtils.cc
33  SubString.cc
34)
35
36IF(GCC_NO_SYSTEM_HEADER_SUPPORT)
37  # Get around displaying a few hundred lines of warning code
38  SET_SOURCE_FILES_PROPERTIES(MultiType.cc PROPERTIES COMPILE_FLAGS "-w")
39ENDIF()
40
41ORXONOX_ADD_LIBRARY(util
42  FIND_HEADER_FILES
43  DEFINE_SYMBOL
44    "UTIL_SHARED_BUILD"
45  LINK_LIBRARIES
46    ${OGRE_LIBRARY}
47  SOURCE_FILES
48    ${UTIL_SRC_FILES}
49)
Note: See TracBrowser for help on using the repository browser.