Commit 697dd058 authored by Victor Kotlyar's avatar Victor Kotlyar
Browse files

Moved castor::utils::SmartArrayPtr to

cta::SmartArrayPtr
parent 91daee59
......@@ -145,6 +145,7 @@ set (COMMON_UNIT_TESTS_LIB_SRC_FILES
log/StringLoggerTest.cpp
remoteFS/RemotePathTest.cpp
SmartFdTest.cpp
SmartArrayPtrTest.cpp
CRCTest.cpp
threading/DaemonTest.cpp
threading/SocketPairTest.cpp
......
/******************************************************************************
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
......@@ -29,8 +24,7 @@
#include <stdio.h>
namespace castor {
namespace utils {
namespace cta {
/**
* A smart pointer that owns a pointer to an array and unlike std::unique_ptr
......@@ -156,6 +150,5 @@ private:
}; // class SmartArrayPtr
} // namespace utils
} // namespace castor
} // namespace cta
/******************************************************************************
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "castor/utils/SmartArrayPtr.hpp"
#include "common/SmartArrayPtr.hpp"
#include <gtest/gtest.h>
#include <list>
......@@ -33,7 +28,7 @@
namespace unitTests {
class castor_utils_SmartArrayPtrTest : public ::testing::Test {
class cta_SmartArrayPtrTest : public ::testing::Test {
protected:
virtual void SetUp() {
......@@ -43,25 +38,25 @@ protected:
}
};
TEST_F(castor_utils_SmartArrayPtrTest, constructor) {
TEST_F(cta_SmartArrayPtrTest, constructor) {
char *ptr = new char[10];
castor::utils::SmartArrayPtr<char> smartPtr(ptr);
cta::SmartArrayPtr<char> smartPtr(ptr);
ASSERT_EQ(ptr, smartPtr.get());
}
TEST_F(castor_utils_SmartArrayPtrTest, reset) {
TEST_F(cta_SmartArrayPtrTest, reset) {
char *ptr = new char[10];
castor::utils::SmartArrayPtr<char> smartPtr;
cta::SmartArrayPtr<char> smartPtr;
ASSERT_EQ((char *)0, smartPtr.get());
smartPtr.reset(ptr);
ASSERT_EQ(ptr, smartPtr.get());
}
TEST_F(castor_utils_SmartArrayPtrTest, assignment) {
castor::utils::SmartArrayPtr<char> smartPtr1;
castor::utils::SmartArrayPtr<char> smartPtr2;
TEST_F(cta_SmartArrayPtrTest, assignment) {
cta::SmartArrayPtr<char> smartPtr1;
cta::SmartArrayPtr<char> smartPtr2;
ASSERT_EQ((char *)0, smartPtr1.get());
ASSERT_EQ((char *)0, smartPtr2.get());
......@@ -75,19 +70,19 @@ TEST_F(castor_utils_SmartArrayPtrTest, assignment) {
ASSERT_EQ(ptr, smartPtr2.get());
}
TEST_F(castor_utils_SmartArrayPtrTest, releaseNull) {
castor::utils::SmartArrayPtr<char> smartPtr;
TEST_F(cta_SmartArrayPtrTest, releaseNull) {
cta::SmartArrayPtr<char> smartPtr;
ASSERT_THROW(smartPtr.release(), cta::exception::NotAnOwner);
}
TEST_F(castor_utils_SmartArrayPtrTest, subscriptRead) {
TEST_F(cta_SmartArrayPtrTest, subscriptRead) {
char *ptr = new char[4];
ptr[0] = 'T';
ptr[1] = 'e';
ptr[2] = 's';
ptr[3] = 't';
castor::utils::SmartArrayPtr<char> smartPtr(ptr);
cta::SmartArrayPtr<char> smartPtr(ptr);
ASSERT_EQ(ptr, smartPtr.get());
ASSERT_EQ('T', smartPtr[0]);
......@@ -96,14 +91,14 @@ TEST_F(castor_utils_SmartArrayPtrTest, subscriptRead) {
ASSERT_EQ('t', smartPtr[3]);
}
TEST_F(castor_utils_SmartArrayPtrTest, subscriptAssigment) {
TEST_F(cta_SmartArrayPtrTest, subscriptAssigment) {
char *ptr = new char[4];
ptr[0] = 'T';
ptr[1] = 'e';
ptr[2] = 's';
ptr[3] = 't';
castor::utils::SmartArrayPtr<char> smartPtr(ptr);
cta::SmartArrayPtr<char> smartPtr(ptr);
ASSERT_EQ(ptr, smartPtr.get());
ASSERT_EQ('T', smartPtr[0]);
......
......@@ -21,7 +21,7 @@
#include "common/exception/BadAlloc.hpp"
#include "castor/tape/reactor/PollReactorImpl.hpp"
#include "castor/utils/SmartArrayPtr.hpp"
#include "common/SmartArrayPtr.hpp"
#include "castor/utils/utils.hpp"
#include <unistd.h>
......@@ -90,7 +90,7 @@ void castor::tape::reactor::PollReactorImpl::removeHandler(
//------------------------------------------------------------------------------
void castor::tape::reactor::PollReactorImpl::handleEvents(const int timeout) {
nfds_t nfds = 0;
castor::utils::SmartArrayPtr<struct pollfd> fds(buildPollFds(nfds));
cta::SmartArrayPtr<struct pollfd> fds(buildPollFds(nfds));
const int pollrc = poll(fds.get(), nfds, timeout);
......@@ -121,7 +121,7 @@ struct pollfd *castor::tape::reactor::PollReactorImpl::buildPollFds(
nfds_t &nfds) {
nfds = m_handlers.size();
castor::utils::SmartArrayPtr<struct pollfd> fds;
cta::SmartArrayPtr<struct pollfd> fds;
try {
fds.reset(new struct pollfd[nfds]);
} catch(std::bad_alloc &ba) {
......
......@@ -44,7 +44,7 @@
#include "castor/tape/tapeserver/daemon/LabelSession.hpp"
#include "castor/tape/tapeserver/daemon/ProcessForker.hpp"
#include "castor/tape/tapeserver/daemon/ProcessForkerUtils.hpp"
#include "castor/utils/SmartArrayPtr.hpp"
#include "common/SmartArrayPtr.hpp"
#include "castor/utils/utils.hpp"
#include "catalogue/CatalogueFactory.hpp"
#include "common/exception/Exception.hpp"
......
......@@ -23,7 +23,7 @@
#include "castor/io/io.hpp"
#include "castor/tape/tapeserver/daemon/ProcessForkerUtils.hpp"
#include "castor/utils/SmartArrayPtr.hpp"
#include "common/SmartArrayPtr.hpp"
#include "castor/utils/utils.hpp"
#include "common/exception/Exception.hpp"
......@@ -469,7 +469,7 @@ std::string castor::tape::tapeserver::daemon::ProcessForkerUtils::
throw ex;
}
utils::SmartArrayPtr<char> payloadBuf(new char[payloadLen]);
cta::SmartArrayPtr<char> payloadBuf(new char[payloadLen]);
io::readBytes(fd, timeout, payloadLen, payloadBuf.get());
return std::string(payloadBuf.get(), payloadLen);
......
......@@ -35,7 +35,6 @@ target_link_libraries(ctautils castorlog)
install(TARGETS ctautils DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
add_library (ctautilsunittests SHARED
SmartArrayPtrTest.cpp
UtilsTest.cpp)
install(TARGETS ctautilsunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
Supports Markdown
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