<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[MAXON Data Type and explicit constructors]]></title><description><![CDATA[<p dir="auto">Is it possible to define an explicit constructor for Custom Data Types?<br />
In the examples provided <a href="https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_maxon_datatype.html" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>, the triplet is configured after allocating it.</p>
<p dir="auto">I would like to initialize my type upon creation. Is this possible?</p>
]]></description><link>http://developers.maxon.net/forum/topic/11294/maxon-data-type-and-explicit-constructors</link><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Nov 2026 20:40:51 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/11294.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 01 Feb 2019 21:35:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to MAXON Data Type and explicit constructors on Tue, 05 Feb 2019 13:14:04 GMT]]></title><description><![CDATA[<p dir="auto">Thanks Riccardo!</p>
<p dir="auto">Now I understand - thanks to your side note. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /><br />
And of course I understand, that this goes hand in hand with your guidelines.</p>
<p dir="auto">Cheers,<br />
Robert</p>
]]></description><link>http://developers.maxon.net/forum/post/57086</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/57086</guid><dc:creator><![CDATA[mp5gosu]]></dc:creator><pubDate>Tue, 05 Feb 2019 13:14:04 GMT</pubDate></item><item><title><![CDATA[Reply to MAXON Data Type and explicit constructors on Tue, 05 Feb 2019 13:49:34 GMT]]></title><description><![CDATA[<p dir="auto">Hi mp5gosu, thanks for following up.</p>
<p dir="auto">I see your point, but actually you can still initialize the member variables to a  "reasonable" default value helping to identify cases when the class was instantiated without any explicit value.</p>
<p dir="auto">A final, additional, side note about initialization: considering that constructors can't return any "evidence" of failure when allocating members we advise against initializing members directly in the constructor.<br />
We rather suggest implementing an additional Init() method where the members' initialization takes place as shown in the code snippet in  the <a href="https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_creation.html#page_maxonapi_creation_objects" target="_blank" rel="noopener noreferrer nofollow ugc">Entity Creation</a> section.</p>
<p dir="auto">Best, Riccardo</p>
]]></description><link>http://developers.maxon.net/forum/post/57085</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/57085</guid><dc:creator><![CDATA[r_gigante]]></dc:creator><pubDate>Tue, 05 Feb 2019 13:49:34 GMT</pubDate></item><item><title><![CDATA[Reply to MAXON Data Type and explicit constructors on Tue, 05 Feb 2019 10:17:29 GMT]]></title><description><![CDATA[<p dir="auto">Of course, but doesn't this make the explicit constructor useless? With that approach the user is still able to instantiate the class without initializing the variable on creation correctly.</p>
<p dir="auto">At least when testing this, I was able to instatntiate the class without the need for an argument, so I assume that the explicit constructor simply gets omitted.</p>
]]></description><link>http://developers.maxon.net/forum/post/57081</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/57081</guid><dc:creator><![CDATA[mp5gosu]]></dc:creator><pubDate>Tue, 05 Feb 2019 10:17:29 GMT</pubDate></item><item><title><![CDATA[Reply to MAXON Data Type and explicit constructors on Tue, 05 Feb 2019 09:54:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/mp5gosu">@<bdi>mp5gosu</bdi></a> said in <a href="https://developers.maxon.net/forum/post/57069" target="_blank" rel="noopener noreferrer nofollow ugc">MAXON Data Type and explicit constructors</a>:</p>
<blockquote>
<p dir="auto">// This gives a compiler error, complaining about that there's no default constructor available.</p>
</blockquote>
<p dir="auto">As suggested by the compiler simply make the default constructor living beside your constructor and the compiler won't complain anymore <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<pre><code class="language-c++">class IntegerTriplet
{
private:
  maxon::Int _val;

public:
  IntegerTriplet(){}
  explicit IntegerTriplet(const maxon::Int val) : _val(val) {} 
};
</code></pre>
<p dir="auto">Cheers, Riccardo</p>
]]></description><link>http://developers.maxon.net/forum/post/57079</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/57079</guid><dc:creator><![CDATA[r_gigante]]></dc:creator><pubDate>Tue, 05 Feb 2019 09:54:10 GMT</pubDate></item><item><title><![CDATA[Reply to MAXON Data Type and explicit constructors on Mon, 04 Feb 2019 12:46:32 GMT]]></title><description><![CDATA[<p dir="auto">Hey Riccardo,</p>
<p dir="auto">Sorry for not being precise.<br />
I'm talking about the new Maxon API and its data containers, not the classic API at all.<br />
As far as I understand the maxon::DataDictionary and maxon::Data types, they are the replacements for both legacy types, BaseContainer and GeData.<br />
Now I wanted to have a class being a registered as a new Data type as written <a href="https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_maxon_datatype.html" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>, so I can use it with a DataDictionary</p>
<p dir="auto">However, I want the type to be initialized with a certain value. Let me illustrate it on the SDK example:</p>
<pre><code class="language-cpp">// This example defines a custom class and declares it as a MAXON data type.
#include "maxon/datatype.h"
#include "maxon/string.h"
// ------------------------------
// Triplet of maxon::Int values.
// ------------------------------
class IntegerTriplet
{
maxon::Int _val; // Keep it private

public:
  explicit IntegerTriplet(const maxon::Int val) : _val(val) {} // This gives a compiler error, complaining about that there's no default constructor available.
};
// register as MAXON data type
MAXON_DATATYPE(IntegerTriplet, "net.maxonexample.datatype.integertriplet"); 
</code></pre>
<p dir="auto">And usage:</p>
<pre><code class="language-cpp">IntegerTriplet triplet(30);
// ...
</code></pre>
<p dir="auto">Can be that I misunderstood the concept of the new MAXON Data types, and I'd be really thankful if you can shed some light onto this.</p>
]]></description><link>http://developers.maxon.net/forum/post/57069</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/57069</guid><dc:creator><![CDATA[mp5gosu]]></dc:creator><pubDate>Mon, 04 Feb 2019 12:46:32 GMT</pubDate></item><item><title><![CDATA[Reply to MAXON Data Type and explicit constructors on Mon, 04 Feb 2019 10:46:45 GMT]]></title><description><![CDATA[<p dir="auto">Hi mp5gosu, thanks for reaching us.</p>
<p dir="auto">I'm a bit confused, since reading the topic and the documentation reference, it's unclear the question about explicit constructor on CustomDataType. <a href="https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_maxon_datatype.html" target="_blank" rel="noopener noreferrer nofollow ugc">MAXON Data Type</a> and <a href="https://developers.maxon.net/docs/cpp/2023_2/struct_custom_data_type.html" target="_blank" rel="noopener noreferrer nofollow ugc">CustomDataType</a> - and the related <a href="https://developers.maxon.net/docs/cpp/2023_2/class_custom_data_type_class.html" target="_blank" rel="noopener noreferrer nofollow ugc">CustomDataTypeClass</a> - address different needs in terms of development.<br />
Whilst the former is a convenient way to define and register new data structures inside the MAXON AP, used in conjunction with <a href="https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_data_dictionary.html" target="_blank" rel="noopener noreferrer nofollow ugc">MAXON::DataDictionary</a>, the second is the base class from which Cinema CustomDataType(s) are inherited from, used in conjuction with BaseContainers, and which are used to stored the data from the respective CustomGui(s) (think about the <a href="https://developers.maxon.net/docs/cpp/2023_2/class_gradient.html" target="_blank" rel="noopener noreferrer nofollow ugc">Gradient</a> custom data type and the <a href="https://developers.maxon.net/docs/cpp/2023_2/class_gradient_custom_gui.html" target="_blank" rel="noopener noreferrer nofollow ugc">GradientGui</a>)</p>
<p dir="auto">That said, can you please elaborate what do you mean by <em>Is it possible to define an explicit constructor for Custom Data Types?</em></p>
<p dir="auto">Best, Riccardo</p>
]]></description><link>http://developers.maxon.net/forum/post/57062</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/57062</guid><dc:creator><![CDATA[r_gigante]]></dc:creator><pubDate>Mon, 04 Feb 2019 10:46:45 GMT</pubDate></item></channel></rss>