Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
daa50679
Commit
daa50679
authored
Mar 30, 2013
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CHANGE
#59
] parsing ROI info from file done. These info are not yet applied. Thats the next step.
parent
31acf5e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
2 deletions
+102
-2
src/core/kernel/WRoiProjectFileIO.cpp
src/core/kernel/WRoiProjectFileIO.cpp
+59
-2
src/core/kernel/WRoiProjectFileIO.h
src/core/kernel/WRoiProjectFileIO.h
+43
-0
No files found.
src/core/kernel/WRoiProjectFileIO.cpp
View file @
daa50679
...
...
@@ -24,6 +24,14 @@
#include <string>
#include <boost/regex.hpp>
#include "../common/WStringUtils.h"
#include "../common/WProperties.h"
#include "../common/WPropertyBase.h"
#include "../common/WPropertyVariable.h"
#include "../common/WPropertyTypes.h"
#include "../common/exceptions/WFileNotFound.h"
#include "../common/WLogger.h"
#include "../graphicsEngine/WROI.h"
#include "../graphicsEngine/WROIBox.h"
...
...
@@ -43,10 +51,59 @@ WRoiProjectFileIO::~WRoiProjectFileIO()
// cleanup
}
bool
WRoiProjectFileIO
::
parse
(
std
::
string
/*
line
*/
,
unsigned
int
/*
lineNumber
*/
)
bool
WRoiProjectFileIO
::
parse
(
std
::
string
line
,
unsigned
int
lineNumber
)
{
// this is the proper regular expression for modules
static
const
boost
::
regex
branchRe
(
"^ *SELECTOR_BRANCH:([0-9]*)$"
);
static
const
boost
::
regex
roiBoxRe
(
"^ *SELECTOR_ROIBOX:([0-9]*):SELECTOR_BRANCH([0-9]*)$"
);
static
const
boost
::
regex
branchPropRe
(
"^ *PROPERTY:
\\
(SELECTOR_BRANCH([0-9]*),(.*)
\\
)=(.*)$"
);
static
const
boost
::
regex
roiBoxPropRe
(
"^ *PROPERTY:
\\
(SELECTOR_ROIBOX([0-9]*),(.*)
\\
)=(.*)$"
);
boost
::
smatch
matches
;
// the list of matches
if
(
boost
::
regex_match
(
line
,
matches
,
branchRe
)
)
{
Branch
branch
=
string_utils
::
fromString
<
Branch
>
(
matches
[
1
]
);
wlog
::
debug
(
"Project Loader [Parser]"
)
<<
"Line "
<<
lineNumber
<<
": Branch with ID "
<<
branch
;
// store info
m_branches
.
push_back
(
branch
);
}
else
if
(
boost
::
regex_match
(
line
,
matches
,
roiBoxRe
)
)
{
Branch
parentBranch
=
string_utils
::
fromString
<
Branch
>
(
matches
[
2
]
);
RoiID
roiID
=
string_utils
::
fromString
<
RoiID
>
(
matches
[
1
]
);
wlog
::
debug
(
"Project Loader [Parser]"
)
<<
"Line "
<<
lineNumber
<<
": ROI with ID "
<<
roiID
<<
" in Branch "
<<
parentBranch
;
// store info
m_rois
.
push_back
(
Roi
(
roiID
,
parentBranch
)
);
}
else
if
(
boost
::
regex_match
(
line
,
matches
,
branchPropRe
)
)
{
Branch
branch
=
string_utils
::
fromString
<
Branch
>
(
matches
[
1
]
);
std
::
string
prop
=
matches
[
2
];
std
::
string
propValue
=
matches
[
3
];
wlog
::
debug
(
"Project Loader [Parser]"
)
<<
"Line "
<<
lineNumber
<<
": Property
\"
"
<<
prop
<<
"
\"
of Branch "
<<
branch
<<
" set to "
<<
propValue
;
// store info
m_branchProperties
[
branch
]
=
Property
(
prop
,
propValue
);
}
else
if
(
boost
::
regex_match
(
line
,
matches
,
roiBoxPropRe
)
)
{
RoiID
roiID
=
string_utils
::
fromString
<
RoiID
>
(
matches
[
1
]
);
std
::
string
prop
=
matches
[
2
];
std
::
string
propValue
=
matches
[
3
];
wlog
::
debug
(
"Project Loader [Parser]"
)
<<
"Line "
<<
lineNumber
<<
": Property
\"
"
<<
prop
<<
"
\"
of ROI "
<<
roiID
<<
" set to "
<<
propValue
;
// store info
m_roiProperties
[
roiID
]
=
Property
(
prop
,
propValue
);
}
else
{
return
false
;
}
// read something
return
fals
e
;
return
tru
e
;
}
void
WRoiProjectFileIO
::
done
()
...
...
src/core/kernel/WRoiProjectFileIO.h
View file @
daa50679
...
...
@@ -26,6 +26,10 @@
#define WROIPROJECTFILEIO_H
#include <string>
#include <vector>
#include <map>
#include "boost/tuple/tuple.hpp"
#include "../common/WProjectFileIO.h"
...
...
@@ -70,6 +74,45 @@ public:
protected:
private:
/**
* Branch by ID
*/
typedef
unsigned
int
Branch
;
/**
* Property for branch/roi with ID. Property name and value are stored as string
*/
typedef
boost
::
tuple
<
std
::
string
,
std
::
string
>
Property
;
/**
* All loaded branch IDs
*/
std
::
vector
<
Branch
>
m_branches
;
/**
* Properties of each branch
*/
std
::
map
<
Branch
,
Property
>
m_branchProperties
;
/**
* ID of a ROI
*/
typedef
unsigned
int
RoiID
;
/**
* ROI by ID, second is parent branch ID
*/
typedef
boost
::
tuple
<
RoiID
,
Branch
>
Roi
;
/**
* All loaded rois
*/
std
::
vector
<
Roi
>
m_rois
;
/**
* Properties of each branch
*/
std
::
map
<
RoiID
,
Property
>
m_roiProperties
;
};
#endif // WROIPROJECTFILEIO_H
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment