categories in core

David Calinski <[email protected]> Sun, 12 Oct 2003 17:20:03 +0200
Newsgroups gmane.comp.tools.memaid.devel
Message-ID <[email protected]>
Hello all,

I just uploaded ("core" module) code that uses categories.

(I also uploaded fresh Fox GUI version in "memaid" module, but it currently 
has *incomplete* implementation of categories - it's in "work in progress" 
state, and I wouldn't reccomend to use this code for anything but testing.)

BTW:
I strongly reccomend to make regular back-up copies, especially when using 
code from CVS, as it may be unstable.
It can, for example, work "stable" but inside may happen weird things - and 
after few runs may be too late... it's a very black scenario, but it's always 
better to have a back-up.
(Memaid, when properly installed, uses a script that makes auto-back-up of 
elements.txt from every memaid run.)


Now about implementation of categories in core:
things may change yet, so certainly feel free to criticize/correct current 
code/implementation.

There are 2 new functions:
1. ma_cat_nr (const char*category_name); // that returns category number
	//(and first creates number<->category_name relation IF it doesn't not exist)

2. ma_cat_desc (u_short cat_nr); // that returns category description

Categories are linked with numbers to optimize many operations, but 
category<->number relations are dynamic - in sense that on next run specific 
category can have a totally different number.
From frontend programmer point of view: categories are just strings (char[]) 
and generally one shouldn't think about numbers (maybe there will be some 
exceptions though).

There is no support for sub-categories in core. (can be implemented in 
frontends, e.g. "Math::algebra")

Almost every externally available function in core has changed to take one 
more parameter: const char *catgr_name;
When *catgr_name points to NULL (or *catgr_name == '\0') (eg. when calling 
ma_make_new_el()) it means that element will be created in the default 
("root") category.
When calling functions like ma_how_many_r_for_today(const char *catgr_name),
or ma_el_to_repeat()
ma_re etc. catgr_name pointing to NULL means that we don't care about 
categories, e.g. ma_el_to_repeat() returns any element that is scheduled for 
a review.
*catgr_name pointing to a category name will force ma_el_to_repeat() to return 
element from this category only.

Binary file (elements.bin) now saves/load an additional variable: 
MA_CORE_VERSION - if "core version" signature in saved elements.bin is 
diffrent, load_bin() gives up and load database from "elements.txt" where it 
can read old format (from memaid 0.4.x era).

Ah.. and root category is defined in MA_ROOTNAME as "root".
I have tried to code it in more neutral way, without any specific name, but it 
forces some compilations in few places - I am not sure if they are worth 
doing and we can live with such root category name, or not.


Dave




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php