Namespaces allow additional scoping to be introduced, so that classes, objects and functions can all be grouped under a common name. This solves the problem that occurs if two different code libraries happen to use the same naming, in which case you will get a compiler error because the object appears to be declared twice due to the conflicting name.
The namespace feature can solve this problem by allowing separate namespaces to be used for each library. With namespaces, each code library can declare a separate, unique namespace with which to place its code into. Since every identifier would then be defined using a different and unique name, no redefinition errors due to name collisions will occur.
Namespaces are defined using the namespace keyword. For example: namespace Scaleform { class Foo { ... }; }
Once a namespace is declared, the objects in that namespace can be referenced in one of two ways:
Fully qualified: In this case the object would be referenced by : Scaleform::Foo var;
With a ‘using’ declaration: using namespace Scaleform; Foo var;
For more information on how namespaces work, please see your favorite C++ text.
For Scaleform, namespaces are adopted with “Scaleform” being the root namespace. The following rules are used:
Although Scaleform uses a number of different namespaces for public and private code, users only need to worry about a relatively small number of Public namespaces when writing code using Scaleform.
Each of the major public namespaces below is under the root Scaleform namespace and represents a major subsystem such as rendering, sound or GFx itself.
Shown below are the major public namespaces used in Scaleform 4: