DumontEXE 0.0.1
cmcObject.cpp
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 #include <QVariant>
00026 #include <QMetaObject>
00027 #include <QMetaProperty>
00028 #include <QString>
00029 #include <QUuid>
00030 #include <QDateTime>
00031 
00032 #include "../version.h"
00033 
00034 #include "cmcObject.h"
00035 #include "cmcApplication.h"
00036 #include "cmcApplications.h"
00037 #include "cmcDatabase.h"
00038 #include "cmcCdaItem.h"
00039 #include "cmcActiveViewInfo.h"
00040 
00041 namespace cmcDatabaseApi {
00042 
00043 const QString vbCr     = "\x0d";
00044 const QString vbLf     = "\x0a";
00045 const QString vbCrLf   = "\x0d\x0a";
00046 const QString vbLfCr   = "\x0a\x0d";
00047 const QString vbCrCr   = "\x0d\x0d";
00048 const QString vbLfLf   = "\x0a\x0a";
00049 const QString vbCrCrLf = "\x0d\x0d\x0a";
00050 
00051 cmcApplications cmcObject::s_applications;
00052 bool cmcObject::s_showWarnings;
00053 
00054 QString cmcObject::YesNo( bool i_bool )
00055 {
00056   return( i_bool? "Yes":"No" );
00057 }
00058 
00059 bool cmcObject::isTrue( const QString & i_yesNo )
00060 {
00061   QString value = i_yesNo.left(1).toUpper();
00062 
00063   bool retVal = false;
00064 
00065   if( value == "Y" ) retVal = true;
00066   if( value == "1" ) retVal = true;
00067   if( value == "T" ) retVal = true;
00068 
00069   return( retVal );
00070 }
00071 
00072 bool cmcObject::isFalse( const QString & i_yesNo )
00073 {
00074   return( !isTrue(i_yesNo) );
00075 }
00076 
00077 QString cmcObject::dq( const QString & in )
00078 {
00079   QString retVal = in;
00080   return( "\"" + retVal.replace("\"","\"\"") + "\"" );
00081 
00082 } // endQString cmcObject::dq( const QString & in )
00083 
00084 
00085 static unsigned char crc8Result;
00086 static void crc8( unsigned char dataByte )
00087 {
00088    /*
00089    ** This is a flag used in the calculation of the CRC.
00090    **
00091    */
00092    bool crcflg;
00093 
00094    /*
00095    ** Perform calculation on all 8 bits.
00096    **
00097    */
00098    unsigned char bits = 8;
00099 
00100    /*
00101    ** loop through each bit individually
00102    **
00103    */
00104    while( bits-- )
00105    {
00106       /*
00107       ** We'll want to know if the bit we're examining
00108       **  is set or not.
00109       **
00110       */
00111       crcflg = (dataByte ^ crc8Result) & 1;
00112 
00113       /*
00114       ** Shift all the bits over.
00115       **
00116       */
00117       crc8Result >>= 1;
00118       dataByte   >>= 1;
00119 
00120       /*
00121       ** If the bit was set (earlier) then we need to
00122       **  apply the polynomial.
00123       **
00124       */
00125       if( crcflg != 0 )
00126          crc8Result ^= 0x8c;
00127 
00128    } // endwhile( bits-- )
00129 
00130 //   qDebug( QString( QString("crc8 ") + QString::number(dataByte) + " " + QString::number(crc8Result) ).toAscii() );
00131 
00132 }
00133 
00134 
00135 QString cmcObject::crc8String( const QString & in )
00136 {
00137   crc8Result = 0;
00138   int x = 0;
00139   while( x < in.length() )
00140   {
00141     crc8( in.at(x).toAscii() );
00142     x++;
00143   }
00144 
00145 //  qDebug( QString( QString("crc calculated ") + QString::number(crc8Result) ).toAscii() );
00146 
00147   return( prependZero( QString::number(crc8Result), 3 ) );
00148 }
00149 
00150 QString cmcObject::pad
00151 (
00152   const QString & string,
00153   const QString & padString,
00154   long length
00155 )
00156 {
00157   QString retVal = string;
00158 
00159   while( retVal.length() < length )
00160          retVal += padString;
00161 
00162   return( retVal );
00163 }
00164 
00165 
00166 QString cmcObject::appendString
00167 (
00168   const QString & initial,
00169   const QString & appendValue,
00170   const QString & separator
00171 )
00172 {
00173   QString retVal = initial;
00174 
00175   if( initial != "" )
00176   {
00177     retVal += separator;
00178   }
00179 
00180   retVal += appendValue;
00181 
00182   return( retVal );
00183 }
00184 
00185 
00186 QString cmcObject::prepend( const QString & prep, const QString string, long count )
00187 {
00188   QString retVal = string;
00189 
00190   while( retVal.length() < count )
00191      retVal = prep + retVal;
00192 
00193   return( retVal );
00194 }
00195 
00196 QString cmcObject::prependZero( const QString & string, long count)
00197 {
00198   return( prepend( "0", string, count ) );
00199 }
00200 
00201 /**
00202  ** \brief Get a var Value
00203  **
00204  ** This pulls a varValue from a long string.  The string is assumed to have
00205  **  encoded \\r\\n (vbCrLf) characters seperating each line of varValue.  The
00206  **  varValue fields contains the format varName=varValue common in most
00207  **  .ini files.
00208  **
00209  */
00210 QString cmcObject::var( const QString & v_var, const QString & v_fld )
00211 {
00212   QString retVal;
00213   QStringList s1 = v_var.split("\r\n").filter(v_fld+"=");
00214   if( s1.count() == 1 ) 
00215     retVal = s1[0].right(s1[0].length()-s1[0].indexOf("=")-1);
00216 
00217   retVal = retVal.replace("{CR}","\r").replace("{LF}","\n");
00218   return retVal;
00219 }
00220 
00221 /**
00222  ** \brief Set a var value
00223  **
00224  ** This sets a varValue in a long string.  The string will be coded with
00225  **  \\r\\n (vbCrLf) characters seperating each line of varValue.  The
00226  **  varValue fields contains the format varName=varValue common in most
00227  **  .ini files.
00228  **
00229  **
00230  */
00231 QString cmcObject::var( const QString & v_var, const QString & v_fld, const QString & v_val )
00232 {
00233   QString newVal = v_fld + "=" + v_val;
00234   newVal = newVal.replace("\r","{CR}").replace("\n","{LF}");
00235   QString retVal = v_var;
00236   if( retVal.contains(v_fld+"=") )
00237     retVal.replace( v_fld + "=" + var(retVal,v_fld), newVal );
00238   else
00239     if( retVal.length() )
00240       retVal.append("\r\n" + newVal);
00241     else
00242       retVal.append(newVal);
00243   retVal.replace( "\r\n\r\n", "\r\n" );
00244   return( retVal );
00245 }
00246 
00247 
00248 /**
00249  ** \brief Delete a var
00250  **
00251  ** This removes a varValue from a long string.  In some cases it is 
00252  **  preferrable to remove any reference to the varValue, and setting
00253  **  the value to "" results in a "varName=" field remaining in the
00254  **  varString.
00255  **
00256  */
00257 QString cmcObject::delVar( const QString & v_var, const QString & v_fld )
00258 {
00259   QString retVal = v_var;
00260 
00261   if( retVal.contains(v_fld+"=") )
00262   {
00263     retVal.replace( v_fld + "=" + var(v_var,v_fld), "" );
00264     retVal.replace( "\r\n\r\n", "\r\n" );
00265   }
00266   return retVal;
00267 }
00268 
00269 /*!
00270 ** \brief Pack the Date//Time
00271 **
00272 ** This converts a QDateTime value into a packed field with no 
00273 **  punctuation.  This is intended for TimeDate stamping in
00274 **  category row items, and the punctuation is removed to reduce
00275 **  the possibility of processing errors and to standardize the 
00276 **  format across system-wide regional time/date formatting 
00277 **  settings.
00278 **
00279 ** \retval QString Packed DateTime value
00280 **
00281 ** \code The format for the field is: 
00282 **  YYYYMMDDHHNNSS
00283 **  +---+-+-+-+-+-
00284 **  |   | | | | |
00285 **  |   | | | | +-- seconds (prepend zero)
00286 **  |   | | | +---- minute (prepend zero)
00287 **  |   | | +------ hour (prepend zero)
00288 **  |   | +-------- day of month (prepend zero)
00289 **  |   +---------- month (prepend zero)
00290 **  +-------------- full (4 digit) year
00291 **  \endcode
00292 */
00293 QString cmcObject::packDate
00294 (
00295   /*! date ~ date in */
00296   const QDate & date
00297 )
00298 {
00299   return( date.toString("yyyyMMdd") );
00300 }
00301 
00302 QString cmcObject::packTime(const QTime & i_time)
00303 {
00304   return( i_time.toString("hhmmss") );
00305 }
00306 
00307 QString cmcObject::packDateTime(const QDateTime & i_dateTime)
00308 {
00309   return
00310   ( 
00311     packDate(i_dateTime.date()) +
00312     packTime(i_dateTime.time()) 
00313   );
00314 }
00315 
00316 QString cmcObject::packDateTime(const QDate & i_date, const QTime & i_time)
00317 {
00318   return
00319   (
00320     packDate(i_date) +
00321     packTime(i_time)
00322   );
00323 }  
00324 
00325                                                                       // 01234567890123
00326 QString cmcObject::unpackDateTime( const QString & i_packedDateTime ) // 20070405101213
00327 {
00328   QString retVal;
00329   if( i_packedDateTime.length() == 14 )
00330   {
00331     retVal = 
00332       i_packedDateTime.mid(  4,2 ) + "/" +
00333       i_packedDateTime.mid(  6,2 ) + "/" +
00334       i_packedDateTime.mid(  0,4 ) + " " +
00335       i_packedDateTime.mid(  8,2 ) + ":" +
00336       i_packedDateTime.mid( 10,2 ) + ":" +
00337       i_packedDateTime.mid( 12,2 );
00338   }
00339   return( retVal );
00340 }  
00341 
00342 
00343 QString cmcObject::formatText( const QString & i_preText, const QString & i_text, const QString & i_postText )
00344 {
00345   return( i_preText + i_text + i_postText );
00346 }
00347 
00348 static bool m_phoneTooShort;
00349 
00350 QString cmcObject::fixCase( const QString & i_value )
00351 {
00352   QString o_value;
00353   QChar   pc;
00354   o_value.append( i_value.at(0).toUpper() );
00355   for( int i = 1; i<i_value.length(); i++ )
00356   {
00357     if( QString(" .,;:'\"\\/[]{}`~!@#$%^&*()-_=+").indexOf(pc) != -1 )
00358       o_value.append( i_value.at(i).toUpper() );
00359     else
00360       o_value.append( i_value.at(i).toLower() );
00361     pc = i_value.at(i);
00362   }
00363 
00364   return( o_value );
00365 }
00366 
00367 QString cmcObject::fixPhone( const QString & i_value )
00368 {
00369   m_phoneTooShort = false;
00370 
00371   /*
00372   ** The following is a list of reasons why we should quit.
00373   **
00374   */
00375   if( i_value.left(1)  == "0" ) return( i_value ); // international
00376   if( i_value.left(1)  == "+" ) return( i_value ); // international
00377   if( i_value.length() ==  0  ) return( i_value ); // empty
00378 
00379   /*
00380   ** Loop through each character and reformat it as a proper
00381   **  phone number.
00382   **
00383   */
00384   QChar c;
00385   QString z;
00386   int i; for( i=0; i<i_value.length(); i++ )
00387   {
00388     c = i_value.at(i);
00389     if( c.isNumber() )
00390       z.append(c);
00391     if( z.length() == 1 && z == "1" ) z = "";
00392     if( z.length() == 10            ) break;
00393   }
00394 
00395   /*
00396   ** Log this as a potential error.
00397   **
00398   */
00399   if( z.length() > 0 && z.length() < 10 ) m_phoneTooShort = true;
00400 
00401   /*
00402   ** Get any remaining characters following the phone number
00403   **
00404   */
00405   if( ++i < i_value.length() )
00406     z.append( i_value.right( i_value.length() - i ) );
00407 
00408   /*
00409   ** Add back in dash seperators
00410   **
00411   */
00412   if( z.length() > 6 )
00413     z = z.left(3) + "-" + z.mid(3,3) + "-" + z.right(z.length()-6);
00414 
00415   /*
00416   ** Return the fixed-up number only if there are at least 12 characters.
00417   **  If we could not find at least 12 characters then the safest thing
00418   **  to do is just drop the processing.
00419   **
00420   */
00421   QString retVal;
00422   if( z.length() >= 12 ) retVal = z;
00423 
00424   return( retVal );
00425 }
00426 
00427 bool cmcObject::phoneTooShort()
00428 {
00429   return( m_phoneTooShort );
00430 }
00431 
00432 
00433 
00434 
00435 
00436 
00437 // -----------------------------------------------------------------------
00438 /**
00439  ** \brief Run-time trace depth
00440  **
00441  ** The TraceDepth represents the run-time module depth as the 
00442  **  application is running.  Various modules can increment the 
00443  **  m_traceDepth at their discretion, and then should decrement the 
00444  **  m_traceDepth at the end of their process path.  The Trace Depth is 
00445  **  compared against the requested TraceLevel (m_traceLevel), and if the 
00446  **  requested trace level is greater than the current depth, a message 
00447  **  is displayed.
00448  **
00449  */
00450 int m_tracDepth = 0;
00451 
00452 /**
00453  ** \brief Requested Trace Level (higher value == more messages)
00454  **
00455  ** The TraceLevel is the requested trace level. This is initialized to 
00456  **  zero, indicating no trace is requested.  As the application runs, 
00457  **  the m_traceDepth is incremented.  If the m_traceLevel is higher then
00458  **  the current depth, then debug messages are sent to the appropriate
00459  **  console terminal.
00460  **
00461  */
00462 int m_tracLevel = 0;
00463 
00464 #ifdef NEVER
00465 /**
00466  ** \brief Message Output Window
00467  **
00468  ** This is some form of a textEdit window.  It needs to be set up by
00469  **  the hosting application in order to get messages to appear on it.
00470  **  If it's left NULL then no trac messages will be developed, formatted
00471  **  or sent.
00472  **
00473  */
00474 QTextEdit * m_tracWin = NULL;
00475 
00476 
00477 #ifdef _OUTPROC_SERVER_ 
00478 // We are building a local or remote server.
00479   // Listbox window handle
00480   extern HWND g_hWndListBox ;
00481 
00482   static inline void output(const char* sz)
00483   {
00484 //    ::SendMessage(g_hWndListBox, LB_ADDSTRING, 0, (LPARAM)sz) ;
00485     if( m_tracWin )
00486     {
00487       m_tracWin->append( sz );
00488     }
00489 //    else
00490 //    {
00491 //      printf( "%s\n", sz );
00492 //    }
00493   }
00494 
00495 #else
00496 // We are building an in-proc server.
00497 //#include <iostream.h>
00498   static inline void output(const char* sz)
00499   {
00500 //    cout << sz << endl ;
00501   }
00502 #endif //_OUTPROC_SERVER_
00503 
00504 /**
00505  ** \brief Format a message for the output window.
00506  **
00507  ** \param v_leader QString of message line prefix
00508  ** \param v_file QString of the file name
00509  ** \param v_line QString of the line number
00510  ** \param v_msg QString of the message to include
00511  **
00512  */
00513 void Trout( QString v_leader, QString v_file, QString v_line, QString v_msg )
00514 {
00515   if( !m_tracWin ) return;
00516   char buf[1024];
00517   sprintf
00518   (
00519     buf,
00520     "%-40s %4s:%d: %s %s%s",
00521     v_file.toAscii().data(),
00522     v_line.toAscii().data(),
00523     m_tracDepth,
00524     v_leader.toAscii().data(),
00525     QString(m_tracDepth,' ').toAscii().data(),
00526     v_msg.toAscii().data()
00527   );
00528   output( buf );
00529 }
00530 
00531 /**
00532  ** \brief Format a message with numeric line number for the output window.
00533  **
00534  ** \param v_leader Message line prefix
00535  ** \param v_file Source file name
00536  ** \param v_line Source Line number
00537  ** \param v_msg Message to include
00538  **
00539  ** This is a convenience function that accepts the __LINE__ macro as
00540  **  a parameter to the line number.  The line number is converted to a
00541  **  QString and control is passed to Trout(s,s,s,s);
00542  **
00543  */
00544 void Trout( QString v_leader, QString v_file, int v_line, QString v_msg )
00545 {
00546   if( !m_tracWin ) return;
00547   Trout( v_leader, v_file, QString::number(v_line), v_msg );
00548 }
00549 
00550 /**
00551  ** \brief TraceOn function - mark the beginning of a function.
00552  **
00553  ** \param v_file Source fileName being traced
00554  ** \param v_line Source LineNumber being traced
00555  ** \param v_msg Message to include
00556  **
00557  */
00558 void Trin( QString v_file, int v_line, QString v_msg )
00559 {
00560   if( !m_tracWin ) return;
00561   Trout( "->", v_file, v_line, v_msg );
00562   m_tracDepth++;
00563 }
00564 
00565 //
00566 // Print out a message with a label.
00567 //
00568 void Trac( QString v_file, int v_line, QString v_msg )
00569 {
00570   if( m_tracLevel < m_tracDepth ) return;
00571   if( !m_tracWin ) return;
00572   Trout( "--", v_file, v_line, v_msg );
00573 }
00574 
00575 void Trac( QString v_file, QString v_line, QString v_msg )
00576 {
00577   if( m_tracLevel < m_tracDepth ) return;
00578   if( !m_tracWin ) return;
00579   Trout( "--", v_file, v_line, v_msg );
00580 }
00581 
00582 void Trot( QString v_file, int v_line, QString v_msg )
00583 {
00584   if( !m_tracWin ) return;
00585   if( m_tracDepth ) m_tracDepth--;
00586   Trout( "<-", v_file, v_line, v_msg );
00587 }
00588 
00589 //
00590 // Print out the COM/OLE error string for an HRESULT.
00591 //
00592 void ErrorMessage( HRESULT hr )
00593 {
00594   void* pMsgBuf;
00595  
00596   ::FormatMessage( 
00597     FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
00598     NULL,
00599     hr,
00600     MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
00601     (LPTSTR)&pMsgBuf,
00602     0,
00603     NULL 
00604   );
00605 
00606   char buf[1024];
00607   sprintf( buf, "Error (%lx): %s", hr, (char*)pMsgBuf) ;
00608   output(  buf );
00609     
00610   // Free the buffer.
00611   LocalFree(pMsgBuf);
00612 
00613 }
00614 #endif
00615 
00616 QString cmcObject::vbString( const QString & i_string )
00617 {
00618   QString retVal = i_string;
00619   retVal = retVal.replace(vbLf,vbCrLf);
00620   retVal = retVal.replace(vbLfLf,vbLf);
00621   retVal = retVal.replace(vbCrCr,vbCr);
00622   return( retVal );
00623 }
00624 
00625 
00626 void cmcObject::dumpString( const QString & i_string )
00627 {
00628   for( int i=0; i<i_string.length(); i += 16 )
00629   {
00630     QString addLine = QString("%1:").arg( i, 4, 16, QChar('0') );
00631 
00632     QString hexLine = "";
00633     QString ascLine = "";
00634     for( int j=0; j<16; j++ )
00635     {
00636       if( i+j < i_string.length() )
00637       {
00638         hexLine += QString("%1 ").arg( i_string.at(i+j).toAscii(), 2, 16, QChar('0') );
00639 
00640         if( i_string.at(i+j).isPrint() )
00641           ascLine += QString("%1").arg(  i_string.at(i+j), 1 );
00642         else
00643           ascLine += ".";
00644       }
00645       else
00646       {
00647         hexLine += ".. ";
00648         ascLine += ".";
00649       }
00650     }
00651 
00652 
00653     qDebug( "%s %s %s", addLine.toAscii().data(), hexLine.toAscii().data(), ascLine.toAscii().data() );
00654   }
00655 }
00656 
00657 QString className( QObject * object )
00658 {
00659   return( QString(object-> metaObject()-> className()).split("::")[1] );
00660 }
00661 
00662 //const char * cn( const char * class )
00663 //{
00664 //  return( qPrintable(className(class)) );
00665 //  return NULL;
00666 //}
00667 
00668 
00669 QString dateTimeStamp(const QDateTime & dateTime, long length)
00670 {
00671   /*!
00672   ** \note The Length parameter is automatically limited to 0 - 17.
00673   */
00674   if( length < 0  ) length = 0;
00675   if( length > 17 ) length = 17;
00676 
00677   return( dateTime.toString("yyyyMMddhhmmsszzz").left(length) );
00678 }
00679 
00680 QString dateTimeStamp(long length)
00681 {
00682   return( dateTimeStamp( QDateTime::currentDateTime(), length ) );
00683 }
00684 
00685 QString dateTimeStamp( const QString & delimiter )
00686 {
00687   QString format = 
00688     "yyyy" + delimiter +
00689     "MM"   + delimiter +
00690     "dd"   + delimiter +
00691     "hh"   + delimiter + 
00692     "mm"   + delimiter +
00693     "ss"   + delimiter +
00694     "zzz";
00695 
00696   return( QDateTime::currentDateTime().toString(format) );
00697 }
00698 
00699 cmcObject::cmcObject( const cmcObject & copy ):
00700   QObject( copy.QObject::parent() )
00701 {
00702 }
00703 
00704 cmcObject::cmcObject( QObject * parent ):
00705   QObject( parent )
00706 {
00707   m_application = NULL;
00708 }
00709 
00710 cmcObject::cmcObject( const QString & i_objectName, cmcApplication * application, QObject * parent ):
00711   QObject(parent),
00712   m_application(application)
00713 {
00714   /*
00715   ** Initialize the document.
00716   **
00717   */
00718 //  m_domDocument = QDomDocument( className(this) );
00719 
00720   /*
00721   ** Set trace to nothing just to prevent problems.
00722   **
00723   */
00724   trace(0);
00725 
00726   /*
00727   ** Set the trace level to the level of the application.
00728   **
00729   */
00730   if( app() ) trace( app()-> trace() );
00731 
00732   /*
00733   ** Set the name before we do anything else.
00734   **
00735   */
00736   setObjectName(i_objectName);
00737 
00738   /*
00739   ** Set an instance ID for this object.  This allows this
00740   **  object to be referred to at any time by this ID value.
00741   **
00742   */
00743   m_instanceID = QUuid::createUuid();
00744 
00745 //  qDebug( "trace %ld", trace() );
00746 
00747 //  if( ((trace() & OBJECT_CREATE) == OBJECT_CREATE) &&
00748 //      ((trace() & TRACE_LEVEL)   >  0) )
00749 //    TRACE_FUNCTION
00750 
00751   m_avi = NULL;
00752 
00753 }
00754 
00755 cmcObject::~cmcObject()
00756 {
00757 //  if( ((trace() & OBJECT_CREATE) == OBJECT_CREATE) &&
00758 //      ((trace() & TRACE_LEVEL)   >  0) )
00759 //    TRACE_FUNCTION
00760 
00761 }
00762 
00763 cmcObject * cmcObject::parent()
00764 {
00765   return( qobject_cast<cmcObject*>(QObject::parent()) );
00766 }
00767 
00768 cmcApplication * cmcObject::app(void)
00769 {
00770   return( m_application );
00771 
00772 } // endcmcApplication * cmcObject::app(void)
00773 
00774 cmcApplication * cmcObject::application(void)
00775 {
00776   return( app() );
00777 
00778 } // endcmcApplication * cmcObject::app(void)
00779 
00780 void cmcObject::setApp( void * i_dispatch, const QString & dumontCategory )
00781 {
00782   m_application = new cmcApplication( (IDispatch*)i_dispatch, dumontCategory, this );
00783 
00784 } // endvoid cmcObject::setApp( void * i_dispatch )
00785 
00786 void cmcObject::setApp( cmcApplication * application )
00787 {
00788   m_application = application;
00789 }
00790 
00791 cmcDatabase * cmcObject::db(void)
00792 {
00793   cmcDatabase * retVal = NULL;
00794   if( app() ) retVal = app()-> database();
00795   return( retVal );
00796 
00797 } // endcmcDatabase * cmcObject::db(void)
00798 
00799 cmcConversation * cmcObject::cv(void)
00800 {
00801   cmcConversation * retVal = NULL;
00802   if( db() ) retVal = db()-> getConversation();
00803   return( retVal );
00804 
00805 } // endcmcConversation * cmcObject::cv(void)
00806 
00807 cmcCdaItem * cmcObject::cdaItem()
00808 {
00809      if( !m_cdaItem )
00810           m_cdaItem = parent()-> cdaItem()-> childItem( name() );
00811   return( m_cdaItem );
00812 }
00813 
00814 
00815 long cmcObject::index()
00816 {
00817   long retVal = -1;
00818 
00819   /*
00820   ** Fetch the parent as an objects collection.  If it casts, then we
00821   **  can use that to find our index.
00822   **
00823   */
00824   cmcObjects * objectsParent = qobject_cast<cmcObjects*>(parent());
00825 
00826   /*
00827   ** If the objects parent pointer is valid then this object is part
00828   **  of a collection.  We can use that to fetch our index as part
00829   **  of that collection.
00830   **
00831   */
00832   if( objectsParent )
00833   {
00834     retVal = objectsParent-> indexOf( objectName() );
00835   }
00836 
00837   /*
00838   ** Return the count, whatever it is.
00839   **
00840   */
00841   return( retVal );
00842 
00843 } // endlong cmcObject::index()
00844 
00845 QString cmcObject::instanceID()
00846 {
00847   return( m_instanceID );
00848 }
00849 
00850 QString cmcObject::name()
00851 {
00852   return( objectName() );
00853 
00854 } // endQString cmcObject::name()
00855 
00856 QString cmcObject::aliasName()
00857 {
00858   return( m_props["aliasName"].toString() );
00859 
00860 } // endQString cmcObject::aliasName()
00861 
00862 void cmcObject::setAliasName( const QString & value )
00863 {
00864   m_props["aliasName"] = value;
00865 
00866 } // endvoid cmcObject::setAliasName( const QString & value )
00867 
00868 QString cmcObject::comment(void)
00869 {
00870 //  return( cdaItem()-> itemData() );
00871 
00872   return( m_props["comment"].toString() );
00873 
00874 } // endQString cmcObject::comment(void)
00875 
00876 void cmcObject::setComment( const QString & value )
00877 {
00878 //  cdaItem()-> setItemData( value );
00879 
00880   m_props["comment"] = value;
00881 
00882 } // endvoid cmcObject::setComment( const QString & value )
00883 
00884 QString cmcObject::description(void)
00885 {
00886   return( m_props["description"].toString() );
00887 
00888 } // endQString cmcObject::description(void)
00889 
00890 void cmcObject::setDescription( const QString & value )
00891 {
00892   m_props["description"] = value;
00893 
00894 } // endvoid cmcObject::setDescription( const QString & value )
00895 
00896 QString cmcObject::documentation(void)
00897 {
00898   return( m_props["documentation"].toString() );
00899 
00900 } // endQString cmcObject::documentation(void)
00901 
00902 void cmcObject::setDocumentation( const QString & value )
00903 {
00904   m_props["documentation"] = value;
00905 
00906 } // endvoid cmcObject::setDocumentation( const QString & value )
00907 
00908 QString cmcObject::guid()
00909 {
00910   QString retVal = m_props["guid"].toString();
00911 
00912   if( retVal == "" )
00913   {
00914     retVal = QUuid::createUuid().toString();
00915     setGuid( retVal );
00916   }
00917 
00918   return( retVal );
00919 
00920 } // endQString cmcObject::guid()
00921 
00922 void cmcObject::setGuid( const QString & newGuid )
00923 {
00924   m_props["guid"] = newGuid;
00925 
00926 } // endvoid cmcObject::setGuid( const QString & newGuid )
00927 
00928 
00929 
00930 QVariant cmcObject::property( const QString & key, const QVariant & defaultValue )
00931 {
00932   if( !m_props.contains(key) )
00933   {
00934     m_props[key] = defaultValue;
00935   }
00936 
00937   return( m_props[key] );
00938 
00939 }
00940 
00941 QVariant cmcObject::property( const char * key, const char * defaultValue )
00942 {
00943   return( property( QString(key), QVariant(defaultValue) ) );
00944 }
00945 
00946 
00947 bool cmcObject::setProperty( const QString & key, const QVariant & value )
00948 {
00949   m_props[key] = value;
00950   return( true );
00951 }
00952 
00953 bool cmcObject::setProperty( const QString & key, const QString  & value )
00954 {
00955   return( setProperty( key, QVariant(value) ) );
00956 }
00957 
00958 
00959 long cmcObject::propertyCount()
00960 {
00961   return( m_props.count() + metaObject()-> propertyCount() );
00962 }
00963 
00964 QString cmcObject::propertyKey( const long index )
00965 {
00966   if( index < metaObject()-> propertyCount() )
00967     return( metaObject()-> property(index).name() );
00968 
00969   return( m_props.keys().at(index - metaObject()-> propertyCount()) );
00970 }
00971 
00972 QVariant cmcObject::propertyValue( const long index )
00973 {
00974   if( index < metaObject()-> propertyCount() )
00975     return( metaObject()-> property(index).read(this).toString() );
00976 
00977   return( m_props[propertyKey(index)] );
00978 
00979 }
00980 
00981 
00982 
00983 QString cmcObject::temp( const QString & i_key )
00984 {
00985   return( m_temp[i_key] );
00986 
00987 } // endQString cmcObject::temp( const QString & i_key )
00988 
00989 void cmcObject::setTemp( const QString & i_key, const QString & i_value )
00990 {
00991   m_temp[i_key] = i_value;
00992 
00993 } // endvoid cmcObject::setTemp( const QString & i_key, const QString & i_value )
00994 
00995 long cmcObject::tempCount(void)
00996 {
00997   return( m_temp.count() );
00998 
00999 } // endlong cmcObject::tempCount(void)
01000 
01001 QString cmcObject::tempKey( const long i_index )
01002 {
01003   return( m_temp.keys().at(i_index) );
01004 
01005 } // endQString cmcObject::tempKey( const long i_index )
01006 
01007 QString cmcObject::tempValue( const long i_index )
01008 {
01009   return( m_temp[tempKey(i_index)] );
01010 
01011 } // endQString cmcObject::tempValue( const long i_index )
01012 
01013 cmcError * cmcObject::error()
01014 {
01015   return( &err );
01016 
01017 } // endcmcError * cmcObject::error()
01018 
01019 QString cmcObject::dateTimeStamp( long length )
01020 {
01021   return( cmcDatabaseApi::dateTimeStamp(length) );
01022 }
01023 
01024 QString cmcObject::dateTimeStamp( const QDateTime & dateTime, long length )
01025 {
01026   return( cmcDatabaseApi::dateTimeStamp( dateTime, length ) );
01027 }
01028 
01029 void cmcObject::trace( long flags )
01030 {
01031   m_traceFlags = flags;
01032 }
01033 
01034 long cmcObject::trace()
01035 {
01036   return( m_traceFlags );
01037 }
01038 
01039 bool cmcObject::showWarnings()
01040 {
01041   return( s_showWarnings );
01042 }
01043 
01044 
01045 void cmcObject::showWarnings( bool setWarnings )
01046 {
01047   s_showWarnings = setWarnings;
01048 }
01049 
01050 
01051 
01052 
01053 cmcActiveViewInfo * cmcObject::avi()
01054 {
01055   if( !m_avi )
01056        m_avi = new cmcActiveViewInfo( app(), this );
01057 
01058   return( m_avi );
01059 }
01060 
01061 cmcStringList * cmcObject::getStringList( long flags )
01062 {
01063   return( new cmcStringList( flags ) );
01064 }
01065 
01066 } // endnamespace cmcDatabaseApi
01067 
01068 
01069 
 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