maix::example

example module, this will be maix.example module in MaixPy, maix::example namespace in MaixCDK

This is maix::example module of MaixCDK.
All of these elements are in namespace maix::example.

For MaixCDK developer: DO NOT edit this doc file manually, this doc is auto generated!

Module

No module

Enum

Kind

Example enum(not recommend! See Kind2)

item describe
values KIND_NONE: Kind none, value always 0, other enum value will auto increase
KIND_DOG: Kind dog
KIND_CAT: Kind cat, value is auto generated according to KING_DOG
KIND_BIRD:
KIND_MAX: Max Kind quantity
You can get max Kind value by KIND_MAX - 1

C++ defination code:

enum Kind
        {
            KIND_NONE = 0, /** Kind none, value always 0, other enum value will auto increase */
            KIND_DOG,      /** Kind dog*/
            KIND_CAT,      // Kind cat, value is auto generated according to KING_DOG
            KIND_BIRD,
            KIND_MAX /* Max Kind quantity,
                        You can get max Kind value by KIND_MAX - 1
                     */
        }

Kind2

Example enum class(recommend!)

item describe
values NONE: Kind none, value always 0, other enum value will auto increase
DOG: Kind dog
CAT: Kind cat, value is auto generated according to KING_DOG
BIRD:
MAX: Max Kind quantity
You can get max Kind value by KIND_MAX - 1

C++ defination code:

enum class Kind2
        {
            NONE = 0, /** Kind none, value always 0, other enum value will auto increase */
            DOG,      /** Kind dog*/
            CAT,      // Kind cat, value is auto generated according to KING_DOG
            BIRD,
            MAX       /* Max Kind quantity,
                         You can get max Kind value by KIND_MAX - 1
                      */
        }

Variable

var1

Example module variable

item description
attention It's a copy of this variable in MaixPy,
so change it in C++ (e.g. update var in hello function) will not take effect the var inMaixPy.
So we add const for this var to avoid this mistake.
value "Sipeed"
readonly True

C++ defination code:

const std::string var1 = "Sipeed"

list_var

Tensor data type size in bytes

item description
attention 1. DO NOT use C/C++ array directly for python API, the python wrapper not support it.
Use std::vector instead.
2. It's a copy of this variable in MaixPy,
so change it in C++ (e.g. update var in hello function) will not take effect the var inMaixPy.
So we add const for this var to avoid this mistake.
value {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
readonly True

C++ defination code:

const std::vector<int> list_var = {
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

test_var

Example module variable test_var

item description
attention It's a copy of this variable in MaixPy, so if you change it in C++, it will not take effect in MaixPy.
And change it in MaixPy will not take effect in C++ as well !!!
If you want to use vars shared between C++ and MaixPy, you can create a class and use its member.
value 100
readonly False

C++ defination code:

int test_var = 100

Function

hello

say hello to someone

item description
param name: direction [in], name of someone, string type
return string type, content is hello + name

C++ defination code:

std::string hello(std::string name)

hello_maixcdk

This is an API only for MaixCDK, MaixPy can't use it.\nOnly item with maixcdk or maixpy keyword will be exported as MaixCDK API.

C++ defination code:

std::string hello_maixcdk(std::string name)

change_arg_name

Change arg name example

item description
param e: Example object
return same as arg

C++ defination code:

example::Example *change_arg_name(example::Example *e)

change_arg_name2

Change arg name example

item description
param e: Example object

C++ defination code:

void change_arg_name2(example::Example &e)

Class

Test

Test class

C++ defination code:

class Test

Test

Test constructor

item description
type func
static False

C++ defination code:

Test()

Example

Example class\nthis class will be export to MaixPy as maix.example.Example

C++ defination code:

class Example

Example

Example constructor\nthis constructor will be export to MaixPy as maix.example.Example.init

item description
type func
param name: direction [in], name of Example, string type
age: direction [in], age of Example, int type, default is 18, value range is [0, 100]
attention to make auto generate code work, param Kind should with full namespace name example::Kind instead of Kind,
namespace maix can be ignored.
static False

C++ defination code:

Example(std::string &name, int age = 18, example::Kind pet = example::KIND_NONE)

get_name

get name of Example\nyou can also get name by property name.

item description
type func
return name of Example, string type
static False

C++ defination code:

std::string get_name()

get_age

get age of Example

item description
type func
return age of Example, int type, value range is [0, 100]
static False

C++ defination code:

int get_age()

set_name

set name of Example

item description
type func
param name: name of Example, string type
static False

C++ defination code:

void set_name(std::string name)

set_age

set age of Example

item description
type func
param age: age of Example, int type, value range is [0, 100]
static False

C++ defination code:

void set_age(int age)

set_pet

Example enum member

item description
type func
attention
static False

C++ defination code:

void set_pet(example::Kind pet)

get_pet

Example enum member

item description
type func
static False

C++ defination code:

example::Kind get_pet()

get_list

get list example

item description
type func
param in: direction [in], input list, items are int type.
In MaixPy, you can pass list or tuple to this API
return list, items are int type, content is [1, 2, 3] + in. Alloc item, del in MaixPy will auto free memory.
static False

C++ defination code:

std::vector<int> *get_list(std::vector<int> in)

get_dict

Example dict API

item description
type func
param in: direction [in], input dict, key is string type, value is int type.
In MaixPy, you can pass dict to this API
return dict, key is string type, value is int type, content is {"a": 1} + in
In MaixPy, return type is dict object
static False

C++ defination code:

std::map<std::string, int> get_dict(std::map<std::string, int> &in)

hello

say hello to someone

item description
type func
param name: name of someone, string type
return string type, content is Example::hello_str + name
static True

C++ defination code:

static std::string hello(std::string name)

hello_bytes

param is bytes example

item description
type func
param bytes: bytes type param
return bytes type, return value is bytes changed value
static True

C++ defination code:

static Bytes *hello_bytes(Bytes &bytes)

callback

Callback example

item description
type func
param cb: callback function, param is two int type, return is int type
return int type, return value is cb's return value.
static True

C++ defination code:

static int callback(std::function<int(int, int)> cb)

callback2

Callback example

item description
type func
param cb: callback function, param is a int list type and int type, return is int type
return int type, return value is cb's return value.
static True

C++ defination code:

static int callback2(std::function<int(std::vector<int>, int)> cb)

hello_dict

Dict param example

item description
type func
param dict: dict type param, key is string type, value is int type
static True

C++ defination code:

static std::map<std::string, int> *hello_dict(std::map<std::string, int> *dict)

name

name member of Example

item description
type var
static False
readonly False

C++ defination code:

std::string name

age

age member of Example, value range should be [0, 100]

item description
type var
static False
readonly False

C++ defination code:

int age

hello_str

hello_str member of Example, default value is "hello "

item description
type var
static True
readonly False

C++ defination code:

static std::string hello_str

var1

Example module readonly variable

item description
type var
static False
readonly True

C++ defination code:

const std::string var1 = "Example.var1"

var2

Example module readonly variable

item description
type var
static False
readonly True

C++ defination code:

std::string var2 = "Example.var2"

dict_test

dict_test, return dict type, and element is pointer type(alloc in C++).\nHere when the returned Tensor object will auto delete by Python GC.

item description
type func
static True

C++ defination code:

static std::map<std::string, example::Test *> *dict_test()