Commit 306c228b by Lars Kosmann

initial commit with source code for imgsee

parents
# Author: Lars Kosmann, Offis e.V.
cmake_minimum_required( VERSION 3.0.2 )
project ( imgsee CXX )
SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
#
# Options
#
option( BUILD_DEBUG "Build with debug logging" OFF )
#
# Configuration
#
# set(CMAKE_CXX_COMPILER "/usr/local/cuda-9.0/bin/nvcc")
#set(CMAKE_CXX_COMPILER "nvcc")
include( "${PROJECT_SOURCE_DIR}/cmake/configuration.cmake" )
#
# Dependencies
#
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/modules" )
add_executable( imgsee
"src/ImgseeMain.cpp"
"src/ConnectionFactoryMgr.cpp"
"src/Receiver.cpp"
"src/TransformTask.cpp"
"src/ResultMessageCreator.cpp"
"src/CmsMessageCreator.cpp"
"src/PerformanceVector.cpp"
"src/Timer.cpp"
"src/PerformanceMonitor.cpp"
"src/PerformanceMessageCreator.cpp"
)
find_package( OpenSSL REQUIRED )
find_package( pugixml REQUIRED )
find_package( activemq-cpp REQUIRED )
find_package( glfw3 REQUIRED )
find_package( apr REQUIRED )
find_package( uuid REQUIRED )
find_package( OpenGL REQUIRED )
find_package( OpenCV REQUIRED core highgui imgproc imgcodecs )
target_include_directories( imgsee
PUBLIC
${APR_INCLUDE_DIR}
${ACTIVEMQCPP_INCLUDE}
${UUID_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${GLFW3_INCLUDE}
"src/spdlog/include"
"src/rapidjson/include"
)
target_link_libraries( imgsee
-lopencv_highgui
-lopencv_core
-lopencv_imgproc
-lopencv_imgcodecs
-lpugixml
-lfreetype
-lGL
-lXrandr
-lXi
-lXxf86vm
-lX11
-lgstpbutils-1.0
-lgstapp-1.0
-lgstbase-1.0
-lgstreamer-1.0
-lgobject-2.0
-lglib-2.0
-lapr-1
-luuid
-lactivemq-cpp
-lssl
-lcrypto
-lstdc++fs
${GLFW3_LIBRARY}
${OPENGL_gl_LIBRARY}
)
find_package( VisionWorks )
if(VisionWorks_FOUND)
find_package( nvxio )
find_package( ovxio )
set(CMAKE_CXX_COMPILER "nvcc")
target_compile_definitions( imgsee PUBLIC USE_VISIONWORKS)
target_include_directories( imgsee
PUBLIC
${NVXIO_INCLUDE}
${OVXIO_INCLUDE}
${VISIONWORKS_INCLUDE}
)
target_link_libraries( imgsee
-lvisionworks
${OVXIO_LIBRARY}
${NVXIO_LIBRARY}
)
endif(VisionWorks_FOUND)
target_compile_definitions( imgsee PUBLIC RAPIDJSON_HAS_STDSTRING)
######## Optimizations ###########
if ( NOT CMAKE_BUILD_TYPE MATCHES Debug )
endif ( )
# include_directories(
# "~/VisionWorks-SFM-0.90-Samples/nvxio/include/"
# # ${NVXIO_INCLUDE}
# )
#
# Build
#
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
include( "${PROJECT_SOURCE_DIR}/cmake/manifest.cmake" )
# Config
if( NOT WIN32 )
string( ASCII 27 Esc )
set( Reset "${Esc}[m" )
set( Red "${Esc}[31m" )
set( Blue "${Esc}[34m" )
set( Green "${Esc}[32m" )
set( Yellow "${Esc}[33m" )
endif( )
# setting the C++ standard to 14 more cmake like
# set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED on)
# set (CMAKE_CXX_FLAGS "--std=c++14 ${CMAKE_CXX_FLAGS}")
if( NOT WIN32 )
if ( CMAKE_BUILD_TYPE MATCHES Debug )
add_definitions(-D_DEBUG_)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Wno-deprecated-declarations -std=c++14" )
else ( )
string( REPLACE "-O3" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wno-deprecated-declarations -std=c++14" )
endif ( )
endif ( )
# set ( CMAKE_CXX_FLAGS "-O3 -ffast-math -flto -march=armv8-a+crypto -mcpu=cortex-a57+crypto ${CMAKE_CXX_FLAGS}")
set ( MANIFEST
)
find_library( ACTIVEMQCPP_LIBRARY NAMES activemq-cpp HINTS "/usr/local/lib/" )
file(GLOB ACTIVEMQCPP_SEARCH_PATH "/usr/local/include/activemq-cpp-*")
find_path( ACTIVEMQCPP_INCLUDE NAMES activemq HINTS ${ACTIVEMQCPP_SEARCH_PATH} )
if ( ACTIVEMQCPP_LIBRARY AND ACTIVEMQCPP_INCLUDE)
set( ACTIVEMQCPP_FOUND TRUE )
message( STATUS "${Green}Found activemq-cpp include at: ${ACTIVEMQCPP_INCLUDE}${Reset}" )
message( STATUS "${Green}Found activemq-cpp library at: ${ACTIVEMQCPP_LIBRARY}${Reset}" )
else ( )
if ( ACTIVEMQCPP_LIBRARY)
message( FATAL_ERROR "${Red}Failed to locate activemq-cpp include dependency.${Reset}" )
endif ()
if ( ACTIVEMQCPP_INCLUDE)
message( FATAL_ERROR "${Red}Failed to locate activemq-cpp library dependency.${Reset}" )
endif ()
message( FATAL_ERROR "${Red}Failed to locate activemq-cpp dependency.${Reset}" )
endif ( )
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# - Find Apache Portable Runtime
# Find the APR includes and libraries
# This module defines
# APR_INCLUDE_DIR and APRUTIL_INCLUDE_DIR, where to find apr.h, etc.
# APR_LIBRARIES and APRUTIL_LIBRARIES, the libraries needed to use APR.
# APR_FOUND and APRUTIL_FOUND, If false, do not try to use APR.
# also defined, but not for general use are
# APR_LIBRARY and APRUTIL_LIBRARY, where to find the APR library.
# APR first.
FIND_PATH(APR_INCLUDE_DIR apr.h
/opt/homebrew/opt/apr/include/apr-1
/usr/local/include/apr-1
/usr/local/include/apr-1.0
/usr/include/apr-1
/usr/include/apr-1.0
/usr/local/apr/include/apr-1
)
SET(APR_NAMES ${APR_NAMES} apr-1)
FIND_LIBRARY(APR_LIBRARY
NAMES ${APR_NAMES}
HINTS
/opt/homebrew/opt/apr/lib
PATHS
/usr/lib
/usr/local/lib
/usr/local/apr/lib
)
IF (APR_LIBRARY AND APR_INCLUDE_DIR)
SET(APR_LIBRARIES ${APR_LIBRARY})
SET(APR_FOUND "YES")
ELSE (APR_LIBRARY AND APR_INCLUDE_DIR)
SET(APR_FOUND "NO")
ENDIF (APR_LIBRARY AND APR_INCLUDE_DIR)
IF (APR_FOUND)
IF (NOT APR_FIND_QUIETLY)
MESSAGE(STATUS "Found APR headers: ${APR_INCLUDE_DIR}")
MESSAGE(STATUS "Found APR library: ${APR_LIBRARIES}")
ENDIF (NOT APR_FIND_QUIETLY)
ELSE (APR_FOUND)
IF (APR_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find APR library")
ENDIF (APR_FIND_REQUIRED)
ENDIF (APR_FOUND)
# Deprecated declarations.
SET (NATIVE_APR_INCLUDE_PATH ${APR_INCLUDE_DIR} )
GET_FILENAME_COMPONENT (NATIVE_APR_LIB_PATH ${APR_LIBRARY} PATH)
MARK_AS_ADVANCED(
APR_LIBRARY
APR_INCLUDE_DIR
)
# Next, APRUTIL.
FIND_PATH(APRUTIL_INCLUDE_DIR apu.h
/opt/homebrew/opt/apr-util/include/apr-1
/usr/local/include/apr-1
/usr/local/include/apr-1.0
/usr/include/apr-1
/usr/include/apr-1.0
/usr/local/apr/include/apr-1
)
SET(APRUTIL_NAMES ${APRUTIL_NAMES} aprutil-1)
FIND_LIBRARY(APRUTIL_LIBRARY
NAMES ${APRUTIL_NAMES}
HINTS
/opt/homebrew/opt/apr-util/lib
PATHS
/usr/lib
/usr/local/lib
/usr/local/apr/lib
)
IF (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR)
SET(APRUTIL_LIBRARIES ${APRUTIL_LIBRARY})
SET(APRUTIL_FOUND "YES")
ELSE (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR)
SET(APRUTIL_FOUND "NO")
ENDIF (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR)
IF (APRUTIL_FOUND)
IF (NOT APRUTIL_FIND_QUIETLY)
MESSAGE(STATUS "Found APRUTIL headers: ${APRUTIL_INCLUDE_DIR}")
MESSAGE(STATUS "Found APRUTIL library: ${APRUTIL_LIBRARIES}")
ENDIF (NOT APRUTIL_FIND_QUIETLY)
ELSE (APRUTIL_FOUND)
IF (APRUTIL_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find APRUTIL library")
ENDIF (APRUTIL_FIND_REQUIRED)
ENDIF (APRUTIL_FOUND)
# Deprecated declarations.
SET (NATIVE_APRUTIL_INCLUDE_PATH ${APRUTIL_INCLUDE_DIR} )
GET_FILENAME_COMPONENT (NATIVE_APRUTIL_LIB_PATH ${APRUTIL_LIBRARY} PATH)
MARK_AS_ADVANCED(
APRUTIL_LIBRARY
APRUTIL_INCLUDE_DIR
)
find_library( NVXIO_LIBRARY
NAMES
nvx
PATHS
"~/VisionWorks-1.6-Samples/libs/aarch64/linux/release"
"~/VisionWorks-SFM-0.90-Samples/libs/aarch64/linux/release" )
find_path(NVXIO_INCLUDE
NAMES
nvx.h
HINTS
/usr/include/NVX/
PATHS
"~/VisionWorks-SFM-0.90-Samples/NVXIO/include/NVX"
"~/Visionworks-1.6-Samples/NVXIO/include/NVX"
)
if ( NVXIO_LIBRARY AND NVXIO_INCLUDE )
set( NVXIO_FOUND TRUE )
message( STATUS "${Green}Found NVXIO include at: ${NVXIO_INCLUDE}${Reset}" )
message( STATUS "${Green}Found NVXIO library at: ${NVXIO_LIBRARY}${Reset}" )
else ( )
if( NVXIO_LIBRARY )
message( FATAL_ERROR "${Red}Failed to locate NVXIO Include dependency.${Reset}" )
else ()
message( FATAL_ERROR "${Red}Failed to locate NVXIO Library dependency.${Reset}" )
endif ()
endif ( )
find_library( OVXIO_LIBRARY
NAMES
ovx
PATHS
"~/VisionWorks-1.6-Samples/libs/aarch64/linux/release"
"~/VisionWorks-SFM-0.90-Samples/libs/aarch64/linux/release" )
find_path(OVXIO_INCLUDE
NAMES
FrameSourceOVX.hpp
HINTS
/usr/include/OVX/
PATHS
"~/VisionWorks-SFM-0.90-Samples/nvxio/include/OVX"
"~/Visionworks-1.6-Samples/nvxio/include/OVX"
)
if ( OVXIO_LIBRARY AND OVXIO_INCLUDE )
set( OVXIO_FOUND TRUE )
message( STATUS "${Green}Found OVXIO include at: ${OVXIO_INCLUDE}${Reset}" )
message( STATUS "${Green}Found OVXIO library at: ${OVXIO_LIBRARY}${Reset}" )
else ( )
if( OVXIO_LIBRARY )
message( FATAL_ERROR "${Red}Failed to locate OVXIO Include dependency.${Reset}" )
else ()
message( FATAL_ERROR "${Red}Failed to locate OVXIO Library dependency.${Reset}" )
endif ()
endif ( )
find_library( pugixml_LIBRARY NAMES pugixml PATH_SUFFIXES "aarch64-linux-gnu" )
#find_path( pugixml_INCLUDE /usr/include/pugixml.hpp )
if ( pugixml_LIBRARY )
set( PUGIXML_FOUND TRUE )
#message( STATUS "${Green}Found pugixml include at: ${pugixml_INCLUDE}${Reset}" )
message( STATUS "${Green}Found pugixml library at: ${pugixml_LIBRARY}${Reset}" )
else ( )
message( FATAL_ERROR "${Red}Failed to locate pugixml dependency.${Reset}" )
endif ( )
# - Try to find UUID
# Once done this will define
#
# UUID_FOUND - system has UUID
# UUID_INCLUDE_DIRS - the UUID include directory
# UUID_LIBRARIES - Link these to use UUID
# UUID_DEFINITIONS - Compiler switches required for using UUID
#
# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (UUID_LIBRARIES AND UUID_INCLUDE_DIRS)
# in cache already
set(UUID_FOUND TRUE)
else (UUID_LIBRARIES AND UUID_INCLUDE_DIRS)
find_path(UUID_INCLUDE_DIR
NAMES
uuid.h
PATH_SUFFIXES
uuid
HINTS
${UUID_DIR}/include
$ENV{UUID_DIR}/include
$ENV{UUID_DIR}
${DELTA3D_EXT_DIR}/inc
$ENV{DELTA_ROOT}/ext/inc
$ENV{DELTA_ROOT}
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/usr/include/gdal
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include
/usr/freeware/include
)
find_library(UUID_LIBRARY
NAMES
uuid ossp-uuid
HINTS
${UUID_DIR}/lib
$ENV{UUID_DIR}/lib
$ENV{UUID_DIR}
${DELTA3D_EXT_DIR}/lib
$ENV{DELTA_ROOT}/ext/lib
$ENV{DELTA_ROOT}
$ENV{OSG_ROOT}/lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
find_library(UUID_LIBRARY_DEBUG
NAMES
uuidd
HINTS
${UUID_DIR}/lib
$ENV{UUID_DIR}/lib
$ENV{UUID_DIR}
${DELTA3D_EXT_DIR}/lib
$ENV{DELTA_ROOT}/ext/lib
$ENV{DELTA_ROOT}
$ENV{OSG_ROOT}/lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
if (NOT UUID_LIBRARY AND BSD)
set(UUID_LIBRARY "")
endif(NOT UUID_LIBRARY AND BSD)
set(UUID_INCLUDE_DIRS ${UUID_INCLUDE_DIR})
set(UUID_LIBRARIES ${UUID_LIBRARY})
if (UUID_INCLUDE_DIRS)
if (BSD OR UUID_LIBRARIES)
set(UUID_FOUND TRUE)
endif (BSD OR UUID_LIBRARIES)
endif (UUID_INCLUDE_DIRS)
if (UUID_FOUND)
if (NOT UUID_FIND_QUIETLY)
message(STATUS "Found UUID: ${UUID_LIBRARIES}")
endif (NOT UUID_FIND_QUIETLY)
else (UUID_FOUND)
if (UUID_FIND_REQUIRED)
message(FATAL_ERROR "Could not find UUID")
endif (UUID_FIND_REQUIRED)
endif (UUID_FOUND)
# show the UUID_INCLUDE_DIRS and UUID_LIBRARIES variables only in the advanced view
mark_as_advanced(UUID_INCLUDE_DIRS UUID_LIBRARIES)
endif (UUID_LIBRARIES AND UUID_INCLUDE_DIRS)
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "CmsMessageCreator.h"
#include <memory>
using namespace std;
using namespace cms;
using namespace cmstemplate;
////////////////////////////////////////////////////////////////////////////////
CmsMessageCreator::CmsMessageCreator(const std::string& text) : text(text) {
}
////////////////////////////////////////////////////////////////////////////////
CmsMessageCreator::~CmsMessageCreator() {
}
////////////////////////////////////////////////////////////////////////////////
cms::Message* CmsMessageCreator::createMessage(cms::Session* session) {
std::auto_ptr<cms::Message> message;
if (session) {
message.reset(session->createTextMessage(text));
}
return message.release();
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _CMSTEMPLATE_CMSMESSAGECREATOR_H_
#define _CMSTEMPLATE_CMSMESSAGECREATOR_H_
#include <cms/Connection.h>
#include <cms/Session.h>
#include <activemq/cmsutil/MessageCreator.h>
namespace cmstemplate {
class CmsMessageCreator : public activemq::cmsutil::MessageCreator {
private:
std::string text;
public:
CmsMessageCreator(const std::string& text);
virtual ~CmsMessageCreator();
virtual cms::Message* createMessage(cms::Session* session);
};
}
#endif /** _CMSTEMPLATE_CMSMESSAGECREATOR_H_ */
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _CMSTEMPLATE_CMSMESSAGEHANDLERDEFINITIONS_H_
#define _CMSTEMPLATE_CMSMESSAGEHANDLERDEFINITIONS_H_
#include <decaf/util/Config.h>
namespace imgsee {
enum ErrorCode { // NOTE: When added an entry to ErrorCode you must add the corresponding error string to ErrorDescription
CMS_SUCCESS = 0,
CMS_ERROR_UNABLE_TO_PARSE_XML,
CMS_ERROR_MESSAGE_HAS_BEEN_DEFINED_ALREADY,
CMS_ERROR_HEADER_HAS_BEEN_DEFINED_ALREADY,
CMS_ERROR_CLIENT_HAS_BEEN_DEFINED_ALREADY,
CMS_ERROR_DESTINATION_HAS_BEEN_DEFINED_ALREADY,
CMS_ERROR_INVALID_CLIENT,
CMS_ERROR_INVALID_DESTINATION,
CMS_ERROR_INVALID_MESSAGE,
CMS_ERROR_INVALID_HEADERS,
CMS_ERROR_INVALID_MESSAGELISTENER,
CMS_ERROR_A_MESSAGELISTENER_HAS_BEEN_REGISTERED_ALREADY,
CMS_ERROR_RECEIVER_TIMEDOUT,
CMS_ERROR_DESTINATION_NOT_CONFIGURED_FOR_SENDING_MESSAGES,
CMS_ERROR_DESTINATION_NOT_CONFIGURED_FOR_RECEIVING_MESSAGES,
CMS_ERROR_CAUGHT_CMS_EXCEPTION,
CMS_ERROR_CAUGHT_TBGENOBJ_ERROR,
CMS_ERROR_MESSAGE_BROKER_ERROR,
CMS_ERROR_BROKER_MONITOR_NOT_FOUND,
CMS_ERROR_BROKER_MONITORING_NOT_TURNED_ON,
CMS_ERROR_INVALID_BROKERSTATUSLISTENER,
CMS_ERROR_A_BROKERSTATUSLISTENER_HAS_BEEN_REGISTERED_ALREADY,
CMS_ERROR_CAUGHT_EXCEPTION_IN_INIT,
CMS_ERROR_CAUGHT_EXCEPTION_IN_UNINIT,
CMS_LAST // Put all error enums BEFORE this one. This one must be listed last.
};
const char ErrorDescription[][100] = {
"Success",
"Unable to parse xml",
"Message has been defined already",
"Header has been defined already",
"Client has been defined already",
"Destination has been defined already",
"Invalid client",
"Invalid destination",
"Invalid message",
"Invalid headers",
"Invalid messagelistener",
"A messagelistener has been registered already with the destination",
"Receiver timed out",
"Destination not configured for sending messages",
"Destination not configured for receiving messages",
"Caught CMS exception",
"Caught TBGenObj error",
"Message broker appears to be offline",
"Can not find broker monitor",
"The broker monitoring functinaliy has not been turned on",
"Invalid brokerStatuslistener",
"This brokerStatuslistener has been registered already with the broker",
"Caught an exception when initializing CmsMessageHandler",
"Caught an exception when uninitializing CmsMessageHandler",
"CMS_LAST - ErrorCodeToString macro index out of range",
};
#define ErrorCodeToString(i) (((i >= CMS_SUCCESS) && (i <= CMS_LAST)) ? ErrorDescription[i] : ErrorDescription[CMS_LAST])
/* #define IsError(i) (i != CMS_SUCCESS) */
}
#endif /** _CMSTEMPLATE_CMSMESSAGEHANDLERDEFINITIONS_H_ */
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ConnectionFactoryMgr.h"
#include <activemq/core/ActiveMQConnectionFactory.h>
using namespace std;
using namespace cms;
using namespace decaf;
using namespace decaf::lang;
using namespace decaf::util;
using namespace decaf::util::concurrent;
using namespace activemq::core;
using namespace imgsee;
////////////////////////////////////////////////////////////////////////////////
StlMap<std::string, ConnectionFactory*> * ConnectionFactoryMgr::connectionFactories;
////////////////////////////////////////////////////////////////////////////////
ConnectionFactoryMgr::ConnectionFactoryMgr() {
}
////////////////////////////////////////////////////////////////////////////////
ConnectionFactoryMgr::~ConnectionFactoryMgr() {
try {
unInitialize();
} catch(...) {
}
}
////////////////////////////////////////////////////////////////////////////////
void ConnectionFactoryMgr::initialize() {
connectionFactories = new StlMap<std::string, ConnectionFactory*>();
}
////////////////////////////////////////////////////////////////////////////////
void ConnectionFactoryMgr::unInitialize() {
connectionFactories->lock();
Pointer<Iterator<ConnectionFactory*> > iter(connectionFactories->values().iterator());
while (iter->hasNext()) {
ConnectionFactory* connectionFactory = iter->next();
if (connectionFactory != NULL) {
delete connectionFactory;
connectionFactory = NULL;
}
}
connectionFactories->clear();
connectionFactories->unlock();
delete connectionFactories;
connectionFactories = NULL;
}
////////////////////////////////////////////////////////////////////////////////
ConnectionFactory* ConnectionFactoryMgr::getConnectionFactory(const std::string& url) {
ConnectionFactory* connectionFactory = NULL;
connectionFactories->lock();
try {
connectionFactory = connectionFactories->get(url);
} catch (NoSuchElementException& ex) {
}
if (!connectionFactory) {
connectionFactory = new ActiveMQConnectionFactory(url);
connectionFactories->put(url, connectionFactory);
}
connectionFactories->unlock();
return connectionFactory;
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _CMSTEMPLATE_CONNECTIONFACTORYMGR_H_
#define _CMSTEMPLATE_CONNECTIONFACTORYMGR_H_
#include <decaf/util/StlMap.h>
#include <cms/ConnectionFactory.h>
namespace imgsee {