Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lima-camera-slsdetector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LimaGroup
Lima-camera-slsdetector
Commits
07c2f381
Commit
07c2f381
authored
6 years ago
by
Alejandro Homs Puron
Committed by
operator for beamline
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
test_bitset: second version
parent
538f3e8d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_bitset.cpp
+38
-40
38 additions, 40 deletions
test/test_bitset.cpp
with
38 additions
and
40 deletions
test/test_bitset.cpp
+
38
−
40
View file @
07c2f381
...
...
@@ -15,54 +15,46 @@ struct sls_detector_header {
#define PMASK_ULONGS \
(MAX_NUM_PACKETS / PMASK_ULONG_BITS)
typedef
st
ruct
{
sls_detector_header
detHeader
;
typedef
st
d
::
bitset
<
MAX_NUM_PACKETS
>
sls_receiver_packets_mask
;
typedef
unsigned
long
sls_receiver_packets_mask_storage
[
PMASK_ULONGS
]
;
typedef
std
::
bitset
<
MAX_NUM_PACKETS
>
packets_mask
;
packets_mask
packetsMask
;
typedef
unsigned
long
packets_mask_block
[
PMASK_ULONGS
];
void
dumpPacketsMask
(
packets_mask_block
&
b
)
const
;
void
loadPacketsMask
(
const
packets_mask_block
&
b
);
}
sls_receiver_header
;
inline
void
sls_receiver_header
::
dumpPacketsMask
(
packets_mask_block
&
b
)
const
inline
void
operator
<<
(
sls_receiver_packets_mask_storage
&
pm_storage
,
const
sls_receiver_packets_mask
&
pm
)
{
packets_mask
aux
=
p
acketsMask
,
mask
=
(
unsigned
long
)(
-
1
);
sls_receiver_
packets_mask
aux
=
p
m
,
mask
=
(
unsigned
long
)(
-
1
);
for
(
unsigned
int
i
=
0
;
i
<
PMASK_ULONGS
;
++
i
)
{
b
[
i
]
=
(
aux
&
mask
).
to_ulong
();
pm_storage
[
i
]
=
(
aux
&
mask
).
to_ulong
();
aux
>>=
PMASK_ULONG_BITS
;
}
}
inline
void
sls_receiver_
header
::
loadPacketsMask
(
const
packets_mask
_block
&
b
)
inline
void
operator
>>
(
const
sls_receiver_packets_mask_storage
&
pm_storage
,
sls_receiver_packets_mask
&
pm
)
{
p
acketsMask
.
reset
();
p
m
.
reset
();
for
(
unsigned
int
i
=
0
;
i
<
PMASK_ULONGS
;
++
i
)
{
packets_mask
aux
=
b
[
i
];
p
acketsMask
|=
aux
<<
PMASK_ULONG_BITS
*
i
;
sls_receiver_
packets_mask
aux
=
pm_storage
[
i
];
p
m
|=
aux
<<
(
PMASK_ULONG_BITS
*
i
)
;
}
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
sls_receiver_
header
::
packets_mask_
block
&
b
)
const
sls_receiver_packets_mask_
storage
&
pm_storage
)
{
os
<<
std
::
hex
<<
std
::
noshowbase
<<
std
::
setfill
(
'0'
);
const
unsigned
long
*
p
=
b
+
PMASK_ULONGS
;
while
(
--
p
>=
b
)
const
unsigned
long
*
p
=
pm_storage
+
PMASK_ULONGS
;
while
(
--
p
>=
pm_storage
)
os
<<
std
::
setw
(
PMASK_ULONG_HEX_DIGITS
)
<<
*
p
;
return
os
<<
std
::
dec
<<
std
::
showbase
<<
std
::
setfill
(
' '
);
}
inline
std
::
istream
&
operator
>>
(
std
::
istream
&
is
,
sls_receiver_
header
::
packets_mask_
block
&
b
)
sls_receiver_packets_mask_
storage
&
pm_storage
)
{
unsigned
long
*
p
=
b
+
PMASK_ULONGS
;
while
(
--
p
>=
b
)
{
unsigned
long
*
p
=
pm_storage
+
PMASK_ULONGS
;
while
(
--
p
>=
pm_storage
)
{
char
s
[
PMASK_ULONG_HEX_DIGITS
];
is
.
read
(
s
,
sizeof
(
s
));
std
::
string
ss
(
s
,
sizeof
(
s
));
...
...
@@ -71,6 +63,12 @@ std::istream& operator >>(std::istream& is,
return
is
;
}
typedef
struct
{
sls_detector_header
detHeader
;
sls_receiver_packets_mask
packetsMask
;
}
sls_receiver_header
;
#include
<fstream>
#include
<memory.h>
...
...
@@ -78,9 +76,9 @@ using namespace std;
int
main
(
int
argc
,
char
*
argv
[])
{
typedef
sls_receiver_header
::
packets_mask
packets_mask
;
typedef
sls_receiver_packets_mask
packets_mask
;
sls_receiver_header
h
;
cout
<<
h
.
packetsMask
<<
endl
;
cout
<<
hex
<<
setfill
(
'0'
);
for
(
int
f
=
0
,
i
=
MAX_NUM_PACKETS
/
8
-
1
,
j
=
0
;
i
>=
0
;
--
i
,
++
j
,
++
f
)
{
...
...
@@ -91,25 +89,26 @@ int main(int argc, char *argv[])
cout
<<
dec
<<
setfill
(
' '
)
<<
endl
;
cout
<<
h
.
packetsMask
<<
endl
;
sls_receiver_header
::
packets_mask_block
b
;
h
.
dumpPacketsMask
(
b
);
sls_receiver_packets_mask_storage
pm_storage
;
pm_storage
<<
h
.
packetsMask
;
const
char
*
fname
=
"/tmp/toto"
;
{
ofstream
f
(
fname
,
ios
::
out
|
ios
::
trunc
|
ios
::
binary
);
void
*
p
=
&
b
;
f
.
write
(
static_cast
<
const
char
*>
(
p
),
sizeof
(
b
));
void
*
p
=
&
pm_storage
;
f
.
write
(
static_cast
<
const
char
*>
(
p
),
sizeof
(
pm_storage
));
}
h
.
packetsMask
.
reset
();
memset
(
b
,
0
,
sizeof
(
b
));
memset
(
pm_storage
,
0
,
sizeof
(
pm_storage
));
cout
<<
h
.
packetsMask
<<
endl
;
{
ifstream
f
(
fname
,
ios
::
in
|
ios
::
binary
);
void
*
p
=
&
b
;
f
.
read
(
static_cast
<
char
*>
(
p
),
sizeof
(
b
));
void
*
p
=
&
pm_storage
;
f
.
read
(
static_cast
<
char
*>
(
p
),
sizeof
(
pm_storage
));
}
h
.
loadP
acketsMask
(
b
)
;
pm_storage
>>
h
.
p
acketsMask
;
cout
<<
hex
<<
setfill
(
'0'
);
for
(
int
f
=
0
,
i
=
MAX_NUM_PACKETS
/
8
-
1
;
i
>=
0
;
--
i
,
++
f
)
{
packets_mask
m
=
0xff
;
...
...
@@ -120,13 +119,12 @@ int main(int argc, char *argv[])
cout
<<
h
.
packetsMask
<<
endl
;
ostringstream
os
;
os
<<
b
;
os
<<
pm_storage
;
cout
<<
os
.
str
()
<<
endl
;
memset
(
b
,
0
,
sizeof
(
b
));
memset
(
pm_storage
,
0
,
sizeof
(
pm_storage
));
istringstream
is
(
os
.
str
());
is
>>
b
;
h
.
loadP
acketsMask
(
b
)
;
is
>>
pm_storage
;
pm_storage
>>
h
.
p
acketsMask
;
cout
<<
h
.
packetsMask
<<
endl
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment