Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Som devel 20 wall #43

Merged
merged 30 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions CLOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C++ 15 120 8 986
C/C++ Header 24 237 197 820
C++ 15 120 10 981
C/C++ Header 20 215 166 756
-------------------------------------------------------------------------------
SUM: 39 357 205 1806
SUM: 35 335 176 1737
-------------------------------------------------------------------------------
```
**testenv**
```
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C/C++ Header 25 227 177 1046
C++ 10 56 25 302
C/C++ Header 24 221 171 1022
C++ 10 55 25 295
-------------------------------------------------------------------------------
SUM: 35 283 202 1348
SUM: 34 276 196 1317
-------------------------------------------------------------------------------
```
**moduletests**
```
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C++ 14 213 220 1877
C++ 14 207 220 1862
-------------------------------------------------------------------------------
SUM: 14 213 220 1877
SUM: 14 207 220 1862
-------------------------------------------------------------------------------
```
**systemtests**
Expand All @@ -46,8 +46,8 @@ SUM: 2 29 25 99
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C/C++ Header 17 105 112 375
C/C++ Header 22 127 142 457
-------------------------------------------------------------------------------
SUM: 17 105 112 375
SUM: 22 127 142 457
-------------------------------------------------------------------------------
```
12 changes: 6 additions & 6 deletions application/components/BAS/I_Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class I_Array
}
}

PosRes find(const T& obj) const
const PosRes find(const T& obj) const
{
PosRes res = { 0, false };

size_t pos = 0;
bool valid = false;
if (size() > 0)
{
size_t pMin = 0;
Expand All @@ -83,13 +83,13 @@ class I_Array
}
else
{
res.pos = pCur;
res.valid = true;
pos = pCur;
valid = true;
break;
}
}
}
return res;
return PosRes{ pos, valid };
}

size_t dupCnt() const
Expand Down
14 changes: 7 additions & 7 deletions application/components/BAS/NtpArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
#define NTPARRAY_H

#include <BAS/coding.h>
#include <BAS/Mem.h>
#include <codebase/Mem.h>
#include <BAS/StaticArray.h>
#include <ifs/DataTypes.h>
#include <ifs/ComTypes.h>

// name, type, position
struct Ntp
{
const ElementName name;
const ComName name;
const INT32 type;
const size_t pos;
inline Ntp(
const ElementName& name,
const ComName& name,
INT32 type = 0,
size_t pos = 0
):
Expand All @@ -41,7 +41,7 @@ class NtpArray :
public:
inline NtpArray() = default;

inline auto add(const ElementName& name, INT32 type, size_t pos)
inline auto add(const ComName& name, INT32 type, size_t pos)
{
return StaticArray<Ntp, CAP>::add(name, type, pos);
}
Expand All @@ -62,15 +62,15 @@ class NtpIndex :
BaseT(a)
{}

inline auto find(const ElementName& name) const
inline auto find(const ComName& name) const
{
return BaseT::find(Ntp(name));
}
NOCOPY(NtpIndex)
NODEF(NtpIndex)

protected:
inline bool isGreater(const Ntp& a, const Ntp& b) const
inline bool isGreater(const Ntp& a, const Ntp& b) const final
{
return Mem::cmp(a.name, b.name) > 0;
}
Expand Down
22 changes: 1 addition & 21 deletions application/components/BAS/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
## directory content

**BaseTypes.h**
```
basic integral types
```

**I_Array.h**
```
defintion of interface I_Array:
Expand All @@ -14,11 +9,6 @@ enables:
- uniqueness check / duplicates count
```

**Mem.h**
```
size safe memset, memcpy, memcmp
```

**NtpArray.h**
```
name, type, position
Expand All @@ -35,7 +25,7 @@ StaticArrays
- act like arrays of pre-defined size
- can be filled with objects at runtime
- can store objects of different size classes
for the same interface
derived from main class
- do not provide any overflow protection

StaticArray
Expand All @@ -58,13 +48,3 @@ class SwapBytes enables static byte swapping
```
misc coding enhancers
```

**packBegin.h**
```
begin of packed alignment for data structs
```

**packEnd.h**
```
end of packed alignment for data structs
```
13 changes: 3 additions & 10 deletions application/components/BAS/StaticArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define STATICARRAY_H

#include <BAS/I_Array.h>
#include <BAS/Mem.h>
#include <codebase/Mem.h>
#include <BAS/SwapBytes.h>
#include <algorithm>
#include <new>
Expand Down Expand Up @@ -104,13 +104,6 @@ class StaticArray :
return reinterpret_cast<const C*>(mData);
}

// void read(std::basic_istream<CHAR>& is, size_t size)
// {
// static_assert(sizeof(C) == DIM);
// mSize = std::min(size, CAP);
// is.read(reinterpret_cast<CHAR*>(mData), mSize * DIM);
// }

NOCOPY(StaticArray)

protected:
Expand Down Expand Up @@ -199,11 +192,11 @@ class StaticIndex : private StaticArray<CRef<T>, CAP>
NODEF(StaticIndex)

protected:
const I_Array<T, CAP>& mSrc;
virtual bool isGreater(const T& a, const T& b) const
{
return mSrc.isGreater(a, b);
}

private:
const I_Array<T, CAP>& mSrc;
};
#endif // H_
11 changes: 2 additions & 9 deletions application/components/BAS/coding.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
#ifndef CODING_H
#define CODING_H

#include <BAS/BaseTypes.h>
#include <codebase/BaseTypes.h>
#include <codebase/nocopy.h>

// enable usage of "and", "or"
#include <ciso646>

// put into empty if / else branches for coverage
inline void pass() {}

// disable copy constructor and copy operator
#define NOCOPY(CLASS) \
CLASS(const CLASS& o) = delete; \
CLASS& operator = (const CLASS& o) = delete;

#define NODEF(CLASS) \
CLASS() = delete;

// unified instance declaration
#define INSTANCE_DEC(NAME) \
static NAME& instance();
Expand Down
2 changes: 1 addition & 1 deletion application/components/LCR/src/LCR_Hub.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <LCR/LCR_Hub.h>

#include <BAS/Mem.h>
#include <codebase/Mem.h>
#include <SYS/IL.h>

INSTANCE_DEF(LCR_Hub)
Expand Down
2 changes: 1 addition & 1 deletion application/components/SIG/src/SIG_Hub.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <SIG/SIG_Hub.h>

#include <BAS/Mem.h>
#include <codebase/Mem.h>
#include <SYS/IL.h>

INSTANCE_DEF(SIG_Hub)
Expand Down
2 changes: 1 addition & 1 deletion application/components/SYS/Dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Dispatcher : public I_Dispatcher
void reset();
void index();

PosRes assign(const ElementName& name, E_Subsys subs, size_t pos);
const PosRes assign(const ComName& name, E_Subsys subs, size_t pos);

void dispatch(const FldState& tele) const;
void dispatch(const GuiCmd& tele) const;
Expand Down
15 changes: 8 additions & 7 deletions application/components/SYS/src/Dispatcher.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <SYS/Dispatcher.h>
#include <BAS/Mem.h>
#include <codebase/Mem.h>
#include <BAS/coding.h>
#include <SYS/IL.h>

Expand All @@ -21,19 +21,20 @@ void Dispatcher::index()
}
}

PosRes Dispatcher::assign(
const ElementName& name,
const PosRes Dispatcher::assign(
const ComName& name,
const E_Subsys subs,
const size_t pos)
{
PosRes res {0, mData.hasSpace()};
if (res.valid)
const bool valid = mData.hasSpace();
size_t dpos = 0;
if (valid)
{
res.pos = mData.add(name, subs, pos);
dpos = mData.add(name, subs, pos);
}
else
{ pass();}
return res;
return PosRes{dpos, valid};
}

void Dispatcher::dispatch(const FldState& tele) const
Expand Down
2 changes: 1 addition & 1 deletion application/components/SYS/src/Reader.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <ifs/ProjData.h>
#include <ifs/ProjTypes.h>
#include <setup/capacities.h>
#include <SYS/IL.h>
#include <SYS/Reader.h>
Expand Down
2 changes: 1 addition & 1 deletion application/components/TSW/src/TSW_Hub.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <TSW/TSW_Hub.h>

#include <BAS/Mem.h>
#include <codebase/Mem.h>
#include <SYS/IL.h>

INSTANCE_DEF(TSW_Hub)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// ============================================================
// size safe memset, memcpy, memcmp
// apply size safe memset, memcpy, memcmp
// ============================================================
// created by Manfred Sorgo

#pragma once
#ifndef MEM_H
#define MEM_H

#include <BAS/BaseTypes.h>
#include <codebase/BaseTypes.h>
#include <cstring>

class Mem
Expand Down
26 changes: 26 additions & 0 deletions specification/codebase/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## directory content

**BaseTypes.h**
```
basic integral types
```

**Mem.h**
```
apply size safe memset, memcpy, memcmp
```

**nocopy.h**
```
block any copying
```

**packBegin.h**
```
begin of packed alignment for data structs
```

**packEnd.h**
```
end of packed alignment for data structs
```
18 changes: 18 additions & 0 deletions specification/codebase/nocopy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// ============================================================
// block any copying
// ============================================================
// created by Manfred Sorgo
#pragma once
#ifndef NOCOPY_H
#define NOCOPY_H

// disable copy constructor and copy operator
#define NOCOPY(CLASS) \
CLASS(const CLASS& o) = delete; \
CLASS& operator = (const CLASS& o) = delete;

// disable default constructor
#define NODEF(CLASS) \
CLASS() = delete;

#endif // H_
File renamed without changes.
Loading
Loading