Pete Robbins wrote:
Actually we are wrong here. To replace the isMany() logic you need to
dob = sequence->getDataObject*Value*(i);
getDataObject returns the sequenced DO not the value at position *i*.
Cheers,
On 15/12/06, Yang ZHONG <[EMAIL PROTECTED]> wrote:
It depends on implementation, e.g. Tuscany C++ get(property)
delegates to
get(int), and Tuscany Java get(int) delegates to get(property)
On 12/14/06, Jean-Sebastien Delfino <[EMAIL PROTECTED]> wrote:
>
> [snip]
> Pete Robbins wrote:
> > On 14/12/06, Yang ZHONG <[EMAIL PROTECTED]> wrote:
> >>
> >> if (seqProperty.isMany())
> >> {
> >> int index =
sequence->getListIndex(i);
> >> dob =
> >> dataObject->getList(seqProperty)[index];
> >> }
> >> else
> >> {
> >> dob =
> >> dataObject->getDataObject(seqProperty);
> >> }
> >> might have an alternative:
> >> dob = sequence->getDataObject(i)
> >
> >
> > Correct. I recall making the same simplification in some code
> recently...
> > can't remember where though ;-) The code in CopyHelper and
> > SDOXMLWriter use
> > the longer method but I'm sure dob = sequence->getDataObject(i) will
> > work.
> >
> > Cheers,
> >
>
> OK, Thanks! I had just blindly mirrored what I had seen in CopyHelper
> for this :) This triggers another question: Is it more efficient to
> access properties by index or by property object? In other words,
should
> I do dob->getXyz(i) or dob->getXyz(property)?
>
> --
> Jean-Sebastien
>
> --
>
> Yang ZHONG
Ok, thanks for the clarification. I am now looking at similar code in
Utils::printDO and have one more question:
This code starts at Utils.cpp:441.
SequencePtr sequence = dataObject->getSequence();
if (sequence != NULL)
{
for (unsigned int i = 0; i < sequence->size(); i++)
{
if (sequence->isText(i))
{
tabs(inc);
cout<< "Text Value: " <<
sequence->getCStringValue(i) <<endl ;
}
else {
const Property& p =
sequence->getProperty(i);
tabs(inc);
cout << "Property: " << p.getName() << endl;
const Type& propertyType = p.getType();
tabs(inc);
cout << "Property Type: " <<
propertyType.getURI()<< "#" << propertyType.getName() << endl;
if (dataObject->isSet(p))
{
//////////////////////////////////////////////////////////////////////
// For a many-valued property get
the list of values
//////////////////////////////////////////////////////////////////////
if (p.isMany())
{
inc++;
DataObjectList& dol =
dataObject->getList(p);
for (unsigned int j = 0; j
<dol.size(); j++)
{
tabs(inc);
cout << "Value " << j <<endl;
inc++;
if (propertyType.isDataType())
{
tabs(inc);
cout<< "Property Value:
" << dol.getCString(j) <<endl ;
}
else
printDO(dol[j], inc);
inc--;
}
inc--;
} // end IsMany
This code iterates over a sequence, gets a DataObjectList from a
property with isMany == true, then iterates over the the DataObjectList
and prints all entries in the list.
On the other hand, my code in SDOUtils::accept(...) iterates over a
sequence, gets a DataObjectList from a property with isMany == true, but
then picks the one entry from the list that matches the sequence entry
(which you said earlier in this thread can be done in a simpler way by
calling sequence->getDataObjectValue(i)).
Which code is right? Does Utils::printDO() print the same entries twice?
Or am I going to miss entries in SDOUtils::accept()?
Thanks
--
Jean-Sebastien
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]