0
7
1
1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
|
2 |
* |
|
3 |
* This file is a part of LEMON, a generic C++ optimization library. |
|
4 |
* |
|
5 |
* Copyright (C) 2003-2012 |
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
|
8 |
* |
|
9 |
* Permission to use, modify and distribute this software is granted |
|
10 |
* provided that this copyright notice appears in all copies. For |
|
11 |
* precise terms see the accompanying LICENSE file. |
|
12 |
* |
|
13 |
* This software is provided "AS IS" with no warranty of any kind, |
|
14 |
* express or implied, and with no claim as to its suitability for any |
|
15 |
* purpose. |
|
16 |
* |
|
17 |
*/ |
|
18 |
|
|
19 |
#ifndef LEMON_BITS_LOCK_H |
|
20 |
#define LEMON_BITS_LOCK_H |
|
21 |
|
|
22 |
#include <lemon/config.h> |
|
23 |
#if defined(LEMON_USE_PTHREAD) |
|
24 |
#include <pthread.h> |
|
25 |
#elif defined(LEMON_USE_WIN32_THREADS) |
|
26 |
#include <lemon/bits/windows.h> |
|
27 |
#endif |
|
28 |
|
|
29 |
namespace lemon { |
|
30 |
namespace bits { |
|
31 |
|
|
32 |
#if defined(LEMON_USE_PTHREAD) |
|
33 |
class Lock { |
|
34 |
public: |
|
35 |
Lock() { |
|
36 |
pthread_mutex_init(&_lock, 0); |
|
37 |
} |
|
38 |
~Lock() { |
|
39 |
pthread_mutex_destroy(&_lock); |
|
40 |
} |
|
41 |
void lock() { |
|
42 |
pthread_mutex_lock(&_lock); |
|
43 |
} |
|
44 |
void unlock() { |
|
45 |
pthread_mutex_unlock(&_lock); |
|
46 |
} |
|
47 |
|
|
48 |
private: |
|
49 |
pthread_mutex_t _lock; |
|
50 |
}; |
|
51 |
#elif defined(LEMON_USE_WIN32_THREADS) |
|
52 |
class Lock : public WinLock {}; |
|
53 |
#else |
|
54 |
class Lock { |
|
55 |
public: |
|
56 |
Lock() {} |
|
57 |
~Lock() {} |
|
58 |
void lock() {} |
|
59 |
void unlock() {} |
|
60 |
}; |
|
61 |
#endif |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
#endif |
... | ... |
@@ -21,192 +21,196 @@ |
21 | 21 |
EXECUTE_PROCESS( |
22 | 22 |
COMMAND hg id -i |
23 | 23 |
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} |
24 | 24 |
OUTPUT_VARIABLE HG_REVISION |
25 | 25 |
ERROR_QUIET |
26 | 26 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
27 | 27 |
) |
28 | 28 |
IF(HG_REVISION STREQUAL "") |
29 | 29 |
SET(HG_REVISION_ID "hg-tip") |
30 | 30 |
ELSE() |
31 | 31 |
IF(HG_REVISION_PATH STREQUAL "") |
32 | 32 |
SET(HG_REVISION_ID ${HG_REVISION}) |
33 | 33 |
ELSE() |
34 | 34 |
SET(HG_REVISION_ID ${HG_REVISION_PATH}.${HG_REVISION}) |
35 | 35 |
ENDIF() |
36 | 36 |
ENDIF() |
37 | 37 |
SET(LEMON_VERSION ${HG_REVISION_ID} CACHE STRING "LEMON version string.") |
38 | 38 |
ENDIF() |
39 | 39 |
|
40 | 40 |
SET(PROJECT_VERSION ${LEMON_VERSION}) |
41 | 41 |
|
42 | 42 |
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) |
43 | 43 |
|
44 | 44 |
FIND_PACKAGE(Doxygen) |
45 | 45 |
FIND_PACKAGE(Ghostscript) |
46 | 46 |
FIND_PACKAGE(GLPK 4.33) |
47 | 47 |
FIND_PACKAGE(CPLEX) |
48 | 48 |
FIND_PACKAGE(COIN) |
49 | 49 |
|
50 | 50 |
IF(DEFINED ENV{LEMON_CXX_WARNING}) |
51 | 51 |
SET(CXX_WARNING $ENV{LEMON_CXX_WARNING}) |
52 | 52 |
ELSE() |
53 | 53 |
IF(CMAKE_COMPILER_IS_GNUCXX) |
54 | 54 |
SET(CXX_WARNING "-Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas") |
55 | 55 |
SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb") |
56 | 56 |
SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb") |
57 | 57 |
ELSEIF(MSVC) |
58 | 58 |
# This part is unnecessary 'casue the same is set by the lemon/core.h. |
59 | 59 |
# Still keep it as an example. |
60 | 60 |
SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996") |
61 | 61 |
# Suppressed warnings: |
62 | 62 |
# C4250: 'class1' : inherits 'class2::member' via dominance |
63 | 63 |
# C4355: 'this' : used in base member initializer list |
64 | 64 |
# C4503: 'function' : decorated name length exceeded, name was truncated |
65 | 65 |
# C4800: 'type' : forcing value to bool 'true' or 'false' |
66 | 66 |
# (performance warning) |
67 | 67 |
# C4996: 'function': was declared deprecated |
68 | 68 |
ELSE() |
69 | 69 |
SET(CXX_WARNING "-Wall") |
70 | 70 |
ENDIF() |
71 | 71 |
ENDIF() |
72 | 72 |
SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.") |
73 | 73 |
|
74 | 74 |
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}") |
75 | 75 |
|
76 | 76 |
SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb -O0" CACHE STRING |
77 | 77 |
"Flags used by the C++ compiler during maintainer builds." |
78 | 78 |
FORCE ) |
79 | 79 |
SET( CMAKE_C_FLAGS_MAINTAINER "-Werror -O0" CACHE STRING |
80 | 80 |
"Flags used by the C compiler during maintainer builds." |
81 | 81 |
FORCE ) |
82 | 82 |
SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER |
83 | 83 |
"-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING |
84 | 84 |
"Flags used for linking binaries during maintainer builds." |
85 | 85 |
FORCE ) |
86 | 86 |
SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER |
87 | 87 |
"-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING |
88 | 88 |
"Flags used by the shared libraries linker during maintainer builds." |
89 | 89 |
FORCE ) |
90 | 90 |
MARK_AS_ADVANCED( |
91 | 91 |
CMAKE_CXX_FLAGS_MAINTAINER |
92 | 92 |
CMAKE_C_FLAGS_MAINTAINER |
93 | 93 |
CMAKE_EXE_LINKER_FLAGS_MAINTAINER |
94 | 94 |
CMAKE_SHARED_LINKER_FLAGS_MAINTAINER ) |
95 | 95 |
|
96 | 96 |
IF(CMAKE_CONFIGURATION_TYPES) |
97 | 97 |
LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer) |
98 | 98 |
LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES) |
99 | 99 |
SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING |
100 | 100 |
"Add the configurations that we need" |
101 | 101 |
FORCE) |
102 | 102 |
endif() |
103 | 103 |
|
104 | 104 |
IF(NOT CMAKE_BUILD_TYPE) |
105 | 105 |
SET(CMAKE_BUILD_TYPE "Release") |
106 | 106 |
ENDIF() |
107 | 107 |
|
108 | 108 |
SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING |
109 | 109 |
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer." |
110 | 110 |
FORCE ) |
111 | 111 |
|
112 | 112 |
|
113 | 113 |
INCLUDE(CheckTypeSize) |
114 | 114 |
CHECK_TYPE_SIZE("long long" LONG_LONG) |
115 | 115 |
SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG}) |
116 | 116 |
|
117 |
INCLUDE(FindThreads) |
|
118 |
SET(LEMON_USE_PTHREAD ${CMAKE_USE_PTHREADS_INIT}) |
|
119 |
SET(LEMON_USE_WIN32_THREADS ${CMAKE_USE_WIN32_THREADS_INIT}) |
|
120 |
|
|
117 | 121 |
ENABLE_TESTING() |
118 | 122 |
|
119 | 123 |
IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") |
120 | 124 |
ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND}) |
121 | 125 |
ELSE() |
122 | 126 |
ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND}) |
123 | 127 |
ENDIF() |
124 | 128 |
|
125 | 129 |
ADD_SUBDIRECTORY(lemon) |
126 | 130 |
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) |
127 | 131 |
ADD_SUBDIRECTORY(contrib) |
128 | 132 |
ADD_SUBDIRECTORY(demo) |
129 | 133 |
ADD_SUBDIRECTORY(tools) |
130 | 134 |
ADD_SUBDIRECTORY(doc) |
131 | 135 |
ADD_SUBDIRECTORY(test) |
132 | 136 |
ENDIF() |
133 | 137 |
|
134 | 138 |
CONFIGURE_FILE( |
135 | 139 |
${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in |
136 | 140 |
${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake |
137 | 141 |
@ONLY |
138 | 142 |
) |
139 | 143 |
IF(UNIX) |
140 | 144 |
INSTALL( |
141 | 145 |
FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake |
142 | 146 |
DESTINATION share/lemon/cmake |
143 | 147 |
) |
144 | 148 |
ELSEIF(WIN32) |
145 | 149 |
INSTALL( |
146 | 150 |
FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake |
147 | 151 |
DESTINATION cmake |
148 | 152 |
) |
149 | 153 |
ENDIF() |
150 | 154 |
|
151 | 155 |
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) |
152 | 156 |
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) |
153 | 157 |
SET(CPACK_PACKAGE_VENDOR "EGRES") |
154 | 158 |
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY |
155 | 159 |
"LEMON - Library for Efficient Modeling and Optimization in Networks") |
156 | 160 |
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") |
157 | 161 |
|
158 | 162 |
SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) |
159 | 163 |
|
160 | 164 |
SET(CPACK_PACKAGE_INSTALL_DIRECTORY |
161 | 165 |
"${PROJECT_NAME} ${PROJECT_VERSION}") |
162 | 166 |
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY |
163 | 167 |
"${PROJECT_NAME} ${PROJECT_VERSION}") |
164 | 168 |
|
165 | 169 |
SET(CPACK_COMPONENTS_ALL headers library html_documentation bin) |
166 | 170 |
|
167 | 171 |
SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers") |
168 | 172 |
SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library") |
169 | 173 |
SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities") |
170 | 174 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation") |
171 | 175 |
|
172 | 176 |
SET(CPACK_COMPONENT_HEADERS_DESCRIPTION |
173 | 177 |
"C++ header files") |
174 | 178 |
SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION |
175 | 179 |
"DLL and import library") |
176 | 180 |
SET(CPACK_COMPONENT_BIN_DESCRIPTION |
177 | 181 |
"Command line utilities") |
178 | 182 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION |
179 | 183 |
"Doxygen generated documentation") |
180 | 184 |
|
181 | 185 |
SET(CPACK_COMPONENT_HEADERS_DEPENDS library) |
182 | 186 |
|
183 | 187 |
SET(CPACK_COMPONENT_HEADERS_GROUP "Development") |
184 | 188 |
SET(CPACK_COMPONENT_LIBRARY_GROUP "Development") |
185 | 189 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation") |
186 | 190 |
|
187 | 191 |
SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION |
188 | 192 |
"Components needed to develop software using LEMON") |
189 | 193 |
SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION |
190 | 194 |
"Documentation of LEMON") |
191 | 195 |
|
192 | 196 |
SET(CPACK_ALL_INSTALL_TYPES Full Developer) |
193 | 197 |
|
194 | 198 |
SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full) |
195 | 199 |
SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full) |
196 | 200 |
SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full) |
197 | 201 |
|
198 | 202 |
SET(CPACK_GENERATOR "NSIS") |
199 | 203 |
SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico") |
200 | 204 |
SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico") |
201 | 205 |
#SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp") |
202 | 206 |
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico") |
203 | 207 |
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}") |
204 | 208 |
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu") |
205 | 209 |
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu") |
206 | 210 |
SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu") |
207 | 211 |
SET(CPACK_NSIS_CREATE_ICONS_EXTRA " |
208 | 212 |
CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\" |
209 | 213 |
") |
210 | 214 |
SET(CPACK_NSIS_DELETE_ICONS_EXTRA " |
211 | 215 |
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP |
212 | 216 |
Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\" |
... | ... |
@@ -45,110 +45,111 @@ |
45 | 45 |
if HAVE_SOPLEX |
46 | 46 |
lemon_libemon_la_SOURCES += lemon/soplex.cc |
47 | 47 |
endif |
48 | 48 |
|
49 | 49 |
if HAVE_CLP |
50 | 50 |
lemon_libemon_la_SOURCES += lemon/clp.cc |
51 | 51 |
endif |
52 | 52 |
|
53 | 53 |
if HAVE_CBC |
54 | 54 |
lemon_libemon_la_SOURCES += lemon/cbc.cc |
55 | 55 |
endif |
56 | 56 |
|
57 | 57 |
lemon_HEADERS += \ |
58 | 58 |
lemon/adaptors.h \ |
59 | 59 |
lemon/arg_parser.h \ |
60 | 60 |
lemon/assert.h \ |
61 | 61 |
lemon/bellman_ford.h \ |
62 | 62 |
lemon/bfs.h \ |
63 | 63 |
lemon/bin_heap.h \ |
64 | 64 |
lemon/binomial_heap.h \ |
65 | 65 |
lemon/bucket_heap.h \ |
66 | 66 |
lemon/capacity_scaling.h \ |
67 | 67 |
lemon/cbc.h \ |
68 | 68 |
lemon/circulation.h \ |
69 | 69 |
lemon/clp.h \ |
70 | 70 |
lemon/color.h \ |
71 | 71 |
lemon/concept_check.h \ |
72 | 72 |
lemon/connectivity.h \ |
73 | 73 |
lemon/core.h \ |
74 | 74 |
lemon/cost_scaling.h \ |
75 | 75 |
lemon/counter.h \ |
76 | 76 |
lemon/cplex.h \ |
77 | 77 |
lemon/cycle_canceling.h \ |
78 | 78 |
lemon/dfs.h \ |
79 | 79 |
lemon/dheap.h \ |
80 | 80 |
lemon/dijkstra.h \ |
81 | 81 |
lemon/dim2.h \ |
82 | 82 |
lemon/dimacs.h \ |
83 | 83 |
lemon/edge_set.h \ |
84 | 84 |
lemon/elevator.h \ |
85 | 85 |
lemon/error.h \ |
86 | 86 |
lemon/euler.h \ |
87 | 87 |
lemon/fib_heap.h \ |
88 | 88 |
lemon/fractional_matching.h \ |
89 | 89 |
lemon/full_graph.h \ |
90 | 90 |
lemon/glpk.h \ |
91 | 91 |
lemon/gomory_hu.h \ |
92 | 92 |
lemon/graph_to_eps.h \ |
93 | 93 |
lemon/grid_graph.h \ |
94 | 94 |
lemon/grosso_locatelli_pullan_mc.h \ |
95 | 95 |
lemon/hartmann_orlin_mmc.h \ |
96 | 96 |
lemon/howard_mmc.h \ |
97 | 97 |
lemon/hypercube_graph.h \ |
98 | 98 |
lemon/karp_mmc.h \ |
99 | 99 |
lemon/kruskal.h \ |
100 | 100 |
lemon/hao_orlin.h \ |
101 | 101 |
lemon/lgf_reader.h \ |
102 | 102 |
lemon/lgf_writer.h \ |
103 | 103 |
lemon/list_graph.h \ |
104 | 104 |
lemon/lp.h \ |
105 | 105 |
lemon/lp_base.h \ |
106 | 106 |
lemon/lp_skeleton.h \ |
107 | 107 |
lemon/maps.h \ |
108 | 108 |
lemon/matching.h \ |
109 | 109 |
lemon/math.h \ |
110 | 110 |
lemon/min_cost_arborescence.h \ |
111 | 111 |
lemon/max_cardinality_search.h \ |
112 | 112 |
lemon/nagamochi_ibaraki.h \ |
113 | 113 |
lemon/nauty_reader.h \ |
114 | 114 |
lemon/network_simplex.h \ |
115 | 115 |
lemon/pairing_heap.h \ |
116 | 116 |
lemon/path.h \ |
117 | 117 |
lemon/planarity.h \ |
118 | 118 |
lemon/preflow.h \ |
119 | 119 |
lemon/quad_heap.h \ |
120 | 120 |
lemon/radix_heap.h \ |
121 | 121 |
lemon/radix_sort.h \ |
122 | 122 |
lemon/random.h \ |
123 | 123 |
lemon/smart_graph.h \ |
124 | 124 |
lemon/soplex.h \ |
125 | 125 |
lemon/static_graph.h \ |
126 | 126 |
lemon/suurballe.h \ |
127 | 127 |
lemon/time_measure.h \ |
128 | 128 |
lemon/tolerance.h \ |
129 | 129 |
lemon/unionfind.h \ |
130 | 130 |
lemon/bits/windows.h |
131 | 131 |
|
132 | 132 |
bits_HEADERS += \ |
133 | 133 |
lemon/bits/alteration_notifier.h \ |
134 | 134 |
lemon/bits/array_map.h \ |
135 | 135 |
lemon/bits/bezier.h \ |
136 | 136 |
lemon/bits/default_map.h \ |
137 | 137 |
lemon/bits/edge_set_extender.h \ |
138 | 138 |
lemon/bits/enable_if.h \ |
139 | 139 |
lemon/bits/graph_adaptor_extender.h \ |
140 | 140 |
lemon/bits/graph_extender.h \ |
141 |
lemon/bits/lock.h \ |
|
141 | 142 |
lemon/bits/map_extender.h \ |
142 | 143 |
lemon/bits/path_dump.h \ |
143 | 144 |
lemon/bits/solver_bits.h \ |
144 | 145 |
lemon/bits/traits.h \ |
145 | 146 |
lemon/bits/variant.h \ |
146 | 147 |
lemon/bits/vector_map.h |
147 | 148 |
|
148 | 149 |
concept_HEADERS += \ |
149 | 150 |
lemon/concepts/digraph.h \ |
150 | 151 |
lemon/concepts/graph.h \ |
151 | 152 |
lemon/concepts/graph_components.h \ |
152 | 153 |
lemon/concepts/heap.h \ |
153 | 154 |
lemon/concepts/maps.h \ |
154 | 155 |
lemon/concepts/path.h |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 | 5 |
* Copyright (C) 2003-2009 |
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_ALTERATION_NOTIFIER_H |
20 | 20 |
#define LEMON_BITS_ALTERATION_NOTIFIER_H |
21 | 21 |
|
22 | 22 |
#include <vector> |
23 | 23 |
#include <list> |
24 | 24 |
|
25 | 25 |
#include <lemon/core.h> |
26 |
#include <lemon/bits/lock.h> |
|
26 | 27 |
|
27 | 28 |
//\ingroup graphbits |
28 | 29 |
//\file |
29 | 30 |
//\brief Observer notifier for graph alteration observers. |
30 | 31 |
|
31 | 32 |
namespace lemon { |
32 | 33 |
|
33 | 34 |
// \ingroup graphbits |
34 | 35 |
// |
35 | 36 |
// \brief Notifier class to notify observes about alterations in |
36 | 37 |
// a container. |
37 | 38 |
// |
38 | 39 |
// The simple graphs can be refered as two containers: a node container |
39 | 40 |
// and an edge container. But they do not store values directly, they |
40 | 41 |
// are just key continars for more value containers, which are the |
41 | 42 |
// node and edge maps. |
42 | 43 |
// |
43 | 44 |
// The node and edge sets of the graphs can be changed as we add or erase |
44 | 45 |
// nodes and edges in the graph. LEMON would like to handle easily |
45 | 46 |
// that the node and edge maps should contain values for all nodes or |
46 | 47 |
// edges. If we want to check on every indicing if the map contains |
47 | 48 |
// the current indicing key that cause a drawback in the performance |
48 | 49 |
// in the library. We use another solution: we notify all maps about |
49 | 50 |
// an alteration in the graph, which cause only drawback on the |
50 | 51 |
// alteration of the graph. |
51 | 52 |
// |
52 | 53 |
// This class provides an interface to a node or edge container. |
53 | 54 |
// The first() and next() member functions make possible |
54 | 55 |
// to iterate on the keys of the container. |
55 | 56 |
// The id() function returns an integer id for each key. |
56 | 57 |
// The maxId() function gives back an upper bound of the ids. |
57 | 58 |
// |
58 | 59 |
// For the proper functonality of this class, we should notify it |
59 | 60 |
// about each alteration in the container. The alterations have four type: |
60 | 61 |
// add(), erase(), build() and clear(). The add() and |
61 | 62 |
// erase() signal that only one or few items added or erased to or |
62 | 63 |
// from the graph. If all items are erased from the graph or if a new graph |
63 | 64 |
// is built from an empty graph, then it can be signaled with the |
64 | 65 |
// clear() and build() members. Important rule that if we erase items |
65 | 66 |
// from graphs we should first signal the alteration and after that erase |
66 | 67 |
// them from the container, on the other way on item addition we should |
67 | 68 |
// first extend the container and just after that signal the alteration. |
68 | 69 |
// |
69 | 70 |
// The alteration can be observed with a class inherited from the |
70 | 71 |
// ObserverBase nested class. The signals can be handled with |
71 | 72 |
// overriding the virtual functions defined in the base class. The |
72 | 73 |
// observer base can be attached to the notifier with the |
73 | 74 |
// attach() member and can be detached with detach() function. The |
74 | 75 |
// alteration handlers should not call any function which signals |
75 | 76 |
// an other alteration in the same notifier and should not |
76 | 77 |
// detach any observer from the notifier. |
77 | 78 |
// |
78 | 79 |
// Alteration observers try to be exception safe. If an add() or |
79 | 80 |
// a clear() function throws an exception then the remaining |
80 | 81 |
// observeres will not be notified and the fulfilled additions will |
81 | 82 |
// be rolled back by calling the erase() or clear() functions. |
82 | 83 |
// Hence erase() and clear() should not throw exception. |
83 | 84 |
// Actullay, they can throw only \ref ImmediateDetach exception, |
84 | 85 |
// which detach the observer from the notifier. |
85 | 86 |
// |
86 | 87 |
// There are some cases, when the alteration observing is not completly |
87 | 88 |
// reliable. If we want to carry out the node degree in the graph |
88 | 89 |
// as in the \ref InDegMap and we use the reverseArc(), then it cause |
89 | 90 |
// unreliable functionality. Because the alteration observing signals |
90 | 91 |
// only erasing and adding but not the reversing, it will stores bad |
91 | 92 |
// degrees. Apart form that the subgraph adaptors cannot even signal |
92 | 93 |
// the alterations because just a setting in the filter map can modify |
93 | 94 |
// the graph and this cannot be watched in any way. |
94 | 95 |
// |
95 | 96 |
// \param _Container The container which is observed. |
96 | 97 |
// \param _Item The item type which is obserbved. |
97 | 98 |
|
98 | 99 |
template <typename _Container, typename _Item> |
99 | 100 |
class AlterationNotifier { |
100 | 101 |
public: |
101 | 102 |
|
102 | 103 |
typedef True Notifier; |
103 | 104 |
|
104 | 105 |
typedef _Container Container; |
105 | 106 |
typedef _Item Item; |
106 | 107 |
|
107 | 108 |
// \brief Exception which can be called from clear() and |
108 | 109 |
// erase(). |
109 | 110 |
// |
110 | 111 |
// From the clear() and erase() function only this |
111 | 112 |
// exception is allowed to throw. The exception immediatly |
112 | 113 |
// detaches the current observer from the notifier. Because the |
113 | 114 |
// clear() and erase() should not throw other exceptions |
114 | 115 |
// it can be used to invalidate the observer. |
115 | 116 |
struct ImmediateDetach {}; |
116 | 117 |
|
117 | 118 |
// \brief ObserverBase is the base class for the observers. |
118 | 119 |
// |
119 | 120 |
// ObserverBase is the abstract base class for the observers. |
120 | 121 |
// It will be notified about an item was inserted into or |
121 | 122 |
// erased from the graph. |
... | ... |
@@ -158,281 +159,285 @@ |
158 | 159 |
// \brief Destructor |
159 | 160 |
virtual ~ObserverBase() { |
160 | 161 |
if (attached()) { |
161 | 162 |
detach(); |
162 | 163 |
} |
163 | 164 |
} |
164 | 165 |
|
165 | 166 |
// \brief Attaches the observer into an AlterationNotifier. |
166 | 167 |
// |
167 | 168 |
// This member attaches the observer into an AlterationNotifier. |
168 | 169 |
void attach(AlterationNotifier& nf) { |
169 | 170 |
nf.attach(*this); |
170 | 171 |
} |
171 | 172 |
|
172 | 173 |
// \brief Detaches the observer into an AlterationNotifier. |
173 | 174 |
// |
174 | 175 |
// This member detaches the observer from an AlterationNotifier. |
175 | 176 |
void detach() { |
176 | 177 |
_notifier->detach(*this); |
177 | 178 |
} |
178 | 179 |
|
179 | 180 |
// \brief Gives back a pointer to the notifier which the map |
180 | 181 |
// attached into. |
181 | 182 |
// |
182 | 183 |
// This function gives back a pointer to the notifier which the map |
183 | 184 |
// attached into. |
184 | 185 |
Notifier* notifier() const { return const_cast<Notifier*>(_notifier); } |
185 | 186 |
|
186 | 187 |
// Gives back true when the observer is attached into a notifier. |
187 | 188 |
bool attached() const { return _notifier != 0; } |
188 | 189 |
|
189 | 190 |
private: |
190 | 191 |
|
191 | 192 |
ObserverBase& operator=(const ObserverBase& copy); |
192 | 193 |
|
193 | 194 |
protected: |
194 | 195 |
|
195 | 196 |
Notifier* _notifier; |
196 | 197 |
typename std::list<ObserverBase*>::iterator _index; |
197 | 198 |
|
198 | 199 |
// \brief The member function to notificate the observer about an |
199 | 200 |
// item is added to the container. |
200 | 201 |
// |
201 | 202 |
// The add() member function notificates the observer about an item |
202 | 203 |
// is added to the container. It have to be overrided in the |
203 | 204 |
// subclasses. |
204 | 205 |
virtual void add(const Item&) = 0; |
205 | 206 |
|
206 | 207 |
// \brief The member function to notificate the observer about |
207 | 208 |
// more item is added to the container. |
208 | 209 |
// |
209 | 210 |
// The add() member function notificates the observer about more item |
210 | 211 |
// is added to the container. It have to be overrided in the |
211 | 212 |
// subclasses. |
212 | 213 |
virtual void add(const std::vector<Item>& items) = 0; |
213 | 214 |
|
214 | 215 |
// \brief The member function to notificate the observer about an |
215 | 216 |
// item is erased from the container. |
216 | 217 |
// |
217 | 218 |
// The erase() member function notificates the observer about an |
218 | 219 |
// item is erased from the container. It have to be overrided in |
219 | 220 |
// the subclasses. |
220 | 221 |
virtual void erase(const Item&) = 0; |
221 | 222 |
|
222 | 223 |
// \brief The member function to notificate the observer about |
223 | 224 |
// more item is erased from the container. |
224 | 225 |
// |
225 | 226 |
// The erase() member function notificates the observer about more item |
226 | 227 |
// is erased from the container. It have to be overrided in the |
227 | 228 |
// subclasses. |
228 | 229 |
virtual void erase(const std::vector<Item>& items) = 0; |
229 | 230 |
|
230 | 231 |
// \brief The member function to notificate the observer about the |
231 | 232 |
// container is built. |
232 | 233 |
// |
233 | 234 |
// The build() member function notificates the observer about the |
234 | 235 |
// container is built from an empty container. It have to be |
235 | 236 |
// overrided in the subclasses. |
236 | 237 |
virtual void build() = 0; |
237 | 238 |
|
238 | 239 |
// \brief The member function to notificate the observer about all |
239 | 240 |
// items are erased from the container. |
240 | 241 |
// |
241 | 242 |
// The clear() member function notificates the observer about all |
242 | 243 |
// items are erased from the container. It have to be overrided in |
243 | 244 |
// the subclasses. |
244 | 245 |
virtual void clear() = 0; |
245 | 246 |
|
246 | 247 |
}; |
247 | 248 |
|
248 | 249 |
protected: |
249 | 250 |
|
250 | 251 |
const Container* container; |
251 | 252 |
|
252 | 253 |
typedef std::list<ObserverBase*> Observers; |
253 | 254 |
Observers _observers; |
254 |
|
|
255 |
lemon::bits::Lock _lock; |
|
255 | 256 |
|
256 | 257 |
public: |
257 | 258 |
|
258 | 259 |
// \brief Default constructor. |
259 | 260 |
// |
260 | 261 |
// The default constructor of the AlterationNotifier. |
261 | 262 |
// It creates an empty notifier. |
262 | 263 |
AlterationNotifier() |
263 | 264 |
: container(0) {} |
264 | 265 |
|
265 | 266 |
// \brief Constructor. |
266 | 267 |
// |
267 | 268 |
// Constructor with the observed container parameter. |
268 | 269 |
AlterationNotifier(const Container& _container) |
269 | 270 |
: container(&_container) {} |
270 | 271 |
|
271 | 272 |
// \brief Copy Constructor of the AlterationNotifier. |
272 | 273 |
// |
273 | 274 |
// Copy constructor of the AlterationNotifier. |
274 | 275 |
// It creates only an empty notifier because the copiable |
275 | 276 |
// notifier's observers have to be registered still into that notifier. |
276 | 277 |
AlterationNotifier(const AlterationNotifier& _notifier) |
277 | 278 |
: container(_notifier.container) {} |
278 | 279 |
|
279 | 280 |
// \brief Destructor. |
280 | 281 |
// |
281 | 282 |
// Destructor of the AlterationNotifier. |
282 | 283 |
~AlterationNotifier() { |
283 | 284 |
typename Observers::iterator it; |
284 | 285 |
for (it = _observers.begin(); it != _observers.end(); ++it) { |
285 | 286 |
(*it)->_notifier = 0; |
286 | 287 |
} |
287 | 288 |
} |
288 | 289 |
|
289 | 290 |
// \brief Sets the container. |
290 | 291 |
// |
291 | 292 |
// Sets the container. |
292 | 293 |
void setContainer(const Container& _container) { |
293 | 294 |
container = &_container; |
294 | 295 |
} |
295 | 296 |
|
296 | 297 |
protected: |
297 | 298 |
|
298 | 299 |
AlterationNotifier& operator=(const AlterationNotifier&); |
299 | 300 |
|
300 | 301 |
public: |
301 | 302 |
|
302 | 303 |
// \brief First item in the container. |
303 | 304 |
// |
304 | 305 |
// Returns the first item in the container. It is |
305 | 306 |
// for start the iteration on the container. |
306 | 307 |
void first(Item& item) const { |
307 | 308 |
container->first(item); |
308 | 309 |
} |
309 | 310 |
|
310 | 311 |
// \brief Next item in the container. |
311 | 312 |
// |
312 | 313 |
// Returns the next item in the container. It is |
313 | 314 |
// for iterate on the container. |
314 | 315 |
void next(Item& item) const { |
315 | 316 |
container->next(item); |
316 | 317 |
} |
317 | 318 |
|
318 | 319 |
// \brief Returns the id of the item. |
319 | 320 |
// |
320 | 321 |
// Returns the id of the item provided by the container. |
321 | 322 |
int id(const Item& item) const { |
322 | 323 |
return container->id(item); |
323 | 324 |
} |
324 | 325 |
|
325 | 326 |
// \brief Returns the maximum id of the container. |
326 | 327 |
// |
327 | 328 |
// Returns the maximum id of the container. |
328 | 329 |
int maxId() const { |
329 | 330 |
return container->maxId(Item()); |
330 | 331 |
} |
331 | 332 |
|
332 | 333 |
protected: |
333 | 334 |
|
334 | 335 |
void attach(ObserverBase& observer) { |
336 |
_lock.lock(); |
|
335 | 337 |
observer._index = _observers.insert(_observers.begin(), &observer); |
336 | 338 |
observer._notifier = this; |
339 |
_lock.unlock(); |
|
337 | 340 |
} |
338 | 341 |
|
339 | 342 |
void detach(ObserverBase& observer) { |
343 |
_lock.lock(); |
|
340 | 344 |
_observers.erase(observer._index); |
341 | 345 |
observer._index = _observers.end(); |
342 | 346 |
observer._notifier = 0; |
347 |
_lock.unlock(); |
|
343 | 348 |
} |
344 | 349 |
|
345 | 350 |
public: |
346 | 351 |
|
347 | 352 |
// \brief Notifies all the registed observers about an item added to |
348 | 353 |
// the container. |
349 | 354 |
// |
350 | 355 |
// It notifies all the registed observers about an item added to |
351 | 356 |
// the container. |
352 | 357 |
void add(const Item& item) { |
353 | 358 |
typename Observers::reverse_iterator it; |
354 | 359 |
try { |
355 | 360 |
for (it = _observers.rbegin(); it != _observers.rend(); ++it) { |
356 | 361 |
(*it)->add(item); |
357 | 362 |
} |
358 | 363 |
} catch (...) { |
359 | 364 |
typename Observers::iterator jt; |
360 | 365 |
for (jt = it.base(); jt != _observers.end(); ++jt) { |
361 | 366 |
(*jt)->erase(item); |
362 | 367 |
} |
363 | 368 |
throw; |
364 | 369 |
} |
365 | 370 |
} |
366 | 371 |
|
367 | 372 |
// \brief Notifies all the registed observers about more item added to |
368 | 373 |
// the container. |
369 | 374 |
// |
370 | 375 |
// It notifies all the registed observers about more item added to |
371 | 376 |
// the container. |
372 | 377 |
void add(const std::vector<Item>& items) { |
373 | 378 |
typename Observers::reverse_iterator it; |
374 | 379 |
try { |
375 | 380 |
for (it = _observers.rbegin(); it != _observers.rend(); ++it) { |
376 | 381 |
(*it)->add(items); |
377 | 382 |
} |
378 | 383 |
} catch (...) { |
379 | 384 |
typename Observers::iterator jt; |
380 | 385 |
for (jt = it.base(); jt != _observers.end(); ++jt) { |
381 | 386 |
(*jt)->erase(items); |
382 | 387 |
} |
383 | 388 |
throw; |
384 | 389 |
} |
385 | 390 |
} |
386 | 391 |
|
387 | 392 |
// \brief Notifies all the registed observers about an item erased from |
388 | 393 |
// the container. |
389 | 394 |
// |
390 | 395 |
// It notifies all the registed observers about an item erased from |
391 | 396 |
// the container. |
392 | 397 |
void erase(const Item& item) throw() { |
393 | 398 |
typename Observers::iterator it = _observers.begin(); |
394 | 399 |
while (it != _observers.end()) { |
395 | 400 |
try { |
396 | 401 |
(*it)->erase(item); |
397 | 402 |
++it; |
398 | 403 |
} catch (const ImmediateDetach&) { |
399 | 404 |
(*it)->_index = _observers.end(); |
400 | 405 |
(*it)->_notifier = 0; |
401 | 406 |
it = _observers.erase(it); |
402 | 407 |
} |
403 | 408 |
} |
404 | 409 |
} |
405 | 410 |
|
406 | 411 |
// \brief Notifies all the registed observers about more item erased |
407 | 412 |
// from the container. |
408 | 413 |
// |
409 | 414 |
// It notifies all the registed observers about more item erased from |
410 | 415 |
// the container. |
411 | 416 |
void erase(const std::vector<Item>& items) { |
412 | 417 |
typename Observers::iterator it = _observers.begin(); |
413 | 418 |
while (it != _observers.end()) { |
414 | 419 |
try { |
415 | 420 |
(*it)->erase(items); |
416 | 421 |
++it; |
417 | 422 |
} catch (const ImmediateDetach&) { |
418 | 423 |
(*it)->_index = _observers.end(); |
419 | 424 |
(*it)->_notifier = 0; |
420 | 425 |
it = _observers.erase(it); |
421 | 426 |
} |
422 | 427 |
} |
423 | 428 |
} |
424 | 429 |
|
425 | 430 |
// \brief Notifies all the registed observers about the container is |
426 | 431 |
// built. |
427 | 432 |
// |
428 | 433 |
// Notifies all the registed observers about the container is built |
429 | 434 |
// from an empty container. |
430 | 435 |
void build() { |
431 | 436 |
typename Observers::reverse_iterator it; |
432 | 437 |
try { |
433 | 438 |
for (it = _observers.rbegin(); it != _observers.rend(); ++it) { |
434 | 439 |
(*it)->build(); |
435 | 440 |
} |
436 | 441 |
} catch (...) { |
437 | 442 |
typename Observers::iterator jt; |
438 | 443 |
for (jt = it.base(); jt != _observers.end(); ++jt) { |
... | ... |
@@ -37,98 +37,128 @@ |
37 | 37 |
#else |
38 | 38 |
#define MY_LOCALE LOCALE_NEUTRAL |
39 | 39 |
#endif |
40 | 40 |
#else |
41 | 41 |
#include <unistd.h> |
42 | 42 |
#include <ctime> |
43 | 43 |
#ifndef WIN32 |
44 | 44 |
#include <sys/times.h> |
45 | 45 |
#endif |
46 | 46 |
#include <sys/time.h> |
47 | 47 |
#endif |
48 | 48 |
|
49 | 49 |
#include <cmath> |
50 | 50 |
#include <sstream> |
51 | 51 |
|
52 | 52 |
namespace lemon { |
53 | 53 |
namespace bits { |
54 | 54 |
void getWinProcTimes(double &rtime, |
55 | 55 |
double &utime, double &stime, |
56 | 56 |
double &cutime, double &cstime) |
57 | 57 |
{ |
58 | 58 |
#ifdef WIN32 |
59 | 59 |
static const double ch = 4294967296.0e-7; |
60 | 60 |
static const double cl = 1.0e-7; |
61 | 61 |
|
62 | 62 |
FILETIME system; |
63 | 63 |
GetSystemTimeAsFileTime(&system); |
64 | 64 |
rtime = ch * system.dwHighDateTime + cl * system.dwLowDateTime; |
65 | 65 |
|
66 | 66 |
FILETIME create, exit, kernel, user; |
67 | 67 |
if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) { |
68 | 68 |
utime = ch * user.dwHighDateTime + cl * user.dwLowDateTime; |
69 | 69 |
stime = ch * kernel.dwHighDateTime + cl * kernel.dwLowDateTime; |
70 | 70 |
cutime = 0; |
71 | 71 |
cstime = 0; |
72 | 72 |
} else { |
73 | 73 |
rtime = 0; |
74 | 74 |
utime = 0; |
75 | 75 |
stime = 0; |
76 | 76 |
cutime = 0; |
77 | 77 |
cstime = 0; |
78 | 78 |
} |
79 | 79 |
#else |
80 | 80 |
timeval tv; |
81 | 81 |
gettimeofday(&tv, 0); |
82 | 82 |
rtime=tv.tv_sec+double(tv.tv_usec)/1e6; |
83 | 83 |
|
84 | 84 |
tms ts; |
85 | 85 |
double tck=sysconf(_SC_CLK_TCK); |
86 | 86 |
times(&ts); |
87 | 87 |
utime=ts.tms_utime/tck; |
88 | 88 |
stime=ts.tms_stime/tck; |
89 | 89 |
cutime=ts.tms_cutime/tck; |
90 | 90 |
cstime=ts.tms_cstime/tck; |
91 | 91 |
#endif |
92 | 92 |
} |
93 | 93 |
|
94 | 94 |
std::string getWinFormattedDate() |
95 | 95 |
{ |
96 | 96 |
std::ostringstream os; |
97 | 97 |
#ifdef WIN32 |
98 | 98 |
SYSTEMTIME time; |
99 | 99 |
GetSystemTime(&time); |
100 | 100 |
char buf1[11], buf2[9], buf3[5]; |
101 | 101 |
if (GetDateFormat(MY_LOCALE, 0, &time, |
102 | 102 |
("ddd MMM dd"), buf1, 11) && |
103 | 103 |
GetTimeFormat(MY_LOCALE, 0, &time, |
104 | 104 |
("HH':'mm':'ss"), buf2, 9) && |
105 | 105 |
GetDateFormat(MY_LOCALE, 0, &time, |
106 | 106 |
("yyyy"), buf3, 5)) { |
107 | 107 |
os << buf1 << ' ' << buf2 << ' ' << buf3; |
108 | 108 |
} |
109 | 109 |
else os << "unknown"; |
110 | 110 |
#else |
111 | 111 |
timeval tv; |
112 | 112 |
gettimeofday(&tv, 0); |
113 | 113 |
|
114 | 114 |
char cbuf[26]; |
115 | 115 |
ctime_r(&tv.tv_sec,cbuf); |
116 | 116 |
os << cbuf; |
117 | 117 |
#endif |
118 | 118 |
return os.str(); |
119 | 119 |
} |
120 | 120 |
|
121 | 121 |
int getWinRndSeed() |
122 | 122 |
{ |
123 | 123 |
#ifdef WIN32 |
124 | 124 |
FILETIME time; |
125 | 125 |
GetSystemTimeAsFileTime(&time); |
126 | 126 |
return GetCurrentProcessId() + time.dwHighDateTime + time.dwLowDateTime; |
127 | 127 |
#else |
128 | 128 |
timeval tv; |
129 | 129 |
gettimeofday(&tv, 0); |
130 | 130 |
return getpid() + tv.tv_sec + tv.tv_usec; |
131 | 131 |
#endif |
132 | 132 |
} |
133 |
|
|
134 |
WinLock::WinLock() { |
|
135 |
#ifdef WIN32 |
|
136 |
CRITICAL_SECTION *lock = new CRITICAL_SECTION; |
|
137 |
InitializeCriticalSection(lock); |
|
138 |
_repr = lock; |
|
139 |
#endif |
|
140 |
} |
|
141 |
|
|
142 |
WinLock::~WinLock() { |
|
143 |
#ifdef WIN32 |
|
144 |
CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr); |
|
145 |
DeleteCriticalSection(lock); |
|
146 |
delete lock; |
|
147 |
#endif |
|
148 |
} |
|
149 |
|
|
150 |
void WinLock::lock() { |
|
151 |
#ifdef WIN32 |
|
152 |
CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr); |
|
153 |
EnterCriticalSection(lock); |
|
154 |
#endif |
|
155 |
} |
|
156 |
|
|
157 |
void WinLock::unlock() { |
|
158 |
#ifdef WIN32 |
|
159 |
CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr); |
|
160 |
LeaveCriticalSection(lock); |
|
161 |
#endif |
|
162 |
} |
|
133 | 163 |
} |
134 | 164 |
} |
1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
4 | 4 |
* |
5 | 5 |
* Copyright (C) 2003-2009 |
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_WINDOWS_H |
20 | 20 |
#define LEMON_BITS_WINDOWS_H |
21 | 21 |
|
22 | 22 |
#include <string> |
23 | 23 |
|
24 | 24 |
namespace lemon { |
25 | 25 |
namespace bits { |
26 | 26 |
void getWinProcTimes(double &rtime, |
27 | 27 |
double &utime, double &stime, |
28 | 28 |
double &cutime, double &cstime); |
29 | 29 |
std::string getWinFormattedDate(); |
30 | 30 |
int getWinRndSeed(); |
31 |
|
|
32 |
class WinLock { |
|
33 |
public: |
|
34 |
WinLock(); |
|
35 |
~WinLock(); |
|
36 |
void lock(); |
|
37 |
void unlock(); |
|
38 |
private: |
|
39 |
void *_repr; |
|
40 |
}; |
|
31 | 41 |
} |
32 | 42 |
} |
33 | 43 |
|
34 | 44 |
#endif |
1 | 1 |
#define LEMON_VERSION "@PROJECT_VERSION@" |
2 | 2 |
#cmakedefine LEMON_HAVE_LONG_LONG 1 |
3 | 3 |
#cmakedefine LEMON_HAVE_LP 1 |
4 | 4 |
#cmakedefine LEMON_HAVE_MIP 1 |
5 | 5 |
#cmakedefine LEMON_HAVE_GLPK 1 |
6 | 6 |
#cmakedefine LEMON_HAVE_CPLEX 1 |
7 | 7 |
#cmakedefine LEMON_HAVE_CLP 1 |
8 | 8 |
#cmakedefine LEMON_HAVE_CBC 1 |
9 |
#cmakedefine LEMON_USE_PTHREAD 1 |
|
10 |
#cmakedefine LEMON_USE_WIN32_THREADS 1 |
1 | 1 |
/* The version string */ |
2 | 2 |
#undef LEMON_VERSION |
3 | 3 |
|
4 | 4 |
/* Define to 1 if you have long long */ |
5 | 5 |
#undef LEMON_HAVE_LONG_LONG |
6 | 6 |
|
7 | 7 |
/* Define to 1 if you have any LP solver. */ |
8 | 8 |
#undef LEMON_HAVE_LP |
9 | 9 |
|
10 | 10 |
/* Define to 1 if you have any MIP solver. */ |
11 | 11 |
#undef LEMON_HAVE_MIP |
12 | 12 |
|
13 | 13 |
/* Define to 1 if you have CPLEX. */ |
14 | 14 |
#undef LEMON_HAVE_CPLEX |
15 | 15 |
|
16 | 16 |
/* Define to 1 if you have GLPK. */ |
17 | 17 |
#undef LEMON_HAVE_GLPK |
18 | 18 |
|
19 | 19 |
/* Define to 1 if you have SOPLEX */ |
20 | 20 |
#undef LEMON_HAVE_SOPLEX |
21 | 21 |
|
22 | 22 |
/* Define to 1 if you have CLP */ |
23 | 23 |
#undef LEMON_HAVE_CLP |
24 | 24 |
|
25 | 25 |
/* Define to 1 if you have CBC */ |
26 | 26 |
#undef LEMON_HAVE_CBC |
27 |
|
|
28 |
/* Define to 1 if you have pthread */ |
|
29 |
#undef LEMON_USE_PTHREAD |
|
30 |
|
|
31 |
/* Define to 1 if you have win32 threads */ |
|
32 |
#undef LEMON_USE_WIN32_THREADS |
0 comments (0 inline)