Commit d57e898e authored by Evgeny Lavrik's avatar Evgeny Lavrik
Browse files

Rename project

parent 5d24643c
cmake_minimum_required(VERSION 2.8)
project(TGenBaseClient)
project(TGenBase)
set(CMAKE_CXX_STANDARD 11)
# set(CMAKE_BUILD_TYPE debug)
set(PROJECT_VERSION 1.0)
......@@ -34,4 +34,4 @@ include(${ROOT_USE_FILE})
add_definitions(${ROOT_CXX_FLAGS})
add_subdirectory(external)
add_subdirectory(TGenBaseClient)
add_subdirectory(TGenBase)
......@@ -24,7 +24,7 @@ Pass `-DCMAKE_INSTALL_PREFIX=/your/installation/path` to `cmake` command to chan
### Configuration
The TGenBase client for C++ needs to know where to fetch the data from.
The client uses the `ServerURI` entry in the `TGenBaseClientConfig.json` file to point to a correct TGenBase database server installation.
The client uses the `ServerURI` entry in the `TGenBaseConfig.json` file to point to a correct TGenBase database server installation.
The authentication information will be stored in this file between C++ sessions under the `AccessToken` configuration key.
......@@ -49,4 +49,4 @@ if (user) {
Note, that code by default is explicitly exception safe. This means you should pay attention to the standard output.
In case of exception, return values for getters with single queries are `nullptr` and for array queries are empty vectors.
If you want to enable the exception handling compile the package with -DTGENBASECLIENT_WITH_EXCEPTIONS
If you want to enable the exception handling compile the package with -DTGENBASE_WITH_EXCEPTIONS
......@@ -5,14 +5,14 @@
* @date 4.7.2018
**/
#ifndef TGENBASECLIENTBASECLASS_H
#define TGENBASECLIENTBASECLASS_H
#ifndef TGENBASEBASECLASS_H
#define TGENBASEBASECLASS_H
#include <jsoncons/json.hpp>
#include <jsoncons_ext/csv/csv_options.hpp>
#include "TGenBaseClient/Utils.h"
#include "TGenBaseClient/TimeStamp.h"
#include "TGenBase/Utils.h"
#include "TGenBase/TimeStamp.h"
namespace TGenBase {
......@@ -64,4 +64,4 @@ class BaseClass
} // namespace TGenBase
#endif /* !TGENBASECLIENTBASECLASS_H */
#endif /* !TGENBASEBASECLASS_H */
......@@ -5,10 +5,10 @@
* @date 4.7.2018
**/
#include "TGenBaseClient/BaseClass.h"
#include "TGenBaseClient/Client.h"
#include "TGenBaseClient/QueryBuilder.h"
#include "TGenBaseClient/Pagination.h"
#include "TGenBase/BaseClass.h"
#include "TGenBase/Client.h"
#include "TGenBase/QueryBuilder.h"
#include "TGenBase/Pagination.h"
#include <jsoncons_ext/csv/csv.hpp>
#include <jsoncons_ext/csv/csv_encoder.hpp>
......@@ -198,7 +198,7 @@ void BaseClass<T>::Store() {
if (!Validate()) {
std::stringstream err;
err << "TGenBase::Client::" << T::classname() << "::Store: Validation failed, record will not be stored";
#ifdef TGENBASECLIENT_WITH_EXCEPTIONS
#ifdef TGENBASE_WITH_EXCEPTIONS
throw std::logic_error(err.str());
#endif
std::cout << err.str() << std::endl;
......@@ -222,7 +222,7 @@ void BaseClass<T>::StoreArray(std::vector<T> array) {
if (valFails) {
std::stringstream err;
err << "TGenBase::Client::" << T::classname() << "::StoreArray: Validation failed for " << valFails << " elements. Array will not be stored";
#ifdef TGENBASECLIENT_WITH_EXCEPTIONS
#ifdef TGENBASE_WITH_EXCEPTIONS
throw std::logic_error(err.str());
#endif
std::cout << err.str() << std::endl;
......
......@@ -5,14 +5,14 @@
* @date 4.7.2018
**/
#ifndef TGENBASECLIENTBASECLASSVERSIONED_H
#define TGENBASECLIENTBASECLASSVERSIONED_H
#ifndef TGENBASEBASECLASSVERSIONED_H
#define TGENBASEBASECLASSVERSIONED_H
#include <jsoncons/json.hpp>
#include <jsoncons_ext/csv/csv_options.hpp>
#include "TGenBaseClient/Utils.h"
#include "TGenBaseClient/TimeStamp.h"
#include "TGenBase/Utils.h"
#include "TGenBase/TimeStamp.h"
namespace TGenBase {
......@@ -61,4 +61,4 @@ class BaseClassVersioned
} // namespace TGenBase
#endif /* !TGENBASECLIENTBASECLASSVERSIONED_H */
#endif /* !TGENBASEBASECLASSVERSIONED_H */
......@@ -5,10 +5,10 @@
* @date 4.7.2018
**/
#include "TGenBaseClient/BaseClassVersioned.h"
#include "TGenBaseClient/Client.h"
#include "TGenBaseClient/QueryBuilder.h"
#include "TGenBaseClient/Pagination.h"
#include "TGenBase/BaseClassVersioned.h"
#include "TGenBase/Client.h"
#include "TGenBase/QueryBuilder.h"
#include "TGenBase/Pagination.h"
#include <jsoncons_ext/csv/csv.hpp>
#include <jsoncons_ext/csv/csv_encoder.hpp>
......@@ -195,7 +195,7 @@ void BaseClassVersioned<T>::Store(TimeStamp rid) {
if (!Validate()) {
std::stringstream err;
err << "TGenBase::Client::" << T::classname() << "::Store: Validation failed, record will not be stored";
#ifdef TGENBASECLIENT_WITH_EXCEPTIONS
#ifdef TGENBASE_WITH_EXCEPTIONS
throw std::logic_error(err.str());
#endif
std::cout << err.str() << std::endl;
......@@ -219,7 +219,7 @@ void BaseClassVersioned<T>::StoreArray(std::vector<T> array, TimeStamp rid) {
if (valFails) {
std::stringstream err;
err << "TGenBase::Client::" << T::classname() << "::StoreArray: Validation failed for " << valFails << " elements. Array will not be stored";
#ifdef TGENBASECLIENT_WITH_EXCEPTIONS
#ifdef TGENBASE_WITH_EXCEPTIONS
throw std::logic_error(err.str());
#endif
std::cout << err.str() << std::endl;
......
set(TGENBASECLIENT_WITH_EXCEPTIONS FALSE CACHE BOOL "Compile with exception raising.")
if(${TGENBASECLIENT_WITH_EXCEPTIONS})
add_definitions(-DTGENBASECLIENT_WITH_EXCEPTIONS)
set(TGENBASE_WITH_EXCEPTIONS FALSE CACHE BOOL "Compile with exception raising.")
if(${TGENBASE_WITH_EXCEPTIONS})
add_definitions(-DTGENBASE_WITH_EXCEPTIONS)
endif()
include_directories(
......@@ -44,11 +44,11 @@ set(PCM_FILE_NAME lib${PROJECT_NAME})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_INSTALL_LIBDIR ${CMAKE_BINARY_DIR}/lib)
ROOT_GENERATE_DICTIONARY(${DICT_FILE_NAME} ${HEADERS} LINKDEF TGenBaseClientLinkDef.h)
add_library(TGenBaseClient SHARED ${SOURCES} ${DICT_FILE_NAME})
add_dependencies(TGenBaseClient CURLPP JSONCONS)
ROOT_GENERATE_DICTIONARY(${DICT_FILE_NAME} ${HEADERS} LINKDEF TGenBaseLinkDef.h)
add_library(TGenBase SHARED ${SOURCES} ${DICT_FILE_NAME})
add_dependencies(TGenBase CURLPP JSONCONS)
target_link_libraries(TGenBaseClient Core RIO ${CURL_LIBRARIES} ${CURLPP_LIBRARIES} ${Boost_SERIALIZATION_LIBRARY})
target_link_libraries(TGenBase Core RIO ${CURL_LIBRARIES} ${CURLPP_LIBRARIES} ${Boost_SERIALIZATION_LIBRARY})
set_target_properties(${LIBRARY_NAME}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
......@@ -57,10 +57,10 @@ set_target_properties(${LIBRARY_NAME}
)
set(PROJECT_VERSION "1.0.0")
set_property(TARGET TGenBaseClient PROPERTY VERSION ${PROJECT_VERSION})
set_property(TARGET TGenBaseClient PROPERTY SOVERSION ${PROJECT_VERSION})
set_property(TARGET TGenBase PROPERTY VERSION ${PROJECT_VERSION})
set_property(TARGET TGenBase PROPERTY SOVERSION ${PROJECT_VERSION})
install(TARGETS TGenBaseClient EXPORT TGenBaseClientTargets
install(TARGETS TGenBase EXPORT TGenBaseTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
......@@ -70,14 +70,14 @@ install(TARGETS TGenBaseClient EXPORT TGenBaseClientTargets
install(FILES
"${CMAKE_BINARY_DIR}/lib/${PCM_FILE_NAME}_rdict.pcm"
"${CMAKE_BINARY_DIR}/lib/${PCM_FILE_NAME}.rootmap"
"${CMAKE_SOURCE_DIR}/TGenBaseClientConfig.json"
"${CMAKE_SOURCE_DIR}/TGenBaseConfig.json"
DESTINATION
lib)
configure_file(${CMAKE_SOURCE_DIR}/TGenBaseClientConfig.json ${CMAKE_BINARY_DIR}/lib/TGenBaseClientConfig.json COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/TGenBaseConfig.json ${CMAKE_BINARY_DIR}/lib/TGenBaseConfig.json COPYONLY)
install(FILES "BaseClass.tpl" "BaseClassVersioned.tpl" DESTINATION include/TGenBaseClient)
install(FILES ${HEADERS} DESTINATION include/TGenBaseClient)
install(FILES "BaseClass.tpl" "BaseClassVersioned.tpl" DESTINATION include/TGenBase)
install(FILES ${HEADERS} DESTINATION include/TGenBase)
install(TARGETS ${LIBRARY_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
......@@ -104,5 +104,5 @@ set(CURLPP_LIBS
install(FILES ${CURLPP_LIBS} DESTINATION lib OPTIONAL)
### Set CMake variables
set(TGenBaseClient_INCLUDE_DIR "include")
set(TGenBaseClient_LIBRARY_DIR "lib")
set(TGenBase_INCLUDE_DIR "include")
set(TGenBase_LIBRARY_DIR "lib")
......@@ -5,7 +5,7 @@
* @date 4.7.2018
**/
#include "TGenBaseClient/Client.h"
#include "TGenBase/Client.h"
#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
......@@ -75,7 +75,7 @@ std::string Client::DownloadFile(std::string url, std::string localPath) {
std::ofstream of(fileName, std::ofstream::out | std::ofstream::trunc);
if (!of.good())
{
#ifdef TGENBASECLIENT_WITH_EXCEPTIONS
#ifdef TGENBASE_WITH_EXCEPTIONS
throw std::logic_error("Client::DownloadFile: Bad output file or file path");
#endif
std::cout << "Client::DownloadFile: Bad output file or file path" << std::endl;
......@@ -93,7 +93,7 @@ std::string Client::DownloadFile(std::string url, std::string localPath) {
request.perform();
}
catch ( const std::exception& e ) {
#ifdef TGENBASECLIENT_WITH_EXCEPTIONS
#ifdef TGENBASE_WITH_EXCEPTIONS
throw std::logic_error(e.what());
#endif
std::cout << e.what() << std::endl;
......@@ -108,7 +108,7 @@ std::string Client::UploadFile(std::string fileName) {
int responseStatus;
try {
if (fAccessToken == "") {
#ifdef TGENBASECLIENT_WITH_EXCEPTIONS
#ifdef TGENBASE_WITH_EXCEPTIONS
throw std::logic_error("Client::UploadFile: Access token was not provided, you have to log in first");
#endif
std::cout << "Client::UploadFile: Access token was not provided, you have to log in first" << std::endl;
......@@ -160,7 +160,7 @@ std::string Client::UploadFile(std::string fileName) {
responseStatus = responseCode;
}
catch ( const std::exception& e ) {
#ifdef TGENBASECLIENT_WITH_EXCEPTIONS
#ifdef TGENBASE_WITH_EXCEPTIONS
throw std::logic_error(e.what());
#endif
std::cout << e.what() << std::endl;
......@@ -175,7 +175,7 @@ std::string Client::UploadFile(std::string fileName) {
}
catch (const jsoncons::ser_error& e)
{
#ifdef TGENBASECLIENT_WITH_EXCEPTIONS
#ifdef TGENBASE_WITH_EXCEPTIONS
throw std::logic_error(std::string("Client::UploadFile error parsing json:\n" + std::string(e.what())).c_str());
#endif
std::cout << "Client::UploadFile\nError parsing response json:\n"
......@@ -212,7 +212,7 @@ jsoncons::ojson Client::PostJsonRequest(std::string className, std::string metho
}
catch (const jsoncons::ser_error& e)
{
#ifdef TGENBASECLIENT_WITH_EXCEPTIONS
#ifdef TGENBASE_WITH_EXCEPTIONS
throw std::logic_error(std::string("Client::PostJsonRequest error parsing json:\n" + std::string(e.what())).c_str());
#endif
std::cout << "Client::PostJsonRequest [" << className << " / " << method << "]\nError parsing response json:\n"
......@@ -237,7 +237,7 @@ jsoncons::ojson Client::PostJsonRequest(std::string className, std::string metho
std::tuple<int, std::string> Client::PostRequest(std::string className, std::string method, std::string requestJsonString) {
if (fServerURI == "") {
#ifdef TGENBASECLIENT_WITH_EXCEPTIONS
#ifdef TGENBASE_WITH_EXCEPTIONS
throw std::logic_error("Client::PostRequest: ServerURI was not set");
#endif
std::cout << "Client::PostRequest: ServerURI was not set" << std::endl;
......@@ -246,7 +246,7 @@ std::tuple<int, std::string> Client::PostRequest(std::string className, std::str
try {
if ((fAccessToken == "") && !(className == "User" && method == "Login")) {
#ifdef TGENBASECLIENT_WITH_EXCEPTIONS
#ifdef TGENBASE_WITH_EXCEPTIONS
throw std::logic_error("Client::PostRequest: Access token was not provided, you have to log in first");
#endif
std::cout << "Client::PostRequest: Access token was not provided, you have to log in first" << std::endl;
......@@ -296,7 +296,7 @@ std::tuple<int, std::string> Client::PostRequest(std::string className, std::str
return std::make_tuple(responseCode, result.str());
}
catch ( const std::exception& e ) {
#ifdef TGENBASECLIENT_WITH_EXCEPTIONS
#ifdef TGENBASE_WITH_EXCEPTIONS
throw std::logic_error(e.what());
#endif
std::cout << e.what() << std::endl;
......
......@@ -5,10 +5,10 @@
* @date 4.7.2018
**/
#ifndef TGENBASECLIENT_H
#define TGENBASECLIENT_H
#ifndef TGENBASE_H
#define TGENBASE_H
#include "TGenBaseClient/Pagination.h"
#include "TGenBase/Pagination.h"
#include <jsoncons/json.hpp>
#include <curlpp/Easy.hpp>
......@@ -26,8 +26,8 @@ class Client
public:
static Client* Instance();
void ReadSession(std::string fileName="TGenBaseClientConfig.json");
void StoreSession(std::string fileName="TGenBaseClientConfig.json");
void ReadSession(std::string fileName="TGenBaseConfig.json");
void StoreSession(std::string fileName="TGenBaseConfig.json");
std::string GetServerURI() { return fServerURI; }
std::string GetAccessToken() { return fAccessToken; }
......@@ -60,4 +60,4 @@ class Client
} // namespace TGenBase
#endif /* !TGENBASECLIENT_H */
#endif /* !TGENBASE_H */
......@@ -5,14 +5,14 @@
* @date 15.10.2019
**/
#include "TGenBaseClient/File.h"
#include "TGenBaseClient/Streamer.h"
#include "TGenBase/File.h"
#include "TGenBase/Streamer.h"
#include <regex>
#include "TGenBaseClient/BaseClass.tpl"
#include "TGenBase/BaseClass.tpl"
template class TGenBase::BaseClass<TGenBase::File>;
namespace TGenBase {
......
......@@ -8,8 +8,8 @@
#ifndef FILE_H
#define FILE_H
#include "TGenBaseClient/Client.h"
#include "TGenBaseClient/BaseClass.h"
#include "TGenBase/Client.h"
#include "TGenBase/BaseClass.h"
......
......@@ -4,14 +4,14 @@
* @author Generator by Evgeny Lavrik <e.lavrik@gsi.de>
**/
#include "TGenBaseClient/ObjectStore.h"
#include "TGenBaseClient/Streamer.h"
#include "TGenBase/ObjectStore.h"
#include "TGenBase/Streamer.h"
#include <regex>
#include "TGenBaseClient/BaseClassVersioned.tpl"
#include "TGenBase/BaseClassVersioned.tpl"
template class TGenBase::BaseClassVersioned<TGenBase::ObjectStore>;
namespace TGenBase {
......
......@@ -9,10 +9,10 @@
#include <jsoncons/json.hpp>
#include "TGenBaseClient/Client.h"
#include "TGenBaseClient/BaseClassVersioned.h"
#include "TGenBase/Client.h"
#include "TGenBase/BaseClassVersioned.h"
#include "TGenBaseClient/Streamer.h"
#include "TGenBase/Streamer.h"
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
......
#include "TGenBaseClient/Pagination.h"
#include "TGenBase/Pagination.h"
namespace TGenBase {
......
......@@ -5,8 +5,8 @@
* @date 4.7.2018
**/
#ifndef TGENBASECLIENTPAGINATION_H
#define TGENBASECLIENTPAGINATION_H
#ifndef TGENBASEPAGINATION_H
#define TGENBASEPAGINATION_H
#include <jsoncons/json.hpp>
......@@ -53,4 +53,4 @@ class Pagination
} // namespace TGenBase
#endif /* !TGENBASECLIENTPAGINATION_H */
#endif /* !TGENBASEPAGINATION_H */
#include "TGenBaseClient/QueryBuilder.h"
#include "TGenBase/QueryBuilder.h"
namespace TGenBase {
......
......@@ -6,15 +6,15 @@
* @date 4.7.2018
**/
#ifndef TGENBASECLIENTQUERYBUILDER_H
#define TGENBASECLIENTQUERYBUILDER_H
#ifndef TGENBASEQUERYBUILDER_H
#define TGENBASEQUERYBUILDER_H
#include <jsoncons/json.hpp>
#include <TGenBaseClient/TimeStamp.h>
#include <TGenBaseClient/Pagination.h>
#include <TGenBase/TimeStamp.h>
#include <TGenBase/Pagination.h>
#include "TGenBaseClient/BaseClass.h"
#include "TGenBaseClient/BaseClassVersioned.h"
#include "TGenBase/BaseClass.h"
#include "TGenBase/BaseClassVersioned.h"
namespace TGenBase {
......@@ -105,4 +105,4 @@ class QueryBuilder
} // namespace TGenBase
#endif /* !TGENBASECLIENTQUERYBUILDER_H */
#endif /* !TGENBASEQUERYBUILDER_H */
......@@ -8,7 +8,7 @@
// Adapted from FairDb
#include "TGenBaseClient/Streamer.h"
#include "TGenBase/Streamer.h"
#include "TClass.h"
#include "TBufferFile.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment