[Q] C++ SDK, the Class way.

Ruslan Zasukhin sunshine at public.kherson.ua
Tue Jun 22 13:59:57 CDT 2004


Hi C++ Developers,
Hi Totte,

Today morning I have made draft of example to work not with new 2.0
Interfaces, but with Valentina 1.x classes way.

File is attached.
Please consider it and let me know what you think on this new style,
Which little differ from Valentina 1.x.


* Fist of all you will see few small wrapper classes VDK_Database,
VDK_Table, VDK_Field...

* you can note, that this classes play role of "smart pointer" around the
main classes I_Database, I_Table, I_Field.

This classes have therefore operator->().


---------
* This trick gives much more flexible solution than in Valentina 1.x IMHO.

-- Because in Valentina 1.x wrapper classes have totally hide kernel object,
    now no. you still will have access to deep kernel objects and their
    methods. 

-- Because in Valentina 1.x if we add functionality to kernel object, I was
need add it to wrapper classes. Now NO!!! Because operator->() dispatch us
to kernel object. So we will get automatically all new features of classes
in future with NO TIME.

-- Because this small wrapper classes have all methods INLINE.
    in the Valentina 1.x all methods of wrapper classes was located in the
    .cpp file, so we have to jump to that wrapper class code, then jump
    to kernel method.

    NOW we will jump directly into interface's methods!!!
    (after inline).

-- In this new way, we will need send into constructor of VDK_Table
    the VDK_Database*. In Valentina 1.x I have use static pointers
    to hide this. I have decide refuse static pointers, because this
    will not work in mutli-threading.



-------
Drawbacks of new way:

-- I see only one potential drawback, but it is small and cosmetic,
    and compiler will not give you to make mistakes.
    Look here

   DbContacts db;

   try
    {
        I_Location_Ptr pLocation = CreateDiskLocation( L"contacts_db.vdb" );

        db->put_Location( pLocation );
        db->Create();
        db->Close();
        
        db.mptPerson.mpfFirstName->put_IsNull( true );
    }

We can create db variable on stack,
But to access kernel methods we need use operator->().

In the same time to access variables and methods of DbContacts class, we
need to use DOT syntax.

Well, at first I have to think that this may be confusing and error prone,
But it seems no. compiler will give you error in case you have made mistake
between . and ->

And we get actually interesting thing:
    it is easy to see where is YOUR variables and methods,
    and where are Valentina Engine methods.


------
In any case, this is the most elegant coding I was able invent around our
new Interfaces in Valentina 2.0.

Do not forget that this is optional way -- usage of classes.
We use it when we know exactly what tables and fields we will have,
When we want to use low level API and Valentina Navigational model.


And I think it will be not very hard to update old sources to this new
syntax. It looks that it will be possible to made N find/replaces on the
whole project to get it working.

What you think?
Totte?

-- 
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
-------------------------------------------------------------

-------------- next part --------------
Skipped content of type multipart/appledouble-------------- next part --------------

Scanned by evaluation version of Dr.Web antivirus Daemon 
http://drweb.ru/unix/



More information about the Valentina-beta mailing list