abc-master
Main Page
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
extraUtilProgress.c
Go to the documentation of this file.
1
/**CFile****************************************************************
2
3
FileName [extraUtilProgress.c]
4
5
SystemName [ABC: Logic synthesis and verification system.]
6
7
PackageName [extra]
8
9
Synopsis [Progress bar.]
10
11
Author [Alan Mishchenko]
12
13
Affiliation [UC Berkeley]
14
15
Date [Ver. 1.0. Started - June 20, 2005.]
16
17
Revision [$Id: extraUtilProgress.c,v 1.0 2003/02/01 00:00:00 alanmi Exp $]
18
19
***********************************************************************/
20
21
#include <stdio.h>
22
#include "
extra.h
"
23
#include "
base/main/main.h
"
24
25
ABC_NAMESPACE_IMPL_START
26
27
28
////////////////////////////////////////////////////////////////////////
29
/// DECLARATIONS ///
30
////////////////////////////////////////////////////////////////////////
31
32
struct
ProgressBarStruct
33
{
34
int
nItemsNext
;
// the number of items for the next update of the progress bar
35
int
nItemsTotal
;
// the total number of items
36
int
posTotal
;
// the total number of positions
37
int
posCur
;
// the current position
38
FILE *
pFile
;
// the output stream
39
};
40
41
static
void
Extra_ProgressBarShow
(
ProgressBar
*
p
,
char
* pString );
42
static
void
Extra_ProgressBarClean
(
ProgressBar
*
p
);
43
44
////////////////////////////////////////////////////////////////////////
45
/// FUNCTION DEFINITIONS ///
46
////////////////////////////////////////////////////////////////////////
47
48
/**Function*************************************************************
49
50
Synopsis [Starts the progress bar.]
51
52
Description [The first parameter is the output stream (pFile), where
53
the progress is printed. The current printing position should be the
54
first one on the given line. The second parameters is the total
55
number of items that correspond to 100% position of the progress bar.]
56
57
SideEffects []
58
59
SeeAlso []
60
61
***********************************************************************/
62
ProgressBar
*
Extra_ProgressBarStart
( FILE * pFile,
int
nItemsTotal )
63
{
64
ProgressBar
*
p
;
65
if
( !
Abc_FrameShowProgress
(
Abc_FrameGetGlobalFrame
()) )
return
NULL;
66
p =
ABC_ALLOC
(
ProgressBar
, 1 );
67
memset
( p, 0,
sizeof
(
ProgressBar
) );
68
p->
pFile
= pFile;
69
p->
nItemsTotal
= nItemsTotal;
70
p->
posTotal
= 78;
71
p->
posCur
= 1;
72
p->
nItemsNext
= (int)((7.0+p->
posCur
)*p->
nItemsTotal
/p->
posTotal
);
73
Extra_ProgressBarShow
( p, NULL );
74
return
p
;
75
}
76
77
/**Function*************************************************************
78
79
Synopsis [Updates the progress bar.]
80
81
Description []
82
83
SideEffects []
84
85
SeeAlso []
86
87
***********************************************************************/
88
void
Extra_ProgressBarUpdate_int
(
ProgressBar
*
p
,
int
nItemsCur,
char
* pString )
89
{
90
if
( p == NULL )
return
;
91
if
( nItemsCur < p->nItemsNext )
92
return
;
93
if
( nItemsCur >= p->
nItemsTotal
)
94
{
95
p->
posCur
= 78;
96
p->
nItemsNext
= 0x7FFFFFFF;
97
}
98
else
99
{
100
p->
posCur
+= 7;
101
p->
nItemsNext
= (int)((7.0+p->
posCur
)*p->
nItemsTotal
/p->
posTotal
);
102
}
103
Extra_ProgressBarShow
( p, pString );
104
}
105
106
107
/**Function*************************************************************
108
109
Synopsis [Stops the progress bar.]
110
111
Description []
112
113
SideEffects []
114
115
SeeAlso []
116
117
***********************************************************************/
118
void
Extra_ProgressBarStop
(
ProgressBar
*
p
)
119
{
120
if
( p == NULL )
return
;
121
Extra_ProgressBarClean
( p );
122
ABC_FREE
( p );
123
}
124
125
/**Function*************************************************************
126
127
Synopsis [Prints the progress bar of the given size.]
128
129
Description []
130
131
SideEffects []
132
133
SeeAlso []
134
135
***********************************************************************/
136
void
Extra_ProgressBarShow
(
ProgressBar
*
p
,
char
* pString )
137
{
138
int
i;
139
if
( p == NULL )
140
return
;
141
if
(
Abc_FrameIsBatchMode
() )
142
return
;
143
if
( pString )
144
fprintf( p->
pFile
,
"%s "
, pString );
145
for
( i = (pString?
strlen
(pString) + 1 : 0); i < p->
posCur
; i++ )
146
fprintf( p->
pFile
,
"-"
);
147
if
( i == p->
posCur
)
148
fprintf( p->
pFile
,
">"
);
149
for
( i++ ; i <= p->
posTotal
; i++ )
150
fprintf( p->
pFile
,
" "
);
151
fprintf( p->
pFile
,
"\r"
);
152
fflush( stdout );
153
}
154
155
/**Function*************************************************************
156
157
Synopsis [Cleans the progress bar before quitting.]
158
159
Description []
160
161
SideEffects []
162
163
SeeAlso []
164
165
***********************************************************************/
166
void
Extra_ProgressBarClean
(
ProgressBar
*
p
)
167
{
168
int
i;
169
if
( p == NULL )
170
return
;
171
if
(
Abc_FrameIsBatchMode
() )
172
return
;
173
for
( i = 0; i <= p->
posTotal
; i++ )
174
fprintf( p->
pFile
,
" "
);
175
fprintf( p->
pFile
,
"\r"
);
176
fflush( stdout );
177
}
178
179
////////////////////////////////////////////////////////////////////////
180
/// END OF FILE ///
181
////////////////////////////////////////////////////////////////////////
182
183
184
ABC_NAMESPACE_IMPL_END
185
memset
char * memset()
Extra_ProgressBarShow
static void Extra_ProgressBarShow(ProgressBar *p, char *pString)
Definition:
extraUtilProgress.c:136
p
static Llb_Mgr_t * p
Definition:
llb3Image.c:950
Abc_FrameIsBatchMode
ABC_DLL int Abc_FrameIsBatchMode()
Definition:
mainFrame.c:92
ProgressBarStruct::nItemsTotal
int nItemsTotal
Definition:
extraUtilProgress.c:35
ABC_ALLOC
#define ABC_ALLOC(type, num)
Definition:
abc_global.h:229
Extra_ProgressBarStop
void Extra_ProgressBarStop(ProgressBar *p)
Definition:
extraUtilProgress.c:118
extra.h
ProgressBarStruct
DECLARATIONS ///.
Definition:
extraUtilProgress.c:32
Extra_ProgressBarUpdate_int
void Extra_ProgressBarUpdate_int(ProgressBar *p, int nItemsCur, char *pString)
Definition:
extraUtilProgress.c:88
Extra_ProgressBarClean
static void Extra_ProgressBarClean(ProgressBar *p)
Definition:
extraUtilProgress.c:166
ABC_NAMESPACE_IMPL_END
#define ABC_NAMESPACE_IMPL_END
Definition:
abc_global.h:108
Abc_FrameGetGlobalFrame
void * Abc_FrameGetGlobalFrame()
Definition:
mainFrame.c:593
ProgressBarStruct::pFile
FILE * pFile
Definition:
extraUtilProgress.c:38
main.h
ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_START
Definition:
abc_global.h:107
Abc_FrameShowProgress
ABC_DLL int Abc_FrameShowProgress(Abc_Frame_t *p)
Definition:
mainFrame.c:265
ProgressBarStruct::posTotal
int posTotal
Definition:
extraUtilProgress.c:36
ProgressBarStruct::posCur
int posCur
Definition:
extraUtilProgress.c:37
ABC_FREE
#define ABC_FREE(obj)
Definition:
abc_global.h:232
Extra_ProgressBarStart
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
Definition:
extraUtilProgress.c:62
strlen
int strlen()
ProgressBarStruct::nItemsNext
int nItemsNext
Definition:
extraUtilProgress.c:34
src
misc
extra
extraUtilProgress.c
Generated on Thu Dec 18 2014 16:11:53 for abc-master by
1.8.6