CORBA Object-by-Value

Slides:



Advertisements
Similar presentations
15 May, 2015 CORBA Object-by-Value An overview of the value type and its IDL-to-C++ mapping. George Edwards Institute for Software-Integrated Systems Vanderbilt.
Advertisements

CORBA Architecture Nitin Prabhu. Outline CORBA Object Model CORBA Architecture Static Invocation Dynamic Invocation CORBA Communication Model.
ITEC200 – Week03 Inheritance and Class Hierarchies.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Persistent State Service 1 CORBA Component  Component model  Container programming model  Component implementation framework  Component packaging and.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
C++ Training Datascope Lawrence D’Antonio Lecture 4 An Overview of C++: What is a Class/Object?
II. Middleware for Distributed Systems
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Lecture 9 Concepts of Programming Languages
CS 2511 Fall  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance  Polymorphism.
Object Based Programming. Summary Slide  Instantiating An Object  Encapsulation  Inheritance  Polymorphism –Overriding Methods –Overloading vs. Overriding.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Classes Mark Hennessy Dept. Computer Science NUI Maynooth C++ Workshop 18 th – 22 nd Spetember 2006.
Classes and Class Members Chapter 3. 3 Public Interface Contract between class and its clients to fulfill certain responsibilities The client is an object.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Inheritance in C++ CS-1030 Dr. Mark L. Hornick.
Module 7: Object-Oriented Programming in Visual Basic .NET
Information Management NTU Interprocess Communication and Middleware.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Defining New Types Lecture 21 Hartmut Kaiser
OOP Class Lawrence D’Antonio Lecture 3 An Overview of C++
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
CSSE501 Object-Oriented Development. Chapter 4: Classes and Methods  Chapters 4 and 5 present two sides of OOP: Chapter 4 discusses the static, compile.
Copyright 2006 Oxford Consulting, Ltd1 February Polymorphism Polymorphism Polymorphism is a major strength of an object centered paradigm Same.
Module 10: Inheritance in C#. Overview Deriving Classes Implementing Methods Using Sealed Classes Using Interfaces Using Abstract Classes.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
A Quick CCM Example. Tutorial on CCM Introduction A Simple Sender&Receiver Scenario Sender sends out the click-out event to inform the Receiver. Receiver.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Object-Oriented Design Concepts University of Sunderland.
OBJECT ORIENTED PROGRAMMING. Design principles for organizing code into user-defined types Principles include: Encapsulation Inheritance Polymorphism.
1 Using const in C++ Classes In the presence of pointers we must take steps to ensure the integrity of the object Can use const method definitions The.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
These materials where developed by Martin Schray
Chapter 2 Objects and Classes
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Creating and Using Objects, Exceptions, Strings
Chapter - 4 OOP with C# S. Nandagopalan.
Objects as a programming concept
Classes (Part 1) Lecture 3
Inheritance and Polymorphism
Java Primer 1: Types, Classes and Operators
Creational Pattern: Prototype
Object-Oriented Programming
Review: Two Programming Paradigms
Chapter 3: Using Methods, Classes, and Objects
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Programming Models for Distributed Application
Lecture 9 Concepts of Programming Languages
Corresponds with Chapter 7
CORBA Object-by-Value
More Object-Oriented Programming
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Polymorphism Polymorphism
Java Programming Course
Defining Classes and Methods
Distribution Infrastructures
Fundaments of Game Design
Overview of C++ Polymorphism
Object-Oriented PHP (1)
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
C++ Object Oriented 1.
Creating and Using Classes
Lecture 9 Concepts of Programming Languages
Presentation transcript:

CORBA Object-by-Value An overview of the value type and its IDL-to-C++ mapping. George Edwards <g.edwards@vanderbilt.edu> Institute for Software-Integrated Systems Vanderbilt University

What is Object-by-Value? Object-by-Value (OBV) is the CORBA mechanism for enabling objects to have pass-by-value semantics in CORBA operations. Conventional CORBA objects always have pass-by-reference semantics. The IDL keyword valuetype declares an object that will be passed by value. Valuetype instances are guaranteed to be local to the context in which they are used. Vanderbilt University

Object-by-Value Semantics OBV implies similar semantics to pass-by-value in standard programming languages. The receiving entity of a valuetype parameter (or returned object) instantiates a new object with identical state to the parameter. The new instance has a separate identity and no relationship to the caller’s parameter. OBV requires that the receiving entity have access to an implementation of the valuetype. Vanderbilt University

When to Use Valuetypes Valuetypes are often useful when: An application needs a “copy” of an object. An object’s primary purpose is encapsulation of data, rather than operation implementations. An application needs the performance predictability of local method invocations. An application needs to transfer an arbitrarily complex or recursive tree, lattice, or other graph data structure. CASE STUDY: Valuetypes in the CORBA Component Model CCM employs valuetypes for events and cookies. Events are messages that are transmitted asynchronously between components. Cookies encapsulate port connection ID information. Vanderbilt University

Basic Valuetype Capabilities Valuetypes in CCM (cont.) An abstract valuetype serves as a base for all event types. When a IDL eventtype is declared, a valuetype that inherits from EventBase is implied. module Components { abstract valuetype EventBase {}; }; Cookies store connection identifiers as a sequence of octets: valuetype Cookie { private CORBA::OctetSeq cookieValue; An IDL valuetype can: have operations, public and private attributes, and factories. be recursively defined. be declared abstract. inherit from a single concrete valuetype. inherit from multiple abstract valuetypes. Vanderbilt University

Valuetype C++ Mapping (1/3) An IDL valuetype maps to an abstract base class with the same name... class Cookie : public virtual CORBA::ValueBase { // ... protected: virtual void cookieValue ( const CORBA::OctetSeq &) = 0; virtual const CORBA::OctetSeq& cookieValue (void) const = 0; virtual CORBA::OctetSeq& cookieValue (void) = 0; Cookie (void); virtual ~Cookie (void); }; Inherits from CORBA::ValueBase. Pure virtual methods corresponding to operations. Pure virtual accessor and modifier methods corresponding to state members. Protected default constructor and destructor. Vanderbilt University

Valuetype C++ Mapping (2/3) …a class with “OBV_” prepended to the fully-scoped name… namespace OBV_Components { class Cookie : public virtual Components::Cookie { // ... protected: virtual void cookieValue ( const CORBA::OctetSeq &); virtual CORBA::OctetSeq& cookieValue (void); Cookie (const CORBA::OctetSeq&); private: CORBA::OctetSeq _pd_cookieValue; }; Inherits from the abstract base class. Is abstract if the valuetype has operations; concrete otherwise. Provides default implementations of accessors and modifiers. Provides a protected constructor that initializes state members. Vanderbilt University

Valuetype C++ Mapping (3/3) …and a factory class with “_init” appended to the valuetype name. Inherits from CORBA::ValueFactoryBase. Each factory method declared in IDL maps to pure virtual method that returns an instance of the valuetype. Must be registered with the ORB via ORB::register_value_factory(). class Cookie_init : public virtual CORBA::ValueFactoryBase { public: Cookie_init (void); virtual CORBA::ValueBase * create_for_unmarshal (void); protected: virtual ~Cookie_init (void); }; Vanderbilt University

Unmarshaling Valuetypes ValueFactoryBase declares a pure virtual create_for_unmarshal() method. The ORB calls create_for_unmarshal() to create an instance of a valuetype received as a parameter or return type. The factory class is concrete for valueboxes and valuetypes that have no IDL factories or operations; an implementation of create_for_unmarshal() is generated. Otherwise, the programmer must provide an implementation of create_for_unmarshal() and any factories declared in IDL. class ValueFactoryBase { public: void _add_ref (void); void _remove_ref (void); virtual CORBA::ValueBase * create_for_unmarshal (void)=0; virtual CORBA::AbstractBase * create_for_unmarshal_abstract(); }; Vanderbilt University

Abstract Valuetypes An IDL valuetype can be declared abstract. interface valuetype single multiple Have only operations – no state or factories. Have no generated OBV_ classes. Are not subject to single inheritance restrictions. Are inherited as public virtual base classes. Cannot be instantiated; cannot be parameters or the return type of an IDL operation. Essentially just a bundle of operation signatures. Vanderbilt University

Supporting a Concrete Interface A valuetype is declared to support a concrete interface with the IDL keyword supports. A valuetype that supports a concrete interface is NOT a subtype of the interface and is NOT substitutable. The interface’s operations are mapped to pure virtual methods in the valuetype ABC. A skeleton (POA_) class is generated for the valuetype that inherits from the interface skeleton. The valuetype can be registered with a POA and manipulated via an object reference of the interface type; pass-by-reference semantics apply. Vanderbilt University

Supporting an Abstract Interface Valuetypes can support multiple abstract interfaces. Abstract interfaces inherit from CORBA::AbstractBase, not CORBA::Object. Abstract interfaces have unique parameter passing semantics to their operations. A valuetype that supports an abstract interface IS a subtype of the interface and IS substitutable. Allows determination of pass-by-value vs. pass-by-reference semantics to be made at run-time. Vanderbilt University

Reference Counting Valuetypes must fulfill the ValueBase reference counting interface with custom implementations or mix-in classes. CORBA::ValueBase declares pure virtual _add_ref() and _remove_ref() methods. CORBA::DefaultValueRefCountBase can serve as a base class for valuetypes that will never be registered with a POA. PortableServer::ValueRefCountBase must serve as a base class for valuetypes that will be registered with a POA. Vanderbilt University

Other Features A valuetype with only a single state member is a “valuebox.” Any IDL type except a valuetype can be boxed. Valueboxes may not be a subtype or base type. Valueboxes for string and wstring are included in the CORBA module as StringValue and WStringValue. A programmer can provide custom code to marshal and unmarshal valuetype instances. A valuetype that is declared custom in IDL implicitly inherits from the abstract valuetype CustomMarshal. The concrete valuetype must provide implementations of the marshal () and unmarshal () operations. Intended to facilitate the integration of legacy code. Vanderbilt University

Conclusions The valuetype is extremely useful, but: Questions? Has some convoluted mapping rules. Doesn’t totally solve the original problem. Standard CORBA objects still can’t be passed by value. Has some questionable features. Questions? Vanderbilt University