1. David Naval
  2. Valentina Database ADK
  3. Freitag, Februar 07 2020, 05:54 PM
  4.  Abonnieren via E-Mail
Hi, I'm updating Valentina ADK for C++ from version 7.x.x to last 9.8.2.

I saw there are some changes in functions as:

virtual I_RowSet_Ptr I_Table::Sort(
I_RowSet_Ptr inSet,
I_Field_Ptr inSortField,
bool inAsc = true ) = 0;

I make the changes to use I_RowSet_Ptr and use the conversion functions to get ArraySet_Ptr and BitSet_Ptr

FBL_SHARED_EXP ArraySet_Ptr toArraySet( I_RowSet_Ptr inRowSet );
FBL_SHARED_EXP BitSet_Ptr toBitSet ( I_RowSet_Ptr inRowSet );

My current problem is how to convert I_RowSet_Ptr to ArraySet_Ptr....

This a pice of my code:

OSErr
UVDBArraySet_v3::Sort(
FBL::ArraySet_Ptr* ioArrayResult,
FBL::I_Table_Ptr inTable,
FBL::I_Field_Ptr inField,
FBL::ArraySet_Ptr inArraySet)
{
OSErr err = noErr;

*ioArrayResult = nil;

try
{

if (inArraySet)
*ioArrayResult = toArraySet(inTable->Sort (inArraySet, inField));
else
{
FBL::I_RowSet_Ptr pAllSet = inTable->SelectAllRecords();
*ioArrayResult = toArraySet(inTable->Sort (pAllSet, inField));
}
}

catch(xException& thrownError)
{
err = (OSErr)thrownError.get_ErrorCode();
UDebugThrow_(err);
}

catch(int32 thrownError)
{
err = (OSErr)thrownError;
UDebugThrow_(err);
}

catch(...)
{
err = memFullErr;
UDebugThrow_(err);
}

return err;
}
Kommentar
There are no comments made yet.
Ruslan Zasukhin Akzeptierte Antwort
Hi David,

1) sorry I have not seen where exactly you have the problem?
Your code above not works? What happens?

2) Notice that

ArraySet_Ptr toArraySet(I_RowSet_Ptr inRowSet)
{
return inRowSet ? dynamic_cast<ArraySet*>(inRowSet->get_Set().get()) : nullptr;
}

i.e. it cannot convert RowSet, which contains BitSet, into ArraySet.
We made these functions for FAST conversions in our code.

In your case Sort() did return of ArraySet, so it should work. But


3) RowSet is a generalization of ArraySet and BitSet. It is going to hide which exactly container is used behind.
We going to develop this direction in the future providing other kinds of sets.

From RowSet you also can get Iterator, as from Set.
Kommentar
There are no comments made yet.
David Naval Akzeptierte Antwort
Hi Ruslan, Im happy to hear you again.

My application uses ArraySet_Ptr as parameter in some function to select a set or records.

1)
sorry I have not seen where exactly you have the problem?
Your code above not works? What happens?


I want to sort a table using a set of registers, and my parameters are two ArraySet_Ptr as input and output:
*ioArrayResult = toArraySet(inTable->Sort (inArraySet, inField));
for output parameter no problems using 'toArraySet', but I don't known how to convert the input parameter from 'ArraySet_Ptr' to 'I_RowSet_Ptr'

2)
Notice that


Thanks for this information:
ArraySet_Ptr toArraySet(I_RowSet_Ptr inRowSet)
{
return inRowSet ? dynamic_cast<ArraySet*>(inRowSet->get_Set().get()) : nullptr;
}
Can I cast 'I_RowSet_Ptr' to 'ArraySet_Ptr' if RowSet contains a ArraySet?
How to know if RowSet contains a ArraySet?

3)
RowSet is a generalization of ArraySet and BitSet. It is going to hide which exactly container is used behind.
We going to develop this direction in the future providing other kinds of sets.

Your sugestion is replace all 'ArraySet_Ptr' by 'I_RowSet_Ptr' in my app?

Thanks in advanced and best regards.
Kommentar
There are no comments made yet.
Ruslan Zasukhin Akzeptierte Antwort
Hi David,

HOW TO CONVERT: ArraySet to RowSet,

Notice in file FBL_I_RowSet.h


// Factory
//
FBL_SHARED_EXP I_RowSet_Ptr MakeNewRowSet( I_Set_Ptr inSet );


It allows you to create a RowSet from BitSet / ArraySet objects.

Hierarchy is: ArraySet => Set => I_Set
Kommentar
There are no comments made yet.
Ruslan Zasukhin Akzeptierte Antwort
I think at first, it is easier to convert in few places, not changing your funcs params

Later, you can switch to RowSet in more places.
Kommentar
There are no comments made yet.
David Naval Akzeptierte Antwort
Thanks!!!
Kommentar
There are no comments made yet.
  • Seite :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 2 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories