Skip to content

Commit

Permalink
update to static lib
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Aug 27, 2024
1 parent 4fbe80b commit 46122fc
Show file tree
Hide file tree
Showing 36 changed files with 1,673 additions and 37 deletions.
108 changes: 108 additions & 0 deletions Source/aqnwb/aqnwb/BaseIO.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#include "aqnwb/BaseIO.hpp"

#include "aqnwb/Utils.hpp"

using namespace AQNWB;

// BaseDataType

BaseDataType::BaseDataType(BaseDataType::Type t, SizeType s)
: type(t)
, typeSize(s)
{
}

BaseDataType BaseDataType::STR(SizeType size)
{
return BaseDataType(T_STR, size);
}

const BaseDataType BaseDataType::U8 = BaseDataType(T_U8, 1);
const BaseDataType BaseDataType::U16 = BaseDataType(T_U16, 1);
const BaseDataType BaseDataType::U32 = BaseDataType(T_U32, 1);
const BaseDataType BaseDataType::U64 = BaseDataType(T_U64, 1);
const BaseDataType BaseDataType::I8 = BaseDataType(T_I8, 1);
const BaseDataType BaseDataType::I16 = BaseDataType(T_I16, 1);
const BaseDataType BaseDataType::I32 = BaseDataType(T_I32, 1);
const BaseDataType BaseDataType::I64 = BaseDataType(T_I64, 1);
const BaseDataType BaseDataType::F32 = BaseDataType(T_F32, 1);
const BaseDataType BaseDataType::F64 = BaseDataType(T_F64, 1);
const BaseDataType BaseDataType::DSTR = BaseDataType(T_STR, DEFAULT_STR_SIZE);

// BaseIO

BaseIO::BaseIO()
: readyToOpen(true)
, opened(false)
{
}

BaseIO::~BaseIO() {}

bool BaseIO::isOpen() const
{
return opened;
}

bool BaseIO::isReadyToOpen() const
{
return readyToOpen;
}

bool BaseIO::canModifyObjects()
{
return true;
}

Status BaseIO::createCommonNWBAttributes(const std::string& path,
const std::string& objectNamespace,
const std::string& neurodataType,
const std::string& description)
{
createAttribute(objectNamespace, path, "namespace");
createAttribute(generateUuid(), path, "object_id");
if (neurodataType != "")
createAttribute(neurodataType, path, "neurodata_type");
if (description != "")
createAttribute(description, path, "description");
return Status::Success;
}

Status BaseIO::createDataAttributes(const std::string& path,
const float& conversion,
const float& resolution,
const std::string& unit)
{
createAttribute(BaseDataType::F32, &conversion, path + "/data", "conversion");
createAttribute(BaseDataType::F32, &resolution, path + "/data", "resolution");
createAttribute(unit, path + "/data", "unit");

return Status::Success;
}

Status BaseIO::createTimestampsAttributes(const std::string& path)
{
int interval = 1;
createAttribute(BaseDataType::I32,
static_cast<const void*>(&interval),
path + "/timestamps",
"interval");
createAttribute("seconds", path + "/timestamps", "unit");

return Status::Success;
}

// BaseRecordingData

BaseRecordingData::BaseRecordingData() {}

BaseRecordingData::~BaseRecordingData() {}

// Overload that uses the member variable position (works for simple data
// extension)
Status BaseRecordingData::writeDataBlock(const std::vector<SizeType>& dataShape,
const BaseDataType& type,
const void* data)
{
return writeDataBlock(dataShape, position, type, data);
}
File renamed without changes.
43 changes: 43 additions & 0 deletions Source/aqnwb/aqnwb/Channel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <string>

#include "aqnwb/Channel.hpp"

using namespace AQNWB;

Channel::Channel(const std::string name,
const std::string groupName,
const SizeType localIndex,
const SizeType globalIndex,
const float conversion,
const float samplingRate,
const float bitVolts,
const std::array<float, 3> position,
const std::string comments)
: name(name)
, groupName(groupName)
, localIndex(localIndex)
, globalIndex(globalIndex)
, position(position)
, conversion(conversion)
, samplingRate(samplingRate)
, bitVolts(bitVolts)
, comments(comments)
{
}

Channel::~Channel() {}

float Channel::getConversion() const
{
return bitVolts / conversion;
}

float Channel::getSamplingRate() const
{
return samplingRate;
}

float Channel::getBitVolts() const
{
return bitVolts;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions Source/aqnwb/aqnwb/aqnwb.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#include <string>

#include "aqnwb/nwb/NWBRecording.hpp"
#include "aqnwb/nwb/NWBFile.hpp"
42 changes: 42 additions & 0 deletions Source/aqnwb/aqnwb/aqnwb_export.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

#ifndef AQNWB_EXPORT_H
#define AQNWB_EXPORT_H

#ifdef AQNWB_STATIC_DEFINE
# define AQNWB_EXPORT
# define AQNWB_NO_EXPORT
#else
# ifndef AQNWB_EXPORT
# ifdef aqnwb_aqnwb_EXPORTS
/* We are building this library */
# define AQNWB_EXPORT
# else
/* We are using this library */
# define AQNWB_EXPORT
# endif
# endif

# ifndef AQNWB_NO_EXPORT
# define AQNWB_NO_EXPORT
# endif
#endif

#ifndef AQNWB_DEPRECATED
# define AQNWB_DEPRECATED __attribute__ ((__deprecated__))
#endif

#ifndef AQNWB_DEPRECATED_EXPORT
# define AQNWB_DEPRECATED_EXPORT AQNWB_EXPORT AQNWB_DEPRECATED
#endif

#ifndef AQNWB_DEPRECATED_NO_EXPORT
# define AQNWB_DEPRECATED_NO_EXPORT AQNWB_NO_EXPORT AQNWB_DEPRECATED
#endif

#if 0 /* DEFINE_NO_DEPRECATED */
# ifndef AQNWB_NO_DEPRECATED
# define AQNWB_NO_DEPRECATED
# endif
#endif

#endif /* AQNWB_EXPORT_H */
Loading

0 comments on commit 46122fc

Please sign in to comment.