Commit 48300133 authored by Dominik Charousset's avatar Dominik Charousset

Reorganize repository

parent d163b221
......@@ -12,3 +12,4 @@ lib/*
manual/manual.pdf
manual/build-pdf/*
manual/build-html/*
*.swp
......@@ -36,7 +36,7 @@ endif ()
# check for g++ >= 4.7 or clang++ > = 3.2
try_run(ProgramResult
CompilationSucceeded
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/get_compiler_version.cpp
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/get_compiler_version.cpp
RUN_OUTPUT_VARIABLE CompilerVersion)
if (NOT CompilationSucceeded OR NOT ProgramResult EQUAL 0)
message(FATAL_ERROR "Cannot determine compiler version")
......@@ -87,15 +87,6 @@ else ()
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
endif ()
include(CheckIncludeFileCXX)
check_include_file_cxx("valgrind/valgrind.h" HAVE_VALGRIND_H)
if (HAVE_VALGRIND_H)
set(VALGRIND "yes")
add_definitions(-DCAF_ANNOTATE_VALGRIND)
else (HAVE_VALGRIND_H)
set(VALGRIND "no")
endif (HAVE_VALGRIND_H)
# set build type (evaluate CAF_ENABLE_RUNTIME_CHECKS flag)
if (CAF_ENABLE_RUNTIME_CHECKS)
add_definitions(-DCAF_ENABLE_RUNTIME_CHECKS)
......@@ -118,88 +109,8 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif ("${CMAKE_BUILD_TYPE}" STREQUAL "")
# get header files; only needed by CMake generators,
# e.g., for creating proper Xcode projects
file(GLOB LIBCAF_HDRS "caf/*.hpp"
"caf/detail/*.hpp"
"caf/intrusive/*.hpp"
"caf/io/*.hpp"
"caf/opencl/*.hpp"
"caf/qtsupport/*.hpp"
"caf/policy/*.hpp"
"caf/mixin/*.hpp"
"cppa/*.hpp")
# list cpp files excluding platform-dependent files
set (LIBCAF_SRCS
${LIBCAF_PLATFORM_SRCS}
src/abstract_actor.cpp
src/abstract_channel.cpp
src/abstract_group.cpp
src/actor.cpp
src/actor_addr.cpp
src/actor_companion.cpp
src/actor_namespace.cpp
src/actor_ostream.cpp
src/actor_proxy.cpp
src/actor_registry.cpp
src/atom.cpp
src/attachable.cpp
src/basp_broker.cpp
src/behavior.cpp
src/behavior_stack.cpp
src/binary_deserializer.cpp
src/binary_serializer.cpp
src/blocking_actor.cpp
src/broker.cpp
src/channel.cpp
src/continue_helper.cpp
src/decorated_tuple.cpp
src/demangle.cpp
src/deserializer.cpp
src/duration.cpp
src/event_based_actor.cpp
src/exception.cpp
src/execution_unit.cpp
src/exit_reason.cpp
src/get_mac_addresses.cpp
src/get_root_uuid.cpp
src/group.cpp
src/group_manager.cpp
src/local_actor.cpp
src/logging.cpp
src/mailbox_element.cpp
src/match.cpp
src/max_msg_size.cpp
src/memory.cpp
src/memory_managed.cpp
src/message.cpp
src/message_builder.cpp
src/message_data.cpp
src/message_handler.cpp
src/middleman.cpp
src/network.cpp
src/node_id.cpp
src/publish_local_groups.cpp
src/ref_counted.cpp
src/remote_actor_proxy.cpp
src/response_promise.cpp
src/resumable.cpp
src/ripemd_160.cpp
src/scheduler.cpp
src/scoped_actor.cpp
src/serializer.cpp
src/shared_spinlock.cpp
src/shutdown.cpp
src/singletons.cpp
src/string_algorithms.cpp
src/string_serialization.cpp
src/sync_request_bouncer.cpp
src/to_uniform_name.cpp
src/uniform_type_info.cpp
src/uniform_type_info_map.cpp)
set(INCLUDE_DIRS .)
# all libs need access to core headers
set(INCLUDE_DIRS libcaf_core)
set(LD_DIRS)
set(LD_FLAGS ${CMAKE_LD_LIBS})
......@@ -216,38 +127,18 @@ if (DISABLE_MEM_MANAGEMENT)
add_definitions(-DCAF_DISABLE_MEM_MANAGEMENT)
endif (DISABLE_MEM_MANAGEMENT)
# build shared library if not compiling static only
if (NOT "${CAF_BUILD_STATIC_ONLY}" STREQUAL "yes")
add_library(libcaf SHARED ${LIBCAF_SRCS} ${LIBCAF_HDRS})
target_link_libraries(libcaf ${LD_FLAGS})
set(LIBRARY_VERSION ${LIBCAF_VERSION_MAJOR}.${LIBCAF_VERSION_MINOR}.${LIBCAF_VERSION_PATCH})
set(LIBRARY_SOVERSION ${LIBCAF_VERSION_MAJOR})
set_target_properties(libcaf
PROPERTIES
SOVERSION ${LIBRARY_SOVERSION}
VERSION ${LIBRARY_VERSION}
OUTPUT_NAME caf)
if(NOT MINGW)
install(TARGETS libcaf LIBRARY DESTINATION lib)
endif()
endif ()
# build static library only if --build-static or --build-static-only was set
if ("${CAF_BUILD_STATIC_ONLY}" STREQUAL "yes" OR "${CAF_BUILD_STATIC}" STREQUAL "yes")
add_library(libcafStatic STATIC ${LIBCAF_HDRS} ${LIBCAF_SRCS})
set_target_properties(libcafStatic PROPERTIES OUTPUT_NAME caf_static)
install(TARGETS libcafStatic ARCHIVE DESTINATION lib)
endif ()
link_directories(${LD_DIRS})
include_directories(${INCLUDE_DIRS})
# install includes
install(DIRECTORY caf/ DESTINATION include/caf FILES_MATCHING PATTERN "*.hpp")
install(DIRECTORY cppa/ DESTINATION include/cppa FILES_MATCHING PATTERN "*.hpp")
# install includes from core
install(DIRECTORY libcaf_core/caf/ DESTINATION include/caf FILES_MATCHING PATTERN "*.hpp")
install(DIRECTORY libcaf_io/cppa/ DESTINATION include/cppa FILES_MATCHING PATTERN "*.hpp")
# install includes from io
install(DIRECTORY libcaf_io/caf/ DESTINATION include/caf FILES_MATCHING PATTERN "*.hpp")
# process cmake_uninstall.cmake.in
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
......@@ -256,46 +147,27 @@ add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
# setting path to caf headers and libcaf
set (CAF_INCLUDE_PATH ${CMAKE_SOURCE_DIR}/libcaf)
set (CAF_INCLUDE ${CAF_INCLUDE_PATH})
if ("${CAF_BUILD_STATIC_ONLY}" STREQUAL "yes")
set (CAF_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcaf_static.a ${LD_FLAGS})
else ()
if (APPLE)
if ("${CMAKE_GENERATOR}" STREQUAL "Xcode")
set (CAF_LIBRARY "-lcaf")
else ()
set (CAF_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcaf.dylib)
endif ()
#set (CAF_LIBRARY -L${LIBRARY_OUTPUT_PATH} -lcaf)
elseif (UNIX)
set (CAF_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcaf.so)
elseif (MINGW)
set (CAF_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcaf.dll)
else ()
message (SEND_FATAL "Host platform not supported ...")
endif ()
endif ()
# set up subdirectories
# set path to caf core & io headers for subdirectories
set (LIBCAF_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/libcaf_core
${CMAKE_SOURCE_DIR}/libcaf_io)
# set up subdirectories, todo: allow configure option to disable io
add_subdirectory(libcaf_core)
# set core lib for sub directories
set (LIBCAF_CORE_LIBRARY libcaf_core)
add_subdirectory(libcaf_io)
# set io lib for sub directories
set (LIBCAF_IO_LIBRARY libcaf_io)
add_dependencies(libcaf_io libcaf_core)
if (NOT "${CAF_NO_UNIT_TESTS}" STREQUAL "yes")
enable_testing()
add_subdirectory(unit_testing)
if ("${CAF_BUILD_STATIC_ONLY}" STREQUAL "yes")
add_dependencies(all_unit_tests libcafStatic)
else ()
add_dependencies(all_unit_tests libcaf)
endif ()
add_dependencies(all_unit_tests libcaf_io)
endif ()
if (NOT "${CAF_NO_EXAMPLES}" STREQUAL "yes")
add_subdirectory(examples)
if ("${CAF_BUILD_STATIC_ONLY}" STREQUAL "yes")
add_dependencies(all_examples libcafStatic)
else ()
add_dependencies(all_examples libcaf)
endif ()
add_dependencies(all_examples libcaf_io)
endif ()
# set optional flags
......
# - Try to find OpenCL
# Once done this will define
#
# OPENCL_FOUND - system has OpenCL
# OPENCL_INCLUDE_DIR - the OpenCL include directory
# OPENCL_LIBRARIES - link these to use OpenCL
#
# WIN32 should work, but is untested
IF (WIN32)
FIND_PATH(OPENCL_INCLUDE_DIR CL/cl.h )
# TODO this is only a hack assuming the 64 bit library will
# not be found on 32 bit system
FIND_LIBRARY(OPENCL_LIBRARIES opencl ) #used to say opencl64
IF( OPENCL_LIBRARIES )
FIND_LIBRARY(OPENCL_LIBRARIES opencl ) #used to say opencl32
ENDIF( OPENCL_LIBRARIES )
ELSE (WIN32)
# Unix style platforms
# We also search for OpenCL in the NVIDIA GPU SDK default location
#SET(OPENCL_INCLUDE_DIR "$ENV{OPENCL_HOME}/common/inc"
# CACHE PATH "path to Opencl Include files")
#message(***** OPENCL_INCLUDE_DIR: "${OPENCL_INCLUDE_DIR}" ********)
# does not work. WHY?
#SET(inc $ENV{CUDA_LOCAL}/../OpenCL/common/inc /usr/include)
#FIND_PATH(OPENCL_INCLUDE_DIR CL/cl.h PATHS ${inc} /usr/include )
message("lib path: $ENV{LD_LIBRARY_PATH}")
#FIND_LIBRARY(OPENCL_LIBRARIES OpenCL $ENV{LD_LIBRARY_PATH})
FIND_LIBRARY(OPENCL_LIBRARIES OpenCL ENV LD_LIBRARY_PATH)
message("==============")
message("opencl_libraries: ${OPENCL_LIBRARIES}")
#message(***** OPENCL ENV: "$ENV{GPU_SDK}" ********)
#~/NVIDIA_GPU_Computing_SDK/OpenCL/common/inc/
ENDIF (WIN32)
SET( OPENCL_FOUND "NO" )
IF(OPENCL_LIBRARIES )
SET( OPENCL_FOUND "YES" )
ENDIF(OPENCL_LIBRARIES)
MARK_AS_ADVANCED(
OPENCL_INCLUDE_DIR
)
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011 - 2014 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the Boost Software License, Version 1.0. See *
* accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt *
\******************************************************************************/
#ifndef CAF_QTSUPPORT_ACTOR_WIDGET_MIXIN_HPP
#define CAF_QTSUPPORT_ACTOR_WIDGET_MIXIN_HPP
#include <QEvent>
#include <QApplication>
#include "caf/actor_companion.hpp"
#include "caf/message_handler.hpp"
#include "caf/policy/sequential_invoke.hpp"
namespace caf {
template<typename Base, int EventId = static_cast<int>(QEvent::User + 31337)>
class actor_widget_mixin : public Base {
public:
using message_pointer = typename actor_companion::message_pointer;
struct event_type : public QEvent {
message_pointer mptr;
event_type(message_pointer ptr)
: QEvent(static_cast<QEvent::Type>(EventId)), mptr(std::move(ptr)) { }
};
template<typename... Ts>
actor_widget_mixin(Ts&&... args) : Base(std::forward<Ts>(args)...) {
m_companion.reset(detail::memory::create<actor_companion>());
m_companion->on_enqueue([=](message_pointer ptr) {
qApp->postEvent(this, new event_type(std::move(ptr)));
});
}
template<typename T>
void set_message_handler(T pfun) {
m_companion->become(pfun(m_companion.get()));
}
virtual bool event(QEvent* event) {
if (event->type() == static_cast<QEvent::Type>(EventId)) {
auto ptr = dynamic_cast<event_type*>(event);
if (ptr) {
m_invoke.handle_message(m_companion.get(),
ptr->mptr.release(),
m_companion->bhvr_stack().back(),
m_companion->bhvr_stack().back_id());
return true;
}
}
return Base::event(event);
}
actor as_actor() const {
return m_companion;
}
private:
policy::sequential_invoke m_invoke;
actor_companion_ptr m_companion;
};
} // namespace caf
#endif // CAF_QTSUPPORT_ACTOR_WIDGET_MIXIN_HPP
......@@ -3,13 +3,22 @@ project(caf_examples CXX)
add_custom_target(all_examples)
include_directories(${LIBCAF_INCLUDE_DIRS})
if (${CMAKE_SYSTEM_NAME} MATCHES "Window")
set(WSLIB -lws2_32)
else ()
set(WSLIB)
endif ()
macro(add name folder)
add_executable(${name} ${folder}/${name}.cpp ${ARGN})
if (${CMAKE_SYSTEM_NAME} MATCHES "Window")
target_link_libraries(${name} ${CMAKE_DL_LIBS} ${CAF_LIBRARY} ${PTHREAD_LIBRARIES} -lws2_32)
else ()
target_link_libraries(${name} ${CMAKE_DL_LIBS} ${CAF_LIBRARY} ${PTHREAD_LIBRARIES})
endif ()
target_link_libraries(${name}
${CMAKE_DL_LIBS}
${LIBCAF_CORE_LIBRARY}
${LIBCAF_IO_LIBRARY}
${PTHREAD_LIBRARIES}
${WSLIB})
add_dependencies(${name} all_examples)
endmacro()
......@@ -42,42 +51,9 @@ if (NOT "${CAF_NO_PROTOBUF_EXAMPLES}" STREQUAL "yes")
endif (PROTOBUF_FOUND)
endif ()
find_package(CURL)
if (CURL_FOUND)
add_executable(curl_fuse curl/curl_fuse.cpp)
target_link_libraries(curl_fuse ${CMAKE_DL_LIBS} ${CAF_LIBRARY} ${PTHREAD_LIBRARIES} ${CURL_LIBRARY})
add_dependencies(curl_fuse all_examples)
endif (CURL_FOUND)
if (NOT "${CAF_NO_QT_EXAMPLES}" STREQUAL "yes")
find_package(Qt4)
if (QT4_FOUND)
include(${QT_USE_FILE})
QT4_ADD_RESOURCES(GROUP_CHAT_RCS )
QT4_WRAP_UI(GROUP_CHAT_UI_HDR qtsupport/chatwindow.ui)
QT4_WRAP_CPP(GROUP_CHAT_MOC_SRC qtsupport/chatwidget.hpp)
# generated headers will be in cmake build directory
#include_directories(. qtsupport ${CMAKE_CURRENT_BINARY_DIR} ${CAF_INCLUDE})
include_directories(qtsupport ${CMAKE_CURRENT_BINARY_DIR})
set(GROUP_CHAT_SRCS qtsupport/qt_group_chat.cpp qtsupport/chatwidget.cpp)
add_executable(qt_group_chat
${GROUP_CHAT_SRCS}
${GROUP_CHAT_MOC_SRC}
${GROUP_CHAT_UI_HDR})
target_link_libraries(qt_group_chat
${CMAKE_DL_LIBS}
${CAF_LIBRARY}
${QT_LIBRARIES})
add_dependencies(qt_group_chat all_examples)
endif (QT4_FOUND)
endif ()
if (ENABLE_OPENCL)
macro(add_opencl name folder)
add_executable(${name} ${folder}/${name}.cpp ${ARGN})
target_link_libraries(${name} ${CMAKE_DL_LIBS} ${CAF_LIBRARY} ${PTHREAD_LIBRARIES} ${OPENCL_LIBRARIES})
add_dependencies(${name} all_examples)
endmacro()
add_opencl(simple_matrix opencl)
add_opencl(proper_matrix opencl)
endif (ENABLE_OPENCL)
#find_package(CURL)
#if (CURL_FOUND)
# add_executable(curl_fuse curl/curl_fuse.cpp)
# target_link_libraries(curl_fuse ${CMAKE_DL_LIBS} ${CAF_LIBRARY} ${PTHREAD_LIBRARIES} ${CURL_LIBRARY})
# add_dependencies(curl_fuse all_examples)
#endif (CURL_FOUND)
......@@ -283,7 +283,7 @@ class curl_worker : public base_actor {
}
}
// avoid 100% cpu utilization if remote side is not accessible
usleep(100000); // 100000 == 100ms
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}
);
......@@ -399,7 +399,9 @@ int main() {
auto master = self->spawn<curl_master, detached>();
self->spawn<client, detached>(master);
// poll CTRL+C flag every second
while (!shutdown_flag) { sleep(1); }
while (!shutdown_flag) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}
aout(self) << color::cyan << "received CTRL+C" << color::reset_endl;
// shutdown actors
anon_send_exit(master, exit_reason::user_shutdown);
......
#include <string>
#include <utility>
#include <QMessageBox>
#include <QInputDialog>
#include "chatwidget.hpp"
#include "caf/all.hpp"
#include "caf/detail/scope_guard.hpp"
using namespace std;
using namespace caf;
ChatWidget::ChatWidget(QWidget* parent, Qt::WindowFlags f)
: super(parent, f), m_input(nullptr), m_output(nullptr) {
set_message_handler ([=](local_actor* self) -> message_handler {
return {
on(atom("join"), arg_match) >> [=](const group& what) {
if (m_chatroom) {
self->send(m_chatroom, m_name + " has left the chatroom");
self->leave(m_chatroom);
}
self->join(what);
print(("*** joined " + to_string(what)).c_str());
m_chatroom = what;
self->send(what, m_name + " has entered the chatroom");
},
on(atom("setName"), arg_match) >> [=](string& name) {
self->send(m_chatroom, m_name + " is now known as " + name);
m_name = std::move(name);
print("*** changed name to "
+ QString::fromUtf8(m_name.c_str()));
},
on(atom("quit")) >> [=] {
close(); // close widget
},
[=](const string& txt) {
// don't print own messages
if (self != self->last_sender()) {
print(QString::fromUtf8(txt.c_str()));
}
},
[=](const group_down_msg& gdm) {
print("*** chatroom offline: "
+ QString::fromUtf8(to_string(gdm.source).c_str()));
}
};
});
}
void ChatWidget::sendChatMessage() {
auto cleanup = detail::make_scope_guard([=] {
input()->setText(QString());
});
QString line = input()->text();
if (line.startsWith('/')) {
match_split(line.midRef(1).toUtf8().constData(), ' ') (
on("join", arg_match) >> [=](const string& mod, const string& g) {
group gptr;
try { gptr = group::get(mod, g); }
catch (exception& e) {
print("*** exception: " + QString::fromUtf8((e.what())));
}
if (gptr) {
send_as(as_actor(), as_actor(), atom("join"), gptr);
}
},
on("setName", arg_match) >> [=](const string& str) {
send_as(as_actor(), as_actor(), atom("setName"), str);
},
others() >> [=] {
print("*** list of commands:\n"
"/join <module> <group id>\n"
"/setName <new name>\n");
}
);
return;
}
if (m_name.empty()) {
print("*** please set a name before sending messages");
return;
}
if (!m_chatroom) {
print("*** no one is listening... please join a group");
return;
}
string msg = m_name;
msg += ": ";
msg += line.toUtf8().constData();
print("<you>: " + input()->text());
// NOTE: we have to use send_as(as_actor(), ...) outside of our
// message handler, because `self` is *not* set properly
// in this context
send_as(as_actor(), m_chatroom, std::move(msg));
}
void ChatWidget::joinGroup() {
if (m_name.empty()) {
QMessageBox::information(this,
"No Name, No Chat",
"Please set a name first.");
return;
}
auto gname = QInputDialog::getText(this,
"Join Group",
"Please enter a group as <module>:<id>",
QLineEdit::Normal,
"remote:chatroom@localhost:4242");
int pos = gname.indexOf(':');
if (pos < 0) {
QMessageBox::warning(this, "Not a Group", "Invalid format");
return;
}
string mod = gname.left(pos).toUtf8().constData();
string gid = gname.midRef(pos+1).toUtf8().constData();
try {
auto gptr = group::get(mod, gid);
send_as(as_actor(), as_actor(), atom("join"), gptr);
}
catch (exception& e) {
QMessageBox::critical(this, "Exception", e.what());
}
}
void ChatWidget::changeName() {
auto name = QInputDialog::getText(this, "Change Name", "Please enter a new name");
if (!name.isEmpty()) {
send_as(as_actor(), as_actor(), atom("setName"), name.toUtf8().constData());
}
}
#include <exception>
#include <QWidget>
#include <QLineEdit>
#include <QTextEdit>
#include "caf/group.hpp"
#include "caf/qtsupport/actor_widget_mixin.hpp"
class ChatWidget : public caf::actor_widget_mixin<QWidget> {
Q_OBJECT
using super = caf::actor_widget_mixin<QWidget>;
public:
ChatWidget(QWidget* parent = nullptr, Qt::WindowFlags f = 0);
public slots:
void sendChatMessage();
void joinGroup();
void changeName();
private:
template<typename T>
T* get(T*& member, const char* name) {
if (member == nullptr) {
member = findChild<T*>(name);
if (member == nullptr)
throw std::runtime_error("unable to find child: "
+ std::string(name));
}
return member;
}
inline QLineEdit* input() {
return get(m_input, "input");
}
inline QTextEdit* output() {
return get(m_output, "output");
}
inline void print(const QString& what) {
output()->append(what);
}
QLineEdit* m_input;
QTextEdit* m_output;
std::string m_name;
caf::group m_chatroom;
};
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChatWindow</class>
<widget class="QMainWindow" name="ChatWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="ChatWidget" name="chatwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QTextEdit" name="output">
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="input">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionJoin_Group"/>
<addaction name="actionSet_Name"/>
</widget>
<addaction name="menuFile"/>
</widget>
<action name="actionJoin_Group">
<property name="text">
<string>Join Group</string>
</property>
</action>
<action name="actionSet_Name">
<property name="text">
<string>Set Name</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>ChatWidget</class>
<extends>QWidget</extends>
<header>chatwidget.hpp</header>
<container>1</container>
<slots>
<slot>sendChatMessage()</slot>
<slot>changeName()</slot>
<slot>joinGroup()</slot>
</slots>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>actionJoin_Group</sender>
<signal>activated()</signal>
<receiver>chatwidget</receiver>
<slot>joinGroup()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>300</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionSet_Name</sender>
<signal>activated()</signal>
<receiver>chatwidget</receiver>
<slot>changeName()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>300</y>
</hint>
</hints>
</connection>
<connection>
<sender>input</sender>
<signal>returnPressed()</signal>
<receiver>chatwidget</receiver>
<slot>sendChatMessage()</slot>
<hints>
<hint type="sourcelabel">
<x>362</x>
<y>547</y>
</hint>
<hint type="destinationlabel">
<x>399</x>
<y>310</y>
</hint>
</hints>
</connection>
</connections>
</ui>
/******************************************************************************\
* This example program represents a minimal GUI chat program *
* based on group communication. This chat program is compatible to the *
* terminal version in remote_actors/group_chat.cpp. *
* *
* Setup for a minimal chat between "alice" and "bob": *
* - ./build/bin/group_server -p 4242 *
* - ./build/bin/qt_group_chat -g remote:chatroom@localhost:4242 -n alice *
* - ./build/bin/qt_group_chat -g remote:chatroom@localhost:4242 -n bob *
\******************************************************************************/
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <time.h>
#include <cstdlib>
#include <QMainWindow>
#include <QApplication>
#include "caf/all.hpp"
// the options_description API is deprecated
#include "cppa/opt.hpp"
#include "ui_chatwindow.h" // auto generated from chatwindow.ui
using namespace std;
using namespace caf;
int main(int argc, char** argv) {
string name;
string group_id;
options_description desc;
bool args_valid = match_stream<string>(argv + 1, argv + argc) (
on_opt1('n', "name", &desc, "set name") >> rd_arg(name),
on_opt1('g', "group", &desc, "join group <arg1>") >> rd_arg(group_id),
on_opt0('h', "help", &desc, "print help") >> print_desc_and_exit(&desc)
);
group gptr;
// evaluate group parameter
if (!group_id.empty()) {
auto p = group_id.find(':');
if (p == std::string::npos) {
cerr << "*** error parsing argument " << group_id
<< ", expected format: <module_name>:<group_id>";
}
else {
try {
gptr = group::get(group_id.substr(0, p),
group_id.substr(p + 1));
}
catch (exception& e) {
ostringstream err;
cerr << "*** exception: group::get(\"" << group_id.substr(0, p)
<< "\", \"" << group_id.substr(p + 1) << "\") failed; "
<< to_verbose_string(e) << endl;
}
}
}
if (!args_valid) print_desc_and_exit(&desc)();
QApplication app(argc, argv);
app.setQuitOnLastWindowClosed(true);
QMainWindow mw;
Ui::ChatWindow helper;
helper.setupUi(&mw);
auto client = helper.chatwidget->as_actor();
if (!name.empty()) {
send_as(client, client, atom("setName"), move(name));
}
if (gptr) {
send_as(client, client, atom("join"), gptr);
}
mw.show();
auto res = app.exec();
shutdown();
await_all_actors_done();
return res;
}
......@@ -22,6 +22,7 @@
#endif
#include "caf/all.hpp"
#include "caf/io/all.hpp"
using namespace std;
using namespace caf;
......
cmake_minimum_required(VERSION 2.8)
project(caf_core C CXX)
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(.)
# get header files; only needed by CMake generators,
# e.g., for creating proper Xcode projects
file(GLOB LIBCAF_CORE_HDRS "caf/*.hpp"
"caf/detail/*.hpp"
"caf/policy/*.hpp"
"caf/mixin/*.hpp"
"cppa/*.hpp")
# list cpp files excluding platform-dependent files
set (LIBCAF_CORE_SRCS
src/abstract_actor.cpp
src/abstract_channel.cpp
src/abstract_group.cpp
src/actor.cpp
src/actor_addr.cpp
src/actor_companion.cpp
src/actor_namespace.cpp
src/actor_ostream.cpp
src/actor_proxy.cpp
src/actor_registry.cpp
src/atom.cpp
src/attachable.cpp
src/behavior.cpp
src/behavior_stack.cpp
src/binary_deserializer.cpp
src/binary_serializer.cpp
src/blocking_actor.cpp
src/channel.cpp
src/continue_helper.cpp
src/decorated_tuple.cpp
src/demangle.cpp
src/deserializer.cpp
src/duration.cpp
src/event_based_actor.cpp
src/exception.cpp
src/execution_unit.cpp
src/exit_reason.cpp
src/get_mac_addresses.cpp
src/get_root_uuid.cpp
src/group.cpp
src/group_manager.cpp
src/local_actor.cpp
src/logging.cpp
src/mailbox_element.cpp
src/match.cpp
src/memory.cpp
src/memory_managed.cpp
src/message.cpp
src/message_builder.cpp
src/message_data.cpp
src/message_handler.cpp
src/node_id.cpp
src/ref_counted.cpp
src/response_promise.cpp
src/resumable.cpp
src/ripemd_160.cpp
src/scheduler.cpp
src/scoped_actor.cpp
src/serializer.cpp
src/shared_spinlock.cpp
src/shutdown.cpp
src/singletons.cpp
src/string_algorithms.cpp
src/string_serialization.cpp
src/sync_request_bouncer.cpp
src/to_uniform_name.cpp
src/uniform_type_info.cpp
src/uniform_type_info_map.cpp)
# build shared library if not compiling static only
if (NOT "${CAF_BUILD_STATIC_ONLY}" STREQUAL "yes")
add_library(libcaf_core SHARED ${LIBCAF_CORE_SRCS} ${LIBCAF_CORE_HDRS})
target_link_libraries(libcaf_core ${LD_FLAGS})
set(LIBRARY_VERSION ${LIBCAF_VERSION_MAJOR}.${LIBCAF_VERSION_MINOR}.${LIBCAF_VERSION_PATCH})
set(LIBRARY_SOVERSION ${LIBCAF_VERSION_MAJOR})
set_target_properties(libcaf_core
PROPERTIES
SOVERSION ${LIBRARY_SOVERSION}
VERSION ${LIBRARY_VERSION}
OUTPUT_NAME caf_core)
if(NOT MINGW)
install(TARGETS libcaf_core LIBRARY DESTINATION lib)
endif()
endif ()
# build static library only if --build-static or --build-static-only was set
if ("${CAF_BUILD_STATIC_ONLY}" STREQUAL "yes" OR "${CAF_BUILD_STATIC}" STREQUAL "yes")
add_library(libcaf_coreStatic STATIC ${LIBCAF_CORE_HDRS} ${LIBCAF_CORE_SRCS})
set_target_properties(libcaf_coreStatic PROPERTIES OUTPUT_NAME caf_core_static)
if(NOT MINGW)
install(TARGETS libcaf_coreStatic ARCHIVE DESTINATION lib)
endif()
endif ()
link_directories(${LD_DIRS})
......@@ -24,6 +24,7 @@
#include <functional>
#include "caf/node_id.hpp"
#include "caf/actor_cast.hpp"
#include "caf/actor_proxy.hpp"
namespace caf {
......
......@@ -37,7 +37,6 @@
#include "caf/behavior.hpp"
#include "caf/duration.hpp"
#include "caf/sb_actor.hpp"
#include "caf/spawn_io.hpp"
#include "caf/shutdown.hpp"
#include "caf/exception.hpp"
#include "caf/resumable.hpp"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment