Core-C Frequently Asked Questions
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
Each class can have properties
, instance variables
And each class is identified in the code by its FourCC
Each class can only inherit from one other class (no multiple inheritences). The base class for all classes is the node
It inherits its variables, actions and methods and can override them if needed.
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
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:
a boolean value, with the type bool_t.
a signed integer, with the type int.
a fraction, with the type fraction_t.
a NULL terminated string, with the type tchar_t.
a rectangle, with the type cc_rect.
a point/coordinate, with the type cc_point.
a RGB value, with the type rgbval_t.
a FourCC, with the type fourcc_t.
a file position, with the type filepos_t.
a tick value, with the type tick_t.
a pointer, with the type void*.
a notify callback, with the type notify.
an integer on 8 bits, with the type int8_t.
an integer on 16 bits, with the type int16_t.
an integer on 32 bits, with the type int32_t.
an integer on 64 bits, with the type int64_t.
a boolean value that is internally mixed with other flags (to save memory), with the type bool_t.
a pin, ie the combination of a node and a variable ID, with the type pin.
an array of values, with the type array.
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 ???
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.
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 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.
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.