Cocoa wrapper
Ruslan Zasukhin
sunshine at public.kherson.ua
Mon May 24 10:01:18 CDT 2004
On 5/24/04 2:32 AM, "Hans Gidlöf" <hasse at techniqueprogram.se> wrote:
> Hello Ruslan
>
> I have problem with making new fields in VDK_BaseObject´s
> perhaps I have not created the VDK_BaseObject the right way?
> I tried :
> if( VDK_DataBase::sDataBase)
> {
> // first test
> // mVDK_BaseObject = new VDK_BaseObject([mName cString]);
>
> // sec. test
> mVDK_BaseObject = VDK_DataBase::sDataBase->NewVDKBaseObject([mName
> cString]);
> }
>
> And how can I verify my VDK_BaseObject.
>
> The VDK_DataBase seems to work.
>
> mVDK_DataBase = new VDK_DataBase();
>
> // try to verify that the object is in good health
> int x = mVDK_DataBase->GetDataBaseList()->GetCount();
> NSLog(@"Count Databas: %i", x);
Hi Hans,
First of all I want point:
C++ SDK, Valentina for REALbasic and Valentina for Java,
These 3 OO-langugaes SDK provide 2 ways for developers:
1) easy way, DYNAMIC way:
VDK_Database* pdb = new VDK_Database()
pDB->Create(); // and only after create or open we can do:
VDK_BaseObject* pPerson = pDB->MakeNewBaseObject( "Person" );
// now pdb->GetBaseObjectCount() == 1
pPerson->MakeShortField( "fld_short", fIndexed );
As you see this way use API of classes, to dictate step by step.
It not use SQL. This is low level API actually.
SQL way in fact after parsing of SQL command use the same calls.
----------------
2) aha, exists also SQL way. It is very simple and short:
VDK_Database* pdb = new VDK_Database()
pDB->Create();
pDB->SQLExecute( "CREATE TABLE Person(fld_short SHORT INDEXED)" );
// btw, after that we can use API to get tabes:
VDK_BaseObject* pPerson = db->GetTable( "Person" )
--------------------
3) STATIC WAY. Or CLASS WAY.
This way can be used for OO developers
- when structure of database is static (i.e. Not changes)
- when developer want to use OO way.
In this way developer define class(es) that will correspond to table
class Person : public VDK_BaseObject
{
VDK_Short mFldShort;
Person( name ) : VDK_BaseObject(name)
mFldShort( "fld_short", fIndexed )
{
}
};
Class MyDatabase : VDK_Database
{
Person mPerson;
}
Main()
{
MyDatabase* pdb = new MyDatabase;
// you see difference?
// we create not VDK_Database, but our class.
// and this one line create in RAM all other tables and fields.
pdb->Create();
// this one line create on disk inside of db all tables
// and fields
}
---------------------
So you Hans, should exactly understand which way you implement NOW.
I think the most easy way to implement -- is SQL way.
After that add API way,
And at the end implement CLASS way. Obj-C also is OO language.
Note, that in C++ we use data members of Tables and fields:
VDK_BaseObject mPerson;
This feature of C++ create object of VDK_BaseObject self when is created
VDK_Daatbase object.
In REALbasic and Java there is no such feature, so they need write creation
of sub-objects manually in constructor
class MyDatabase
{
Person mPerson; in RB and Java this is pointer in fact.
myDatabase()
{
mPerson = new Person() // this line must be in RB and Java.
}
};
--
Best regards,
Ruslan Zasukhin [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com
To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------
More information about the Valentina
mailing list