170 likes | 313 Vues
This guide covers the integration of external code into Rational Rose RealTime using C++. It describes two methods for integration, defines key terms like Sendable, Observable, and Marshallable, and outlines integration requirements. You will learn about the class-by-class and model-wide integration levels, the importance of including header files, and how to handle external data classes. The document also details options for creating type descriptors and functions needed for seamless integration. Enhance your model's capabilities by effectively using legacy code and third-party libraries.
E N D
Mastering Rational Rose RealTimeIntegrating C++ External Code
Objectives • Describe the two methods of integrating external code • Define the terms • Sendable • Observable • Marshallable
Topics • Integrating External Code • Integrating External Data
Reasons for Integrating External Code There are several possible reasons for wanting to include external code in your Rose RealTime model: • Required to interface to legacy code • Required to interface to code that is being developed outside of the Rose RealTime toolset • A part of your system can be developed efficiently using third-party libraries
Integration Requirements • To integrate external code you need: • The name of the header file • The path to the header file • The path to the .obj file • It’s a good idea to use a variable instead of hard-coding the path and name
C++ Level of Integration There are two levels of integration: • Class-by-class • To make an #include file for a class, use the capsule/class specification dialog box: HeaderPreface (Capsule, C++ ) • Model-wide • To make an #include file for the entire model, do it in a component using the component specification dialog box: CommonPreface(Component, C++ Generation)
Topics • Integrating External Code • Integrating External Data
Model 3 Target Model 1 Model 2 Sendable, Observable, Marshallable Host Observable Sendable Marshallable (Injectable)
Auto-Magic • Data classes are automatically sendable, observable and marshallable if they don’t have attributes that are pointers • This section tells you how to use external data classes
Integration Types There are two options for integrating a passive class • Simple • Includes header files • Knows how to encode strings • Sendable • Observable or marshallable • Type descriptor for passive class needs to be created • Includes header files • Knows how to decode strings • Knows how to inject strings
Linking in External Code • If objects are: • Only used to store information within a single capsule instance • Only sent by reference never to be observed or injected • Then make the external class definitions visible to the compiler • Once the definition is visible to the compiler, you can use the class or type within any detail-level code
C++ Linking in External Code (cont.) To make the external class definitions visible to the compiler: • Add the include files to the HeaderPreface section in the C++ tab of the Capsule Specification dialog • Link the external code in with the model (from the component specification)
Integrating External Classes • If objects: • Need to be sent by value between capsule instances (sendable) • Need to be observed during debugging (observable) • Need to be encoded/decoded because they are injected or sent to other processes (marshallable) • Then create a type descriptor for the class to describe the types to the Services Library
C++ Generating Type Descriptors • Needed to inform the RTS of structure • Array • Multiple instances • Generate Descriptor • Generate Type Modifier
C++ Options for Integrating External Classes • There are three ways to handle an externally defined class or data type: • Create a class with the same attributes as the external class and let the Rose RealTime toolset generate the type descriptor • Add the code yourself for describing how to copy, initialize, destroy, encode, and decode an instance of this type • Use the C++ Analyzer (via Tools menu) to reverse engineer existing code • An external class can be made sendable by value without being observable and vice versa (encode/decode not needed)
C++ Option 1: Let RoseRT Create Type Descriptors
C++ Option 2: Defining Required Functions Yourself • To integrate classes in this manner, you must understand the usage of the 5 functions: • InitFunctionBody • CopyFunctionBody • DestroyFunctionBody • DecodeFunctionBody • EncodeFunctionBody • Defined in the C++ TargetRTS tab of the class specification