[Vala] abstract method with random return value or parameters



Hi,

I'm new to Vala, and not very experienced using objects.

My Problem:

I want to create a datafile format for my games.

I try to implement an Item class, which is an container for any kind of
data. Numbers, strings, images, etc. This items are stored in a hash
table.

I derive StringItem, NumberItem and similar types from Item. They all
should have read and write methods and a data member.

For This purpose, I created an Item interface.

interface Item : GLib.Object
{
 public abstract void read(...);
 public abstract void write(...);
}

The problem is the data member. Every data member of all the sub classes
has its own type(double, string ...). If I add it as a member of the sub
class, I need to cast the Item to the correct type before I can access
the data. But I don't see a way, make it accessible from the base class.
Any idea?

Thanks,


-- 
Martin Kalbfuß <ma kalbfuss web de>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]