Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Project Juggler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
EIC
Project Juggler
Commits
97f83fb1
Commit
97f83fb1
authored
2 years ago
by
Sylvester Joosten
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
2e42d833
Branches
feat-context-service-overhaul
No related tags found
1 merge request
!502
Feat context service overhaul
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
external/algorithms/core/include/algorithms/algorithm.h
+4
-3
4 additions, 3 deletions
external/algorithms/core/include/algorithms/algorithm.h
external/algorithms/core/include/algorithms/resource.h
+13
-33
13 additions, 33 deletions
external/algorithms/core/include/algorithms/resource.h
with
17 additions
and
36 deletions
external/algorithms/core/include/algorithms/algorithm.h
+
4
−
3
View file @
97f83fb1
...
...
@@ -92,10 +92,11 @@ public:
void
initialize
()
{
init
();
}
void
execute
(
const
Input
&
i
,
const
Output
&
o
)
const
{
process
(
i
,
o
);
}
void
executeInContext
(
const
Input
&
i
,
const
Output
&
o
,
const
Context
&
c
)
const
{
Algorithm
clone
=
*
this
;
c
lone
.
context
(
c
,
&
clone
);
c
lone
.
execute
(
i
,
o
);
auto
copy
=
clone
()
;
c
opy
->
context
(
c
,
copy
.
get
()
);
c
opy
->
execute
(
i
,
o
);
}
auto
clone
()
const
{
return
std
::
make_unique
<
Algorithm
>
(
*
this
);
}
const
InputNames
&
inputNames
()
const
{
return
m_input_names
;
}
const
OutputNames
&
outputNames
()
const
{
return
m_output_names
;
}
...
...
This diff is collapsed.
Click to expand it.
external/algorithms/core/include/algorithms/resource.h
+
13
−
33
View file @
97f83fb1
...
...
@@ -48,21 +48,16 @@ public:
ResourceMixin
()
=
default
;
// Copy constructor for the ResourceMixin needs to update the addresses of the contained
// resources to refer to the new copies.
ResourceMixin
(
const
ResourceMixin
&
rhs
)
:
m_resources
(
rhs
.
m_resources
.
size
(),
nullptr
)
{
for
(
size_t
i
=
0
;
i
<
m_resources
.
size
();
++
i
)
{
m_resources
[
i
]
=
rhs
.
m_resources
[
i
]
->
relocate
(
this
);
// std::cout << m_resources[i] << " " << rhs.m_resources[i] << std::endl;
// m_resources[i]->context(&m_context);
}
}
// Copy constructor for the ResourceMixin assumes new auto-registration (as
// pointers need to be relocated to the new instance)
ResourceMixin
(
const
ResourceMixin
&
)
:
m_resources
()
{}
ResourceMixin
&
operator
=
(
const
ResourceMixin
&
rhs
)
=
delete
;
void
context
(
const
Context
&
c
,
const
NameMixin
*
s
=
nullptr
)
{
m_context
=
c
;
if
(
s
)
{
m_context
.
scope
(
s
);
void
context
(
const
Context
&
c
tx
,
const
NameMixin
*
s
cope
=
nullptr
)
{
m_context
=
c
tx
;
if
(
s
cope
)
{
m_context
.
scope
(
s
cope
);
}
}
const
Context
&
context
()
const
{
return
m_context
;
}
...
...
@@ -79,27 +74,15 @@ public:
// management. Implementation is similar to Property
class
ResourceHandle
{
public:
ResourceHandle
(
const
ResourceMixin
*
owner
)
:
m_offset
{
reinterpret_cast
<
const
char
*>
(
this
)
-
reinterpret_cast
<
const
char
*>
(
owner
)}
{
std
::
cout
<<
"resources handle offset: "
<<
m_offset
<<
std
::
endl
;
}
ResourceHandle
()
=
default
;
virtual
void
context
(
const
Context
*
)
=
0
;
virtual
const
Context
*
context
()
const
=
0
;
// return the relocated address for the copied object in the new instance
ResourceHandle
*
relocate
(
ResourceMixin
*
clone
)
const
{
return
reinterpret_cast
<
ResourceHandle
*>
(
reinterpret_cast
<
char
*>
(
clone
)
+
m_offset
);
}
private
:
// offset versus the ResourceMixin `this` pointer to allow relocating views
const
ptrdiff_t
m_offset
;
};
template
<
class
ResourceType
>
class
Resource
:
public
ResourceHandle
{
public:
template
<
class
...
Args
>
Resource
(
ResourceMixin
*
owner
,
Args
&&
...
args
)
:
ResourceHandle
{
owner
},
m_impl
{
std
::
forward
<
Args
>
(
args
)...}
{
std
::
cout
<<
"Hi, I'm the original and I'm here: "
<<
this
<<
std
::
endl
;
Resource
(
ResourceMixin
*
owner
,
Args
&&
...
args
)
:
m_impl
{
std
::
forward
<
Args
>
(
args
)...}
{
std
::
cout
<<
"DEBUGDEBUG Hi, I'm a resource and I'm here: "
<<
this
<<
std
::
endl
;
if
(
owner
)
{
owner
->
registerResource
(
this
);
m_impl
.
context
(
&
(
owner
->
context
()));
...
...
@@ -108,10 +91,7 @@ public:
fmt
::
format
(
"Attempting to create Resource '{}' without valid owner"
,
m_impl
.
name
()));
}
}
Resource
(
const
Resource
&
rhs
)
:
m_impl
{
rhs
.
m_impl
}
{
std
::
cout
<<
"Hi I'm the copy and I'm here: "
<<
this
<<
" compared to previous: "
<<
&
rhs
<<
" offset: "
<<
(
&
rhs
-
this
)
<<
std
::
endl
;
}
Resource
(
const
Resource
&
rhs
)
=
delete
;
void
context
(
const
Context
*
c
)
final
{
m_impl
.
context
(
c
);
}
const
Context
*
context
()
const
final
{
return
m_impl
.
context
();
}
...
...
@@ -124,7 +104,7 @@ public:
private
:
ResourceType
m_impl
;
};
};
};
// namespace algorithms
}
// namespace algorithms
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