File indexing completed on 2025-06-29 04:09:05
0001 /*************************************************************************** 0002 datacollection.cpp 0003 ------------------- 0004 begin : June 12, 2003 0005 copyright : (C) 2003 The University of Toronto 0006 email : netterfield@astro.utoronto.ca 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 #include "datacollection.h" 0018 0019 #include <config.h> 0020 0021 #include <stdlib.h> 0022 #include <qapplication.h> 0023 0024 #include "debug.h" 0025 #include "sysinfo.h" 0026 #include "psversion.h" 0027 0028 #ifdef Q_OS_WIN 0029 #include <windows.h> 0030 #endif 0031 0032 namespace Kst { 0033 0034 static QMutex bigLock; 0035 0036 0037 double Data::AvailableMemory() { 0038 double one_GB = 1024.0*1024.0*1024.0; 0039 double available_memory = 0; 0040 0041 #ifdef Q_OS_WIN 0042 // (http://msdn.microsoft.com/en-us/library/aa366589) 0043 MEMORYSTATUSEX statex; 0044 statex.dwLength = sizeof(statex); 0045 GlobalMemoryStatusEx(&statex); 0046 available_memory = statex.ullAvailPhys; 0047 #elif defined Q_OS_LINUX 0048 QMutexLocker ml(&bigLock); 0049 meminfo(); 0050 available_memory = double(S(kb_main_free + kb_main_cached)) - 30.0*1024.0*1024.0; // 30MB margin 0051 #else 0052 // TODO other OSs 0053 // or assume 32-bit on a big system 0054 available_memory = 4 * one_GB; 0055 #endif 0056 Debug::self()->log(QString("Available memory: %1 GB").arg(available_memory/one_GB)); 0057 return available_memory; 0058 } 0059 0060 Data *Data::_self = 0L; 0061 void Data::cleanup() { 0062 delete _self; 0063 _self = 0; 0064 } 0065 0066 0067 Data *Data::self() { 0068 Q_ASSERT(_self); 0069 return _self; 0070 } 0071 0072 0073 void Data::replaceSelf(Data *newInstance) { 0074 cleanup(); 0075 _self = newInstance; 0076 } 0077 0078 0079 Data::Data() { 0080 qAddPostRoutine(Data::cleanup); 0081 } 0082 0083 0084 Data::~Data() { 0085 } 0086 0087 0088 void Data::removeCurveFromPlots(Relation *c) { 0089 Q_UNUSED(c) 0090 // meaningless in no GUI: no plots! 0091 } 0092 0093 QList<PlotItemInterface*> Data::plotList() const { 0094 return QList<PlotItemInterface*>(); 0095 } 0096 0097 0098 int Data::rows() const { 0099 return -1; 0100 } 0101 0102 0103 int Data::columns() const { 0104 return -1; 0105 } 0106 0107 } 0108 0109 // vim: ts=2 sw=2 et