Skip to content

Commit

Permalink
Introduce a more canonical C++ project structure (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjperkins authored Sep 27, 2023
1 parent 0ccbd0c commit d12660c
Show file tree
Hide file tree
Showing 21 changed files with 38 additions and 35 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ endif(CCACHE_FOUND)
include(FindPyArrow)
include(SetupVCPKG)
project(main CXX C)

include_directories(cpp)
add_subdirectory(cpp)

if(SKBUILD)
Expand Down
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ History

X.Y.Z (YYYY-MM-DD)
------------------
* Introduce a more canonical C++ project structure (:pr:`57`)
* Consistently use CamelCase throughout the C++ layer (:pr:`56`)
* Support getcol, tabledesc and getcoldesc (:pr:`55`)
* Enable initial OSX support in the build process (:pr:`54`)
Expand Down
1 change: 0 additions & 1 deletion arcae/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ set_target_properties(arrow_tables PROPERTIES
POSITION_INDEPENDENT_CODE 1)

install(TARGETS arrow_tables LIBRARY DESTINATION ${ARCAE_LIB_INSTALL_PATH})

12 changes: 6 additions & 6 deletions arcae/arrow_tables.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ cdef extern from "<climits>" nogil:
cdef unsigned int UINT_MAX


cdef extern from "../cpp/service_locator.h" namespace "arcae" nogil:
cdef extern from "../cpp/arcae/service_locator.h" namespace "arcae" nogil:
cdef cppclass CServiceLocator" arcae::ServiceLocator":
@staticmethod
CConfiguration & configuration" ServiceLocator::configuration"()

cdef extern from "../cpp/configuration.h" namespace "arcae" nogil:
cdef extern from "../cpp/arcae/configuration.h" namespace "arcae" nogil:
cdef cppclass CConfiguration" arcae::Configuration":
void Set" Configuration::Set"(const string & key, string value)
CResult[string] Get" Configuration::Get"(const string & key)
CResult[bool] Delete" Configuration::Delete"(const string & key)
vector[string] GetKeys" Configuration::GetKeys"()
size_t Size" Configuration::Size"()

cdef extern from "../cpp/descriptor.h" namespace "arcae" nogil:
cdef extern from "../cpp/arcae/descriptor.h" namespace "arcae" nogil:
cdef CResult[string] CMSDescriptor" arcae::MSDescriptor"(const string & table, bool complete)

cdef extern from "../cpp/safe_table_proxy.h" namespace "arcae" nogil:
cdef extern from "../cpp/arcae/safe_table_proxy.h" namespace "arcae" nogil:
cdef cppclass CCasaTable" arcae::SafeTableProxy":
@staticmethod
CResult[bool] Close" SafeTableProxy::Close"()
Expand All @@ -45,7 +45,7 @@ cdef extern from "../cpp/safe_table_proxy.h" namespace "arcae" nogil:
CResult[bool] AddRows " SafeTableProxy::AddRows"(unsigned int nrows)


cdef extern from "../cpp/table_factory.h" namespace "arcae" nogil:
cdef extern from "../cpp/arcae/table_factory.h" namespace "arcae" nogil:
cdef CResult[shared_ptr[CCasaTable]] COpenTable" arcae::OpenTable"(
const string & filename)
cdef CResult[shared_ptr[CCasaTable]] CDefaultMS" arcae::DefaultMS"(
Expand All @@ -55,7 +55,7 @@ cdef extern from "../cpp/table_factory.h" namespace "arcae" nogil:
const string & json_dminfo)


cdef extern from "../cpp/complex_type.h" namespace "arcae" nogil:
cdef extern from "../cpp/arcae/complex_type.h" namespace "arcae" nogil:
cdef cppclass CComplexType" arcae::ComplexType"(CExtensionType):
shared_ptr[CDataType] value_type" ComplexType::value_type"()
string extension_name()
Expand Down
20 changes: 10 additions & 10 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ find_package(PkgConfig REQUIRED)
pkg_check_modules(casacore REQUIRED IMPORTED_TARGET casacore)

add_library(arcae SHARED
casa_visitors.cpp
column_convert_visitor.cpp
complex_type.cpp
configuration.cpp
descriptor.cpp
service_locator.cpp
safe_table_proxy.cpp
table_factory.cpp)
arcae/casa_visitors.cc
arcae/column_convert_visitor.cc
arcae/complex_type.cc
arcae/configuration.cc
arcae/descriptor.cc
arcae/service_locator.cc
arcae/safe_table_proxy.cc
arcae/table_factory.cc)

target_link_directories(arcae PUBLIC ${PYARROW_LIBDIRS})
target_link_libraries(arcae PkgConfig::casacore arrow)
target_include_directories(arcae PUBLIC PkgConfig::casacore ${PYARROW_INCLUDE})
target_include_directories(arcae PUBLIC PkgConfig::casacore ${PYARROW_INCLUDE} ${CMAKE_INCLUDE_CURRENT_DIR})
target_compile_options(arcae PUBLIC "-D_GLIBCXX_USE_CXX11_ABI=0")

set_target_properties(arcae PROPERTIES
POSITION_INDEPENDENT_CODE 1)

install(TARGETS arcae LIBRARY DESTINATION ${ARCAE_LIB_INSTALL_PATH})
install(TARGETS arcae LIBRARY DESTINATION ${ARCAE_LIB_INSTALL_PATH})
2 changes: 1 addition & 1 deletion cpp/casa_visitors.cpp → cpp/arcae/casa_visitors.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "casa_visitors.h"
#include "arcae/casa_visitors.h"

namespace arcae {

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <casacore/tables/Tables.h>

#include "column_convert_visitor.h"
#include "complex_type.h"
#include "arcae/column_convert_visitor.h"
#include "arcae/complex_type.h"

using ::arrow::DataType;
using ::arrow::Buffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

#include <arrow/util/logging.h> // IWYU pragma: keep

#include "casa_visitors.h"
#include "complex_type.h"
#include "service_locator.h"
#include "arcae/casa_visitors.h"
#include "arcae/complex_type.h"
#include "arcae/service_locator.h"

namespace arcae {

Expand Down
2 changes: 1 addition & 1 deletion cpp/complex_type.cpp → cpp/arcae/complex_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <mutex>

#include "complex_type.h"
#include "arcae/complex_type.h"

namespace arcae {

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cpp/configuration.cpp → cpp/arcae/configuration.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "configuration.h"
#include "arcae/configuration.h"


namespace arcae {
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions cpp/descriptor.cpp → cpp/arcae/descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#include <sstream>

#include "descriptor.h"

#include <arrow/result.h>

#include <casacore/casa/Json.h>
Expand All @@ -27,6 +25,9 @@
#include <casacore/tables/Tables/TableProxy.h>
#include <casacore/casa/Containers/ValueHolder.h>

#include "arcae/descriptor.h"


using ::arrow::Result;
using ::arrow::Status;

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cpp/safe_table_proxy.cpp → cpp/arcae/safe_table_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <casacore/casa/Json.h>
#include <casacore/tables/Tables/TableIterProxy.h>

#include "safe_table_proxy.h"
#include "arcae/safe_table_proxy.h"


using ::arrow::DataType;
Expand Down
2 changes: 1 addition & 1 deletion cpp/safe_table_proxy.h → cpp/arcae/safe_table_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <arrow/util/thread_pool.h>

#include "column_convert_visitor.h"
#include "arcae/column_convert_visitor.h"


namespace arcae {
Expand Down
2 changes: 1 addition & 1 deletion cpp/service_locator.cpp → cpp/arcae/service_locator.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "service_locator.h"
#include "arcae/service_locator.h"

namespace arcae {

Expand Down
2 changes: 1 addition & 1 deletion cpp/service_locator.h → cpp/arcae/service_locator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <memory>
#include <mutex>

#include "configuration.h"
#include "arcae/configuration.h"

namespace arcae {

Expand Down
6 changes: 3 additions & 3 deletions cpp/table_factory.cpp → cpp/arcae/table_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include <algorithm>

#include "descriptor.h"
#include "safe_table_proxy.h"
#include "table_factory.h"
#include "arcae/descriptor.h"
#include "arcae/safe_table_proxy.h"
#include "arcae/table_factory.h"

#include <arrow/api.h>

Expand Down
2 changes: 1 addition & 1 deletion cpp/table_factory.h → cpp/arcae/table_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <arrow/result.h>

#include "safe_table_proxy.h"
#include "arcae/safe_table_proxy.h"

namespace arcae {

Expand Down

0 comments on commit d12660c

Please sign in to comment.