Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1.  
  2.  
  3. #ifndef __genericobject_h__
  4. #define __genericobject_h__
  5.  
  6. #include "yacasbase.h"
  7.  
  8. /// Not used.
  9. /// This class has pure virtual functions, but no derived classes, so
  10. /// it can never be used.
  11. class LispArgList : public YacasBase
  12. {
  13. public:
  14.   virtual ~LispArgList();
  15.   virtual LispInt NrArguments()=0;
  16.   virtual LispChar * GetArgument(LispInt aIndex, LispInt& aLength)=0;
  17.   virtual LispBoolean Compare(LispInt aIndex, LispChar * aString)=0;
  18. };
  19.  
  20. /// Abstract class which can be put inside a LispGenericClass.
  21. class GenericClass : public YacasBase
  22. {
  23. public:
  24.     GenericClass() : iReferenceCount(0) {};
  25.     virtual ~GenericClass();
  26.     virtual LispChar * Send(LispArgList& aArgList)=0;
  27.     virtual LispChar * TypeName()=0;
  28. public:
  29.     LispInt iReferenceCount; //TODO: perhaps share the method of reference counting with how it is done in other places
  30. };
  31.  
  32.  
  33. /* Definition of DYNCAST: either the cast succeeds, or the variable is assigned NULL.
  34. */
  35.  
  36. #define DYNCAST(_type,_name,_var,_object) \
  37.     _type * _var = NULL ; \
  38.     if (_object != NULL) \
  39.     { \
  40.       if (StrEqual((_object)->TypeName(),_name)) _var = (_type *)(_object); \
  41.     }
  42.  
  43. #endif
  44.  
  45.