How to Program for the WPS - Tutorial

From EDM2
Revision as of 16:04, 10 March 2017 by Ak120 (Talk | contribs)

Jump to: navigation, search

Select an appropriate base class

Before starting you've to think about the features of your new WPS class. Do you need persistent storage (this means data will survive a reboot), just a fancy notebook for your program or do you want to create a special filesystem class with specific behaviour?

Depending on the desired feature set you will choose the class your new class will be derived from. For example if you only need access to the WPS or want to signal something using WPS features deriving your class from WPTransient is a good idea because such a class will never save any data anywhere on your system. If you want to save some data in your filesystem you have to derive your class from WPFileSystem or one of it's subclasses.

The WPUrl class in Warp 4 is an example for choosing an appropriate base class for the derived class. Any URL object must obviously save it's URL somewhere. So the WPUrl class is simply derived from WPDataFile and the URL is saved as normal text in the file. So every WPUrl object is in fact a normal file in your file system. You may easily proof that by just opening an WPUrl object in a normal text editor.

In general you should choose a base class which has most of the functionality you'll need so you don't have to reimplement it.

Create interface definition

As fast as you selected base class you need to define new methods and attributes of your new class. This job can be (in most cases MUST BE) done via the SOM Interface Definition Language.