00001 /**************************************************************************** 00002 00003 This file is part of the GLC-lib library. 00004 Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net) 00005 Version 2.0.0 Beta 1, packaged on April 2010. 00006 00007 http://glc-lib.sourceforge.net 00008 00009 GLC-lib is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 2 of the License, or 00012 (at your option) any later version. 00013 00014 GLC-lib is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with GLC-lib; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 00023 *****************************************************************************/ 00024 00026 00027 #include "glc_global.h" 00028 00029 QMutex glc::iDMutex; 00030 QMutex glc::geomIdMutex; 00031 QMutex glc::userIdMutex; 00032 QMutex glc::widget3dIdMutex; 00033 00034 GLC_uint glc::GLC_GenID(void) 00035 { 00036 static GLC_uint Id= 0; 00037 glc::iDMutex.lock(); 00038 Id++; 00039 glc::iDMutex.unlock(); 00040 return Id; 00041 } 00042 00043 GLC_uint glc::GLC_GenGeomID(void) 00044 { 00045 static GLC_uint Id= 0; 00046 glc::geomIdMutex.lock(); 00047 Id++; 00048 glc::geomIdMutex.unlock(); 00049 return Id; 00050 } 00051 00052 GLC_uint glc::GLC_GenUserID(void) 00053 { 00054 static GLC_uint Id= 0; 00055 glc::userIdMutex.lock(); 00056 Id++; 00057 glc::userIdMutex.unlock(); 00058 return Id; 00059 } 00060 00061 GLC_uint glc::GLC_Gen3DWidgetID(void) 00062 { 00063 static GLC_uint Id= 0; 00064 glc::widget3dIdMutex.lock(); 00065 Id++; 00066 glc::widget3dIdMutex.unlock(); 00067 return Id; 00068 } 00069 00070 const QString glc::archivePrefix() 00071 { 00072 return "glc_Zip::"; 00073 } 00074 00075 const QString glc::archiveInfix() 00076 { 00077 return "::glc_Zip::"; 00078 } 00079 00080 bool glc::isArchiveString(const QString& fileName) 00081 { 00082 bool inArchive= fileName.startsWith(archivePrefix()); 00083 inArchive= inArchive && fileName.contains(archiveInfix()); 00084 return inArchive; 00085 } 00086 00087 QString glc::builtArchiveString(const QString& Archive, const QString& entry) 00088 { 00089 return QString(archivePrefix() + Archive + archiveInfix() + entry); 00090 } 00091 00092 QString glc::archiveFileName(const QString& archiveString) 00093 { 00094 Q_ASSERT(isArchiveString(archiveString)); 00095 const int indexOfInfix= archiveString.indexOf(archiveInfix()); 00096 const int prefixLength= archivePrefix().length(); 00097 const int length= indexOfInfix - prefixLength; 00098 return archiveString.mid(prefixLength, length); 00099 } 00100 00101 QString glc::archiveEntryFileName(const QString& archiveString) 00102 { 00103 Q_ASSERT(isArchiveString(archiveString)); 00104 const int indexOfInfix= archiveString.indexOf(archiveInfix()); 00105 const int infixLength= archiveInfix().length(); 00106 const int length= archiveString.length() - (indexOfInfix + infixLength); 00107 return archiveString.right(length); 00108 } 00109