Essentials
Overview of essential interfaces, classes, concepts, etc.
Fundamentals
Interface / Class |
Notes |
|---|---|
Basic interface to manage object lifetime and to obtain other interface pointers |
|
Reference-counted base class for implementing interfaces. Initial reference count is 1 |
|
Object base class with RTTI, messages, storage |
|
16-Byte Globally Unique Identifier.
|
|
Smart pointer. Takes ownership on assignement of raw IUnknown/Object pointer |
|
Smart pointer. Similar to AutoPtr, calls addRef and release balanced |
|
Smart pointer + queryInterface |
|
Data type used to store different types of data. A Variant can contain various types of data, such as:
|
Using IUnknown
Function / Interface |
Notes / Examples |
|---|---|
Create instance via Plug-in Manager AutoPtr<IProgressNotify> dialog;
dialog = ccl_new<IProgressNotify> (CCL::ClassID::ProgressDialog);
|
|
Instances of ‘real’ plug-ins (dynamically loaded modules) must be released with ccl_release. This can be a little bit tricky, because ccl_release is not not supported by smart pointers. |
|
Test if interface pointers have the same implementation class instance bool isSame (ISubject* subject, IUnknown* unknown)
{
return isEqualUnknown (subject, unknown);
}
Pointers must not be compared directly ! |
|
Cast interfaces: |
Example for casting one interface to another void addObserver (IUnknown* unknown, IObserver* observer)
{
UnknownPtr<ISubject> subject (unknown);
if(subject)
subject->addObserver (observer);
}
|
Define interface based on IUnknown
Only “public” data types are allowed as parameters and return types. The idea is that the code has the same binary output with any compiler on a platform.
Per value: fundamental data types:
int, int64
float, double
tbool, tresult
but no compiler dependent types like ‘bool’
enum types are allowed if they specify an explicit underlying type, like enum Mode: int
Per reference or pointer:
String, Variant
struct (interface specific with no or inline methods)
IUnknown and other interfaces but no implementation classes.
Macro |
Notes |
Example |
|---|---|---|
|
Declare and define identifier of interface |
interface INewInterface: IUnknown
{
// ...
DECLARE_IID (INewInterface)
};
DEFINE_IID (INewInterface, 0xc5d8ffd1, 0xd7cd, ...)
|
Calling convention needed for every interface method |
virtual tresult CCL_API interfaceMethod () = 0;
|
Object Details
Macro / Function |
Notes |
Example |
|---|---|---|
Header: Declare RTTI for Object ( |
class MyClass: public CCL::Object
{
public:
DECLARE_CLASS (MyClass, Object)
// ...
};
|
|
CPP: Define Meta Class |
DEFINE_CLASS_HIDDEN (MyClass, Object)
Hidden: Class is not added to the class registry. |
|
Define Interfaces in an implementation class |
class MyClass: public CCL::Object,
public CCL::IMyInterface
{
public:
// ...
CLASS_INTERFACE (IMyInterface, Object)
// ...
};
|
|
Template function to get the meta class of a class derived from Object |
ccl_typeid<MyClass> ().getPersistentName ();
|
Casting
Case |
Function |
Example |
|---|---|---|
Object to Object |
Url* asUrl (Object* obj)
{
return ccl_cast<Url> (obj);
}
|
|
Interface to Object |
Object* getUrlObject (IUrl* url)
{
return unknown_cast<Object> (url);
}
Only works if the implementation of interface is in the same module |
|
Object to interface |
bool activateObject (Object* object, bool state)
{
if(IActivatable* act = ccl_as_unknown<IActivatable> (object))
{
if(state)
act->activate ();
else
act->deactivate ();
}
}
|
Container
Familiy |
Class |
Notes |
|---|---|---|
Template Container |
Double-linked list container class |
|
One-dimensional array that grows dynamically |
||
Object Container |
Abstract container base class and iterator |
|
Double-linked object list |
||
Container class for array of objects |
||
Interface Container |
List of IUnknown instances |
Template Container
+ type-safe
+ can contain any data
+ reference counting can be added via smart pointers
Vector <AutoPtr <Unknown> > UnknownVector;- storage not supported
- no scripting access
Object Container
+ common abstract interfaces (Container, Iterator)
+ provide reference counting (but not in ‘remove’)
+ provide storage support
- content type always unspecific (
ccl_castis needed)preferred for types derived from Object
combine with iterate_as<> in range-for loop
use when script access is needed
Interface Container
use with interface at ABI boundaries (IUnknownList)
Strings
Classs |
Related |
Notes |
|---|---|---|
Unicode string and utility classes. |
||
C-String, 8-Bit. CString is read only |
Messages + Observer
Interface / Class |
Related |
Notes |
|---|---|---|
Has Identifier + Parameter. Most messages are specific to a class, but there a some common messages:
|
||
Implemented in |
A subject notifies observers about changes. Observers register with a subject |
|
Implemented in |
Message receiver. Will be notified if one of its subjects sends a message. |
|
|
Central registry of ISubject/IObserver relations. Also implements deferred messages. |
|
Process-wide signals. Categories and Message are defined in namespace |
Message instances can be created direcly (no ccl_new needed)
Object implements both ISubject (full) and IObserver (empty)
kDestroyed is usually called inside of a destructor. isEqualUnknown or other methods that modify the reference count of an object must not used when this message is received
Message can be delivered deferred. In this case the receiver must call cancelSignals in its destructor
Example:
DEFINE_STRINGID_MEMBER_ (MyClass, kOpenWindow, "openWindow") ////////////////////////////////////////////////////////////////////////////////// MyClass::~MyClass { cancelSignals (); } ////////////////////////////////////////////////////////////////////////////////// void MyClass::openWindow (bool deferred) { if(deferred) (NEW Message (kOpenWindow))->post (this, -1); else { // ... } } ////////////////////////////////////////////////////////////////////////////////// void CCL_API MyClass::notify (ISubject* subject, MessageRef msg) { if(msg == kOpenWindow) { openWindow (false); return; } SuperClass::notify (subject, msg); }
File System
Interface / Class |
Notes |
|---|---|
Extension, MIME type, Description |
|
Uniform Resource Locator |
|
Singleton |
|
Access to open file. See also |
|
Helper class |
Object Persistence
Class / Method |
Notes |
|---|---|
Overwrite in derived class to store values of members in Attributes. See also |
|
Nested map of string id and value |
|
An archive reads/writes Attributes from/to streams. Archive is a base class. Most often used archive type is XML |
|
Storage combines Archive and Attributes. |
|
Helper class to load/save objects from/to a structured storage (Zip-File). An Archive in this case reads/writes a sub-stream (file) of the structured file. |
Miscellaneous
Interface / Class |
Notes |
|---|---|
Singleton mix-in, destroyed automatically on exit class MyClass: public CCL::Object,
public CCL::Singleton<MyClass>
{
void myMethod ();
};
// ...
MyClass::instance ().myMethod ();
// ...
Variants: |
|
Namespace containing constants like |
|
Primitives |
Various utility functions, examples:
|
Initializers are called on application/module startup. The main purpose is to register something somewhere. Example: CCL_KERNEL_INIT (AudioEffect)
{
// register native .fxpreset handler
(NEW AudioFXPresetHandler)->registerSelf ();
return true;
}
|
|
Used to report the progress of an operation |
Parameter + Controller
Class / Method |
Notes |
|---|---|
GUI data object representing a simple value that is displayed and modified by standard controls. Usually a IParameter is owned by a controller that handles changes. |
|
Implements the back-end logic for user interaction. It provides parameters and other objects used by GUI widgets. It can also be in the role of a model, or it can represent another data model |
|
Standard implementation of a Controller. Ready to use or base class for user defined components. Components are nested and can also create specific views. |
|
Manages parameters. Has methods to create and add standard and user defined parameter objects.
Is a member ‘paramList’ of |
Frequently Used
Interface |
Function |
Notes |
|---|---|---|
|
Get file system singleton |
|
|
Get system information singleton |
|
|
Get signal handler singleton |
|
|
Get GUI Management singleton |
|
|
Get Desktop singleton |
|
|
Get Window Manager singleton |
|
Get plug-in manager singleton. Manages classes from all process modules (“Plug-ins”). |
Class ID |
Interfaces |
Notes |
|---|---|---|
|
Creates a progress dialog |
|
|
Creates a platform specific file selector dialog. Can be used to select files for open or save in the platform file system. |
|
|
Creates a platform specific folder selector dialog. Can be used to let the user select a folder in the platform file system. |
|
|
Create a popup window that allows to select one out of multiple items. |