Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CEP27: toolkit Snippet #297

Merged
merged 21 commits into from
Mar 27, 2021
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions source/cep/cep27.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
CEP 27 - Agent Toolkit Capabilities
gonuke marked this conversation as resolved.
Show resolved Hide resolved
***********************************

:CEP: 27
:Title: Agent Toolkit Capabilities
:Last-Modified: 2019-10-28
:Author: Baptiste Mouginot <[email protected]>
:Status: Active
:Type: Standards Track
:Created: Baptiste Mouginot


Abstract
========

|Cyclus| toolkit is designed to easily implement specific capabilities in newly
bam241 marked this conversation as resolved.
Show resolved Hide resolved
developed archetypes, such as trading policy, commodity producers... To add
characteristics to archetypes such as Position or Metadata, the actual
implementation method is very verbosy where in each archetypes one need to add
bam241 marked this conversation as resolved.
Show resolved Hide resolved
the inew specification in the header, assign it and use it in the cpp file,
bam241 marked this conversation as resolved.
Show resolved Hide resolved
without guaranty on the consistency in the variables naming and implementation
bam241 marked this conversation as resolved.
Show resolved Hide resolved
across multiple archetypes.
This CEP explains how to use snippets would simplify and maintain consistency
bam241 marked this conversation as resolved.
Show resolved Hide resolved
in the implementation and the usage, across multiple archetypes.


Toolkit Implementation
======================

The |Cyclus| toolkit will contain 3 different files: 2 for the definition of the
bam241 marked this conversation as resolved.
Show resolved Hide resolved
snippet C++ class (``cpp`` and header) that allows to use the capabilities, and
bam241 marked this conversation as resolved.
Show resolved Hide resolved
optionally to register its values in the output database, a snippet simplifying
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand the grammar here. Is the purpose of the snippet to "simplify the integration of the feature..."

the integration of the feature in a newly develop archetypes.

The snippet file with then be included in the header part of the archetypes
class declaration as": ``#include toolkit/my_snippet.cycpp.h``
bam241 marked this conversation as resolved.
Show resolved Hide resolved

(The use of the ``cycpp.h`` has been chosen to allow syntax highlighting and
inform developers that this is not a standard C++ header)
The snippet file, will contain the declaration of all the variables required
to use the capabilities class:

- the definition of the capability class as a member variable.

- (optional) if the capability requires/allows variable input from users,
standard |Cyclus| member variable declaration with variable ``#pragma`` is
required. In addition, to the standard variable declaration and the
``#pragma`` the method also require a ``std::vector<int>
cycpp_shape_myvariable0`` to be declared for each of the decorated variable.
``cycpp preprocessor`` is not able at the time to add them automatically for
included files.


The main interest of this include method would be to insure consistency across
bam241 marked this conversation as resolved.
Show resolved Hide resolved
archetypes using the same toolkit capability requiring user input, avoiding 1
set of input syntax per archetypes for the same capability.

If the toolkit features needs to capabilities to write in the output database a
bam241 marked this conversation as resolved.
Show resolved Hide resolved
``RecordSnippet(Agent* agent)`` method will be implemented to avoid
multiplication of implementation in the archetypes.


Archetypes Integration
======================

When the capability is integrated in an Archetype the following implementations
have to be done:

1. Include the snippet in the class header core: ``#include
toolkit/my_snippet.cycpp,h``.

2. Add the proper default initialisation of the variable required for the
bam241 marked this conversation as resolved.
Show resolved Hide resolved
snippet.

3. In the ``Archetype::EnterNotify()``, assign the Snippet with value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really assign the "Snippet" with a value???

corresponding to the user input.

4. (optional) If required, call the ``RecordSnippet()`` method when necessary during the
Archetype operation.


Class member vs Inheritance
===========================

With inheritance of the capability class, one will need to also modify the
archetype class declaration in addition to simply including the snippet at the
right place.
This may also lead to confusion, as one can believe that the user input value
for variable are passed in the constructor of the class and might lead the
develop to skip the assignation of the value in the inherited class in the
``EnterNotify``...

Otherwise behavior would be very similar.