Dismiss
InnovationQ will be updated on Sunday, Oct. 22, from 10am ET - noon. You may experience brief service interruptions during that time.
Browse Prior Art Database

Targeted Interface

IP.com Disclosure Number: IPCOM000013055D
Original Publication Date: 2001-Jun-16
Included in the Prior Art Database: 2003-Jun-12
Document File: 3 page(s) / 55K

Publishing Venue

IBM

Abstract

Disclosed is an extension to object-oriented programming languages which allows access to class members to be restricted to specified classes or groups of classes. In the context of C++ a class member can only be public or non-public (ie., protected or private). If a class member is made public then any class can in principle access that member. Allowing full public access can increase the chances of an unwanted side-effect, especially if the application is large and involves many programmers. Full public access might also seem a bit 'unnatural' in that in some situations it only makes sense to allow a limited number of other classes access to the class member in question. The C++ keywords public , protected and private are called member access specifiers. The essence of the disclosure is to introduce a fourth type of specifier to allow access of specified class members to other classes that are not derived from the class in question. This 'targeted interfacing' could be implemented in one of two ways: 1. Give the name of the targeted class in question. For example, if a class called ClassA has a method called methodX to which objects of a second class, ClassB , are to be granted access, then ClassA could be defined in the following manner:

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 54% of the total text.

Page 1 of 3

Targeted Interface

Disclosed is an extension to object-oriented programming languages which allows access to class members to be restricted to specified classes or groups of classes.

     In the context of C++ a class member can only be public or non-public (ie., protected or private). If a class member is made public then any class can in principle access that member. Allowing full public access can increase the chances of an unwanted side-effect, especially if the application is large and involves many programmers. Full public access might also seem a bit 'unnatural' in that in some situations it only makes sense to allow a limited number of other classes access to the class member in question.

     The C++ keywords public, protected and private are called member access specifiers. The essence of the disclosure is to introduce a fourth type of specifier to allow access of specified class members to other classes that are not derived from the class in question. This 'targeted interfacing' could be implemented in one of two ways:
1. Give the name of the targeted class in question. For example, if a class called ClassA has a method called methodX to which objects of a second class, ClassB, are to be granted access, then ClassAcould be defined in the following manner:
class ClassA
{ public:

// public members.

ClassB:

void methodX(void);

protected:

// protected members.

private:

// private members. };

2. The second method for targeted interfacing (termed 'groupwise access') is somewhat akin to the file access modes in UNIX*. The idea is that one or more classes can be designated as belonging to a certain group (and the same class could be allowed to belong to more than one group). Then the member access specifier gives the name of the group which is allowed to have access to the class member. All classes belonging to the group are then allowed to access the named class members. For example, three classes ClassB, ClassC and ClassD are made to belong to Group GroupJ with a command such as:
group GroupJ ClassB, ClassC, ClassD;

     Then, in the definition of ClassE, methodY is made visible to members of GroupJ, and no other classes, by writing the following:
class ClassE

1

Page 2 of 3

{

public:

// public members.

GroupJ:

void methodY(void);

protected:

// protected members.

private:

// private members. };

Points to note:
1. Method (1) for implementing targeted interfacing is a short-hand version of method
(2) in which only a single class belongs to a group.
2. The illustrations above used methods but targeted interfacing could just as easily be applied to any class attribute (eg., an int or float etc).
3. C++ provides the friend keyword which allows a second class to have access to the members of a given class. However, the class named as the friend has access to all the members of the original class, including the private ones. This erodes the object-oriented principle of encapsula...