[Kst] Re: branches/work/kst/portto4/kst/src

Peter Kümmel syntheticpp at gmx.net
Sun Feb 6 11:20:32 CET 2011


On 05.02.2011 20:03, Barth Netterfield wrote:
--- branches/work/kst/portto4/kst/src/libkst/objectstore.h #1219026:1219027
> @@ -80,6 +80,16 @@
>
>   //    void deleteDependentObjects(const Primitive&p);
>
> +    // some variables for overriding data source properties
> +    // from the command line when opening a .kst file
> +    struct {
> +      QString fileName;
> +      int f0;
> +      int N;
> +      int skip;
> +      int doAve;
> +    } override;
> +
>     private:
>       Q_DISABLE_COPY(ObjectStore)
>
> @@ -88,6 +98,7 @@
>       // objects are stored in these lists
>       DataSourceList _dataSourceList;
>       QList<ObjectPtr>  _list;
> +
>   };


Shouldn't we pass those values as parameters instead of making them global?
In principle they could be handled like the QXmlStreamReader:


Index: src/libkst/datasourcefactory.h
===================================================================
--- src/libkst/datasourcefactory.h	(revision 1219092)
+++ src/libkst/datasourcefactory.h	(working copy)
@@ -31,8 +31,21 @@
      // This takes ownership
      static void registerFactory(const QString& node, DataSourceFactory *factory);
      static void registerFactory(const QStringList& nodes, DataSourceFactory *factory);
-    KSTCORE_EXPORT static DataSourcePtr parse(ObjectStore *store, QXmlStreamReader& stream);
-    virtual DataSourcePtr generateDataSource(ObjectStore *store, QXmlStreamReader& stream) = 0;
+
+    struct ReadInfo
+    {

+      QString filename;
+      QXmlStreamReader xml;
+
+      int startingFrame;
+      int numberOfFrames;
+      int skipFrame;
+      int *lastFrameRead;
+    };
+
+    KSTCORE_EXPORT static DataSourcePtr parse(ObjectStore *store, ReadInfo&);
+
+    virtual DataSourcePtr generateDataSource(ObjectStore *store, ReadInfo&) = 0;
  };

We could also add a function to ReadInfo which implements the logic for getting
the filename when we have file names in 'xml' and 'filename' set.

It would be much cleaner and simpler to extend.

Peter


More information about the Kst mailing list