SoPlex
Toggle main menu visibility
Loading...
Searching...
No Matches
src
soplex
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-2026 Zuse Institute Berlin (ZIB) */
7
/* */
8
/* Licensed under the Apache License, Version 2.0 (the "License"); */
9
/* you may not use this file except in compliance with the License. */
10
/* You may obtain a copy of the License at */
11
/* */
12
/* http://www.apache.org/licenses/LICENSE-2.0 */
13
/* */
14
/* Unless required by applicable law or agreed to in writing, software */
15
/* distributed under the License is distributed on an "AS IS" BASIS, */
16
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17
/* See the License for the specific language governing permissions and */
18
/* limitations under the License. */
19
/* */
20
/* You should have received a copy of the Apache-2.0 license */
21
/* along with SoPlex; see the file LICENSE. If not email to soplex@zib.de. */
22
/* */
23
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25
/**@file timerfactory.h
26
* @brief TimerFactory class.
27
*/
28
29
#ifndef _TIMERFACTORY_H_
30
#define _TIMERFACTORY_H_
31
32
#include "
soplex/spxdefines.h
"
33
#include "
soplex/spxalloc.h
"
34
#include "
soplex/timer.h
"
35
#include "
soplex/notimer.h
"
36
#include "
soplex/usertimer.h
"
37
#include "
soplex/wallclocktimer.h
"
38
39
namespace
soplex
40
{
41
/**@class TimerFactory
42
@ingroup Elementary
43
44
@brief Class to create new timers and to switch types of exiting ones
45
*/
46
47
class
TimerFactory
48
{
49
50
public
:
51
52
/// create timers and allocate memory for them
53
static
Timer
*
createTimer
(
Timer::TYPE
ttype)
54
{
55
Timer
* timer =
nullptr
;
56
57
switch
(ttype)
58
{
59
case
Timer::OFF
:
60
spx_alloc
(timer,
sizeof
(
NoTimer
));
61
timer =
new
(timer)
NoTimer
();
62
break
;
63
64
case
Timer::USER_TIME
:
65
spx_alloc
(timer,
sizeof
(
UserTimer
));
66
timer =
new
(timer)
UserTimer
();
67
break
;
68
69
case
Timer::WALLCLOCK_TIME
:
70
spx_alloc
(timer,
sizeof
(
WallclockTimer
));
71
timer =
new
(timer)
WallclockTimer
();
72
break
;
73
74
default
:
75
SPX_MSG_ERROR
(std::cerr <<
"wrong timer specified"
<< std::endl;)
76
}
77
78
return
timer;
79
}
80
81
static
Timer
*
switchTimer
(
Timer
* timer,
Timer::TYPE
ttype)
82
{
83
// check whether the type is different from the current one
84
if
(ttype != timer->
type
())
85
{
86
// @todo transfer the old times
87
spx_free
(timer);
88
timer =
createTimer
(ttype);
89
}
90
91
return
timer;
92
}
93
94
};
95
}
// namespace soplex
96
#endif
// _TIMERFACTORY_H_
soplex::NoTimer
Definition
notimer.h:39
soplex::TimerFactory
Class to create new timers and to switch types of exiting ones.
Definition
timerfactory.h:48
soplex::TimerFactory::switchTimer
static Timer * switchTimer(Timer *timer, Timer::TYPE ttype)
Definition
timerfactory.h:81
soplex::TimerFactory::createTimer
static Timer * createTimer(Timer::TYPE ttype)
create timers and allocate memory for them
Definition
timerfactory.h:53
soplex::Timer
Wrapper for the system time query methods.
Definition
timer.h:86
soplex::Timer::TYPE
TYPE
types of timers
Definition
timer.h:109
soplex::Timer::WALLCLOCK_TIME
@ WALLCLOCK_TIME
Definition
timer.h:112
soplex::Timer::OFF
@ OFF
Definition
timer.h:110
soplex::Timer::USER_TIME
@ USER_TIME
Definition
timer.h:111
soplex::Timer::type
virtual TYPE type()=0
return type of timer
soplex::UserTimer
Definition
usertimer.h:39
soplex::WallclockTimer
Definition
wallclocktimer.h:39
soplex
Everything should be within this namespace.
soplex::spx_alloc
void spx_alloc(T &p, size_t n=1)
Allocate memory.
Definition
spxalloc.h:58
soplex::spx_free
void spx_free(T &p)
Release memory.
Definition
spxalloc.h:118
notimer.h
NoTimer class.
spxalloc.h
Memory allocation routines.
spxdefines.h
Debugging, floating point type and parameter definitions.
SPX_MSG_ERROR
#define SPX_MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::VERB_ERROR.
Definition
spxdefines.h:163
timer.h
Timer class.
usertimer.h
UserTimer class.
wallclocktimer.h
WallclockTimer class.
Generated by
1.17.0