2024-01-19 15:27:32 -05:00
|
|
|
/*
|
|
|
|
* <Short Description>
|
|
|
|
* Copyright (C) 2024 Brett Terpstra
|
|
|
|
*
|
|
|
|
* 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 3 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 <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GP_IMAGE_TEST_FUNCTIONS_H
|
|
|
|
#define GP_IMAGE_TEST_FUNCTIONS_H
|
|
|
|
|
|
|
|
// FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ALLOWED_FUNCS)
|
|
|
|
// FUNC_ALLOW_ANY
|
|
|
|
|
|
|
|
#include <initializer_list>
|
|
|
|
#include <vector>
|
2024-01-22 08:48:51 -05:00
|
|
|
#include "blt/std/hashmap.h"
|
|
|
|
#include "blt/std/types.h"
|
2024-01-19 15:27:32 -05:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
using allowed_funcs = std::vector<T>;
|
|
|
|
|
|
|
|
class empty {};
|
|
|
|
|
2024-01-22 08:48:51 -05:00
|
|
|
// #define FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ALLOWED)
|
|
|
|
|
2024-01-19 15:27:32 -05:00
|
|
|
#define FUNC_ALLOW_ANY std::vector<empty>();
|
|
|
|
#define FUNC_ALLOW_NONE std::vector<empty>();
|
|
|
|
|
|
|
|
#define FUNC_FUNCTIONS \
|
|
|
|
FUNC_DEFINE(RANDOM, 0, void(), allowed_funcs(FUNC_ALLOW_NONE)) \
|
|
|
|
FUNC_DEFINE(NOISE, 0, void(), allowed_funcs(FUNC_ALLOW_NONE)) \
|
|
|
|
FUNC_DEFINE(COLOR, 0, void(), allowed_funcs(FUNC_ALLOW_NONE)) \
|
|
|
|
FUNC_DEFINE(SCALAR, 0, void(), allowed_funcs(FUNC_ALLOW_NONE)) \
|
|
|
|
FUNC_DEFINE(ADD, 2, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \
|
|
|
|
FUNC_DEFINE(SUB, 2, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \
|
|
|
|
FUNC_DEFINE(MUL, 2, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \
|
|
|
|
FUNC_DEFINE(DIV, 2, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \
|
|
|
|
FUNC_DEFINE(EXP, 2, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \
|
|
|
|
FUNC_DEFINE(LOG, 1, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \
|
|
|
|
FUNC_DEFINE(SQRT, 1, void(), allowed_funcs(FUNC_ALLOW_ANY, FUNC_ALLOW_ANY)) \
|
|
|
|
|
|
|
|
#undef FUNC_ALLOW_ANY
|
2024-01-22 08:48:51 -05:00
|
|
|
#undef FUNC_ALLOW_NONE
|
2024-01-19 15:27:32 -05:00
|
|
|
|
|
|
|
#define FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ALLOWED) NAME,
|
|
|
|
enum class function_t
|
|
|
|
{
|
|
|
|
FUNC_FUNCTIONS
|
|
|
|
};
|
|
|
|
#undef FUNC_DEFINE
|
|
|
|
|
|
|
|
#define FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ALLOWED) function_t::NAME,
|
|
|
|
static inline allowed_funcs<function_t> FUNC_ALLOW_ANY_LIST{FUNC_FUNCTIONS};
|
2024-01-22 08:48:51 -05:00
|
|
|
static inline allowed_funcs<function_t> FUNC_ALLOW_NONE_LIST{};
|
2024-01-19 15:27:32 -05:00
|
|
|
#define FUNC_ALLOW_ANY FUNC_ALLOW_ANY_LIST
|
2024-01-22 08:48:51 -05:00
|
|
|
#define FUNC_ALLOW_NONE FUNC_ALLOW_NONE_LIST
|
2024-01-19 15:27:32 -05:00
|
|
|
#undef FUNC_DEFINE
|
|
|
|
|
2024-01-22 08:48:51 -05:00
|
|
|
#define FUNC_DEFINE(NAME, REQUIRED_ARGS, FUNC, ALLOWED) {REQUIRED_ARGS, function_t::NAME},
|
|
|
|
HASHMAP<blt::u32, function_t> function_arg_map = {
|
|
|
|
FUNC_FUNCTIONS
|
|
|
|
};
|
|
|
|
#undef FUNC_DEFINE
|
|
|
|
|
|
|
|
|
2024-01-19 15:27:32 -05:00
|
|
|
//enum class function_t
|
|
|
|
//{
|
|
|
|
// // FUNC // inputs
|
|
|
|
// ADD, // 2
|
|
|
|
// SUB, // 2
|
|
|
|
// MUL, // 2
|
|
|
|
// DIV, // 2
|
|
|
|
// EXP, // 2
|
|
|
|
//
|
|
|
|
// LOG, // 1
|
|
|
|
// SQRT, // 1
|
|
|
|
// QUAD, // 1
|
|
|
|
//
|
|
|
|
// RANDOM, // 0
|
|
|
|
// NOISE, // 0
|
|
|
|
// COLOR, // 0
|
|
|
|
// SCALAR // 0
|
|
|
|
//};
|
|
|
|
|
|
|
|
static constexpr int OPERATOR_COUNT = static_cast<int>(function_t::SCALAR) + 1;
|
|
|
|
|
|
|
|
#endif //GP_IMAGE_TEST_FUNCTIONS_H
|