DumontEXE 0.0.1
cmcDatabase.h
00001 /* ***************************************************************************
00002 **
00003 ** Copyright (C) 2007 Lorimark Solutions, LLC. All rights reserved.
00004 **
00005 ** This file is part of the DumontEXE Scripting Extension Kit
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://dumont.showoff-db.org/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://dumont.showoff-db.org/licensing.html 
00017 ** or contact the sales department at sales@lorimarksolutions.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ** author: Mark Petryk ~ Lorimark Solutions, LLC
00023 ** **************************************************************************/
00024 
00025 #ifndef CDA_DATABASE_H_422FD07F_0597_4cbb_A034_9AE85166472E
00026 #define CDA_DATABASE_H_422FD07F_0597_4cbb_A034_9AE85166472E
00027 
00028 #include <QString>
00029 #include <QPointer>
00030 
00031 #include "cmcApi.h"
00032 #include "cmcCursor.h"
00033 #include "cmcCursors.h"
00034 #include "cmcForm.h"
00035 #include "cmcForms.h"
00036 #include "cmcMeInfo.h"
00037 #include "cmcItem.h"
00038 #include "cmcItems.h"
00039 
00040 namespace cmcDatabaseApi {
00041 
00042 class cmcForms;
00043 class cmcForm;
00044 class cmcItem;
00045 
00046 /*!
00047 ** \brief Commence Database Object
00048 **
00049 ** \todo Item Models
00050 ** The Database object should provide data models compatible with the Qt framework
00051 **  instead of requiring that all data access is performed through the cursors
00052 **  and rowsets.  This would allow programmers to to use the Qt user interface 
00053 **  controls as activex components in their applications, as well as simplify the
00054 **  whole data interface.
00055 **
00056 */
00057 class cmcDatabase:
00058   public cmcApi
00059 {
00060   Q_OBJECT
00061   Q_CLASSINFO( "explorer", "yes" )
00062   Q_CLASSINFO( "stored",   "no"  )
00063   public:
00064 
00065     cmcDatabase( const cmcDatabase & copy );
00066 
00067     cmcDatabase( IDispatch * iDispatch, cmcApplication * application );
00068 
00069     virtual ~cmcDatabase();
00070 
00071   public slots:
00072 
00073     /*!
00074     ** \brief Name of the Commence database \n
00075     **
00076     */
00077     virtual QString name();
00078 
00079     /*!
00080     ** \brief Full path of the Commence database \n
00081     **
00082     */
00083     virtual QString path();
00084 
00085     /*!
00086     ** \brief CR/LF delimited string with user name, company name and serial number \n
00087     **
00088     */
00089     virtual QString registeredUser();
00090 
00091     /*!
00092     ** \brief TRUE if database is enrolled in a workgroup \n
00093     **
00094     */
00095     virtual bool shared();
00096 
00097     /*!
00098     ** \brief Version number in x.y format \n
00099     **
00100     */
00101     virtual QString version();
00102 
00103     /*!
00104     ** \brief Version number in x.y.z.w format \n
00105     **
00106     */
00107     virtual QString versionExt();
00108 
00109     /*!
00110     ** \brief Create a conversation object \n
00111     **
00112     */
00113     virtual cmcConversation * getConversation
00114     (
00115       const QString & applicationName = "",
00116       const QString & topic = ""
00117     );
00118 
00119     /*!
00120     ** \brief Get a Cursor Object \n
00121     **
00122     ** This is the original version of the Get Cursor function.  This function
00123     **  accepts the cursor mode just like the original Commence version.  The 
00124     **  flags parameter is not required.
00125     **
00126     ** \par vbScript Example ~ original (code compatible) method of opening a cursor
00127     ** \code
00128     ** dim dexe: set dexe = createObject("Dumont.EXE") ' hook dumont
00129     ** dim dapp: set dapp = dexe.applications("MyDB")  ' fetch an app from the R.O.T.
00130     **
00131     ** '
00132     ** ' get a cursor the 'old fashioned' way.  Specify the 'mode' and 'flags'
00133     ** '
00134     ** dim cursor: set cursor = dapp.db.getCursor(0,"Person",0)
00135     ** \endcode
00136     **
00137     ** \sa \ref getCursor(const QString &,long) "getCursor( simplified )"
00138     ** \sa \ref cmcCursor::CURSOR_MODES "Cursor Modes"
00139     ** 
00140     ** \return cmcCursor object
00141     */
00142     virtual cmcCursor * getCursor
00143     (
00144       /*! long ~ see: \ref cmcCursor::CURSOR_MODES "Cursor Modes" \n\n */
00145       long mode,
00146 
00147       /*! String ~ must be an existing category name \n\n */
00148       const QString & name,
00149 
00150       /*! long ~ defaults to 0 \n\n */
00151       long flags = 0 // + 256 //+ 512
00152     );
00153 
00154     /*!
00155     ** \brief <b>extended:</b> Get a Cursor Object \n
00156     **
00157     ** This is a simplified version of the Get Cursor function.  This function
00158     **  assumes a cursor 'mode' zero, which opens a cursor on the category
00159     **  directly, and not on one of the views or pilot categories.
00160     **
00161     ** \par vbScript Example ~ simplified method of opening a cursor
00162     ** \code
00163     ** dim dexe: set dexe = createObject("Dumont.EXE") ' hook dumont
00164     ** dim dapp: set dapp = dexe.applications("MyDB")  ' fetch an app from the R.O.T.
00165     **
00166     ** '
00167     ** ' get a cursor the easy way.  
00168     ** '
00169     ** dim cursor: set cursor = dapp.db.getCursor("Person")
00170     ** \endcode
00171     **
00172     ** \sa \ref getCursor(long,const QString &,long) "getCursor( original )"
00173     **
00174     ** \return cmcCursor object
00175     */
00176     virtual cmcCursor * getCursor
00177     (
00178       /*! String ~ must be an existing category name \n\n */
00179       const QString & name,
00180 
00181       /*! long ~ defaults to 0 \n\n */
00182       long flags = 0 // + 256 //+ 512
00183     );
00184 
00185     /*!
00186     ** \brief Get a Commence Item by Item Name \n
00187     **
00188     ** This will get an item from a category by item name.  In order for
00189     **  this procedure to work properly the item name referenced must
00190     **  be unique.  It does not matter if the category allows duplicates
00191     **  or not, just so long as the item name referenced can be found by
00192     **  its name property.
00193     **
00194     ** \return cmcItem
00195     */
00196     virtual cmcItem * getItem
00197     (
00198       /*! string ~ name of the category \n\n */
00199       const QString & categoryName,
00200 
00201       /*! string ~ Item Name Value (optional must be unique) \n\n */
00202       const QString & itemKey = "",
00203 
00204       /*! long ~ flags (default to zero) \n\n */
00205       long flags = 0
00206     );
00207 
00208     /*!
00209     ** \brief Get a Commence Item by Guid \n
00210     **
00211     */
00212     virtual cmcItem * getItemByGuid
00213     (
00214       /*! string ~ name of the category \n\n */
00215       const QString & categoryName,
00216 
00217       /*! string ~ guid value of the item \n\n */
00218       const QString & itemGuid,
00219 
00220       /*! long ~ flags (default to zero) \n\n */
00221       long flags = 0
00222     );
00223 
00224     /*!
00225     ** \brief Get a Commence Item by a Field Value \n
00226     **
00227     **
00228     */
00229     virtual cmcItem * getItemByField
00230     (
00231       /*! string ~ Category Name \n\n */
00232       const QString & categoryName,
00233 
00234       /*! string ~ Field Name \n\n */
00235       const QString & fieldName,
00236 
00237       /*! string ~ Qualifier (F,CTI,CTCTI...) \n\n */
00238       const QString & qualifier,
00239 
00240       /*! string ~ Value \n\n */
00241       const QString & value,
00242 
00243       /*! boolean ~ Not Flag \n\n */
00244       bool notFlag = false,
00245 
00246       /*! boolean ~ Case Sensitive \n\n */
00247       bool caseSensitive = false
00248     );
00249 
00250     /*!
00251     ** \brief Get a Commence items list \n
00252     **
00253     ** \note Be careful with this function call!  If you do not filter the
00254     **  set .or. apply some limited columns to it before querying any
00255     **  of the fields, you're going to end up crashing your db due to
00256     **  data overload ~ unless you have just a few items.
00257     **
00258     */
00259     virtual cmcItems * getItems
00260     (
00261       /*! string ~ Category Name \n\n */
00262       const QString & categoryName
00263     );
00264 
00265 
00266     /*!
00267     ** \brief Return the Forms collection \n
00268     **
00269     **
00270     */
00271     virtual cmcForms * forms();
00272 
00273     /*!
00274     ** \brief Return a Form by Index \n
00275     **
00276     **
00277     */
00278     virtual cmcForm * form
00279     (
00280       long index
00281     );
00282 
00283     /*!
00284     ** \brief Return a Form by Index \n
00285     **
00286     **
00287     */
00288     virtual cmcForm * forms( long index )
00289     { return( form(index) ); }
00290 
00291     /*!
00292     ** \brief Return a Form by Name \n
00293     **
00294     **
00295     */
00296     virtual cmcForm * form
00297     ( 
00298       const QString & name 
00299     );
00300 
00301     /*!
00302     ** \brief Return a Form by Name \n
00303     **
00304     **
00305     */
00306     virtual cmcForm * forms( const QString & name )
00307     { return( form(name) ); }
00308 
00309     /*!
00310     ** \brief Return Previous Form \n
00311     **
00312     ** Return a handle on the form that was opened just prior to this
00313     **  form.
00314     **
00315     ** \par vbScript Example ~ Access Previous Form
00316     ** \code
00317     ** dim dexe: set dexe = createObject("Dumont.EXE")
00318     ** dim dfrm: set dfrm = dexe.form(Form)
00319     **
00320     ** dim pfrm: set pfrm = dfrm.db.previousForm
00321     **
00322     ** if( not pfrm is nothing ) then
00323     **
00324     **   dexe.debug "itemName: " & pfrm.itemName
00325     **   dexe.debug "keyField: " & pfrm.keyField.value
00326     **
00327     ** end if
00328     ** \endcode
00329     **
00330     ** \note In order for this function to work properly, two forms must be 
00331     **  opened.  If there is only one form opened, then this function will
00332     **  return a NULL object.
00333     **
00334     */
00335     virtual cmcForm * previousForm();
00336 
00337     virtual cmcCursors * cursors()
00338     {
00339       if( !m_cursors )
00340            m_cursors = new cmcCursors(app());
00341 
00342       return( m_cursors );
00343     }
00344 
00345     /*!
00346     ** \brief Get Last ID
00347     **
00348     ** This will fetch the last ID number used on a category.
00349     **  It is based upon the assumption that the field is sortable
00350     **  and will sort in the negative which will put the last ID
00351     **  string used as the first record in the set.
00352     **
00353     */
00354     virtual QString getLastID
00355     (
00356       const QString & category,
00357       const QString & field,
00358       const QString & filter = ""
00359     );
00360 
00361 
00362     /*!
00363     ** \brief Me Info \n
00364     **
00365     **
00366     */
00367     virtual cmcMeInfo * meInfo();
00368 
00369   signals:
00370 
00371   protected:
00372 
00373   private:
00374 
00375     QPointer<cmcConversation> m_conversation;
00376 
00377     QPointer<cmcForms> m_forms;
00378 
00379     QPointer<cmcCursors> m_cursors;
00380 
00381     QPointer<cmcMeInfo> m_meInfo;
00382 
00383 }; // endclass cmcDatabase
00384 
00385 } // namespace cmcDatabaseApi
00386 
00387 #endif // #ifndef CDA_DATABASE_H
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties




~ ~ ~ ~ ~ ~
Source Code without Comments is like a Cranberry Garland
without the berries. Comment your Code!
 
Commence Database User Support Group Forum
http://newsgroup.showoff-db.org/
~ ~ ~ ~ ~ ~
Author: Mark Petryk
Lorimark Solutions, LLC
mark@lorimarksolutions.com