File: AddingInterfaces

package info (click to toggle)
kst 2.0.8-6
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 30,748 kB
  • sloc: cpp: 97,086; ansic: 13,364; python: 2,970; sh: 761; yacc: 184; lex: 143; makefile: 141; javascript: 122; perl: 30; xml: 30
file content (36 lines) | stat: -rw-r--r-- 1,192 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
How to add an interface for a new NamedObject.

-Create a class which inherits from ScriptInterface.
  eg, ScalarGenSI in scalarsscriptinterface.cpp

-Implement the 5 methods.
  -doCommand actually parses the commands from pyKst.py
  -you probably want to call doNamedObjectCommand as is done
   in ScalarGenSI::doCommand()

-Add virtual ScriptInterface* createScriptInterface() to the
 class you are making an interface for.  eg, Scalar.

    ScriptInterface* Scalar::createScriptInterface() {
      return new ScalarGenSI(this);
    }

-Create a command in ScripServer.h
  eg, QByteArray newGeneratedScalar(QByteArray& command, QLocalSocket* s,ObjectStore*_store);

-Implement it in ScripServer.cpp

  QByteArray ScriptServer::newGeneratedScalar(QByteArray&, QLocalSocket* s,ObjectStore*) {
    if(_interface) {
      return handleResponse("To access this function, first call endEdit()",s);
    } else {
      _interface = ScalarGenSI::newScalar(_store); return handleResponse("Ok",s);
    }
  }

-register it in _fnMap
   _fnMap.insert("newGeneratedScalar()",&ScriptServer::newGeneratedScalar);

-Call the interface you just wrote in pyKst.py
  search for GeneratedScalar as an example.