Skip to content

Commit

Permalink
simplified CMake options, use target_link_dependencies(), target_incl…
Browse files Browse the repository at this point in the history
…ude_directories(), some libs installed on Vagrant build machines (see Build.txt). Builds all solvers (except Chombo and Hy3S) on Linux64-client, Linux64-server, Win64.

svn path=/vcell/trunk/numerics/; revision=21109


Former-commit-id: 74137fd147f6351f78ac0ada7b33b14678c597f8
  • Loading branch information
jcschaff committed Jun 20, 2017
1 parent 1196af5 commit e66bc1c
Show file tree
Hide file tree
Showing 9 changed files with 4,492 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ endif()

if (${OPTION_TARGET_MOVINGBOUNDARY_SOLVER})
message(STATUS "adding MovingBoundarySolver")
add_subdirectory(MovingBoundarySolver)
add_subdirectory(MBSolver)
message(STATUS "adding FronTierLib")
add_subdirectory(FronTierLib)
endif()
Expand Down
17 changes: 17 additions & 0 deletions vcommons/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

project(vcommons)

file(GLOB SRC_FILES src/*cpp)

file(GLOB HEADER_FILES include/*h include/*hpp)
include_directories(${PROJECT_SOURCE_DIR}/include)

include_directories(include)
set_source_files_properties( ${SRC_FILES} PROPERTIES LANGUAGE CXX)
add_library(vcommons ${SRC_FILES} ${HEADER_FILES})
target_include_directories(vcommons PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include> # <prefix>/include
)

install(TARGETS vcommons ARCHIVE DESTINATION lib)
86 changes: 86 additions & 0 deletions vcommons/include/OstreamSpy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#ifndef OstreamSpy_h
#define OstreamSpy_h
#include <streambuf>
namespace vcell_util {

/**
* specialized streambuf for uses in OStreamSpy
* @tparam Spy class which implements intercept(char_type)
*/
template <class Spy, typename char_type, typename traits = std::char_traits<char_type> >
struct Spybuf: public std::basic_streambuf<char_type, traits> {
// based on public domain code by Thomas Guest
// http://wordaligned.org/articles/cpp-streambufs

typedef typename traits::int_type int_type;

/**
@param spy_ -- reference must remain valid
@param sb streambuf to spy upon
*/
Spybuf(Spy & spy_,std::basic_streambuf<char_type, traits> * sb)
:spy(spy_),
realbuf(sb)
{
}

private:
virtual int sync()
{
return realbuf->pubsync( );
}

virtual int_type overflow(int_type c)
{
int_type const eof = traits::eof();

if (traits::eq_int_type(c, eof))
{
return traits::not_eof(c);
}
else
{
char_type const ch = traits::to_char_type(c);
spy.intercept(ch);
return realbuf->sputc(ch);
}
}

private:
Spy & spy;
std::basic_streambuf<char_type, traits> * realbuf;
};

/**
* class to intercept writes to an existing ostream
* @tparam Spy class which implements intercept(char_type)
*/
template <class Spy, typename char_type = char, typename traits = std::char_traits<char_type> >
struct OStreamSpy {
/**
@param target stream to intercept
@param spy -- reference must remain valid
*/
OStreamSpy( std::basic_ostream<char_type,traits> & target_, Spy & spy_ )
:target(target_),
spy(spy_),
targetbuf(target_.rdbuf( )),
spybuf(spy_,targetbuf)
{
target.rdbuf(&spybuf);
}
/**
* restores previous streambuf
*/
~OStreamSpy( ) {
target.rdbuf(targetbuf);
}
private:
std::basic_ostream<char_type,traits> & target;
Spy & spy;
std::basic_streambuf<char,traits> * targetbuf;
// must come after targetbuf in class declaration due to initialization order
Spybuf<Spy, char_type, traits> spybuf;
};
}
#endif
14 changes: 14 additions & 0 deletions vcommons/include/VCellException.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef VCellException_h
#define VCellException_h
#include <sstream>
#include <stdexcept>

/**
* based on some ideas in apache Log4jcxxx (BSD licensed)
* @param EXC std:: exception to throw
* @param x code fragment to stream
*/
#define VCELL_RUNTIME_EXCEPTION(x) { std::ostringstream oss; oss << x << " at " << __FILE__ << ':' << __LINE__ << std::ends; throw std::runtime_error(oss.str( )); }
#define VCELL_EXCEPTION(EXC,x) { std::ostringstream oss; oss << x << " at " << __FILE__ << ':' << __LINE__ << std::ends; throw std::EXC(oss.str( )); }
#define VCELL_EXCEPTION_NOLOCATION(EXC,x) { std::ostringstream oss; oss << x << std::ends; throw std::EXC(oss.str( )); }
#endif
Loading

0 comments on commit e66bc1c

Please sign in to comment.