<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi guys..<div>I have another issue. How do you set new values to a dynamictype attribute?</div><div>I've seen clam code such as:</div><div><div><span class="Apple-tab-span" style="white-space:pre"> </span>ConcreteString & value = *(ConcreteString *)object.GetAttributeAsVoidPtr(attribute);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>value = input->toPlainText().toLocal8Bit().constData();</div></div><div><br></div><div>but in my code I do:</div><div><div><span class="Apple-tab-span" style="white-space:pre"> </span>std::string old = config.attributeValue<std::string>(i);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>old = value;</div></div><div>with value being passed as const std::string& and attributeValue<type> being:</div><div><div><span class="Apple-tab-span" style="white-space:pre"> </span>*(type *)_processingConfig->GetAttributeAsVoidPtr( i )</div></div><div>and nothing changes. What am I doing wrong?</div><div><br></div><div>Thanks!</div><div><br></div><div>PS: I hate pointers</div><div><br></div><div><div><div>On May 25, 2011, at 8:39 PM, Pau Arumi wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<div><p>Check the Component interface. Maybe it is called Clone() or DeepCopy().
<br>P
<br><font color="#999999">-- </font>
<br><font color="#999999">Sent on the road</font>
<br>
<br>----- Mensaje original -----
<br>> On May 25, 2011, at 7:48 PM, David García Garzón wrote:
<br>>
<br>> > On Wednesday 25 May 2011 19:09:23 Xavier Serra Román wrote:
<br>> > > Hi guys,
<br>> > > I'm now at the part of ipyclam dealing with configurations and I've
<br>> > > run into some trouble, I defined a c++ class to wrap into python with
<br>> > > boost.python that holds a processingconfig.
<br>> > >
<br>> > > I need to create the processingconfig in the class from a copy of
<br>> > > another one so I've defined: ConfigurationProxy(const
<br>> > > CLAM::ProcessingConfig & prototype)
<br>> > > {
<br>> > > _processingConfig = new CLAM::ProcessingConfig(prototype);
<br>> > > }
<br>> > > this, obviously. doesn't work because abstract classes cannot be
<br>> > > allocated but I don't know what else to do.
<br>> >
<br>> > Use the Component::Species() virtual method. It is redefined in
<br>> > subclasses (including ProcessinConfig's derivatives) in a way that it
<br>> > returns an object of the same class than the receiver. Not a copy,
<br>> > just the default constructed one.
<br>>
<br>> How do you call it? I don't seem to be able to make it work, I've tried
<br>> from prototype.Species() to CLAM::ProcessingConfig::Species(prototype)..
<br>>
<br>> >
<br>> > Be carefull on the code below, if you ned the default constructor (do
<br>> > you need it?) initialize all the members.
<br>> >
<br>> > Be also carefull with the copy constructor (generated by default). The
<br>> > default copy constructor copies all members, in this case will copy
<br>> > the pointer and you will double delete it on the destructor. This
<br>> > might happen not just in assignments but also when passing it as
<br>> > parameter or returning not as reference, and it may not be you but
<br>> > maybe boost::python. So my suggestiong is to implement it private and
<br>> > assert false inside, so, at least if boost::python uses it you will
<br>> > be notified at compilation or runtime.
<br>> >
<br>> >
<br>> > > The complete code of the class is:
<br>> > > class ConfigurationProxy
<br>> > > {
<br>> > > public:
<br>> > > CLAM::ProcessingConfig * _processingConfig;
<br>> > > ConfigurationProxy() {}
<br>> > > ConfigurationProxy(const CLAM::ProcessingConfig & prototype)
<br>> > > {
<br>> > > _processingConfig = new CLAM::ProcessingConfig(prototype);
<br>> > > }
<br>> > > ~ConfigurationProxy()
<br>> > > {
<br>> > > delete _processingConfig;
<br>> > > }
<br>> > > };
<br>> > >
<br>> > > Thanks!
<br>> > > _______________________________________________
<br>> > > clam-devel mailing list
<br>> > > <a href="mailto:clam-devel@lists.clam-project.org">clam-devel@lists.clam-project.org</a>
<br>> > > <a href="http://lists.clam-project.org/listinfo.cgi/clam-devel-clam-project.org">http://lists.clam-project.org/listinfo.cgi/clam-devel-clam-project.org</a>
<br>>
<br>> _______________________________________________
<br>> clam-devel mailing list
<br>> <a href="mailto:clam-devel@lists.clam-project.org">clam-devel@lists.clam-project.org</a>
<br>> <a href="http://lists.clam-project.org/listinfo.cgi/clam-devel-clam-project.org">http://lists.clam-project.org/listinfo.cgi/clam-devel-clam-project.org</a>
<br><br></p>
</div>
</blockquote></div><br></div></body></html>