Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add APIs to SDLTemplateConfiguration for Objective-C++ compatibility #1485

Merged
merged 3 commits into from Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 29 additions & 3 deletions SmartDeviceLink/SDLTemplateConfiguration.h
Expand Up @@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN

/**
Used to set an alternate template layout to a window.

@since SDL 6.0
*/
@interface SDLTemplateConfiguration : SDLRPCStruct
Expand All @@ -22,17 +22,18 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (instancetype)initWithPredefinedLayout:(SDLPredefinedLayout)predefinedLayout;

#ifndef __cplusplus
joeljfischer marked this conversation as resolved.
Show resolved Hide resolved
/**
Init with the required values.

@param template Predefined or dynamically created window template. Currently only predefined window template layouts are defined.
*/
- (instancetype)initWithTemplate:(NSString *)template;


/**
Convinience constructor with all the parameters.

@param template Predefined or dynamically created window template. Currently only predefined window template layouts are defined.
@param dayColorScheme The color scheme to use when the head unit is in a light / day situation. If nil, the existing color scheme will be used.
@param nightColorScheme The color scheme to use when the head unit is in a dark / night situation.
Expand All @@ -43,6 +44,31 @@ NS_ASSUME_NONNULL_BEGIN
Predefined or dynamically created window template. Currently only predefined window template layouts are defined.
*/
@property (strong, nonatomic) NSString *template;
#endif

#ifdef __cplusplus
/**
Init with the required values.

@param templateName Predefined or dynamically created window template. Currently only predefined window template layouts are defined.
*/
- (instancetype)initWithTemplate:(NSString *)templateName;


/**
Convinience constructor with all the parameters.

@param templateName Predefined or dynamically created window template. Currently only predefined window template layouts are defined.
@param dayColorScheme The color scheme to use when the head unit is in a light / day situation. If nil, the existing color scheme will be used.
@param nightColorScheme The color scheme to use when the head unit is in a dark / night situation.
*/
- (instancetype)initWithTemplate:(NSString *)templateName dayColorScheme:(nullable SDLTemplateColorScheme *)dayColorScheme nightColorScheme:(nullable SDLTemplateColorScheme *)nightColorScheme;

/**
Predefined or dynamically created window template. Currently only predefined window template layouts are defined.
*/
@property (strong, nonatomic) NSString *templateName;
#endif

/**
The color scheme to use when the head unit is in a light / day situation.
Expand Down
31 changes: 31 additions & 0 deletions SmartDeviceLink/SDLTemplateConfiguration.m
Expand Up @@ -14,6 +14,7 @@ - (instancetype)initWithPredefinedLayout:(SDLPredefinedLayout)predefinedLayout {
return [self initWithTemplate:predefinedLayout];
}

#ifndef __cplusplus
- (instancetype)initWithTemplate:(NSString *)template {
self = [super init];
if (!self) {
Expand All @@ -40,6 +41,36 @@ - (void)setTemplate:(NSString *)template {
- (NSString *)template {
return [self.store sdl_objectForName:SDLRPCParameterNameTemplate ofClass:NSString.class error:nil];
}
#endif

#ifdef _cplusplus
- (instancetype)initWithTemplate:(NSString *)templateName {
self = [super init];
if (!self) {
return nil;
}
self.templateName = templateName;
return self;
}

- (instancetype)initWithTemplate:(NSString *)templateName dayColorScheme:(nullable SDLTemplateColorScheme *)dayColorScheme nightColorScheme:(nullable SDLTemplateColorScheme *)nightColorScheme; {
self = [self initWithTemplate:templateName];
if (!self) {
return nil;
}
self.dayColorScheme = dayColorScheme;
self.nightColorScheme = nightColorScheme;
return self;
}

- (void)setTemplateName:(NSString *)templateName {
[self.store sdl_setObject:template forName:SDLRPCParameterNameTemplate];
}

- (NSString *)templateName {
return [self.store sdl_objectForName:SDLRPCParameterNameTemplate ofClass:NSString.class error:nil];
}
#endif

- (void)setDayColorScheme:(nullable SDLTemplateColorScheme *)dayColorScheme {
[self.store sdl_setObject:dayColorScheme forName:SDLRPCParameterNameDayColorScheme];
Expand Down