Class Property |
A singleton class that provides global access to a set of persistent properties. Persistent properties are stored in an SQL database and can be retrieved by other program executions. A persistent property is a simple name/value pair that represents an item of information that is available across Unicon applications. The value can be any Unicon type that can be converted to and from a JSON string representation by the json support. Note that this should not include structures containing multiple references to the same structure (e.g. circular graphs, etc.) as the fetched property will not match the saved property.
The base implementation works with PostgreSQL 9.6+ via ODBC. All of the database-specific code can be found in the class propertydb::PropertyUtil, found in the file $UNICON/src/lib/pdb_util.icn which can serve as a template for adapting to different SQL databases. The Property constructor can be passed the string name of the required adaptation class, e.g. "MySQL_utils" (or whatever).
Details |
Constructor |
Property(user, passwd:"", dsn, tabl, uClass)
user | name of user owning the database table |
passwd | that user's database access password (defaults to "") |
dsn | database name as known by ODBC]. The default is the
same as the user name |
tabl | name of the property table in that database
(defaults to "property_table") |
uClass | name of the support class for a specific
type of SQL database. The default is
"propertydb::PropertyUtil" which is suitable for
PostgreSQL 9.6+ (and possibly others). See the
PropertyDB class for more details. |
Construct a singleton Property class.
Methods: |
Remove all properties from the database
the number of properties |
Produce the number of properties.
set of property names |
Produce a set of the names of all of the properties.
table of all the properties |
Produce a table containing all of the properties. The keys are the property names.
pName | name of the property |
the current value of the named property |
Produce a property's value.
pName | name of the property |
the JSON string value of the named property |
Produce a property's value as a JSON string.
pName | name of property to remove |
Remove a property from the database
pName | name of the property |
value | value for the named property |
Set a property's value.
switchPropertyTable(tableName)
tableName | name of property table to use |
Switch to a different property table in the database. Reference properties in a different table. The table must be (and will be created there if not) in the same SQL database as the original.
Fields: |