Toggle navigation
SCIP Optimization Suite
SCIP
SoPlex
ZIMPL
UG
GCG
Documentation
SoPlex 6.0.3
SoPlex 5.0.2
SoPlex 4.0.2
SoPlex 3.1.0
SoPlex 3.0.1
SoPlex 2.2.1
SoPlex
Sequential object-oriented simPlex
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
soplex-repo
src
timerfactory.h
Go to the documentation of this file.
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2
/* */
3
/* This file is part of the class library */
4
/* SoPlex --- the Sequential object-oriented simPlex. */
5
/* */
6
/* Copyright (C) 1996-2015 Konrad-Zuse-Zentrum */
7
/* fuer Informationstechnik Berlin */
8
/* */
9
/* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10
/* */
11
/* You should have received a copy of the ZIB Academic License */
12
/* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13
/* */
14
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15
16
/**@file timerfactory.h
17
* @brief TimerFactory class.
18
*/
19
20
#ifndef _TIMERFACTORY_H_
21
#define _TIMERFACTORY_H_
22
23
#include "
spxdefines.h
"
24
#include "
spxalloc.h
"
25
#include "
notimer.h
"
26
#include "
usertimer.h
"
27
#include "
wallclocktimer.h
"
28
29
namespace
soplex
30
{
31
/**@class TimerFactory
32
@ingroup Elementary
33
34
@brief Class to create new timers and to switch types of exiting ones
35
*/
36
37
class
TimerFactory
38
{
39
40
public
:
41
42
/// create timers and allocate memory for them
43
static
Timer
*
createTimer
(
Timer::TYPE
ttype)
44
{
45
Timer
* timer = 0;
46
switch
( ttype )
47
{
48
case
Timer::OFF
:
49
spx_alloc
(timer,
sizeof
(
NoTimer
));
50
timer =
new
(timer)
NoTimer
();
51
break
;
52
case
Timer::USER_TIME
:
53
spx_alloc
(timer,
sizeof
(
UserTimer
));
54
timer =
new
(timer)
UserTimer
();
55
break
;
56
case
Timer::WALLCLOCK_TIME
:
57
spx_alloc
(timer,
sizeof
(
WallclockTimer
));
58
timer =
new
(timer)
WallclockTimer
();
59
break
;
60
default
:
61
MSG_ERROR
( std::cerr <<
"wrong timer specified"
<< std::endl; )
62
}
63
return
timer;
64
}
65
66
static
Timer
*
switchTimer
(
Timer
* timer,
Timer::TYPE
ttype)
67
{
68
// check whether the type is different from the current one
69
if
( ttype != timer->
type
() )
70
{
71
// @todo transfer the old times
72
spx_free
(timer);
73
timer =
createTimer
(ttype);
74
}
75
return
timer;
76
}
77
78
};
79
}
// namespace soplex
80
#endif // _TIMERFACTORY_H_