Skip to content

Commit

Permalink
Merge pull request #104 from SynBioDex/develop
Browse files Browse the repository at this point in the history
Push Develop
  • Loading branch information
Kiri Choi authored Dec 24, 2016
2 parents 848ea2c + 614bd00 commit 91bfb4d
Show file tree
Hide file tree
Showing 630 changed files with 31,011 additions and 200,169 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "restbed"]
path = restbed
url = https://github.com/Corvusoft/restbed.git
[submodule "jsconcpp"]
path = jsoncpp
url = https://github.com/open-source-parsers/jsoncpp
19 changes: 10 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9")
set(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk)

CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
PROJECT( SBOL )
Expand Down Expand Up @@ -37,13 +38,17 @@ endif()
OPTION( SBOL_BUILD_PYTHON2 "Generate Python version 2 wrapper using SWIG" FALSE )
OPTION( SBOL_BUILD_PYTHON3 "Generate Python version 3 wrapper using SWIG" FALSE )
OPTION( SBOL_BUILD_MANUAL "Generate SBOL documentation using Doxygen" FALSE )
#OPTION( SBOL_BUILD_REST "Generate RESTful API" FALSE )
OPTION( SBOL_BUILD_JSON "Build JsonCpp library (for Linux users primarily)" FALSE)

# -fPIC from boost Python
# -fPIC from boost Python
set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)

# build libSBOLc
#ADD_SUBDIRECTORY( schema )
# build examples
IF( SBOL_BUILD_JSON )
ADD_SUBDIRECTORY( jsoncpp )
ENDIF()

# build libSBOL
ADD_SUBDIRECTORY( source )

# build examples
Expand All @@ -61,10 +66,6 @@ IF( SBOL_BUILD_MANUAL )
ADD_SUBDIRECTORY( manual )
ENDIF()

IF( SBOL_BUILD_REST )
ADD_SUBDIRECTORY( restbed )
ENDIF()

IF( SBOL_BUILD_PYTHON2 OR SBOL_BUILD_PYTHON3 )
ADD_SUBDIRECTORY( wrapper )
ENDIF()
Expand Down
1 change: 1 addition & 0 deletions jsoncpp
Submodule jsoncpp added at 810657
2 changes: 1 addition & 1 deletion manual/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -1905,7 +1905,7 @@ MAN_LINKS = NO
# captures the structure of the code including all documentation.
# The default value is: NO.

GENERATE_XML = NO
GENERATE_XML = YES

# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
Expand Down
1 change: 0 additions & 1 deletion restbed
Submodule restbed deleted from cd3bb3
29 changes: 20 additions & 9 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ADD_SUBDIRECTORY( raptor )

# gather headers
include_directories( ${RAPTOR_INCLUDE_DIR})
include_directories( ${JsonCpp_INCLUDE_DIR})
include_directories( ${CURL_INCLUDE_DIR})

# gather source files
FILE(GLOB SBOL_HEADER_FILES
Expand Down Expand Up @@ -62,14 +64,16 @@ ENDIF()

# link against raptor
#ADD_DEFINITIONS( -DRAPTOR_STATIC -DLIBXML_STATIC)
ADD_DEFINITIONS(-DLIBXML_STATIC -DRAPTOR_STATIC -DLIBXSLT_STATIC -DCURL_STATIC)
ADD_DEFINITIONS(-DLIBXML_STATIC -DRAPTOR_STATIC -DLIBXSLT_STATIC -DCURL_STATIC -DCURL_STATICLIB)

get_directory_property( DirDefs COMPILE_DEFINITIONS )
#message( "COMPILE_DEFINITIONS = ${DirDefs}" )


message("${INCLUDE_DIRECTORIES}")

if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
include_directories( ${JSONCPP_INCLUDE_DIR}/..)
include_directories( ${CURL_INCLUDE_DIR}/..)
if(SBOL_BUILD_32)
message("Configuring for x86")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
Expand All @@ -85,10 +89,12 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
${SBOL_SOURCE_FILES})
endif()
target_link_libraries( sbol32
${RAPTOR_LIBRARY}
${LIBXML2_LIBRARIES}
${raptor2}
${xml2}
${zlib}
${iconv}
${jsoncpp}
${libcurl}
Ws2_32.lib )
install(TARGETS sbol32 DESTINATION lib) # Installs to C:\Program Files (x86)\SBOL\lib
install(DIRECTORY ${HEADER_OUTPUT_PATH} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
Expand All @@ -109,10 +115,12 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
${SBOL_SOURCE_FILES})
endif()
target_link_libraries( sbol64
${RAPTOR_LIBRARY}
${LIBXML2_LIBRARIES}
${raptor2}
${xml2}
${zlib}
${iconv}
${jsoncpp}
${libcurl}
Ws2_32.lib )
install(TARGETS sbol64 DESTINATION lib) # Installs to C:\Program Files (x86)\SBOL\lib
install(DIRECTORY ${HEADER_OUTPUT_PATH} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
Expand All @@ -139,7 +147,8 @@ else () # If Mac OSX or Linux
target_link_libraries( sbol32
${RAPTOR_LIBRARY}
${CURL_LIBRARY}
${LIBXSLT_LIBRARIES})
${LIBXSLT_LIBRARIES}
${JsonCpp_LIBRARY})
install(TARGETS sbol32 DESTINATION lib) # Installs to /usr/local/lib
install(DIRECTORY ${HEADER_OUTPUT_PATH} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
set_target_properties(sbol32 PROPERTIES OUTPUT_NAME "sbol")
Expand All @@ -166,7 +175,8 @@ else () # If Mac OSX or Linux
target_link_libraries( _raptor
${RAPTOR_LIBRARY}
${CURL_LIBRARY}
${LIBXSLT_LIBRARIES})
${LIBXSLT_LIBRARIES}
${JsonCpp_LIBRARY})
#add_library( _raptor STATIC IMPORTED )
#set_property(TARGET _raptor PROPERTY IMPORTED_LOCATION ${RAPTOR_LIBRARY})

Expand All @@ -189,7 +199,8 @@ else () # If Mac OSX or Linux
target_link_libraries( sbol64
${RAPTOR_LIBRARY}
${CURL_LIBRARY}
${LIBXSLT_LIBRARIES})
${LIBXSLT_LIBRARIES}
${JsonCpp_LIBRARY})
install(TARGETS sbol64 DESTINATION lib) # Installs to /usr/local/lib
install(DIRECTORY ${HEADER_OUTPUT_PATH} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
set_target_properties(sbol64 PROPERTIES OUTPUT_NAME "sbol")
Expand Down
71 changes: 71 additions & 0 deletions source/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,84 @@
#include <string>
#include <stdlib.h> /* srand, rand */
#include <time.h>
#include <vector>
#include <algorithm>

using namespace sbol;
using namespace std;

extern Config& config = * new sbol::Config(); ///< Global configuration object that governs library behavior, especially with regards to URI generation
//Config& config = * new sbol::Config(); ///< Global configuration object that governs library behavior, especially with regards to URI generation

std::map<std::string, std::string> sbol::Config::options {
{"validate", "True"},
{"validatorURL", "http://www.async.ece.utah.edu/sbol-validator/endpoint.php"},
{"output", "SBOL2"},
{"diff", "False"},
{"noncompliantUrisAllowed", "False"},
{"incompleteDocumentsAllowed", "False"},
{"bestPracticesCheck", "False"},
{"failOnFirstError", "False"},
{"displayFullErrorStackTrace", "False"},
{"topLevelToConvert", ""},
{"uriPrefix", ""},
{"version", ""},
{"wantFileBack", "False"}
};
std::map<std::string, std::vector<std::string>> sbol::Config::valid_options {
{"validate", { "True", "False" }},
{"output", { "SBOL2", "FASTA", "GenBank" }},
{"diff", { "True", "False" }},
{"noncompliantUrisAllowed", { "True", "False" }},
{"incompleteDocumentsAllowed", { "True", "False" }},
{"bestPracticesCheck", { "True", "False" }},
{"failOnFirstError", { "True", "False" }},
{"displayFullErrorStackTrace", { "True", "False" }},
{"topLevelToConvert", {"", "True", "False" }},
{"wantFileBack", {"True", "False"}}
};

void sbol::Config::setOption(std::string option, std::string value)
{
if (options.find(option) != options.end())
{
// Check if this option has valid arguments to validate against
if (valid_options.find(option) != valid_options.end())
{
// Set the option if a valid argument is provided
if (std::find(valid_options[option].begin(), valid_options[option].end(), value) != valid_options[option].end())
options[option] = value;
else
{
// Format error message
std::string msg;
for (auto const& arg : valid_options[option]) { msg += arg + ", "; }
msg[msg.size()-2] = '.'; // Replace last , with a .
throw SBOLError(SBOL_ERROR_INVALID_ARGUMENT, value + " not a valid value for this option. Valid options are " + msg);

}
}
else
// Any argument is valid, eg uriPrefix
options[option] = value;
}
else
{
throw SBOLError(SBOL_ERROR_INVALID_ARGUMENT, option + " not a valid configuration option for libSBOL");
}
};

std::string sbol::Config::getOption(std::string option)
{
if (options.find(option) != options.end())
{
return options[option];
}
else
{
throw SBOLError(SBOL_ERROR_INVALID_ARGUMENT, option + " not a valid configuration option for libSBOL");
}
};

// @TODO move sbol_type TYPEDEF declaration to this file and use sbol_type instead of string for 2nd argument
std::string sbol::constructCompliantURI(std::string sbol_type, std::string display_id, std::string version)
Expand Down
6 changes: 6 additions & 0 deletions source/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@

#include "sbolerror.h"
#include <string>
#include <map>
#include <vector>

namespace sbol
{
/// A class which contains global configuration variables for the libSBOL environment. Intended to be used like a static class, configuration variables are accessed through the `config' object.
class Config
{
private:
static std::map<std::string, std::string> options;
static std::map<std::string, std::vector<std::string>> valid_options;
std::string home; ///< The authoritative namespace for the Document. Setting the home namespace is like signing a piece of paper.
int SBOLCompliant; ///< Flag indicating whether to autoconstruct URI's consistent with SBOL's versioning scheme
int SBOLCompliantTypes; ///< Flag indicating whether an object's type is included in SBOL-compliant URIs
Expand All @@ -33,6 +37,8 @@ namespace sbol
int exceptionsEnabled();
void setFileFormat(std::string file_format);
std::string getFileFormat();
static void setOption(std::string option, std::string value);
static std::string getOption(std::string option);
};

void setHomespace(std::string ns); ///< Set the default namespace for autocreation of URIs when a new SBOL object is created
Expand Down
Loading

0 comments on commit 91bfb4d

Please sign in to comment.