<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On May 26, 2011, at 10:15 PM, Pau Arumi wrote:</div><blockquote type="cite">
<div><p>I thing you are missing the & in "string & old = ..."
<br>however i might not be understanding completely the situation.
<br>P
<br></p></div></blockquote><div>I already tried it and it forces me to put "constant" if I put the "&". If i put</div><div>the constant obviously then I can't change the value which is what I want.</div><div><br></div><div>Generally speaking, what I am trying to do is modify the value of an attribute</div><div>in a DynamicType and I try to do it by getting an attribute from a DynamicType</div><div>as void*, casting it to std::string and changing the value</div><div><br></div><blockquote type="cite"><div><p><font color="#999999">-- </font>
<br><font color="#999999">Sent on the road</font>
<br>
<br>----- Mensaje original -----
<br>> Hi guys..
<br>> I have another issue. How do you set new values to a dynamictype
<br>> attribute? I've seen clam code such as:
<br>> ConcreteString & value = *(ConcreteString
<br>> *)object.GetAttributeAsVoidPtr(attribute); value =
<br>> input->toPlainText().toLocal8Bit().constData();
<br>>
<br>> but in my code I do:
<br>> std::string old = config.attributeValue<std::string>(i);
<br>> old = value;
<br>> with value being passed as const std::string& and attributeValue<type>
<br>> being: *(type *)_processingConfig->GetAttributeAsVoidPtr( i )
<br>> and nothing changes. What am I doing wrong?
<br>>
<br>> Thanks!
<br>>
<br>> PS: I hate pointers
<br>>
<br>> On May 25, 2011, at 8:39 PM, Pau Arumi wrote:
<br>>
<br>>
<br>> Check the Component interface. Maybe it is called Clone() or DeepCopy().
<br>> P
<br>> --
<br>> Sent on the road
<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
<br>> > > > with 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
<br>> > > it returns an object of the same class than the receiver. Not a
<br>> > > copy, 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
<br>> > 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).
<br>> > > The default copy constructor copies all members, in this case will
<br>> > > copy the pointer and you will double delete it on the destructor.
<br>> > > This might happen not just in assignments but also when passing it
<br>> > > as parameter or returning not as reference, and it may not be you
<br>> > > but maybe boost::python. So my suggestiong is to implement it
<br>> > > private and assert false inside, so, at least if boost::python uses
<br>> > > it you will 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><<a href="mailto:clam-devel@lists.clam-project.org">mailto: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><<a href="mailto:clam-devel@lists.clam-project.org">mailto: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>
<br><Archivo adjunto> ATT00001.txt
<br><br></p>
</div>
</blockquote></div><br></body></html>