Classes | Defines | Typedefs | Functions
base1.c File Reference
#include "base1_friend.h"

Go to the source code of this file.

Classes

struct  base1_private_st_

Defines

#define BASE1_STR_SIZE   128

Typedefs

typedef struct base1_private_st_ base1_private_st

Functions

const char * base1_get_val1_description (void)
my_rc_e base1_get_public_data (base1_handle base1_h, base1_public_data_st *public_data)
my_rc_e base1_set_public_data (base1_handle base1_h, base1_public_data_st *public_data)
my_rc_e base1_string_size (base1_handle base1_h, size_t *buffer_size)
const char * base1_type_string (base1_handle base1_h)
my_rc_e base1_string (base1_handle base1_h, char *buffer, size_t buffer_size)
void base1_friend_delete (base1_handle base1_h)
void base1_delete (base1_handle base1_h)
my_rc_e base1_increase_val3 (base1_handle base1_h)
my_rc_e base1_inherit_vtable (const base1_vtable_st *parent_vtable, base1_vtable_st *child_vtable, bool do_null_check)
my_rc_e base1_set_vtable (base1_handle base1_h, base1_vtable_st *vtable)
my_rc_e base1_init (base1_handle base1_h)
base1_handle base1_new1 (void)
base1_handle base1_new2 (base1_public_data_st *public_data)
base1_handle base1_new3 (uint8_t val1, uint32_t val3)

Detailed Description

Author:
Matt Miller <matt@matthewjmiller.net>

LICENSE

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

DESCRIPTION

This is the implements a base class from which children class may inherit.

Definition in file base1.c.


Define Documentation

#define BASE1_STR_SIZE   128

Size for this object to use for base1_string_size_fn

Definition at line 27 of file base1.c.


Typedef Documentation

Private variables which cannot be directly accessed by any other class including children.


Function Documentation

void base1_delete ( base1_handle  base1_h)

Delete the object. This is a virtual function. Upon return, the object is not longer valid.

Parameters:
base1_hThe object. If NULL, then this function is a no-op.

Definition at line 307 of file base1.c.

void base1_friend_delete ( base1_handle  base1_h)

Allow a friend class to delete the base1 object. It is assumed that the friend class is managing the memory for the base1 object and, thus, the object will not be freed. However, members within the base1 object may be freed. This does not call the virtual function table version of delete, but rather the delete specifically for type base1.

Parameters:
base1_hThe object. If NULL, then this function is a no-op.
See also:
base1_delete()

Definition at line 281 of file base1.c.

my_rc_e base1_get_public_data ( base1_handle  base1_h,
base1_public_data_st public_data 
)

Gets a copy of the public data for the given object. Note this is a shallow copy of the data, modifying it will not change the object's state. Writing the object's state is handled seperately by base1_set_public_data().

Parameters:
base1_hThe object
public_dataThe data buffer into which the values should be read
Returns:
Return code
See also:
base1_set_public_data()

Definition at line 59 of file base1.c.

const char* base1_get_val1_description ( void  )

Example of a static class method. It takes no instance of an object.

Returns:
Description of val1

Definition at line 43 of file base1.c.

my_rc_e base1_increase_val3 ( base1_handle  base1_h)

Increase val3 for the object. This is a virtual function.

Parameters:
base1_hThe object
Returns:
Return code

Definition at line 347 of file base1.c.

my_rc_e base1_inherit_vtable ( const base1_vtable_st parent_vtable,
base1_vtable_st child_vtable,
bool  do_null_check 
)

Fill in the child vtable with values inherited from the parent_vtable for all functions left NULL in the child vtable.

Parameters:
parent_vtableThe parent vtable from which to inherit.
child_vtableThe child vtable to which functions may be inherited.
do_null_checkIndicates whether an error should be thrown if a function in the child vtable is NULL after inheritance.

Definition at line 382 of file base1.c.

my_rc_e base1_init ( base1_handle  base1_h)

Allows a friend class to initialize their inner base1 object. Must be called before the base1 object is used. If an error is returned, any clean-up was handled internally and there is no need to call a delete function.

Parameters:
base1_hThe object
Returns:
Return code
See also:
base1_delete()
base1_friend_delete()

Definition at line 461 of file base1.c.

base1_handle base1_new1 ( void  )

Create a new base1 object.

Returns:
The object or NULL if creation failed

Definition at line 499 of file base1.c.

base1_handle base1_new2 ( base1_public_data_st public_data)

Create a new base1 object.

Parameters:
public_dataThe initial public data for the new object.
Returns:
The object or NULL if creation failed

Definition at line 529 of file base1.c.

base1_handle base1_new3 ( uint8_t  val1,
uint32_t  val3 
)

Create a new base1 object.

Parameters:
val1The initial val1 for the new object.
val3The initial val3 for the new object.
Returns:
The object or NULL if creation failed

Definition at line 554 of file base1.c.

my_rc_e base1_set_public_data ( base1_handle  base1_h,
base1_public_data_st public_data 
)

Set the public data for the given object. Note that this creates a deep copy of the data in the object. Also note that it overwrites all public data in the object, not certain fields seletively.

Parameters:
base1_hThe object
public_dataThe data buffer whose values should be written into the object
Returns:
Return code
See also:
base1_get_public_data()

Definition at line 85 of file base1.c.

my_rc_e base1_set_vtable ( base1_handle  base1_h,
base1_vtable_st vtable 
)

This is a function used by friend classes to set the virtual table according to which methods they wish to override.

Parameters:
base1_hThe object
vtableThe virtual table specification for the friend class. If a function pointer is NULL, then the base1 function is inherited.
Returns:
Return code

Definition at line 425 of file base1.c.

my_rc_e base1_string ( base1_handle  base1_h,
char *  buffer,
size_t  buffer_size 
)

Get a string representation of the object. This is a virtual function.

Parameters:
base1_hThe object
bufferThe buffer in which to put the string.
buffer_sizeThe size of the buffer.
Returns:
Return code
See also:
base1_string_size()

Definition at line 186 of file base1.c.

my_rc_e base1_string_size ( base1_handle  base1_h,
size_t *  buffer_size 
)

Get the minimum size of a string buffer that should be used to get a string representation of the object. This is a virtual function.

Parameters:
base1_hThe object
buffer_sizeOutputs the size of the buffer that should be used.
Returns:
Return code
See also:
base1_string()

Definition at line 109 of file base1.c.

const char* base1_type_string ( base1_handle  base1_h)

Get the string describing the type of the object. This is a virtual function.

Parameters:
base1_hThe object
Returns:
The string indicating the object type.

Definition at line 164 of file base1.c.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines