Top Up Prev Next Bottom Contents Index Search

4.5 The File and String Types


There are two experimental types in Ptolemy that support non-numeric computation. These types represent the beginnings of an effort to extend Ptolemy's dataflow model to "non-dataflow" problems such as scheduling and design flow. Their interfaces are still being developed, so should be expected to change in future releases. We would welcome suggestions on how to improve the interface and functionality of these two types.

4.5.1 The File type

The file type is implemented by the classes FileMessage and FileParticle, which are derived from Message and Particle. It uses the reference-counting mechanism of the Message and Envelope classes to ensure that files are not deleted until no longer needed. Although we created a new particle type to allow these types to appear in the pigi graphical interface, we recommend that you use the Message interface described in Section 4.3 for your own types.

The File type adds the following functions to Message:

Constructors


FileMessage()

Create a new file message with a unique filename. By default, the file will be deleted when no file messages reference it.


FileMessage(const char* name)

Create a new file message with the given filename. By default, the file will not be deleted when no file messages reference it.


FileMessage(const FileMessage& src)

Create a new file message containing the same filename as the given file message. By default, the file will not be deleted when no file messages reference it.

Operations


const char* fileName()

Return the file name contained in this message.


StringList print()

Return the file name contained in this message in a StringList object.


const char* fileName()

Return the file name contained in this message.


void setTransient(int transient)

Set the status of the file. If transient is TRUE, the file will be deleted when no file messages reference it; if FALSE, then it will not be deleted.

4.5.2 The String type

The string type is implemented by the classes StringMessage and StringParticle, which are derived from Message and Particle. It contains an InfString object-InfString is a version of StringList that allows limited modification, and is used to interface C++ to Tcl. Again, It uses the reference-counting mechanism of the Message and Envelope classes to ensure that strings are not deleted until no longer needed. StringMessage is currently very simple-it adds the following functions to Message:

Constructors


StringMessage()

Create a new string message an empty string.


StringMessage(const char* name)

Create a new string message with a copy of the given string. The given string can be deleted, since the new message does not reference it.


StringMessage(const StringMessage& src)

Create a new string message containing the same string as the given string message. Again, the string is copied.

Operations


StringList print()

Return the string contained in this message in a StringList object.



Top Up Prev Next Bottom Contents Index Search

Copyright © 1990-1997, University of California. All rights reserved.