File indexing completed on 2024-12-22 04:17:22
0001 /*************************************************************************** 0002 primitive.cpp 0003 ------------------- 0004 begin : Tue Jun 20, 2006 0005 copyright : Copyright (C) 2006, 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 * Permission is granted to link with any opensource library * 0016 * * 0017 ***************************************************************************/ 0018 0019 //#define UPDATEDEBUG 0020 #include "primitive.h" 0021 #include <QDebug> 0022 #include <QMessageBox> 0023 0024 #include <limits.h> 0025 0026 #include "updatemanager.h" 0027 #include "datasource.h" 0028 0029 namespace Kst { 0030 0031 const QString Primitive::staticTypeString = "Primitive"; 0032 0033 Primitive::Primitive(ObjectStore *store, Object *provider) 0034 : Object(), _provider(provider) { 0035 Q_UNUSED(store); 0036 _slaveName = "fixme: set _slaveName"; 0037 0038 _hidden = false; 0039 } 0040 0041 0042 Primitive::~Primitive() { 0043 } 0044 0045 0046 const QString& Primitive::typeString() const { 0047 return staticTypeString; 0048 } 0049 0050 void Primitive::setProvider(Object* obj) { 0051 _provider = obj; 0052 } 0053 0054 void Primitive::setSlaveName(QString slaveName) { 0055 _slaveName=slaveName; 0056 } 0057 0058 QString Primitive::_automaticDescriptiveName() const { 0059 QString name; 0060 if (_provider) { 0061 name = _provider->descriptiveName() + ':'; 0062 } 0063 name += _slaveName; 0064 0065 return name; 0066 } 0067 0068 qint64 Primitive::minInputSerial() const { 0069 if (_provider) { 0070 return (_provider->serial()); 0071 } 0072 return LLONG_MAX; 0073 } 0074 0075 qint64 Primitive::maxInputSerialOfLastChange() const { 0076 if (_provider) { 0077 return (_provider->serialOfLastChange()); 0078 } 0079 return NoInputs; 0080 } 0081 0082 0083 QString Primitive::propertyString() const { 0084 return QString("Base Class Property String"); 0085 } 0086 0087 QString Primitive::sizeString() const { 0088 return QString("Base Class Size String"); 0089 } 0090 0091 bool Primitive::used() const { 0092 if (_provider) { 0093 return true; 0094 } else { 0095 return Object::used(); 0096 } 0097 } 0098 0099 void Primitive::setUsed(bool used_in) { 0100 _used = used_in; 0101 if (_used && provider()) { 0102 provider()->setUsed(true); 0103 } 0104 } 0105 0106 void Primitive::fatalError(const QString& msg) 0107 { 0108 QString message = msg; 0109 message +="\nError could be ignored, but chances are high that Kst will crash."; 0110 message += "\nWhen reading ASCII data you could limit the size of the file buffer to save memory."; 0111 QMessageBox::StandardButton btn = QMessageBox::critical(0, "A fatal error occurred", message, QMessageBox::Abort | QMessageBox::Ignore); 0112 if (btn == QMessageBox::Abort) { 0113 exit(-2); 0114 } 0115 } 0116 0117 bool Primitive::hidden() const 0118 { 0119 return _hidden; 0120 } 0121 0122 void Primitive::setHidden(bool hidden) { 0123 _hidden = hidden; 0124 } 0125 0126 0127 } 0128 0129 // vim: et sw=2 ts=2