Difference between revisions of "V4 Requirements for Standard Types"

From EPICSWIKI
Line 1: Line 1:
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.
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.
 
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 [[Talk:V4 Standard Types|here]].


= epicsTypes.h =
= epicsTypes.h =


This header will include a set of <tt>typedef</tt>s (OS dependent if necessary) as follows:
This C++ header will include a set of <tt>typedef</tt>s (OS dependent if necessary) as follows:


== epicsBoolean ==
== epicsBoolean ==


A boolean type.
A boolean type.
typedef bool epicsBoolean;


== epicsInt16 ==
== epicsInt16 ==


A signed 16-bit integer type.
A signed 16-bit integer type.
typedef short epicsInt16;


== epicsInt32 ==
== epicsInt32 ==


A signed 32-bit integer type.
A signed 32-bit integer type.
typedef int epicsInt32;


== epicsInt64 ==
== epicsInt64 ==


A signed 64-bit integer type.
A signed 64-bit integer type.
typedef long long epicsInt64;
On some architectures, this may be defined as:
typedef long epicsInt64;


== epicsFloat32 ==
== epicsFloat32 ==


A 32-bit IEEE floating-point numeric type.
A 32-bit IEEE floating-point numeric type.
typedef float epicsFloat32;


== epicsFloat64 ==
== epicsFloat64 ==


A 64-bit IEEE floating-point numeric type.
A 64-bit IEEE floating-point numeric type.
typedef double epicsFloat64


== epicsOctet ==
== epicsOctet ==
Line 35: Line 49:
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.
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 ==
typedef char epicsOctet;
 
----
 
Below here, things become a little more speculative...
 
== EpicsString ==


A Unicode/UTF-8 encoded string.
A Unicode/UTF-8 encoded string.
Line 41: Line 61:
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.
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.


----
== EpicsEnum ==
 
Below here, things become more speculative...
 
== epicsEnum ==


A 16-bit index with an interface to convert between index values and choice strings; something like this perhaps?
A 16-bit index, with an interface to convert between choice strings and their  index values.  Here's a proposal:


  class EpicsEnumBase {
  class EpicsEnumBase {
  public:
  public:
    virtual void release() = 0;
     virtual epicsInt16 nChoices() const = 0;
     virtual epicsInt16 nChoices() const = 0;
     virtual epicsInt16 index(const EpicsString &choice) const = 0;
     virtual epicsInt16 index(const EpicsString &choice) const = 0;
Line 61: Line 76:
     enum {invalid = -1};
     enum {invalid = -1};
      
      
     EpicsEnum() : pbase(NULL), index(invalid) {};
     EpicsEnum() : pbase(NULL), index(invalid) {}
     EpicsEnum(EpicsEnumBase *ib) : pbase(ib), index(invalid) {};
     EpicsEnum(EpicsEnumBase *ib) : pbase(ib), index(invalid) {}
     EpicsEnum(EpicsEnumBase *ib, epicsInt16 in) : pbase(ib), index(in) {};
     EpicsEnum(EpicsEnumBase *ib, epicsInt16 in) : pbase(ib), index(in) {}
    // C++ will generate EpicsEnum(const EpicsEnum &e);
     virtual ~EpicsEnum();
     virtual ~EpicsEnum();
    EpicsEnum& operator=(const EpicsEnum &rhs);
      
      
     virtual void base(EpicsEnumBase *pbase);
     virtual void base(EpicsEnumBase *pbase);
Line 70: Line 87:
     epicsInt16 nChoices() const { return pbase ? pbase->nChoices() : 0; }
     epicsInt16 nChoices() const { return pbase ? pbase->nChoices() : 0; }
     epicsInt16 get() const { return index; }
     epicsInt16 get() const { return index; }
     virtual void get(EpicsString &state) const;
     virtual void get(EpicsString &choice) const;
     virtual void put(epicsInt16 index);
     virtual void put(epicsInt16 index);
     virtual void put(const EpicsString &state);
     virtual void put(const EpicsString &choice);
  protected:
  protected:
     EpicsEnumBase *pbase;
     EpicsEnumBase *pbase;
Line 78: Line 95:
  }
  }


== epicsBits ==
== EpicsBits ==


Some way to store a collection of named bits.
A way to store a collection of named bits.  This might even be able to reuse <tt>EpicsEnumBase</tt> to define the bit name to bit number conversion process.

Revision as of 21:45, 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.

epicsTypes.h

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

epicsBoolean

A boolean type.

typedef bool epicsBoolean;

epicsInt16

A signed 16-bit integer type.

typedef short epicsInt16;

epicsInt32

A signed 32-bit integer type.

typedef int epicsInt32;

epicsInt64

A signed 64-bit integer type.

typedef long long epicsInt64;

On some architectures, this may be defined as:

typedef long epicsInt64;

epicsFloat32

A 32-bit IEEE floating-point numeric type.

typedef float epicsFloat32;

epicsFloat64

A 64-bit IEEE floating-point numeric type.

typedef double epicsFloat64

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.

typedef char epicsOctet;

Below here, things become a little more speculative...

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.

EpicsEnum

A 16-bit index, with an interface to convert between choice strings and their index values. Here's a proposal:

class EpicsEnumBase {
public:
    virtual epicsInt16 nChoices() 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() : pbase(NULL), index(invalid) {}
    EpicsEnum(EpicsEnumBase *ib) : pbase(ib), index(invalid) {}
    EpicsEnum(EpicsEnumBase *ib, epicsInt16 in) : pbase(ib), index(in) {}
    // C++ will generate EpicsEnum(const EpicsEnum &e);
    virtual ~EpicsEnum();
    EpicsEnum& operator=(const EpicsEnum &rhs);
    
    virtual void base(EpicsEnumBase *pbase);
    EpicsEnumBase *base() const { return pbase; }
    epicsInt16 nChoices() const { return pbase ? pbase->nChoices() : 0; }
    epicsInt16 get() const { return index; }
    virtual void get(EpicsString &choice) const;
    virtual void put(epicsInt16 index);
    virtual void put(const EpicsString &choice);
protected:
    EpicsEnumBase *pbase;
    epicsInt16 index;
}

EpicsBits

A way to store a collection of named bits. This might even be able to reuse EpicsEnumBase to define the bit name to bit number conversion process.