<p dir="ltr">You don&#39;t need to transform the value at all. EnumOption should be able to parse directly a string value. You may want to add something to the transform class to make expressing such a &quot;move-only&quot; transform less verbosely.</p>
<p dir="ltr">Teemu</p>
<br><div class="gmail_quote"><div dir="ltr">On Thu, Sep 21, 2017, 16:53 Mark Abraham &lt;<a href="mailto:mark.j.abraham@gmail.com">mark.j.abraham@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I had a go at that as part of <a href="https://gerrit.gromacs.org/c/6485/2/src/gromacs/mdtypes/legacymdp.cpp" target="_blank">https://gerrit.gromacs.org/c/6485/2/src/gromacs/mdtypes/legacymdp.cpp</a>. Teemu had some initial feedback for me (thanks), but I haven&#39;t followed up yet. (We&#39;ve refactored some of the related stuff since then.)</div><div><br></div><div>Basically, I used some adapter functions stringToEnum() and vice-versa. You&#39;re using an enum class it seems, but the same kind of approach should still work.</div></div><div dir="ltr"><div><br></div><div>Mark</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Sep 21, 2017 at 2:50 PM Kutzner, Carsten &lt;<a href="mailto:ckutzne@gwdg.de" target="_blank">ckutzne@gwdg.de</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear developers,<br>
<br>
I want to read in an additional option from the .mdp file that is entered as a string and<br>
is one of several choices. How should/can such enum-style options be implemented within<br>
the IMdpOptionProvider framework? An example would be a temperature coupling<br>
option with possible values<br>
<br>
mytcoupl = no  ; or andersen, or v-rescale, ...<br>
<br>
I have defined<br>
enum TempCouplType { tc_none, tc_andersen, tc_vrescale };<br>
const char *const TempCouplDesc[] = { &quot;no&quot;, &quot;andersen&quot;, &quot;v-rescale&quot; }<br>
<br>
The following three methods need to be implemented:<br>
1) buildMdpOutput()<br>
2) initMdpOptions()<br>
3) initMdpTransform()<br>
<br>
in (1) I use<br>
TempCouplType myTcoupl = 1; // e.g.<br>
builder-&gt;addValue&lt;string&gt;(&quot;tcoupl&quot;, TempCouplDesc[myTcoupl] ); // outputs &quot;tcoupl = andersen&quot; in mdout.mdp<br>
<br>
in (2)<br>
section.addOption(EnumOption&lt;TempCouplType&gt;(&quot;mytcoupl&quot;).enumValue(TempCouplDesc).store(&amp;myTcoupl));<br>
<br>
for (3) at the moment I use the following, which allows me to put _integers_ in the .mdp,<br>
but not _strings_ as I would like to:<br>
<br>
IKeyValueTreeTransformRules *rules;<br>
rules-&gt;addRule().from&lt;string&gt;(&quot;mytcoupl&quot;).to&lt;int&gt;(&quot;/special-section/tcoupl&quot;).transformWith(&amp;fromStdString&lt;int&gt;);<br>
<br>
Thanks for any hint!<br>
  Carsten<br>
<br>
<br>
<br>
--<br>
Gromacs Developers mailing list<br>
<br>
* Please search the archive at <a href="http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List" rel="noreferrer" target="_blank">http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List</a> before posting!<br>
<br>
* Can&#39;t post? Read <a href="http://www.gromacs.org/Support/Mailing_Lists" rel="noreferrer" target="_blank">http://www.gromacs.org/Support/Mailing_Lists</a><br>
<br>
* For (un)subscribe requests visit<br>
<a href="https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers" rel="noreferrer" target="_blank">https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers</a> or send a mail to <a href="mailto:gmx-developers-request@gromacs.org" target="_blank">gmx-developers-request@gromacs.org</a>.<br>
</blockquote></div>
--<br>
Gromacs Developers mailing list<br>
<br>
* Please search the archive at <a href="http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List" rel="noreferrer" target="_blank">http://www.gromacs.org/Support/Mailing_Lists/GMX-developers_List</a> before posting!<br>
<br>
* Can&#39;t post? Read <a href="http://www.gromacs.org/Support/Mailing_Lists" rel="noreferrer" target="_blank">http://www.gromacs.org/Support/Mailing_Lists</a><br>
<br>
* For (un)subscribe requests visit<br>
<a href="https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers" rel="noreferrer" target="_blank">https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers</a> or send a mail to <a href="mailto:gmx-developers-request@gromacs.org" target="_blank">gmx-developers-request@gromacs.org</a>.</blockquote></div>