Skip to content

Commit

Permalink
finish deleting externals/nitro/externals
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith authored and Dan Smith committed Nov 25, 2022
2 parents 3d8a22b + de053b6 commit cb1d561
Show file tree
Hide file tree
Showing 39 changed files with 6,368 additions and 0 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/* =========================================================================
* This file is part of io-c++
* =========================================================================
*
* (C) Copyright 2004 - 2014, MDA Information Systems LLC
*
* io-c++ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* see <http://www.gnu.org/licenses/>.
*
*/

#ifndef __DBG_STREAM_H__
#define __DBG_STREAM_H__

#include <memory>

#include "io/OutputStream.h"
#include "mem/SharedPtr.h"


/*!
* \file DbgStream.h
* \brief This is the class for debugging with streams
*
* This class should be used by high-level entities for defining
* degug streams. If the stream is "on", printing will occur to a bound
* OutputStream (Impl style). Otherwise, nothing will occur
*
*/

namespace io
{
/*!
* \class DbgStream
* \brief A class for printing to a debug stream
*
* This class should be used by high-level entities for defining
* degug streams. If the stream is "on", printing will occur to a bound
* OutputStream (Impl style). Otherwise, nothing will occur
*
*/

struct DbgStream : public OutputStream
{
DbgStream() = default;
virtual ~DbgStream() = default;
DbgStream(const DbgStream&) = delete;
DbgStream& operator=(const DbgStream&) = delete;


/*!
* Alternate constructor
* \param s An output stream to adopt
* \param on The state of the stream (on or off)
*/
DbgStream(OutputStream* s, bool on = false)
{
set(s, on);
}

using OutputStream::write;

/*!
* Set the output and debug stream
* \param s An output stream to adopt
* \param on The state of the stream (on or off)
*/
virtual void set(OutputStream* s, bool on = false)
{
mOn = on;
mStream.reset(s);
}

/*!
* This method uses the bound OutputStream to print,
* if the switch is on.
* \param buffer The byte array to write to the stream
* \param len The length
* \throw IOException
*/
virtual void write(const void* buffer, sys::Size_T len)
{
if (mOn)
{
mStream->write(buffer, len);
}
}

/*!
* Is the stream on or off??
* \return The state of the stream
*/
bool isOn()
{
return mOn;
}

/*!
* Set the state of the stream
* \param on The new state of the stream
*/
void setDebug(bool on)
{
mOn = on;
}
protected:
//! The bound stream
std::unique_ptr<OutputStream> mStream;
//! On or off??
bool mOn = false;
};
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/* =========================================================================
* This file is part of io-c++
* =========================================================================
*
* (C) Copyright 2004 - 2014, MDA Information Systems LLC
*
* io-c++ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* see <http://www.gnu.org/licenses/>.
*
*/

#ifndef __IO_PROXY_STREAMS_H__
#define __IO_PROXY_STREAMS_H__

#include "config/Exports.h"
#include "io/InputStream.h"
#include "io/OutputStream.h"
#include "io/NullStreams.h"
#include "mem/SharedPtr.h"

namespace io
{
struct CODA_OSS_API ProxyInputStream : public InputStream
{
ProxyInputStream(InputStream *proxy, bool ownPtr = false) :
mOwnPtr(ownPtr)
{
mProxy.reset(proxy);
}
ProxyInputStream(const ProxyInputStream&) = delete;
ProxyInputStream& operator=(const ProxyInputStream&) = delete;

virtual ~ProxyInputStream()
{
if (!mOwnPtr)
mProxy.release();
}

virtual sys::Off_T available()
{
return mProxy->available();
}

virtual void setProxy(InputStream *proxy, bool ownPtr = false)
{
if (!mOwnPtr)
mProxy.release();
mProxy.reset(proxy);
mOwnPtr = ownPtr;
}

protected:
virtual sys::SSize_T readImpl(void* buffer, size_t len)
{
return mProxy->read(buffer, len);
}

std::unique_ptr<InputStream> mProxy;
bool mOwnPtr;
};

/**
* Proxies to the given OutputStream.
*/
struct CODA_OSS_API ProxyOutputStream : public OutputStream
{
ProxyOutputStream() = default;
ProxyOutputStream(OutputStream *proxy, bool ownPtr = false) :
mOwnPtr(ownPtr)
{
mProxy.reset(proxy);
}
virtual ~ProxyOutputStream()
{
if (!mOwnPtr)
mProxy.release();
}
ProxyOutputStream(const ProxyOutputStream&) = delete;
ProxyOutputStream& operator=(const ProxyOutputStream&) = delete;
ProxyOutputStream(ProxyOutputStream&&) = default;
ProxyOutputStream& operator=(ProxyOutputStream&&) = default;

using OutputStream::write;

virtual void write(const void* buffer, size_t len)
{
mProxy->write(buffer, len);
}

virtual void flush()
{
mProxy->flush();
}

virtual void close()
{
mProxy->close();
}

virtual void setProxy(OutputStream *proxy, bool ownPtr = false)
{
if (!mOwnPtr)
mProxy.release();
mProxy.reset(proxy);
mOwnPtr = ownPtr;
}

protected:
std::unique_ptr<OutputStream> mProxy;
bool mOwnPtr = false;
};

/**
* An output stream that can be enabled/disabled (toggled).
*/
struct CODA_OSS_API ToggleOutputStream : public io::ProxyOutputStream
{
ToggleOutputStream() = default;
ToggleOutputStream(io::OutputStream *output, bool ownPtr = false) :
io::ProxyOutputStream(nullptr), mPtr(output), mOwnPtr(ownPtr)
{
}
virtual ~ToggleOutputStream()
{
if (mOwnPtr && mPtr)
delete mPtr;
}
ToggleOutputStream(const ToggleOutputStream&) = delete;
ToggleOutputStream& operator=(const ToggleOutputStream&) = delete;
ToggleOutputStream(ToggleOutputStream&&) = default;
ToggleOutputStream& operator=(ToggleOutputStream&&) = default;

void setEnabled(bool flag)
{
mEnabled = flag && mPtr;
setProxy(mEnabled ? mPtr : &mNullStream, false);
}

inline bool isEnabled() const
{
return mEnabled;
}

void close()
{
if (mEnabled && mPtr)
mPtr->close();
setEnabled(false);
}

protected:
io::OutputStream* mPtr = nullptr;
io::NullOutputStream mNullStream;
bool mOwnPtr = false, mEnabled = false;
};

}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* =========================================================================
* This file is part of logging-c++
* =========================================================================
*
* (C) Copyright 2004 - 2014, MDA Information Systems LLC
*
* logging-c++ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* see <http://www.gnu.org/licenses/>.
*
*/

#ifndef CODA_OSS_logging_Setup_h_INCLUDED_
#define CODA_OSS_logging_Setup_h_INCLUDED_

#include <memory>
#include <string>

#include "sys/filesystem.h"
#include "mem/SharedPtr.h"
#include "logging/Logger.h"

#include "sys/CPlusPlus.h"
#if CODA_OSS_cpp17
#include <std/filesystem>
#endif

namespace logging
{

/*!
* \fn setupLogger
*
* This is a simple utility for logging. Creation of the logger is
* non-trivial in nature, so this helpful utility reduces the setup
* to a few parameters.
*
* \param program - name of the program doing the logging
* \param logLevel - level of logging (debug|warning|info|error|critical)
* \param logFile - location where to log (default: console logs to std::cout)
* \param logFormat- format of the log (default: [%p] (%d) %m)
* \param logCount - number of rotating logs to keep (default: 0 no rotation)
* \param logBytes - number of bytes per rotating log (default: 0 no rotation)
*/
#if CODA_OSS_cpp17
using path = std::filesystem::path;
#else
using path = coda_oss::filesystem::path;
#endif
std::unique_ptr<logging::Logger> setupLogger(
const path& program,
const std::string& logLevel = "warning",
const path& logFile = "console",
const std::string& logFormat = "[%p] (%d) %m",
size_t logCount = 0,
size_t logBytes = 0);
}

#endif // CODA_OSS_logging_Setup_h_INCLUDED_
Loading

0 comments on commit cb1d561

Please sign in to comment.