Core-C Frequently Asked Questions
Introduction
Core-C is a set of C structures that adds a whole Object Oriented layer to the C language. It is fully and only based on the C language.
As any Object Oriented language it uses the concept of classes and of class instances, called 
node in Core-C.
  Each class can have 
properties, 
instance variables, 
actions and 
methods. 
  And each class is identified in the code by its 
FourCC value.
Each class can only inherit from one other class (no multiple inheritences). The base class for all classes is the 
node class.
  It inherits its variables, actions and methods and can override them if needed.
Class Properties
Each class has its own properties used by the Core-C engine to enable some special treatments depending on the flags. The properties are not inherited by child classes.
    Local - CFLAG_LOCAL
    A local class is not saved during a NodeDump().
 
    Appears in Settings - CFLAG_SETTINGS
    This class is available in the user settings for configuration.
 
    Saved Settings - CFLAG_CONFIG
    This class saves and restores its settings in the config.xml file.
 
    Abstract - CFLAG_ABSTRACT
    This class defines an API via the variables, actions and methods. But only children of that class can be instanciated. It's equivalent to a virtual class in C++.
 
    Singleton - CFLAG_SINGLETON
    
 
Instance Variables
Most of a class is defined by its instance variables. It defines all that can be read/written on each class instance. 
  The most basic features of a variable are the Set (Node_Set) and Get (Node_Get) calls.
Each variable has a type and flags to define particular use of the variable. It can also have an internal name (use by CoreUI).
The possible types include:
    TYPE_BOOLEAN
    a boolean value, with the type bool_t.
 
    TYPE_INT
    a signed integer, with the type int.
 
    TYPE_FRACTION
    a fraction, with the type fraction_t.
 
    TYPE_STRING
    a NULL terminated string, with the type tchar_t.
 
    TYPE_RECT
    a rectangle, with the type cc_rect.
 
    TYPE_POINT
    a point/coordinate, with the type cc_point.
 
    TYPE_RGB
    a RGB value, with the type rgbval_t.
 
    TYPE_FOURCC
    a FourCC, with the type fourcc_t.
 
    TYPE_FILEPOS
    a file position, with the type filepos_t.
 
    TYPE_TICK
    a tick value, with the type tick_t.
 
    TYPE_PTR
    a pointer, with the type void*.
 
    TYPE_NOTIFY
    a notify callback, with the type notify.
 
    TYPE_INT8
    an integer on 8 bits, with the type int8_t.
 
    TYPE_INT16
    an integer on 16 bits, with the type int16_t.
 
    TYPE_INT32
    an integer on 32 bits, with the type int32_t.
 
    TYPE_INT64
    an integer on 64 bits, with the type int64_t.
 
    TYPE_BOOL_BIT
    a boolean value that is internally mixed with other flags (to save memory), with the type bool_t.
 
    TYPE_PIN
    a pin, ie the combination of a node and a variable ID, with the type pin.
 
    TYPE_ARRAY
    an array of values, with the type array.
 
    TYPE_DATETIME
    a date & time value, with the type datetime_t.
 
The possible variable flags include:
    Default - TFLAG_DEFAULT
    When reading data it's filled with a default empty value even if the data don't exist.
 
    Read-Only - TFLAG_RDONLY
    The value can only be read, not written.
 
    Setup - TFLAG_SETUP
    A variable that can be saved/restored into a XML file
 
    Settings - TFLAG_SETTINGS
    The variable can be displayed/changed in the user preferences.
 
    Not Saved - TFLAG_NOSAVE
    The value isn't kept when a node is copied.
 
    Notify When Changed - TFLAG_NOTIFY
    This variables can be monitored for changes using a notiyfunc callback.
 
    Update Mode - TFLAG_UPDATEMODE
    In CoreUI, forces the update of the display when an event is fired.
 
    No Dump - TFLAG_NODUMP
    The value of this variable is not dump when a crash occurs.
 
    Hotkey - TFLAG_HOTKEY
    Indicates that a hotkey can be assigned to toggle the value of this variable.
 
    Hotkey - TFLAG_INPUT
    Indicates that a the data with PIN_FORMAT flag is available as input source.
 
    Display - TFLAG_DISPLAY
    When reading a data as a string, indicates it's for displaying and not internal use.
 
    Available - TFLAG_AVAILABLE
    The pin includes an entry with DATA_AVAILABLE to tell if the pin is usable or not.
 
The possible variable unit modifiers are:
    Checklist - TUNIT_CHECKLIST
    The boolean value should be shown as a checklist.
 
    Enumerate - TUNIT_ENUM
    The pin includes various possible values that can be read with the DATA_ENUM flag.
 
    Enumerate - TUNIT_NUMBER
    The integer should be displayed with no type.
 
    Hexadecimal - TUNIT_HEX
    The integer should be displayed as a value in hexadecimal.
 
    Percent - TUNIT_PERCENT
    The integer should be displayed as a percentage.
 
    KiloBytes - TUNIT_KBYTE
    The integer should be displayed as a value in kilobytes.
 
    Second - TUNIT_SECOND
    The integer should be displayed as a value in seconds.
 
    MegaHertz - TUNIT_MHZ
    The integer should be displayed as a value in MHz.
 
    BitRate - TUNIT_BYTERATE
    The integer should be displayed as a bitrate.
 
    X Coordinates - TUNIT_XCOORD
    The integer value represents a X coordinate.
 
    Y Coordinates - TUNIT_YCOORD
    The integer value represents a Y coordinate.
 
    UpperCase - TUNIT_UPPER
    The string value should be shown and stored as uppercase.
 
    Folder - TUNIT_FOLDER
    The string value represents a path to a folder.
 
    Hotkey - TUNIT_HOTKEY
    The value is representing a hotkey.
 
    AnyChar - TUNIT_ANYCHAR
    The node value can have any char in the expression ???
 
Class Actions
An action are implemented like 
variables of type 
TYPE_EVENT. These variables are only set and take no parameter.
Node_Set(ClassInstance, ACTION_ID, NULL, 0)
Actions used to make instances perform actions without having to call a method. It is useful for scripting like in CoreUI.
Class Methods
Methods are functions that can be called directly on the class. A child class can override the methods of its parents, and add new methods.
The basic 
node class has 4 methods: Get(), Set(), Meta() and Enum().
Singleton Classes
Singleton classes are classes that can be used from anywhere in the code. They can be queried using NodeSingleton(<Class_FourCC>). They are created with the flag CFLAG_SINGLETON.
A singleton class has no parent and only has one instance created. It's equivalent to the singleton design pattern.
Singleton Events
Classes can have their own events, but in addition Core-C provides some generic singleton events that every singleton classes receive:
- NODE_SINGLETON_STARTUP: called when a module is loaded or the program is started.
- NODE_SINGLETON_CONFIGURED: called when all the modules are loaded and all the class are registered.
- NODE_SINGLETON_SHUTDOWN: called when a module is unloaded or the program is shutting down.
- NODE_SINGLETON_INSTALL: called when a CoreUI program is called with --install in the command-line.
- NODE_SINGLETON_UNINSTALL: called when a CoreUI program is called with --uninstall in the command-line.
Copyright © 2008-2009 CoreCodec, Inc.