Skip to content

Commit

Permalink
Merge pull request #5 from h-haris/last_use_NSConnection
Browse files Browse the repository at this point in the history
fixed an issue with returned TQ3ControllerRef
  • Loading branch information
h-haris authored Apr 28, 2021
2 parents 804021a + b912bbf commit 50a8020
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Development/Source/Core/System/E3Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,8 @@ E3ControllerState_New(TQ3ControllerRef controllerRef)
#else
return((TQ3ControllerStateObject)0);
#endif
//TODO: (or not todo?) Q3Object_Dispose(aTQ3ControllerStateObject) to be implemented... (locally)
}
#warning TODO? Q3Object_Dispose(aTQ3ControllerStateObject) to be implemented... (locally)



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ client is implemented via PDO (portable distributed objects).
#include "ControllerCoreOSXinternals.h"

#if Q3_DEBUG
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
#endif

//=============================================================================
Expand All @@ -108,15 +108,6 @@ client is implemented via PDO (portable distributed objects).
//-----------------------------------------------------------------------------
// Internal variables go here

/*
ControllerInstance:
-holds library local instance data of controller
-TBC/TBD:
--change in a way that the library's local data supports more than one controller
--Best place to do this is the Controller Driver class ControllerDriverCoreOSX
*/
//ControllerDriverCoreOSX *ControllerInstances = NULL;


/*
privateDeviceDBProxy:
Expand All @@ -134,7 +125,7 @@ client is implemented via PDO (portable distributed objects).
#pragma mark -

//proxy object id of Controller DB vended by Device Server App
static TQ3Status idOfDB(id *theID)
static TQ3Status proxyOfDeviceDB(id *theID)
{
TQ3Status status = kQ3Failure;
*theID = nil;
Expand All @@ -161,19 +152,20 @@ static TQ3Status idOfDB(id *theID)

//proxy object id for key in controllerRef
static id proxyOfControllerRef(TQ3ControllerRef controllerRef)
//TODO: proxyOfControllerRef: change in a way that the library's local data supports more than one controller, local or remote
//TODO: cache the proxy in a dictionary, controllerRef would be the key
{
//hunt for the connection name as given by the controllerRef and return the proxy
#if Q3_DEBUG
NSLog(@"proxyOfControllerRef: hunt for: %@\n",(NSString*)controllerRef);
NSLog(@"proxyOfControllerRef: hunt for: %@\n",(NSString*)controllerRef);//bad access when different processes!
#endif
//fetch vended database object: server name is passed key
id proxy = [NSConnection
rootProxyForConnectionWithRegisteredName:(NSString*)controllerRef
host:nil];
[proxy setProtocolForProxy:@protocol(Q3DOController)];

return proxy;
};//TODO: proxyOfControllerRef: change in a way that the library's local data supports more than one controller, local or remote
};


#pragma mark -
Expand All @@ -196,7 +188,7 @@ static id proxyOfControllerRef(TQ3ControllerRef controllerRef)
TQ3ControllerRef controllerRef = (TQ3ControllerRef)NULL; //TQ3ControllerRef is a *void !!
id proxyDB;

status = idOfDB(&proxyDB);
status = proxyOfDeviceDB(&proxyDB);

if (kQ3Success==status)
{
Expand Down Expand Up @@ -241,7 +233,7 @@ static id proxyOfControllerRef(TQ3ControllerRef controllerRef)
TQ3Status status = kQ3Failure;
id proxyDB;

status = idOfDB(&proxyDB);
status = proxyOfDeviceDB(&proxyDB);

if (kQ3Success==status)
status = [proxyDB getListChanged:listChanged SerialNumber:serialNumber];
Expand All @@ -261,7 +253,7 @@ static id proxyOfControllerRef(TQ3ControllerRef controllerRef)
TQ3Status status = kQ3Failure;
id proxyDB;

status = idOfDB(&proxyDB);
status = proxyOfDeviceDB(&proxyDB);

if (kQ3Success==status){
/*next Controller in db; returns string with key (UUID);
Expand Down Expand Up @@ -830,7 +822,7 @@ static id proxyOfControllerRef(TQ3ControllerRef controllerRef)
TQ3Status status = kQ3Failure;
id proxyDB;

status = idOfDB(&proxyDB);
status = proxyOfDeviceDB(&proxyDB);
if (kQ3Success==status)
{
(void)[proxyDB trackerDeleted:[trackerObject->instance trackerUUID]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
#ifndef ControllerCoreOSX_ControllerCoreOSXinternals_h
#define ControllerCoreOSX_ControllerCoreOSXinternals_h

//=============================================================================
// C++ preamble
//-----------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif

typedef struct TC3TrackerEvent
{
TQ3Uns32 EventTimeStampKey;
Expand Down Expand Up @@ -75,4 +82,11 @@ typedef struct TC3ControllerInstanceData
TQ3ControllerData instanceData;//public instance data from Controller_New
} TC3ControllerInstanceData, *TC3ControllerInstanceDataPtr;

//=============================================================================
// C++ postamble
//-----------------------------------------------------------------------------
#ifdef __cplusplus
}
#endif

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@

@interface ControllerDriverCoreOSX : NSObject <Q3DOControllerDriverState>
{
/*
ControllerDriverCoreOSX: holds library local instance data of controller
*/
@private
//TODO: change according to coding convention
TQ3ControllerData _controllerData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#import "Q3DcontrollerPDO.h"

#if Q3_DEBUG
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
#endif

@implementation Q3DcontrollerPDO
Expand Down
9 changes: 5 additions & 4 deletions Development/Source/Platform/Cocoa/ControllerDB/Q3Ddb.mm
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
#import "Q3Ddb.h"
#import "Q3DcontrollerPDO.h"
#import "IPCprotocolPDO.h"
#include "E3MacDeviceDbStart.h"

#if Q3_DEBUG
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
#endif

#include "E3MacDeviceDbStart.h"

@implementation Q3Ddb : NSObject

- (id)init {
Expand Down Expand Up @@ -213,7 +213,8 @@ - (out TQ3ControllerRefCast)nextCC3Controller: (in TQ3ControllerRefCast) current

if (idx>=[_controllerPDOs count])
return NULL;
return (TQ3ControllerRefCast)[[_controllerPDOs objectAtIndex:idx] controllerRef];

return (TQ3ControllerRefCast)[[_controllerPDOs objectAtIndex:idx] UUID];
};


Expand Down
6 changes: 3 additions & 3 deletions Development/Source/Platform/Cocoa/E3CocoaPrefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@
// compile controller support in
#ifndef QUESA_SUPPORT_CONTROLLER
#define QUESA_SUPPORT_CONTROLLER 1
#define QD3D_CONTROLLER_LEGACY_FUNCTIONALITY 1
#define QD3D_CONTROLLER_LEGACY_FUNCTIONALITY 1 //used for implementing Q3ControllerState_SaveAndReset
#endif

#if Q3_DEBUG
#if QUESA_SUPPORT_CONTROLLER
#warning QUESA_SUPPORT_CONTROLLER is set
#warning QUESA_SUPPORT_CONTROLLER, Q3_DEBUG are set
#else
#warning QUESA_SUPPORT_CONTROLLER not set
#warning QUESA_SUPPORT_CONTROLLER, Q3_DEBUG are not set
#endif
#endif

Expand Down

0 comments on commit 50a8020

Please sign in to comment.