2005/5/10

     
 

Object Types

artefaktur

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



The major type of ACDK are Objects.


Content of this chapter:

   Simple ACDK objects
   ACDK objects implementing an interface
   ACDK Objects and acdk::lang::Class
   Other class'es and struct's



 Simple ACDK objects


All ACDK objects must be directly or indirectly derived from  acdk::lang::Object.



// declare the R-type RLegalAcdkClass
// and the Array type LegalAcdkClassArray and RLegalAcdkClassArray
ACDK_DECL_CLASS(LegalAcdkClass); 

// The class itself:
class LegalAcdkClass
: extends acdk::lang::Object // extend the Object class
{
  ACDK_WITH_METAINFO(LegalAcdkClass) // optional, for class information see  Metainfo
private:
  RString message;
public:
  // constructor
  LegalAcdkClass() 
  : Object()
  , message("")
  {
  } 
  
  // a method
  RString getMessage() 
  {
    return message;
  }
};


The class model of ACDK does not allow multi inheritence (like Java and C#), but provides a quite similar (and better) concept of interfaces.
See also:  Interface Types.

 ACDK objects implementing an interface




// declare the R-type RLegalAcdkClass
// and the Array type LegalAcdkClassArray and RLegalAcdkClassArray
ACDK_DECL_CLASS(LegalAcdkClass); 

// The class itself:
class LegalAcdkClass
: extends acdk::lang::Object // extend the Object class
, implements acdk::lang::Comparable // implements the interface
{
  ACDK_WITH_METAINFO(LegalAcdkClass) // optional, for class information see  Metainfo
private:
  RString message;
public:
  // implement the Comparable interface method
  int compareTo(IN(RObject) other) 
  {
    return getMessage()->compareTo(RLegalAcdkClass(other)->getMessage());
  }
  RString getMessage() { return message; }
};

 ACDK Objects and acdk::lang::Class

With every ACDK Object have meta info an instance of  acdk::lang::Class is connected.

The methods getClass and the static version GetClass returns the acdk::lang::Class for the given object/or class. Instances of the one class always return the same instance.

 RStringBuffer sb1 = new StringBuffer("ACDK");
 RStringBuffer sb2 = new StringBuffer("JAVA");
 RClass cls1 = sb1->getClass();
 RClass cls2 = sb2->getClass();
 cls1 == cls2; // always true

See also:  acdk::lang::Class.

 Other class'es and struct's


You can also create other classes or structs in a ACDK application, but they don't work with ACDK Meta-Features, like distributed object, scriping and garbage collecting.