Thursday, October 13, 2011

Good bye , Dennis M. Ritchie

#include <stdio.h>

int main() {
    printf("Good bye , Dennis M. Ritchie\n");
}

Thursday, May 26, 2011

Getting Started with Bazaar - The slide

Hi,

Recently I have conduct a training about Bazaar . Here is the slide. Enjoy it ;)

Thursday, March 31, 2011

DQuest 0.2 is released



Hi all,

 I would like to announce that the DQuest 0.2 is released! The API is
more powerful now!

The changes:

Feature enhancements:
 * Supported to create index
 * Supported to query for more complex rules
 * New utility class to create data model initial field

Critial Changes:
 * The usage of DQWhere class is changed to adapt a faster way of
usage. It is incompatible with 0.1.

Detailed Changes:

 DQWhere
 * Deprecated &,| operator overloading and removed from code. It is
replaced by && and ||
 * Changed the definition of constructor. The left operand pass to
constructor is restricted to data model field only. It is not
compatible with old code
 * Improved the operator overloading mechanism. It become a more
powerful class
 * Supported to query by compare the value on different field. The
following query become possible:
 - select * from table where field1 = field2
 * New supported operators: &&,||,+,-,*,/,
%,equal,notEqual,between,in,notIn,like,glob,is,isNot.


 DQ_DECLARE_MODEL
 * Supported private field

 DQIndex
 * A new class for sqlite indexing

 DQField
 * Supported bool and QStringList as the template type T
 * Added operator T() casting. It can be casted to T automatically.

 DQBaseField::get() / DQModelMetaInfo::value() - Added a new argument
"convert"
 * It is true if the QVariant return should be converted to a type
which is suitable for saving. It is designed for type like QStringList
which is not supported by SQLite backend by default.

 DQConnection
 * Change this connection to be the default connection
 * operator == / !- compare is two connection share the same database

 DQSharedQuery
 * Added new function select()  - Construct a new query object with
only the fields assigned in result
 * Added new function orderBy() - Construct a new query object with
required sorting order
 * Added new function setConnection() - Set the database connection

 DQStream
 * A new class, it provides a stream interface for reading and writing
data model field

 DQListWriter
 * A new class, it is a utility class to create the content for DQList
object with predefined field

 DQSharedList
 * Added new function save() - Save all the contained item to database
Reply

Forward







Project page: http://code.google.com/p/d-quest/

Monday, March 28, 2011

A tiny utility - QTestLib application runner

The QTestLib framework, provided by Nokia, is a tool for unit testing Qt based applications and libraries. The framework is very easy to use and sutiable for TDD like development approach.

To make a test program, you just have to create the an unit test project in Qt Creator.

However, when the no. of test case growth, you may break down the test case into few different classes. But the code template generated by Qt Creator combined everything into a single  source file. And it do not support to run multiple test classes.

There have no a direct way to run all the test program in your project. You may have to spend extra time to reorganize the source file for this purpose. It is quite troublesome.

In order to simplify the process, I have made a tiny utility class called TestRunner. It provides a mechanism to exeucte multiple test program without any change of the program's source code. The result for each test program will be recorded and combined to a  summary report.

Example code: 

#include <QtCore/QCoreApplication>
#include "testrunner.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    TestRunner runner;

    runner.run("../testa/tst_testa");
    runner.run("../testb/tst_testb");
    runner.run("../testc/tst_testc"); // not existed test program

    runner.report();

    return 0;
}
Example output:
********* Start testing of TestA *********
Config: Using QTest library 4.7.2, Qt 4.7.2
PASS : TestA::initTestCase()
PASS : TestA::simple()
FAIL! : TestA::fail() 'false' returned FALSE. ()
Loc: [../../testrunner/testa/tst_testa.cpp(26)]
PASS : TestA::cleanupTestCase()
Totals: 3 passed, 1 failed, 0 skipped
********* Finished testing of TestA *********
********* Start testing of TestB *********
Config: Using QTest library 4.7.2, Qt 4.7.2
PASS : TestB::initTestCase()
PASS : TestB::complex()
PASS : TestB::cleanupTestCase()
Totals: 3 passed, 0 failed, 0 skipped
********* Finished testing of TestB *********
FAIL! : Can not start "../testc/tst_testc"
Totals: 6 passed, 2 failed, 0 skipped
********* Finished testing *********
The TestRunner is a C++ class with only very simple interface to execute the binary built with QTestLib , but it will save your time for running all the test program developed.  

The code is licensed under new BSD.(Well.. It is almost meaningless as I don't think you will bundle the class with your binary application)

The source code and example can be found at GitHub:

https://github.com/benlau/testrunner

Sunday, March 20, 2011

Qt Keyring

My Qt keyring ;)


Monday, October 4, 2010

DQuest , ORM framework for Qt/Sqlite

I have made a new OSS project for Qt and mobile. It is DQuest , a C++ ORM (Object-relational mapping) for Qt framework. It aims to provide a rapid development environment for application with database access. The database model declaration is very simple , just like other C++/Qt class. It is designed for mobile environment but also useful for desktop and embedded application that do not demand for maximized performance for database.

It is getting more number of application use Sqlite for their data storage. However, writing data model in SQL is complicated . Usually it need to write two set of interface : One for C/C++ and other for Sql. The work load is duplicated, and debug is troublesome.


With DQuest, you can declare a database model using C++ directly. Read / write access can be made through the C++ interface. You won't need to wbrite any SQL to gain the benefit of using Sqlite in your application.

To declare your database model, you need to:
  • Create a class that inherits DQModel
  • Added a DQ_MODEL macro to the class declaration
  • Design your database field by using DQField template type
  • Register your model with DQ_DECLARE_MODEL macro function.

Remarks: DQModel is not QObject based, (QObject is rarely used in DQuest) , therefore you don't need to write setter/getter for each database field.

Features
  • Database model declaration and registration is simple.
    • Declare model in C++/Qt way (p.s QObject is not used)
    • o Support model inheritance
    • o Foreign key - auto load entry
  • Supported operations : create table , drop table , select , delete , insert , query the existence of table , ...
  • Support Sqlite - usable on mobile platform
  • Open source (New BSD license)

    Pending features
    • Multiple database access
      • The software design support to access multiple database , but it is not tested.
    • Multi-threading
      • The software design support multi-threading , but it is not tested.

    Limitations
    • DQuest is still in alpha stage. Use at your own risk.
    • Not all SQL statement and options are implemented , most of them can be added upon on user request. Please join the mailing list.
    • Not implemented operations : create trigger , create index
    • Not supported operations : join select
    Licensing

    DQuest source code is licensed under BSD license. You may use it for open source and closed source application , you just need to obey the requirement of BSD (e.g distribute the license agreement). Moreover, if you can inform us that your application is using DQuest. It can encourage developer to further develop the software.


    Project Page:
    http://code.google.com/p/d-quest/


    Mailing list:
    http://groups.google.com/group/dquest-dev


    API Document
    http://d-quest.googlecode.com/svn/trunk/docs/annotated.html



    Motivation:

    When I develop the 0.1 version of PenPen Sketchbook , the prototype of drawing interface only spend me few hours , and a working code is completed within two night. However, when I make the sqlite code , it a much longer time to develolop in compare with the drawing function. 60% of time spent on database code totally. I think it is non-sense for such a tiny project. Therefore , that inspired me to develop a C++ ORM for Qt and sqlite.

    Wednesday, August 12, 2009

    Moblin Image Creator for Ubuntu 9.04

    Although MIC1 is deprecated and replaced by MIC2, I think it is still the best Ubuntu image customization tool. It is pity to throw it away. I would like to resume the development and extend it to build image for latest Ubuntu version like 9.04 . The first prototype is ready. It could build image for Ubuntu 9.04. The source code is available in my github account.


    Reference:

    Sponsor