Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

gov::cca::KeyValuePort Class Reference

UNADOPTED Standard: KeyValuePort for use decorating components with strings external to the implementation of the component. More...

#include <KeyValuePort.h>

Inheritance diagram for gov::cca::KeyValuePort:

Inheritance graph
[legend]
Collaboration diagram for gov::cca::KeyValuePort:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual ~KeyValuePort ()
 obligatory vdtor. More...

virtual CONST char * getValue (CONST char *key)=0
 Return the value of the requested key. More...

virtual int setValue (CONST char *key, CONST char *value)=0
 Store the value for the given key, possibly replacing previous. More...

virtual CFREE char * remove (CONST char *key)=0
 Delete a key and associated value. More...

virtual CFREE char ** getKeys ()=0
 Return NULL-terminated list of all known keys. More...


Detailed Description

UNADOPTED Standard: KeyValuePort for use decorating components with strings external to the implementation of the component.

Alternative, misleading names for this would be

   EnvironmentPort (which has too many global connotations)
   RegistryPort (which has way too many global connotations)
   PropertiesPort (which will be confused with port properties and java Propertie
s...).
   ParameterPort (which is already taken in the CCAFFEINE framework.).
 

This class is deliberately simpler than java Properties, for compatibility with basic c++ implementations.

In a reasonable framework, each component will just be automatically decorated with one of these if that framework exposes the component to external agents.

The following code fragment illustrates the use of the KeyValuePort by a framework Services implementation to decorate every component with a properties for the frameworks use.

    int err;
    err = addProvidesPort(kvp,createPortInfo("cProps","gov.cca.ComponentProperties",0));
    assert(!err); // cannot fail, due to other framework design features
 

The following code fragment illustrates the use of the port as a service by a component that wants to know/modify what the framework says about it.

   setServices(Services *s) {
     int err;
     err= s->registerUsesPort(kvp,createPortInfo("sProps","gov.cca.ComponentPropertiesService",0));
     assert(!err); // cannot fail, if we adopt it as a well known service.
     Port *p = getPort("sProps");
     KeyValuePort *kvp = dynamic_cast<KeyValuePort *>(p);
     kvp->setValue("gov.babel.guiApplet.URL",
                "http://z.ca.sandia.gov/cgi-bin/babel.asp?component=gov.sandia.viz");
     s->releasePort("sProps");
     s->unregisterUsesPort("sProps");
   }
 
Author:
Ben Allan, 8/5/2000, Sandia National Laboratories.
Version:
Id:
KeyValuePort.h,v 1.3 2001/04/24 20:13:13 baallan Exp


Constructor & Destructor Documentation

virtual gov::cca::KeyValuePort::~KeyValuePort   [inline, virtual]
 

obligatory vdtor.

00053 {}


Member Function Documentation

virtual CONST char* gov::cca::KeyValuePort::getValue CONST char *    key [pure virtual]
 

Return the value of the requested key.

If key unknown, returns null. The value returned is owned by the port and should not be destroyed.

virtual int gov::cca::KeyValuePort::setValue CONST char *    key,
CONST char *    value
[pure virtual]
 

Store the value for the given key, possibly replacing previous.

The pointers to key, value are not kept -- just copied. Keys cannot contain the whitespace or '='. Returns nonzero on bogus input or other error.

virtual CFREE char* gov::cca::KeyValuePort::remove CONST char *    key [pure virtual]
 

Delete a key and associated value.

The deleted value is returned, and the caller owns the returned pointer.

virtual CFREE char** gov::cca::KeyValuePort::getKeys   [pure virtual]
 

Return NULL-terminated list of all known keys.

May be the empty list. The caller owns the argv returned, but not the strings pointed to by the argv. Returns NULL only in the event of malloc failure.


The documentation for this class was generated from the following file:
Generated on Tue Aug 20 14:30:32 2002 for CCA Specification/Proposals by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002