Difference between revisions of "V4 Requirements for Standard Types"

From EPICSWIKI
Line 47: Line 47:
== epicsEnum ==
== epicsEnum ==


A 16-bit index and a set of choice strings.
A 16-bit index and an interface to convert between index values and choice strings; something like this perhaps?
 
class epicsEnumInterface {
public:
    virtual ~EpicsEnumInterface() = 0;
   
    virtual epicsInt16 choices() const = 0;
   
    virtual epicsInt16 index(const EpicsString &choice) const = 0;
    virtual void choice(epicsInt16 index, EpicsString &choice) const = 0;
}
class EpicsEnum {
public:
    enum {invalid = -1};
   
    EpicsEnum() : pif(NULL), index(invalid) {};
    EpicsEnum(EpicsEnumInterface *if) : pif(if), index(invalid) {};
    EpicsEnum(EpicsEnumInterface *if, epicsInt16 in) : pif(if), index(in) {};
    virtual ~EpicsEnum();
   
    void interface(EpicsEnumInterface *pif);
    EpicsEnumInterface *interface() const;
   
    epicsInt16 choices() const;
   
    epicsInt16 get() const { return index; };
    void get(EpicsString &state) const;
   
    void put(epicsInt16 index);
    void put(const EpicsString &state);
   
protected:
    EpicsEnumInterface *pif;
    epicsInt16 index;
}


== epicsBits ==
== epicsBits ==


Some way to store a collection of named bits.
Some way to store a collection of named bits.

Revision as of 19:39, 2 June 2005

The purpose of this page is to discuss and agree on a set of standard basic data types that will be supported throughout EPICS V4. As at 2005-5-19 the latest implementation of Data Access doesn't support all the types that the V4 database is proposed to support; we should try to converge on a common set.

If you wish to comment, please use the "Post a comment" link under "This Page" in the left-hand column of this page; your comment will be added to the bottom of the Talk page which you can read here.

epicsTypes.h

This header will include a set of typedefs (OS dependent if necessary) as follows:

epicsBoolean

A boolean type.

epicsInt16

A signed 16-bit integer type.

epicsInt32

A signed 32-bit integer type.

epicsInt64

A signed 64-bit integer type.

epicsFloat32

A 32-bit IEEE floating-point numeric type.

epicsFloat64

A 64-bit IEEE floating-point numeric type.

epicsOctet

An 8-bit character type which may be signed or unsigned depending on the particular platform. This is not intended to be used for numeric operations, just for storing and manipulating raw data bytes, including use for Unicode/UTF-8 encoded strings.

epicsString

A Unicode/UTF-8 encoded string.

Since this type does not map directly to any native C/C++ type, we're going to have to discuss the implementation and facilities we'll provide. Marty has a proposal for an interface that supports both segmented and contiguous buffer management and the requirements of character encoding conversions. I'll link to that proposal from here when it's ready for public consumption.


Below here, things become more speculative...

epicsEnum

A 16-bit index and an interface to convert between index values and choice strings; something like this perhaps?

class epicsEnumInterface {
public:
    virtual ~EpicsEnumInterface() = 0;
    
    virtual epicsInt16 choices() const = 0;
    
    virtual epicsInt16 index(const EpicsString &choice) const = 0;
    virtual void choice(epicsInt16 index, EpicsString &choice) const = 0;
}

class EpicsEnum {
public:
    enum {invalid = -1};
    
    EpicsEnum() : pif(NULL), index(invalid) {};
    EpicsEnum(EpicsEnumInterface *if) : pif(if), index(invalid) {};
    EpicsEnum(EpicsEnumInterface *if, epicsInt16 in) : pif(if), index(in) {};
    virtual ~EpicsEnum();
    
    void interface(EpicsEnumInterface *pif);
    EpicsEnumInterface *interface() const;
    
    epicsInt16 choices() const;
    
    epicsInt16 get() const { return index; };
    void get(EpicsString &state) const;
    
    void put(epicsInt16 index);
    void put(const EpicsString &state);
    
protected:
    EpicsEnumInterface *pif;
    epicsInt16 index;
}

epicsBits

Some way to store a collection of named bits.