DumontEXE 0.0.1
cmcConnectionDefs.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 <QStringList>
00026 
00027 #include "cmcConnectionDefs.h"
00028 #include "cmcCategoryDef.h"
00029 #include "cmcApplication.h"
00030 #include "cmcDatabase.h"
00031 #include "cmcConversation.h"
00032 #include "cmcConnectionDef.h"
00033 
00034 namespace cmcDatabaseApi {
00035 
00036 cmcConnectionDefs::cmcConnectionDefs( const cmcConnectionDefs & copy ):
00037   cmcObjects( copy )
00038 {
00039 }
00040 
00041 cmcConnectionDefs::cmcConnectionDefs( cmcCategoryDef * i_categoryDef ):
00042   cmcObjects( "Connections", i_categoryDef-> app(), i_categoryDef )
00043 {
00044   setObjectName("Connections");
00045 
00046 //  TRACE_FUNCTION
00047 
00048   /*
00049   ** Get the connection names from the DDE
00050   **
00051   */
00052   QString names = cv()-> getConnectionNames( categoryName() );
00053 
00054   if( names.length() > 0 )
00055   {
00056     m_names = names.split("\r\n");
00057   }
00058 
00059 }
00060 
00061 cmcConnectionDefs::~cmcConnectionDefs()
00062 {
00063 //  TRACE_FUNCTION
00064 }
00065 
00066 bool cmcConnectionDefs::load()
00067 {
00068   TRACE_FUNCTION
00069 
00070   for( int i=0; i<m_names.count(); i++ )
00071     load( m_names[i] );
00072 
00073   return( true );
00074 }
00075 
00076 cmcObject * cmcConnectionDefs::load( const QString & conCatName )
00077 {
00078   return( new cmcConnectionDef( conCatName, this ) );
00079 }
00080 
00081 bool cmcConnectionDefs::save()
00082 {
00083   return( true );
00084 }
00085 
00086 long cmcConnectionDefs::count()
00087 {
00088 //  TRACE_FUNCTION
00089   return( m_names.count() );
00090 }
00091 
00092 bool cmcConnectionDefs::contains( const QString & conCatName )
00093 {
00094   /*
00095   ** First, search for this conCatConnection name via the base
00096   **  class.
00097   **
00098   */
00099   bool retVal = cmcObjects::contains( conCatName );
00100 
00101   /*
00102   ** If we were not able to find the name from the base
00103   **  class, then try searching via the original conCat name
00104   **  this is the ConCat name *without* the ' -> ' separator.
00105   **
00106   */
00107   if( !retVal )
00108   {
00109     retVal = m_names.join("\r\n").replace(" -> ", " ").contains(conCatName);
00110   }
00111 
00112   return( retVal );
00113 
00114 }
00115 
00116 cmcCategoryDef * cmcConnectionDefs::categoryDef()
00117 {
00118   return( qobject_cast<cmcCategoryDef*>(parent()) );
00119 }
00120 
00121 QString cmcConnectionDefs::categoryName()
00122 {
00123   return( categoryDef()-> categoryName() );
00124 }
00125 
00126 cmcConnectionDef * cmcConnectionDefs::get( const QString & conCatName )
00127 {
00128   cmcConnectionDef * retVal = qobject_cast<cmcConnectionDef*>(cmcObjects::get(conCatName));
00129 
00130   if( !retVal )
00131     retVal = new cmcConnectionDef( conCatName, this );
00132 
00133   return( retVal );
00134 }
00135 
00136 cmcConnectionDef * cmcConnectionDefs::get( const QString & conName, const QString & toCategory )
00137 {
00138   return( get( conName + CONCAT_DELIMITER + toCategory ) );
00139 }
00140 
00141 cmcConnectionDef * cmcConnectionDefs::get( long index )
00142 {
00143   return( get(m_names.at(index)) );
00144 }
00145 
00146 
00147 
00148 } // endnamespace cmcDatabaseApi
00149 
 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