Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Commits
2e034cb3
Commit
2e034cb3
authored
2 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Add explicit ObjectID::FromString() and setFromString()
parent
ed01df81
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!301
Add explicit ObjectID::FromString() and setFromString()
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/RobotAPI/libraries/ArmarXObjects/ObjectID.cpp
+25
-10
25 additions, 10 deletions
source/RobotAPI/libraries/ArmarXObjects/ObjectID.cpp
source/RobotAPI/libraries/ArmarXObjects/ObjectID.h
+5
-0
5 additions, 0 deletions
source/RobotAPI/libraries/ArmarXObjects/ObjectID.h
with
30 additions
and
10 deletions
source/RobotAPI/libraries/ArmarXObjects/ObjectID.cpp
+
25
−
10
View file @
2e034cb3
...
...
@@ -19,16 +19,7 @@ namespace armarx
{
if
(
nameOrID
.
find
(
"/"
)
!=
nameOrID
.
npos
)
{
const
std
::
vector
<
std
::
string
>
split
=
simox
::
alg
::
split
(
nameOrID
,
"/"
,
true
);
ARMARX_CHECK
(
split
.
size
()
==
2
||
split
.
size
()
==
3
)
<<
"Expected ID of format 'Dataset/ClassName' or 'Dataset/ClassName/InstanceName'"
<<
", but got: '"
<<
nameOrID
<<
"' (too many '/')."
;
_dataset
=
split
[
0
];
_className
=
split
[
1
];
if
(
split
.
size
()
==
3
)
{
_instanceName
=
split
[
2
];
}
setFromString
(
nameOrID
);
}
else
{
...
...
@@ -37,6 +28,30 @@ namespace armarx
}
}
ObjectID
ObjectID
::
FromString
(
const
std
::
string
&
idString
)
{
ObjectID
id
;
id
.
setFromString
(
idString
);
return
id
;
}
void
ObjectID
::
setFromString
(
const
std
::
string
&
idString
)
{
const
std
::
vector
<
std
::
string
>
split
=
simox
::
alg
::
split
(
idString
,
"/"
,
true
);
ARMARX_CHECK
(
split
.
size
()
==
2
||
split
.
size
()
==
3
)
<<
"Expected ID of format 'Dataset/ClassName' or 'Dataset/ClassName/InstanceName'"
<<
", but got: '"
<<
idString
<<
"' "
<<
"(expected 2 or 3 '/'s, but found "
<<
split
.
size
()
<<
")."
;
_dataset
=
split
[
0
];
_className
=
split
[
1
];
if
(
split
.
size
()
==
3
)
{
_instanceName
=
split
[
2
];
}
}
std
::
string
ObjectID
::
str
()
const
{
std
::
string
_str
=
_dataset
+
"/"
+
_className
;
...
...
This diff is collapsed.
Click to expand it.
source/RobotAPI/libraries/ArmarXObjects/ObjectID.h
+
5
−
0
View file @
2e034cb3
...
...
@@ -17,6 +17,9 @@ namespace armarx
/// Construct from either a class name ("myobject") or ID ("mydataset/myobject", "mydataset/myclass/myinstance").
ObjectID
(
const
std
::
string
&
nameOrID
);
/// Construct from a string produced by `str()`, e.g. ("mydataset/myobject", "mydataset/myclass/myinstance").
static
ObjectID
FromString
(
const
std
::
string
&
idString
);
inline
std
::
string
dataset
()
const
{
...
...
@@ -37,6 +40,8 @@ namespace armarx
/// Return "dataset/className" or "dataset/className/instanceName".
std
::
string
str
()
const
;
void
setFromString
(
const
std
::
string
&
idString
);
/// Return just the class ID without an intance name.
ObjectID
getClassID
()
const
;
...
...
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