"keylist" is used to create a link list of data elements NOTE: this class does NOT free up the data elements when destroyed.
class keylist : public dbl_llist {
public:
void *key;
This data element contains a pointer to the data in this node. It is assumed that the programmer knows the type of this data.
virtual ~keylist(); };
"resource_type" is the base class for all geometric, material, and texture data.
class resource_type {
public:
char dataname[MAXSTRLEN];
This field contains the primary filename associated with the data in the object (if any).
char altname[MAXSTRLEN];
This field contains the secondary filename associated with the data in the object (if any). (Usually refers to data not in the primary file)
float access_time;
This field contains a hash time value that represents the last time this object was accessed for dynamically managed data.
unsigned int statusflag;
This field contains a mask of status flags for the current state of the object.
resource_type *next, *back;
These fields are used to implement a double link list.
resource_type();
virtual ~resource_type();
virtual void update(float current_time) = 0;
This method is used to dynamically managed memory by allocating/freeing blocks of data/memory to the system, based on current usage.
virtual void *query_data() = 0;
This method is used to access the dynamically managed memory, as well as update it's current status.
virtual void replace_data(void *subresource) = 0;
This method is used to set the dynamically managed memory.
};
"resource_manager" is a container class that manages groups of objects, from data to file format loaders. This class also performs dynamic data load management.
class resource_manager {
protected:
sfile sinfile;
This member is used to handle file i/o management
virtual void local_init();
This method is used to "initialize" the object w/r/t this class only
virtual void reset();
This method is used to "reset" the object w/r/t this class only
public:
virtual ~resource_manager();
virtual void init(int x);
resource_manager();
This method initializes the manager's data members. "x" is the number of frames to be kept in memory at a time - typically it is set to 1.
virtual void reset();
This method is used to free up non-static data elements to allow the manager to be reused for a different scene. This method is also activated by resource_manager::dest().
virtual void register_resource_object(int type, void *data);
This method is used to insert a data item into the resource container. "type" is a predefined identifier used for resource identification, and "data" is the data item to be inserted.
virtual void *find_resource_object(int type, char *id, char *alias);
This method is used to retrieve a data item. "type" is a predefined identifier used for resource identification, "id" is a character string used as a search key, and "alias" is a secondary search key.
virtual void *get_resource_object(int type);
This method is used to retrieve the data member from this class - usually the head of a list of data items. "type" is a predefined identifer used for resource identification.
virtual void update(float current_time);
This method is used to unload data elements that have not been accessed in a predetermined time frame.
};
"superclass" is the super parent class for most of the classes in Pixcon and defines the common characteristics for all these objects.
class superclass {
public:
int id;
Each object has a unique identifier assigned to it when instantiated.
superclass();
virtual ~superclass();
virtual int query_category();
This method returns a unique integer identifier used to group different classes and is generally used to identify which library it was written for. The Pixcon API reserves category identifiers in range of 0..999 for its own internal use.
virtual int query_whatami();
This method returns a unique integer identifier used to identify the class. The Pixcon API reserves class identifiers in the range of 0..999
virtual int query_whatwasi(int type);
This method is an extension of the query_whatami() method. This method is used to identify whether or not the current object inherits from a parent class who's query_whatami() returns "type".
virtual int parse(FILE *infile, char *token);
parse() is used by each object to identify "token", and to extract additional data from "infile" if necessary. If parse() successfully identifies the "token", it returns true, else it must call the nearest parent's version of parse() and returns to the caller the parent's return value.
virtual void preprocess(void *data);
After the object is initialized via constructors and parse(), this method is called to complete the initialization process. This method must also call its nearest parent's version of preprocess().
};
"frameclass" is used by objects that do not render in real time.
class frameclass : public superclass {
public:
A replacement for the virtual function defined in "superclass"
int parse(FILE *infile, char *token);
void preprocess(void *data); A replacement for the virtual function defined in "superclass"
int frame; This field is used to control at which frame this object is to be rendered
frameclass *next;
Each object is designed to be part of a linked list, and has a pointer to the "next" node in the list.
frameclass();
virtual ~frameclass();
virtual int dump_frame(FILE *outfile);
};
The class "loader" is the base class for a group of child classes whose purpose is to identify, instantiate, and parse a child class of superclass.
class loader : public dbl_llist {
protected:
virtual superclass *make_object() = 0;
This field contains a pointer to a character string used to identify the loader and/or object it instantiates.
char *object_name;
This virtual function allocates and returns an instance of the object it was designed for. The caller is responsible for deleting the allocated object.
public:
loader();
virtual ~loader();
char *query_name();
virtual superclass *parse(FILE *infile, char *token);
This method provides access to the "object_name" field.
};
The "doer" class is designed to store and manage callback function pointers in a binary tree. Each callback has a string identifier, and an optional initialization function. The callback has only one argument, of type (void *), which passes the address of a user defined data structure. The initialization function has no arguments.
class doer : public string_binary_data {
protected:
This field contains a pointer to the callback function.
void *fcn;
void *init_fcn;
This field contains a pointer to an initalization function - to be
activated automaticly before the callback is used. If this field is
not set, it is assumed that there is no initialization function.
public:
virtual ~doer();
doer *find(char *target);
This method searches for "target" w/in each node in the tree. If successful, it
returns the corresponding node, otherwise returns NULL.
int set(char *tmpstr, void *func_call, void *init_call = (void *)NULL);
int query_data(void *x);
void init();
};
The "dbl_llist" class is designed store data in a double linked list. For the most part, the methods in this base class should not be accessed directly w/o extreme caution - instead use dbl_llist_manager to build/manipulate/destroy your lists.
class dbl_llist {
public:
This is the next and back pointers to the adjacent nodes in the list.
dbl_llist *next, *back;
dbl_llist();
virtual ~dbl_llist();
void dest();
virtual void insert(dbl_llist *x);
virtual void append(dbl_llist *x);
virtual void remove(); This method disengages this node from the list.
};
The "dbl_llist_manager" class is designed safely manipulate the dbl_llist objects, minimizing memory leaks and garbage lists.
class dbl_llist_manager {
public:
These fields are pointers that represent the head node and tail node of the double link list, initially set to NULL.
dbl_llist *head, *tail;
int count;
dbl_llist_manager();
virtual ~dbl_llist_manager();
void dest();
virtual dbl_llist *insert(dbl_llist *x, dbl_llist *target);
virtual dbl_llist *append(dbl_llist *x, dbl_llist *target);
virtual int remove(dbl_llist *x);
};
The "circular_dbl_llist" class is designed store data in a circular double linked list, where the "head" field is generally considered the current access point into the list, and the "tail" field is invalid. For the most part, the methods in this base class should not be accessed directly w/o extreme caution - instead use circular_dbl_llist_manager to build/manipulate/destroy your lists.
class circular_dbl_llist : public dbl_llist {
public:
This method inserts the new node "x" into the list. If "target" is "NULL",
"x" is inserted before the current "head" of the list and becomes the new "head", otherwise "x" is inserted before "target".
void insert(dbl_llist *x);
void append(dbl_llist *x);
void remove();
};
The "circular_dbl_llist_manager" class is designed safely manipulate the circular_dbl_llist objects, minimizing memory leaks and garbage lists.
class circular_dbl_llist_manager {
public:
This field is a pointer that represent the head node of the circular double link list, initially set to NULL.
circular_dbl_llist *head;
int count;
circular_dbl_llist_manager();
virtual ~circular_dbl_llist_manager();
void dest();
void make_head(circular_dbl_llist *x);
virtual circular_dbl_llist *append(circular_dbl_llist *x, circular_dbl_llist *target = NULL);
virtual circular_dbl_llist *insert(circular_dbl_llist *x, circular_dbl_llist *target = NULL);
virtual int remove(circular_dbl_llist *x);
};
The "binary_data" class is used as a parent class for storing and evaluating data used in calculating the placement of a binary_node object in a binary_tree object.
class binary_data {
virtual int compare(binary_data *x) = 0;
public:
This method is used to determine if "this" is considered less than, equal, or greater than "x", and
returns -1, 0, 1 respectively
virtual ~binary_data();
};
The "binary_node" class represents a node in a binary_tree
class binary_node {
public:
This field contains the "key" which will determine the nodes placement in the tree
binary_data *key;
binary_node *next, *back;
binary_node();
virtual ~binary_node();
virtual binary_node *insert(binary_node *x);
int remove(binary_node *x);
virtual binary_node *find(binary_data *x);
};
The "binary_tree" class manages a binary tree built w/ binary_node objects
class binary_tree {
public:
This field points to the head of the tree of binary_nodes
binary_node *head;
void dest();
binary_tree();
virtual ~binary_tree();
virtual binary_node *insert(binary_node *x);
virtual int remove(binary_node *x);
binary_node *find(binary_data *x);
};
The "string_type" class manages a resizeable character string
class string_type : public dbl_llist {
protected:
This field contains the actual amount of memory allocated for the character string.
int size;
int length;
public:
char *string;
This field contains point to the character string
string_type();
string_type(char* src);
virtual ~string_type();
int stringlen();
void stringsize(int len);
int recalc();
void reset();
char *stringcpy(char *src);
char *stringncpy(char *src, int len);
char *stringcpy(string_type *src);
char *stringcat(char *src);
char *stringcat(string_type *src);
int stringcmp(char *str);
int stringcmp(string_type *str);
};
The "buffer_type" class manages a resizeable memory buffer
class buffer_type : public dbl_llist {
protected:
This field contains the actual amount of memory allocated for the buffer.
int size;
int length;
public:
char *data;
This field points to the memory buffer
buffer_type();
virtual ~buffer_type();
int bufferlen();
void bufferlen(int len);
int buffersize();
void buffersize(int len);
char *buffercpy(char *src, int len);
char *buffercpy(buffer_type *buff);
};
The "string_binary_data" class uses string_type as a key for placement bye the binary_tree manager
class string_binary_data : public binary_data {
public:
int compare(binary_data *x);
A replacement for the virtual function defined in "binary_data".
string_type string;
virtual ~string_binary_data();
};