home *** CD-ROM | disk | FTP | other *** search
- #ifdef COMP_BCB
- // BORLAND C++ BUILDER INCLUDES
- #include <condefs.h>
- #else
- #define USELIB( arg )
- #endif
-
-
- //---------------------------------------------------------------------------
- // ORIENT DIRECT INCLUDE HEADER
- #include "ojust.h"
- //---------------------------------------------------------------------------
- // ORIENT HEADERS FOR SCHEMA CREATION
- #include "oLibrary.h"
- #include "oOrient.h"
- #include "oInterfaceManager.h"
- #include "oClass.h"
- #include "oMember.h"
- //---------------------------------------------------------------------------
- #include <stdio.h>
- //---------------------------------------------------------------------------
- // BORLAND C++ BUILDER DIRECTIVES
- USELIB("..\..\..\lib\win32\bcb\ojust.lib");
-
-
-
- bool registerUserClasses();
-
- //---------------------------------------------------------------------------
- int main(int argc, char* argv[])
- {
- // REGISTER USER CLASSES
- registerUserClasses();
-
- // START TRY/CATCH BLOCK FOR EXCEPTIONS CATCHING
- try
- {
- d_Database db;
- d_Project proj;
-
- // CREATE DATABASE
- db.create( proj, "database/business", 10000000, 1000000, 5000000, 500000 );
- }
- catch( d_Error &e )
- {
- // DATABASE ERROR
- cout << "Database error: " << e.what() << endl;
- }
- catch( ... )
- {
- // APPLICATION ERROR
- cout << "Generic error" << endl;
- }
-
- return 0;
- }
-
-
-
- bool registerUserClasses()
- {
- // REGISTER PERSONA CLASS
- oClass * clsPerson;
-
- clsPerson = new oClass( "Person" );
- clsPerson->makePersistent();
- clsPerson->addProperty( "name", oMember::D_STRING, oMember::PERSISTENT );
- clsPerson->addProperty( "surname", oMember::D_STRING, oMember::PERSISTENT );
- clsPerson->addProperty( "age", oMember::D_SHORT, oMember::PERSISTENT );
- oInterfaceManager::registerInterface( "business", clsPerson );
-
- // REGISTER CLIENTE CLASS
- oClass * clsCustomer;
-
- clsCustomer = new oClass( "Customer" );
- clsCustomer->addBase( clsPerson );
- clsCustomer->addProperty( "code", oMember::D_ULONG, oMember::PERSISTENT );
- clsCustomer->addProperty( "notes", oMember::D_STRING, oMember::PERSISTENT );
- clsCustomer->addMethod( "display", 0 );
- oInterfaceManager::registerInterface( "business", clsCustomer );
-
- // REGISTER MERCE CLASS
- oClass * clsProduct;
-
- clsProduct = new oClass( "Product" );
- clsProduct->makePersistent();
- clsProduct->addProperty( "name", oMember::D_STRING, oMember::PERSISTENT );
- clsProduct->addProperty( "price", oMember::D_LONG, oMember::PERSISTENT );
- oInterfaceManager::registerInterface( "business", clsProduct );
-
- // REGISTER FATTURA CLASS
- oClass * clsInvoice;
-
- clsInvoice = new oClass( "Invoice" );
- clsInvoice->makePersistent();
- clsInvoice->addProperty( "number", oMember::D_LONG, oMember::PERSISTENT );
- clsInvoice->addProperty( "ownCustomer", oMember::D_REF, oMember::PERSISTENT, "business::Customer" );
- clsInvoice->addProperty( "products", oMember::EMBEDDED, oMember::PERSISTENT, "System::d_Varray" );
- oInterfaceManager::registerInterface( "business", clsInvoice );
-
- return true;
- }
-
-
-