[Kst] kdeextragear-2/kst/kst/datasources/planck
George Staikos
staikos at kde.org
Wed Feb 9 16:36:45 CET 2005
CVS commit by staikos:
some utility functions to be used later
M +2 -1 planck.cpp 1.35
M +50 -1 planckobj.cpp 1.26
M +5 -0 planckobj.h 1.8
--- kdeextragear-2/kst/kst/datasources/planck/planck.cpp #1.34:1.35
@@ -229,6 +229,7 @@ bool PlanckSource::isEmpty() const {
+
bool PlanckSource::supportsTimeConversions() const {
- return true;
+ return _fieldList.contains("TIMES_OF_SAMPLES") || _fieldList.contains("TIMESEC");
}
--- kdeextragear-2/kst/kst/datasources/planck/planckobj.cpp #1.25:1.26
@@ -36,5 +37,5 @@ using namespace Planck;
class Planck::ObjectGroup {
friend class Object;
- protected:
+ public:
ObjectGroup();
~ObjectGroup();
@@ -57,4 +58,51 @@ class Planck::ObjectGroup {
+Planck::TimeType Object::typeOfTime() {
+ PIOParseData MyData, MyDataFlag;
+ PIOObject *obj = 0L;
+ char range[128];
+ Planck::ObjectGroup *g = _groupInfo[_group];
+ snprintf(range, 127, "Begin=%ld\nEnd=%ld", *g->firstIndex, *g->lastIndex);
+
+ long n = PIORead_1(const_cast<char*>("TIMES_OF_SAMPLES"), const_cast<char*>("Written"), const_cast<char*>("PIODOUBLE"), range, &g->_group, &obj, &MyData, &MyDataFlag);
+
+ if (n != 1) {
+ n = PIORead_1(const_cast<char*>("TIMESEC"), const_cast<char*>("Written"), const_cast<char*>("PIODOUBLE"), range, &g->_group, &obj, &MyData, &MyDataFlag);
+ if (n != 1) {
+ return Planck::Unknown;
+ } else {
+ return Planck::TimeSec;
+ }
+ }
+ return Planck::TimesOfSamples;
+}
+
+
+double Object::fetchTimePoint(long indx) {
+ PIOLONG idx = indx;
+ PIOParseData MyData, MyDataFlag;
+ PIOObject *obj = 0L;
+ char range[128];
+ long n;
+ snprintf(range, 127, "Begin=%ld\nEnd=%ld", (long)idx, (long)idx);
+ double buf[1];
+ Planck::ObjectGroup *g = _groupInfo[_group];
+ static PIOFLAG Mask[1];
+
+ switch (_tt) {
+ case Planck::TimeSec:
+ n = PIORead_1(const_cast<char*>("TIMESEC"), const_cast<char*>("Written"), const_cast<char*>("PIODOUBLE"), range, &g->_group, &obj, &MyData, &MyDataFlag);
+ PIORead_2(buf, 0L, Mask, const_cast<char*>("TIMESEC"), const_cast<char*>("PIODOUBLE"), range, const_cast<char*>("Written"), g->_group, &obj, &MyData, &MyDataFlag, PIOLONG(n));
+ break;
+ case Planck::TimesOfSamples:
+ n = PIORead_1(const_cast<char*>("TIMES_OF_SAMPLES"), const_cast<char*>("Written"), const_cast<char*>("PIODOUBLE"), range, &g->_group, &obj, &MyData, &MyDataFlag);
+ PIORead_2(buf, 0L, Mask, const_cast<char*>("TIMES_OF_SAMPLES"), const_cast<char*>("PIODOUBLE"), range, const_cast<char*>("Written"), g->_group, &obj, &MyData, &MyDataFlag, PIOLONG(n));
+ break;
+ default:
+ return NOPOINT;
+ }
+
+ return buf[0];
+}
@@ -63,4 +111,5 @@ Object::Object() : Source() {
kdDebug() << ">>>>>>>>> Object created " << (void*)this << endl;
#endif
+ _tt = Undetermined;
}
--- kdeextragear-2/kst/kst/datasources/planck/planckobj.h #1.7:1.8
@@ -25,4 +25,5 @@
namespace Planck {
+ enum TimeType { Undetermined = -1, Unknown = 0, TimeSec = 1, TimesOfSamples = 2 };
class ObjectGroup;
@@ -46,8 +47,12 @@ class Object : public Source {
virtual QSize range(const QString& object) const;
+ TimeType typeOfTime();
+ double fetchTimePoint(long);
+
private:
// We lazy load the groups, hence mutable
mutable QMap<QString, ObjectGroup*> _groupInfo;
ObjectGroup *findGroup(const QString& group) const;
+ TimeType _tt;
};
More information about the Kst
mailing list