Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

So, this works on linux now, only on unix because it is using pthreads. #2

Closed
wants to merge 8 commits into from
3 changes: 3 additions & 0 deletions .gitignore
@@ -1,3 +1,6 @@
\bin
\lib
\obj

\build
\install
41 changes: 41 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,41 @@
cmake_minimum_required (VERSION 3.2)
project (DataFrame)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Produce compile_commands.json

add_subdirectory(DMScu) # Build DMscu module first

set(SOURCE
src/BaseContainer.cc
)
set(HEADERS
include/BaseContainer.h
include/BaseContainer.tcc
include/DFVisitors.h
include/DataFrame.h
include/DataFrame.tcc
include/DataFrame_get.tcc
include/DataFrame_misc.tcc
include/DataFrame_opt.tcc
include/DataFrame_read.tcc
include/DataFrame_set.tcc
)


# Build the Dataframe library
add_definitions(-D DMS_INCLUDE_SOURCE)
add_library(Dataframe SHARED ${SOURCE})
target_link_libraries(Dataframe DMScu) # Link DMscu to Dataframe

# Find pthreads library
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(Dataframe Threads::Threads)

# Build the test binary
add_executable(datasci_tester src/datasci_tester.cc)
target_link_libraries(datasci_tester Dataframe) # Link the Dataframe library to the test binary

# Install the library
install(TARGETS Dataframe DESTINATION lib) # Move the lib file
install(FILES ${HEADERS} DESTINATION include) # Move the header files
33 changes: 33 additions & 0 deletions DMScu/CMakeLists.txt
@@ -0,0 +1,33 @@
message(STATUS "-- Configuring DMscu module")

set(SOURCE
src/DMScu_FileBase.cc
src/DMScu_MMapBase.cc
src/DMScu_MMapFile.cc
)
set(HEADERS
include/DMScu_Exception.h
include/DMScu_FileBase.h
include/DMScu_FileDef.h
include/DMScu_FixedSizeString.h
include/DMScu_MMapBase.h
include/DMScu_MMapFile.h
)

# Build the DMScu library
add_library(DMScu SHARED ${SOURCE})

# Build the test binary
add_executable(filebase_tester src/filebase_tester.cc)
add_executable(fixsizestr_tester src/fixsizestr_tester.cc)
add_executable(mmfile_tester src/mmfile_tester.cc)
# Link the Dataframe library to the test binary
target_link_libraries(filebase_tester DMScu)
target_link_libraries(fixsizestr_tester DMScu)
target_link_libraries(mmfile_tester DMScu)

# Install the library/module
install(TARGETS DMScu DESTINATION lib)
install(FILES ${HEADERS} DESTINATION include)

message(STATUS "-- Configuring DMscu module - done")
4 changes: 2 additions & 2 deletions DMScu/include/DMScu_FileBase.h
Expand Up @@ -16,8 +16,8 @@
#include <errno.h>
#include <strings.h>

#include <DMScu_Exception.h>
#include <DMScu_FileDef.h>
#include "DMScu_Exception.h"
#include "DMScu_FileDef.h"

// ----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion DMScu/include/DMScu_FileDef.h
Expand Up @@ -11,7 +11,7 @@
#include <cstdlib>
#include <cstdio>

#include <DMScu_FixedSizeString.h>
#include "DMScu_FixedSizeString.h"

// ----------------------------------------------------------------------------

Expand Down
36 changes: 18 additions & 18 deletions DMScu/include/DMScu_MMapBase.h
Expand Up @@ -17,8 +17,8 @@
#include <errno.h>
#include <strings.h>

#include <DMScu_Exception.h>
#include <DMScu_FileDef.h>
#include "DMScu_Exception.h"
#include "DMScu_FileDef.h"

// ----------------------------------------------------------------------------

Expand Down Expand Up @@ -351,7 +351,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (char *rhs) throw () {

if (_file_flags & _s_bread_ || _file_flags & _s_bwrite_ ||
_file_flags & _s_bappend_)
_file_flags & _s_bappend_)
read (rhs, sizeof (char), _width);
else {
strncpy (rhs, get_token (" ").c_str (), _width);
Expand All @@ -363,7 +363,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (std::ostream &rhs) {

if (_file_flags & _s_read_ || _file_flags & _s_write_ ||
_file_flags & _s_append_)
_file_flags & _s_append_)
rhs << get_token (" ").data ();
else {
DMScu_FixedSizeString<1023> err;
Expand All @@ -378,7 +378,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (std::string &rhs) {

if (_file_flags & _s_read_ || _file_flags & _s_write_ ||
_file_flags & _s_append_)
_file_flags & _s_append_)
rhs += get_token (" ");
else {
DMScu_FixedSizeString<1023> err;
Expand All @@ -393,7 +393,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (DMScu_VirtualString &rhs) {

if (_file_flags & _s_read_ || _file_flags & _s_write_ ||
_file_flags & _s_append_)
_file_flags & _s_append_)
rhs += get_token (" ").c_str ();
else {
DMScu_FixedSizeString<1023> err;
Expand All @@ -408,7 +408,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (char &rhs) throw () {

if (_file_flags & _s_bread_ || _file_flags & _s_bwrite_ ||
_file_flags & _s_bappend_)
_file_flags & _s_bappend_)
read (&rhs, sizeof (char), 1);
else
rhs = static_cast<char>(get_char ());
Expand All @@ -418,7 +418,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (unsigned char &rhs) throw () {

if (_file_flags & _s_bread_ || _file_flags & _s_bwrite_ ||
_file_flags & _s_bappend_)
_file_flags & _s_bappend_)
read (&rhs, sizeof (unsigned char), 1);
else
rhs = static_cast<unsigned char>(get_char ());
Expand All @@ -428,7 +428,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (short &rhs) throw () {

if (_file_flags & _s_bread_ || _file_flags & _s_bwrite_ ||
_file_flags & _s_bappend_)
_file_flags & _s_bappend_)
read (&rhs, sizeof (short), 1);
else
rhs = static_cast<short>
Expand All @@ -439,7 +439,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (int &rhs) throw () {

if (_file_flags & _s_bread_ || _file_flags & _s_bwrite_ ||
_file_flags & _s_bappend_)
_file_flags & _s_bappend_)
read (&rhs, sizeof (int), 1);
else
rhs = static_cast<int>
Expand All @@ -450,7 +450,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (long int &rhs) throw () {

if (_file_flags & _s_bread_ || _file_flags & _s_bwrite_ ||
_file_flags & _s_bappend_)
_file_flags & _s_bappend_)
read (&rhs, sizeof (long int), 1);
else
rhs = strtol (get_string ("0123456789").c_str (), NULL, 0);
Expand All @@ -460,7 +460,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (long long int &rhs) throw () {

if (_file_flags & _s_bread_ || _file_flags & _s_bwrite_ ||
_file_flags & _s_bappend_)
_file_flags & _s_bappend_)
read (&rhs, sizeof (long long int), 1);
else
rhs = strtoll (get_string ("0123456789").c_str (), NULL, 0);
Expand All @@ -470,7 +470,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (unsigned short &rhs) throw () {

if (_file_flags & _s_bread_ || _file_flags & _s_bwrite_ ||
_file_flags & _s_bappend_)
_file_flags & _s_bappend_)
read (&rhs, sizeof (unsigned short), 1);
else
rhs = static_cast<unsigned short>
Expand All @@ -481,7 +481,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (unsigned int &rhs) throw () {

if (_file_flags & _s_bread_ || _file_flags & _s_bwrite_ ||
_file_flags & _s_bappend_)
_file_flags & _s_bappend_)
read (&rhs, sizeof (unsigned int), 1);
else
rhs = static_cast<unsigned int>
Expand All @@ -493,7 +493,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
throw () {

if (_file_flags & _s_bread_ || _file_flags & _s_bwrite_ ||
_file_flags & _s_bappend_)
_file_flags & _s_bappend_)
read (&rhs, sizeof (unsigned long int), 1);
else
rhs = static_cast<unsigned long int>
Expand All @@ -505,7 +505,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
throw () {

if (_file_flags & _s_bread_ || _file_flags & _s_bwrite_ ||
_file_flags & _s_bappend_)
_file_flags & _s_bappend_)
read (&rhs, sizeof (unsigned long long int), 1);
else
rhs = static_cast<unsigned long long int>
Expand All @@ -516,7 +516,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (float &rhs) throw () {

if (_file_flags & _s_bread_ || _file_flags & _s_bwrite_ ||
_file_flags & _s_bappend_)
_file_flags & _s_bappend_)
read (&rhs, sizeof (float), 1);
else
rhs = static_cast<float>
Expand All @@ -527,7 +527,7 @@ class DMScu_MMapBase : public DMScu_FileDef {
inline DMScu_MMapBase &operator >> (double &rhs) throw () {

if (_file_flags & _s_bread_ || _file_flags & _s_bwrite_ ||
_file_flags & _s_bappend_)
_file_flags & _s_bappend_)
read (&rhs, sizeof (double), 1);
else
rhs = strtod (get_string ("0123456789.").c_str (), NULL);
Expand Down
2 changes: 1 addition & 1 deletion DMScu/include/DMScu_MMapFile.h
Expand Up @@ -8,7 +8,7 @@

// ----------------------------------------------------------------------------

#include <DMScu_MMapBase.h>
#include "DMScu_MMapBase.h"

// ----------------------------------------------------------------------------

Expand Down
38 changes: 19 additions & 19 deletions DMScu/src/DMScu_FileBase.cc
Expand Up @@ -7,32 +7,32 @@
#include <sys/stat.h>
#include <unistd.h>

#include <DMScu_FileBase.h>
#include "../include/DMScu_FileBase.h"

// ----------------------------------------------------------------------------

bool DMScu_FileBase::_translate_open_mode () throw () {

switch (_get_open_mode ()) {

case _read_:
_file_flags = _s_read_ | _in_use_;
break;
case _bread_:
_file_flags = _s_bread_ | _in_use_;
break;
case _write_:
_file_flags = _s_write_ | _s_read_ | _in_use_;
break;
case _bwrite_:
_file_flags = _s_bwrite_ | _s_bread_ | _in_use_;
break;
case _append_:
_file_flags = _s_append_ | _s_read_ | _in_use_;
break;
case _bappend_:
_file_flags = _s_bappend_ | _s_bread_ | _in_use_;
break;
case _read_:
_file_flags = _s_read_ | _in_use_;
break;
case _bread_:
_file_flags = _s_bread_ | _in_use_;
break;
case _write_:
_file_flags = _s_write_ | _s_read_ | _in_use_;
break;
case _bwrite_:
_file_flags = _s_bwrite_ | _s_bread_ | _in_use_;
break;
case _append_:
_file_flags = _s_append_ | _s_read_ | _in_use_;
break;
case _bappend_:
_file_flags = _s_bappend_ | _s_bread_ | _in_use_;
break;
}

return (true);
Expand Down
2 changes: 1 addition & 1 deletion DMScu/src/DMScu_MMapBase.cc
Expand Up @@ -7,7 +7,7 @@
#include <sys/stat.h>
#include <unistd.h>

#include <DMScu_MMapBase.h>
#include "../include/DMScu_MMapBase.h"

// ----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion DMScu/src/DMScu_MMapFile.cc
Expand Up @@ -7,7 +7,7 @@
#include <sys/stat.h>
#include <unistd.h>

#include <DMScu_MMapFile.h>
#include "../include/DMScu_MMapFile.h"

// ----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion DMScu/src/filebase_tester.cc
Expand Up @@ -3,7 +3,7 @@
// Copyright (C) 2017-2018 Hossein Moein
// Distributed under the BSD Software License (see file License)

#include <DMScu_FileBase.h>
#include "../include/DMScu_FileBase.h"

bool WriteFile (DMScu_FileBase &);
bool ReadFile (DMScu_FileBase &);
Expand Down
2 changes: 1 addition & 1 deletion DMScu/src/fixsizestr_tester.cc
Expand Up @@ -7,7 +7,7 @@
#include <iostream>
#include <string>

#include <DMScu_FixedSizeString.h>
#include "../include/DMScu_FixedSizeString.h"

using namespace std;

Expand Down
2 changes: 1 addition & 1 deletion DMScu/src/mmfile_tester.cc
Expand Up @@ -3,7 +3,7 @@

#include <fstream>

#include <DMScu_MMapFile.h>
#include "../include/DMScu_MMapFile.h"

int WriteFile (DMScu_MMapFile &);
int ReadFile (DMScu_MMapFile &);
Expand Down
10 changes: 10 additions & 0 deletions README.md
@@ -1,2 +1,12 @@
# DataFrame
This is a C++ statistical library to provide an interface similar to Pandas package in Python

# Building using CMake(beta?)

```
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=../install
make
make install
```
2 changes: 1 addition & 1 deletion include/BaseContainer.h
Expand Up @@ -164,7 +164,7 @@ struct HeteroVector {
// ----------------------------------------------------------------------------

# ifdef DMS_INCLUDE_SOURCE
# include <BaseContainer.tcc>
# include "BaseContainer.tcc"
# endif // DMS_INCLUDE_SOURCE

// ----------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions include/BaseContainer.tcc
Expand Up @@ -3,7 +3,7 @@
// Copyright (C) 2017-2018 Hossein Moein
// Distributed under the BSD Software License (see file License)

#include <BaseContainer.h>
#include "BaseContainer.h"
#include <type_traits>
#include <limits>

Expand Down Expand Up @@ -252,4 +252,3 @@ const T &HeteroVector::front() const { return (get_vec<T, V>().front ()); }
// tab-width:4
// c-basic-offset:4
// End: