<div dir="ltr">German,<br><br><div class="gmail_quote">On Fri, Sep 12, 2008 at 11:18 AM, Germ�n Diago <span dir="ltr">&lt;<a href="mailto:germandiago@gmail.com" target="_blank">germandiago@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
Hello. I&#39;m implementing a property class which uses my own library<br>
(still in early stages) and<br>
I want to extend it to general reflection (not for now) and shared<br>
library loading.<br>
I found boost.extensions, which is not a boost library for now.<br>
<br>
I don&#39;t know if this is the place to ask for this, if it is not, point<br>
me where I could go. It&#39;s great<br>
to see I won&#39;t have to taje any more pain to load plugins :-).<br>
I would like to make a feature request. In boost.extensions, factories<br>
are used to construct<br>
types of a derived class with pointers. So, in order to register a new<br>
class, you have to tell which is the base<br>
class to the extensions system. I think there is a better way, with<br>
which you wouldn&#39;t need to do<br>
this. It is inspired in this type style of value-based type system:<br>
<br>
<a href="http://stlab.adobe.com/wiki/index.php/Image:2008_06_26_classes_that_work.pdf" target="_blank">http://stlab.adobe.com/wiki/index.php/Image:2008_06_26_classes_that_work.pdf</a><br></blockquote><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">

<br>
<br>
An object which can contain any other object (like boost::any) could<br>
be created. This way (this is how I do<br>
in my own solution) you just have to register a type without worrying<br>
about its base class:<br>
<br>
REGISTER_CLASS(myns, myclass)<br>
<br>
Now I can do like this:<br>
<br>
object_t myobject = introspection::create_object(&quot;myns&quot;, &quot;myclass&quot;);<br>
when I want my object to become &quot;myclass&quot; I do:<br>
<br>
myns::myclass &amp; refclass = get_reference&lt;myns::myclass&gt;(myobject);</blockquote><div><br></div><div>OK, if I read this correctly, what you want is a global object containing factories indexed by name that return a reference that can be converted back to their correct type.</div>
<div><br></div><div>This entire functionality is provided by Boost.Reflection (with much more), with the exception of the global registry. If you want to use a global registry for objects, you can wrap the objects in the library and provide your own macros. I did not want to create a dependency on Boost.Thread to ensure thread safety for the global objects, and I didn&#39;t want to constrain users to use the global objects.</div>
<div><br></div><div>Problems I see with your API however:</div><div><ol><li>This requires that the caller of get_reference know the type of the object being looked up. If the class is defined in a plugin, then the main executable may not know that type when it was compiled. The executable may have been compiled before the plugin was even created!</li>
<li>What about constructors with parameters?</li></ol></div><div>&nbsp;</div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<br>
This works fairly well, and factories go away, freeing the user from<br>
learning more interfaces.</blockquote><div><br></div><div>Don&#39;t you still have to know the interface to myns::myclass? Besides, interfaces, polymorphism, reusable base classes etc. are usually considered helpful when doing object-oriented programming...</div>
<div>&nbsp;</div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><br>
&nbsp;Just register your type and use it. Everything else is transparent.</blockquote><div><br></div><div>Why do you need to register it if you&#39;re just going to use it using it&#39;s standard interface?</div><div>&nbsp;</div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<br>
The interface is simple, no factories or anything else to handle. </blockquote><div><br></div><div>Well, there need to be some sort of factories to create the objects.</div><div>&nbsp;</div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
This<br>
can be also used from shared libraries without problems.</blockquote><div><br></div><div>Besides thread-safety, RTTI, differing compiler settings, etc...</div><div>&nbsp;</div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<br>
At least, I think that it should be provided a way to register a<br>
factory of non-pointer types. In the documentation it says<br>
a pointer is created for the animal class, disabling this type of<br>
value-based registration.</blockquote><div><br></div><div>A factory of non-pointer types? I&#39;m confused - the example you describe appears to create the objects on the heap, thus pointers are involved somewhere. As soon as you right myns::myclass&amp;, you are basically using a pointer.</div>
<div><br></div><div>Could you try and describe your use cases a little bit more clearly, and also take a look at the Extension documentation at&nbsp;<a href="http://boost-extension.redshoelace.com/docs/boost/extension/index.html">http://boost-extension.redshoelace.com/docs/boost/extension/index.html</a>? Let me apologize for the still incomplete reflection documentation.</div>
<div><br></div><div>Jeremy Pack</div></div></div>