Skip to content

Commit

Permalink
Merge pull request #89 from kspangsege/flexible_replication
Browse files Browse the repository at this point in the history
Improve flexibility of replication hook
  • Loading branch information
bmunkholm committed May 8, 2013
2 parents fc5e283 + 89ce04d commit f11d716
Show file tree
Hide file tree
Showing 34 changed files with 1,249 additions and 1,324 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,6 @@ There are also a number of environment variables that serve to enable
or disable special features during building:

Set `TIGHTDB_ENABLE_REPLICATION` to a nonempty value to enable
replication.
replication. For example:

TIGHTDB_ENABLE_REPLICATION=1 sh build.sh src-dist all
6 changes: 3 additions & 3 deletions TightDB.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@
<ClCompile Include="src\tightdb\column_string_enum.cpp" />
<ClCompile Include="src\tightdb\column_table.cpp" />
<ClCompile Include="src\tightdb\file.cpp" />
<ClCompile Include="src\tightdb\pthread_helpers.cpp" />
<ClCompile Include="src\tightdb\thread.cpp" />
<ClCompile Include="src\tightdb\group.cpp" />
<ClCompile Include="src\tightdb\group_shared.cpp" />
<ClCompile Include="src\tightdb\group_writer.cpp" />
Expand Down Expand Up @@ -613,7 +613,7 @@
<ClInclude Include="src\tightdb\meta.hpp" />
<ClInclude Include="src\tightdb\mixed.hpp" />
<ClInclude Include="src\tightdb\overflow.hpp" />
<ClInclude Include="src\tightdb\pthread_helpers.hpp" />
<ClInclude Include="src\tightdb\thread.hpp" />
<ClInclude Include="src\tightdb\query.hpp" />
<ClInclude Include="src\tightdb\query_conditions.hpp" />
<ClInclude Include="src\tightdb\query_engine.hpp" />
Expand Down Expand Up @@ -658,4 +658,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions TightDB.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<ClCompile Include="src\tightdb\file.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\tightdb\pthread_helpers.cpp">
<ClCompile Include="src\tightdb\thread.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\tightdb\index_string.cpp">
Expand Down Expand Up @@ -334,7 +334,7 @@
<ClInclude Include="src\tightdb\string_buffer.hpp">
<Filter>src\include</Filter>
</ClInclude>
<ClInclude Include="src\tightdb\pthread_helpers.hpp">
<ClInclude Include="src\tightdb\thread.hpp">
<Filter>src\include</Filter>
</ClInclude>
<ClInclude Include="src\tightdb\tightdb_nmmintrin.h">
Expand Down
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ MODE="$1"

EXTENSIONS="java python objc node php c gui"

if [ "$TIGHTDB_ENABLE_REPLICATION" ]; then
EXTENSIONS="$EXTENSIONS replication"
fi


map_ext_name_to_dir()
Expand Down
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Format:
==================


2013-05-07 (Kristian Spangsege)
. Exception File::OpenError renamed to File::AccessError. This affects
various methods in Group and SharedGroup.


2013-04-23 (Kristian Spangsege)
+ Support for explicit string lengths added. Most method arguments and
return values of type 'const char*' have been changed to be of type
Expand Down
12 changes: 6 additions & 6 deletions doc/ref_cpp/data/group_ref.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ CATEGORIES:
TYPES : Group
DESCR : A - possibly empty - group.
THROWS:
- EXCEPT : File::OpenError
- EXCEPT : File::AccessError
DESCR : If the file (or buffer) could not be opened. If the reason
corresponds to one of the exception types that are
derived from File::OpenError, the derived exception
derived from File::AccessError, the derived exception
type is thrown. Note that InvalidDatabase is among
these derived exception types.
EXAMPLES:
Expand Down Expand Up @@ -248,10 +248,10 @@ CATEGORIES:
TYPES : const std::string&
DESCR : A filesystem path.
THROWS:
- EXCEPT : File::OpenError
- EXCEPT : File::AccessError
DESCR : If the file could not be opened. If the reason
corresponds to one of the exception types that are
derived from File::OpenError, the derived exception
derived from File::AccessError, the derived exception
type is thrown.
EXAMPLES:
- DESCR :
Expand Down Expand Up @@ -361,10 +361,10 @@ CATEGORIES:
TYPES : BinaryData
DESCR : In-memory binary encoded representation of a group.
THROWS:
- EXCEPT : File::OpenError
- EXCEPT : File::AccessError
DESCR : If the file (or buffer) could not be opened. If the reason
corresponds to one of the exception types that are
derived from File::OpenError, the derived exception
derived from File::AccessError, the derived exception
type is thrown. Note that InvalidDatabase is among
these derived exception types.
EXAMPLES:
Expand Down
8 changes: 4 additions & 4 deletions doc/ref_cpp/data/shared_group_ref.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ CATEGORIES:
TYPES : SharedGroup
DESCR : A shared group.
THROWS:
- EXCEPT : File::OpenError
- EXCEPT : File::AccessError
DESCR : If the file could not be opened. If the reason
corresponds to one of the exception types that are
derived from File::OpenError, the derived exception
derived from File::AccessError, the derived exception
type is thrown. Note that InvalidDatabase is among
these derived exception types.
EXAMPLES:
Expand Down Expand Up @@ -133,10 +133,10 @@ CATEGORIES:
TYPES : DurabilityLevel
DESCR : Durability Level (durability_Full or durability_MemOnly)
THROWS:
- EXCEPT : File::OpenError
- EXCEPT : File::AccessError
DESCR : If the file could not be opened. If the reason
corresponds to one of the exception types that are
derived from File::OpenError, the derived exception
derived from File::AccessError, the derived exception
type is thrown. Note that InvalidDatabase is among
these derived exception types.
EXAMPLES:
Expand Down
16 changes: 10 additions & 6 deletions generic.mk
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
# local Makefile.
SOURCE_ROOT =

CFLAGS_OPTIM =
CFLAGS_OPTIM = -DNDEBUG
CFLAGS_DEBUG =
CFLAGS_COVER =
CFLAGS_SHARED =
Expand All @@ -68,9 +68,9 @@ CFLAGS_OBJC =
CFLAGS_ARCH =
CFLAGS_INCLUDE =
CFLAGS_AUTODEP =
LDFLAGS_OPTIM = $(CFLAGS_OPTIM)
LDFLAGS_DEBUG = $(CFLAGS_DEBUG)
LDFLAGS_COVER = $(CFLAGS_COVER)
LDFLAGS_OPTIM = $(filter-out -D%,$(CFLAGS_OPTIM))
LDFLAGS_DEBUG = $(filter-out -D%,$(CFLAGS_DEBUG))
LDFLAGS_COVER = $(filter-out -D%,$(CFLAGS_COVER))
LDFLAGS_SHARED =
LDFLAGS_PTHREAD = $(CFLAGS_PTHREAD)
LDFLAGS_GENERAL =
Expand Down Expand Up @@ -286,7 +286,7 @@ endif
endif
CC_AND_CXX_ARE_GCC_LIKE = $(and $(call IS_GCC_LIKE,$(CC)),$(or $(call IS_GCC_LIKE,$(CXX)),$(call IS_GXX_LIKE,$(CXX))))
ifneq ($(CC_AND_CXX_ARE_GCC_LIKE),)
CFLAGS_OPTIM = -O3
CFLAGS_OPTIM = -O3 -DNDEBUG
CFLAGS_DEBUG = -ggdb
CFLAGS_COVER = --coverage
CFLAGS_SHARED = -fPIC -DPIC
Expand Down Expand Up @@ -788,7 +788,11 @@ $(eval $(TEST_RULES))

# LINKING PROGRAMS

# FIXME: Add '-Wl,-rpath' if linking against locally built and installed libraries, but it requires us to know the library installation directory. Or maybe it is better to set LD_RUN_PATH.
# FIXME: Add '-Wl,-rpath' if linking against locally built and
# installed libraries. This will allow the programs to find the
# installed libraries even if they are installed into a non-standard
# location. But it requires us to know the library installation
# directory. Or maybe it is better to set LD_RUN_PATH.

# neither inst nor noinst libs can have noinst lib dependencies
# noinst libs can have associated LDFLAGS
Expand Down
4 changes: 2 additions & 2 deletions src/tightdb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TABLE_MACROS_HPP = table_macros.hpp
GENERATED_SOURCES = $(TABLE_MACROS_HPP)

INST_HEADERS = config.h meta.hpp assert.hpp exceptions.hpp terminate.hpp type_list.hpp tuple.hpp \
safe_int_ops.hpp unique_ptr.hpp bind_ptr.hpp string_buffer.hpp file.hpp pthread_helpers.hpp \
bind.hpp safe_int_ops.hpp unique_ptr.hpp bind_ptr.hpp string_buffer.hpp file.hpp thread.hpp \
utf8.hpp utilities.hpp alloc.hpp alloc_slab.hpp array.hpp array_string.hpp data_type.hpp \
column_type.hpp column_fwd.hpp spec.hpp date.hpp string_data.hpp binary_data.hpp mixed.hpp \
table.hpp table_ref.hpp table_basic_fwd.hpp table_accessors.hpp table_basic.hpp table_view.hpp \
Expand All @@ -13,7 +13,7 @@ query_conditions.hpp lang_bind_helper.hpp tightdb_nmmintrin.h replication.hpp
lib_LIBRARIES = libtightdb.a
bin_PROGRAMS = tightdb-config

libtightdb_a_SOURCES = terminate.cpp string_buffer.cpp file.cpp pthread_helpers.cpp utf8.cpp \
libtightdb_a_SOURCES = terminate.cpp string_buffer.cpp file.cpp thread.cpp utf8.cpp \
utilities.cpp alloc.cpp alloc_slab.cpp array.cpp array_string.cpp array_string_long.cpp \
array_binary.cpp array_blob.cpp column.cpp column_string.cpp column_string_enum.cpp \
column_binary.cpp column_table.cpp column_mixed.cpp spec.cpp table.cpp table_view.cpp group.cpp \
Expand Down
2 changes: 1 addition & 1 deletion src/tightdb/alloc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace tightdb {

#ifdef TIGHTDB_ENABLE_REPLICATION
struct Replication;
class Replication;
#endif

struct MemRef {
Expand Down
9 changes: 5 additions & 4 deletions src/tightdb/alloc_slab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class GroupWriter;
/// Thrown by Group and SharedGroup constructors if the specified file
/// (or memory buffer) does not appear to contain a valid TightDB
/// database.
struct InvalidDatabase: File::OpenError {
InvalidDatabase(): File::OpenError("Invalid database") {}
struct InvalidDatabase: File::AccessError {
InvalidDatabase(): File::AccessError("Invalid database") {}
};


Expand All @@ -63,7 +63,7 @@ class SlabAlloc: public Allocator {
///
/// \param no_create Fail if the file does not already exist.
///
/// \throw File::OpenError
/// \throw File::AccessError
void attach_file(const std::string& path, bool is_shared, bool read_only, bool no_create);

/// Attach this allocator to the specified memory buffer.
Expand Down Expand Up @@ -126,7 +126,8 @@ class SlabAlloc: public Allocator {
bool validate_buffer(const char* data, size_t len) const;

#ifdef TIGHTDB_ENABLE_REPLICATION
void set_replication(Replication* r) { m_replication = r; }
Replication* get_replication() const TIGHTDB_NOEXCEPT { return m_replication; }
void set_replication(Replication* r) TIGHTDB_NOEXCEPT { m_replication = r; }
#endif
};

Expand Down
2 changes: 1 addition & 1 deletion src/tightdb/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ template <bool gt, Action action, size_t width, class Callback> bool Array::Find

template <bool gt, Action action, size_t width, class Callback> bool Array::FindGTLT(int64_t v, uint64_t chunk, QueryState<int64_t>* state, size_t baseindex, Callback callback) const
{
// Fínd items in 'chunk' that are greater (if gt == true) or smaller (if gt == false) than 'v'. Fixme, __forceinline can make it crash in vS2010 - find out why
// Find items in 'chunk' that are greater (if gt == true) or smaller (if gt == false) than 'v'. Fixme, __forceinline can make it crash in vS2010 - find out why
if (width == 1) {
for (size_t t = 0; t < 64; t++) {
if (gt ? (int64_t)(chunk & 0x1) > v : (int64_t)(chunk & 0x1) < v) {if (!find_action<action, Callback>( t + baseindex, (int64_t)(chunk & 0x1), state, callback)) return false;} chunk >>= 1;
Expand Down
82 changes: 82 additions & 0 deletions src/tightdb/bind.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*************************************************************************
*
* TIGHTDB CONFIDENTIAL
* __________________
*
* [2011] - [2012] TightDB Inc
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of TightDB Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to TightDB Incorporated
* and its suppliers and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from TightDB Incorporated.
*
**************************************************************************/
#ifndef TIGHTDB_UTIL_BIND_HPP
#define TIGHTDB_UTIL_BIND_HPP

namespace tightdb {
namespace _impl {


template<class O> class MemFunObjBinder {
public:
MemFunObjBinder(void (O::*mem_fun)(), O* obj): m_mem_fun(mem_fun), m_obj(obj) {}
void operator()() const { (m_obj->*m_mem_fun)(); }
private:
void (O::* const m_mem_fun)();
O* const m_obj;
};

template<class O, class A> class MemFunObjBinder1 {
public:
MemFunObjBinder1(void (O::*mem_fun)(A), O* obj): m_mem_fun(mem_fun), m_obj(obj) {}
void operator()(A a) const { (m_obj->*m_mem_fun)(a); }
private:
void (O::* const m_mem_fun)(A);
O* const m_obj;
};

template<class O, class A, class B> class MemFunObjBinder2 {
public:
MemFunObjBinder2(void (O::*mem_fun)(A,B), O* obj): m_mem_fun(mem_fun), m_obj(obj) {}
void operator()(A a, B b) const { (m_obj->*m_mem_fun)(a,b); }
private:
void (O::* const m_mem_fun)(A,B);
O* const m_obj;
};


} // namespace _impl

namespace util {


template<class O>
inline _impl::MemFunObjBinder<O> bind(void (O::*mem_fun)(), O* obj)
{
return _impl::MemFunObjBinder<O>(mem_fun, obj);
}

template<class O, class A>
inline _impl::MemFunObjBinder1<O,A> bind(void (O::*mem_fun)(A), O* obj)
{
return _impl::MemFunObjBinder1<O,A>(mem_fun, obj);
}

template<class O, class A, class B>
inline _impl::MemFunObjBinder2<O,A,B> bind(void (O::*mem_fun)(A,B), O* obj)
{
return _impl::MemFunObjBinder2<O,A,B>(mem_fun, obj);
}


} // namespace util
} // namespace tightdb

#endif // TIGHTDB_UTIL_BIND_HPP
Loading

0 comments on commit f11d716

Please sign in to comment.