本文整理汇总了C++中IPC::map_function方法的典型用法代码示例。如果您正苦于以下问题:C++ IPC::map_function方法的具体用法?C++ IPC::map_function怎么用?C++ IPC::map_function使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPC
的用法示例。
在下文中一共展示了IPC::map_function方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
#endif
{
// freopen("C:\\touch_plus_software_log.txt", "w", stdout);
console_log_ipc = &ipc;
#ifdef _WIN32
char buffer[MAX_PATH];
GetModuleFileName(NULL, buffer, MAX_PATH);
string::size_type pos = string(buffer).find_last_of("\\/");
executable_path = string(buffer).substr(0, pos);
#elif __APPLE__
char path_buffer[1024];
uint32_t path_size = sizeof(path_buffer);
_NSGetExecutablePath(path_buffer, &path_size);
string path_str(path_buffer);
executable_path = path_str.substr(0, path_str.find_last_of("/"));
#endif
data_path = executable_path + slash + "userdata";
settings_file_path = data_path + slash + "settings.nrocinunerrad";
ipc_path = executable_path + slash + "ipc";
if (!directory_exists(ipc_path))
create_directory(ipc_path);
else
delete_all_files(ipc_path);
if (file_exists(executable_path + "/lock"))
delete_file(executable_path + "/lock");
Settings settings;
if (!file_exists(settings_file_path))
{
settings.launch_on_startup = "1";
settings.power_saving_mode = "0";
settings.check_for_updates = "1";
settings.touch_control = "1";
settings.table_mode = "0";
settings.detect_interaction_plane = "0";
settings.click_height = "5";
if (!directory_exists(data_path))
create_directory(data_path);
ofstream settings_ofs(settings_file_path, ios::binary);
settings_ofs.write((char*)&settings, sizeof(settings));
console_log("settings file created");
}
else
{
ifstream ifs(settings_file_path, ios::binary);
ifs.read((char*)&settings, sizeof(settings));
console_log("settings file loaded");
}
IPC* ipc_ptr = &ipc;
Settings* settings_ptr = &settings;
ipc.map_function("get toggles", [ipc_ptr, settings_ptr](const string message_body)
{
string response = "";
response += settings_ptr->launch_on_startup
+ settings_ptr->power_saving_mode
+ settings_ptr->check_for_updates
+ settings_ptr->touch_control
+ settings_ptr->table_mode
+ settings_ptr->detect_interaction_plane
+ settings_ptr->click_height;
ipc_ptr->send_message("menu_plus", "get toggles", response);
});
ipc.map_function("set toggle", [ipc_ptr, settings_ptr](const string message_body)
{
const string toggle_name = message_body.substr(0, message_body.size() - 1);
const string toggle_value = message_body.substr(message_body.size() - 1, message_body.size());
if (toggle_name == "launch_on_startup")
settings_ptr->launch_on_startup = toggle_value;
else if (toggle_name == "power_saving_mode")
settings_ptr->power_saving_mode = toggle_value;
else if (toggle_name == "check_for_updates")
settings_ptr->check_for_updates = toggle_value;
else if (toggle_name == "touch_control")
settings_ptr->touch_control = toggle_value;
else if (toggle_name == "table_mode")
settings_ptr->table_mode = toggle_value;
else if (toggle_name == "detect_interaction_plane")
settings_ptr->detect_interaction_plane = toggle_value;
//.........这里部分代码省略.........