DatasheetQ Logo
Electronic component search and free download site. Transistors,MosFET ,Diode,Integrated circuits

AN672 데이터 시트보기 (PDF) - Silicon Laboratories

부품명
상세내역
제조사
AN672
Silabs
Silicon Laboratories Silabs
AN672 Datasheet PDF : 30 Pages
1 2 3 4 5 6 7 8 9 10 Next Last
AN672
6. Object Component
COMPONENT: si32ObjectComponent
REQUIRES: si32BaseComponent
PROVIDES: si32RootObject
Although it is sometimes practical to implement applications in C++ by using only a subset of the language’s
features, use of C++ may be precluded by the target application's requirements. The si32Library object system
provides a C99 based subset of the capabilities of C++ for use in applications where C++ is inappropriate or
unavailable. The si32Library is object based, providing encapsulation, inheritance, and polymorphism. The object
system provides a simple class hierarchy, but is neither truly class or prototype based. It is simply a design pattern
that uses structure composition and aggregation to implement a type system wherein new types can be derived
from base types, inheriting their behavior and properties. Therefore, the term class is generally avoided.
In many cases the precise type of an object is known a-priori, at compile time. In such cases, early binding can be
employed effectively to eliminate indirect function calls. For example:
_SomeType_SomeOperation(SomeObject, SomeArguments);
In other cases, however, late binding is necessary because the type of an object is not known until run-time. This is
particularly true for objects representing optional hardware that is discovered at run-time. For example:
SomeObject->Operations->SomeOperation(SomeObject, SomeArguments);
The si32ObjectComponent provides both early and late binding capabilities.
Objects are implemented as C structures. These structures contain specific fields and are constructed in a manner
that facilitates the implementation of inheritance by means of structure composition. Figure 4 shows the essential
structure of a base object.
obj* my_ object
functions
variable
...
variable
(*fn)()
...
(*fn)()
Figure 4. Object Structure
An object's variables can be accessed in this manner:
my_object->context.variable
The object’s functions can be called as follows:
my_object->context.functions->fn(my_object, ...)
An object reference (or a pointer to an object) is represented by the type obj*. This is an anonymous (void) pointer
that can reference anything. Therefore, it must be assigned to a variable of the appropriate type and checked at
runtime.
8
Rev. 0.1

Share Link: 

datasheetq.com  [ Privacy Policy ]Request Datasheet ] [ Contact Us ]