artefaktur
software engineer &        architecture

 
 
 
 

Enum Types

| Basic Types | Enum Types | Object Types | Array Types | Interface Types | Exception Types | Member Types | Method Types | Namespace Types | Foreign Types |



Enumaration are directly supported by ACDK.


ACDK Enumeration are simple C++ 'enum's.
You can use them directly as member or parameter in a ACDK object.

There is only one limitation regarding the ACDK meta compiler:
In the same header, where the enum will be used in a ACDK object, the enumeration has to be declared or defined:


//SomeHeaderWithEnumDefintion.h
enum AnEnum
{
  MyFirstVal,
  MySecondVal
};
ACDK_DEF_ENUM(TestEnum);

The ACDK_DEF_ENUM(TestEnum); defines a class, which provides meta information about the enumeration.

If you define enumeration in shared libraries you have to use instead of the ACDK_DEF_ENUM macro the ACDK_DEF_LIB_ENUM(MY_EXPORT_DLL_MACRO, TestEnum) macro.



// defines 'enum AnEnum'
#include <SomeHeaderWithEnumDefintion.h>

// hint for the ACDK meta compiler, that AnEnum is a legal 
// ACDK type
enum AnEnum;

ACDK_DECL_CLASS(LegalAcdkClass);
class LegalAcdkClass
: extends acdk::lang::Object // extend the Object class
{
private:
  // legal ACDK member
  AnEnum setting; 
public:
  // legal ACDK meber
  void setSetting(AnEnum set) { setting = set; }
  
  // the enum can be used in declarations of methods and members inside this class
  // but there will no meta info available
  enum Direction
  {
    North, West, South, East
  };  
  // legal ACDK method, but foreign, because enums has 
  // to be defined on global or namespace scope
  void go(Direction direction);
};

If an enum should not be used in connection with metainfo the enum should be flagged with foreign.


foreign enum MyEnum
{
  First,
  Second
};
ACDK_DECL_CLASS(LegalAcdkClass);
class LegalAcdkClass
: extends acdk::lang::Object // extend the Object class
{
private:
  // using enumeration, which doesn't have meta info, should be itself foreign
  foreign AnEnum setting; 
public:
  // using enumeration, which doesn't have meta info, should be itself foreign
  foreign void setSetting(AnEnum set) { setting = set; }
  // ...
};

 
Last modified 2005-05-08 18:15 by SYSTEM By Artefaktur, Ing. Bureau Kommer