Skip to content

Commit c4372d3

Browse files
Deal with checkpoint name
1 parent de5dee8 commit c4372d3

File tree

5 files changed

+77
-7
lines changed

5 files changed

+77
-7
lines changed

smcore/checkpoint.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,32 @@ namespace smos
2929
namespace smcore
3030
{
3131
//******************************************************************************
32-
Checkpoint::Checkpoint(void) : m_version()
32+
Checkpoint::Checkpoint(void) : m_version(), m_name("")
3333
{
3434
}
3535
//******************************************************************************
3636
Checkpoint::~Checkpoint(void)
3737
{
3838
}
3939
//******************************************************************************
40+
smos::smcore::Version Checkpoint::versionGet(void)
41+
{
42+
return this->m_version;
43+
}
44+
//******************************************************************************
4045
void Checkpoint::versionSet(const smos::smcore::Version &version)
4146
{
4247
this->m_version = version;
4348
}
4449
//******************************************************************************
45-
smos::smcore::Version Checkpoint::versionGet(void)
50+
smos::smcore::SMString Checkpoint::checkpointNameGet(void)
4651
{
47-
return this->m_version;
52+
return this->m_name;
53+
}
54+
//******************************************************************************
55+
void Checkpoint::checkpointNameSet(const smos::smcore::SMString &checkpointName)
56+
{
57+
this->m_name = checkpointName;
4858
}
4959
//******************************************************************************
5060
}

smcore/checkpoint.h

+27-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#pragma once
2424

2525
#include "archivereader.h"
26+
#include "smstring.h"
2627
#include "version.h"
2728

2829
namespace smos
@@ -44,6 +45,13 @@ namespace smos
4445
*/
4546
~Checkpoint(void);
4647

48+
/**
49+
* @brief Get version information object
50+
*
51+
* @return smos::smcore::Version
52+
*/
53+
smos::smcore::Version versionGet(void);
54+
4755
/**
4856
* @brief Set version information object
4957
*
@@ -52,14 +60,30 @@ namespace smos
5260
void versionSet(const smos::smcore::Version &version);
5361

5462
/**
55-
* @brief Get version information object
63+
* @brief Get name of checkpoint
5664
*
57-
* @return smos::smcore::Version
65+
* @return smos::smcore::SMString
5866
*/
59-
smos::smcore::Version versionGet(void);
67+
smos::smcore::SMString checkpointNameGet(void);
68+
69+
/**
70+
* @brief Set name of checkpoint
71+
*
72+
* @param checkpointName
73+
*/
74+
void checkpointNameSet(const smos::smcore::SMString &checkpointName);
6075

6176
protected:
77+
/**
78+
* @brief Version information of checkpoint
79+
*
80+
*/
6281
smos::smcore::Version m_version;
82+
83+
/**
84+
* @brief Name of checkpoins
85+
*/
86+
smos::smcore::SMString m_name;
6387
};
6488
}
6589
}

smcore/smcheckpointsreader.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ namespace smos
4949
// ar >> m_sName >> m_oDate >> m_fUseModifiedComplexity >> m_poLanguage;
5050
std::string nameSMCheckpoint = m_archiveReader.Read<std::string>();
5151
std::cout << "nameSMCheckpoint: " << nameSMCheckpoint << std::endl;
52+
curCheckpoint.checkpointNameSet(nameSMCheckpoint);
53+
5254
std::time_t t64_checkpointSMCheckpoint = m_archiveReader.Read<std::time_t>();
5355
std::cout << "Checkpoint time: " << t64_checkpointSMCheckpoint << std::endl;
5456

smtest/test_checkpoint.cpp

+33-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,39 @@ namespace smos
4141
smos::smcore::Checkpoint checkpoint = smos::smcore::Checkpoint();
4242
smos::smcore::Version version = smos::smcore::Version();
4343

44-
QCOMPARE(version, checkpoint.versionGet());
44+
QCOMPARE(checkpoint.versionGet(), version);
45+
46+
QString nameObject = QString::fromUtf8(checkpoint.checkpointNameGet().c_str());
47+
smos::smcore::SMString nameExpectedRaw = "";
48+
QString nameExpected = QString::fromUtf8(nameExpectedRaw.c_str());
49+
50+
QCOMPARE(nameObject, nameExpected);
51+
}
52+
//******************************************************************************
53+
void TestCheckpoint::TestVersion(void)
54+
{
55+
smos::smcore::Checkpoint checkpoint = smos::smcore::Checkpoint();
56+
smos::smcore::Version version = smos::smcore::Version();
57+
58+
QCOMPARE(checkpoint.versionGet(), version);
59+
60+
smos::smcore::Version versionNew = smos::smcore::Version(2, 2, 2);
61+
checkpoint.versionSet(versionNew);
62+
QCOMPARE(checkpoint.versionGet(), versionNew);
63+
}
64+
//******************************************************************************
65+
void TestCheckpoint::TestName(void)
66+
{
67+
smos::smcore::Checkpoint checkpoint = smos::smcore::Checkpoint();
68+
QString nameObject = QString::fromUtf8(checkpoint.checkpointNameGet().c_str());
69+
smos::smcore::SMString nameExpectedRaw = "";
70+
QString nameExpected = QString::fromUtf8(nameExpectedRaw.c_str());
71+
72+
nameExpectedRaw = "Hello world!";
73+
checkpoint.checkpointNameSet(nameExpectedRaw);
74+
nameObject = QString::fromUtf8(checkpoint.checkpointNameGet().c_str());
75+
nameExpected = QString::fromUtf8(nameExpectedRaw.c_str());
76+
QCOMPARE(nameObject, nameExpected);
4577
}
4678
//******************************************************************************
4779
void TestCheckpoint::cleanupTestCase(void)

smtest/test_checkpoint.h

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ namespace smos
3535
private slots:
3636
void initTestCase(void);
3737
void TestConstructor(void);
38+
void TestVersion(void);
39+
void TestName(void);
3840
void cleanupTestCase(void);
3941
};
4042
}

0 commit comments

Comments
 (0)