Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4680 | right-hear | 1 | /** \file genericstructs.h defines the class that handles structs and classes for plugins. |
2 | */ |
||
3 | #ifndef __genericstruct_h__ |
||
4 | #define __genericstruct_h__ |
||
5 | |||
6 | #include "yacasbase.h" |
||
7 | #include "genericobject.h" |
||
8 | #include "lispassert.h" |
||
9 | |||
10 | /** \class GenericStruct This class maintains a pointer to some arbitrary |
||
11 | * object (which can be any thing). The plugin is responsible for supplying |
||
12 | * functions for manipulating such structs/classes/arrays. The Yacas core |
||
13 | * then needs to know nothing about the internals of such a struct. |
||
14 | * |
||
15 | * The struct is represented by a void pointer to the struct, a pointer |
||
16 | * to a function that can clean up the struct (used when automatically |
||
17 | * deleting the object), and a pointer to a text string representing the |
||
18 | * type of the object (useful for testing if the type passed as an argument |
||
19 | * to a function is correct). |
||
20 | */ |
||
21 | class GenericStruct : public GenericClass |
||
22 | { |
||
23 | public: |
||
24 | GenericStruct(LispChar * aTypeName, void* aData, void (*aDestructor)(void*)); |
||
25 | virtual ~GenericStruct(); |
||
26 | virtual LispChar * Send(LispArgList& aArgList); |
||
27 | virtual LispChar * TypeName(); |
||
28 | inline void* Data() {return iData;} |
||
29 | private: |
||
30 | GenericStruct(const GenericStruct& aOther) : iData(NULL),iTypeName(NULL),iDestructor(NULL) |
||
31 | { |
||
32 | // copy constructor not written yet, hence the assert |
||
33 | LISPASSERT(0); |
||
34 | } |
||
35 | GenericStruct& operator=(const GenericStruct& aOther) |
||
36 | { |
||
37 | // copy constructor not written yet, hence the assert |
||
38 | LISPASSERT(0); |
||
39 | return *this; |
||
40 | } |
||
41 | public: |
||
42 | void* iData; |
||
43 | LispChar * iTypeName; |
||
44 | void (*iDestructor)(void* data); |
||
45 | }; |
||
46 | |||
47 | |||
48 | #endif |
||
49 |