Skip to content

Commit

Permalink
[occ] Move RCOPrivate in own header and expose RunNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
teo committed May 14, 2019
1 parent 8ca49a2 commit 956cc15
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 26 deletions.
32 changes: 6 additions & 26 deletions occ/occlib/RuntimeControlledObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,14 @@

#include "RuntimeControlledObject.h"

#include "RuntimeControlledObjectPrivate.h"

#include <boost/property_tree/ptree.hpp>

#include <thread>

using namespace std::chrono_literals;

class RuntimeControlledObjectPrivate {
explicit RuntimeControlledObjectPrivate(const std::string objectName)
: mCurrentState(t_State::undefined)
, mName(objectName)
{}

virtual ~RuntimeControlledObjectPrivate() = default;

friend class RuntimeControlledObject;
friend class OccServer;
private:
t_State mCurrentState;
std::string mName;

int getState(t_State &currentState)
{
currentState=mCurrentState;
return 0;
}

void setState(t_State newState)
{
mCurrentState=newState;
}
};

RuntimeControlledObject::RuntimeControlledObject(const std::string objectName)
: dPtr(new RuntimeControlledObjectPrivate(objectName))
{
Expand Down Expand Up @@ -135,6 +111,10 @@ int RuntimeControlledObject::iterateCheck()
return 0;
}

RunNumber RuntimeControlledObject::getRunNumber() {
return dPtr->mCurrentRunNumber;
}

void RuntimeControlledObject::setState(t_State state)
{
dPtr->setState(state);
Expand Down
5 changes: 5 additions & 0 deletions occ/occlib/RuntimeControlledObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ typedef basic_ptree< std::string, std::string, std::less<std::string> > ptree;
}
}

typedef uint64_t RunNumber;
const RunNumber RunNumber_UNDEFINED = 0;


class RuntimeControlledObjectPrivate;

class OCC_EXPORT RuntimeControlledObject {
Expand Down Expand Up @@ -235,6 +239,7 @@ class OCC_EXPORT RuntimeControlledObject {
private:
RuntimeControlledObjectPrivate *dPtr;

RunNumber getRunNumber();
void setState(t_State state);

friend class OccServer;
Expand Down
52 changes: 52 additions & 0 deletions occ/occlib/RuntimeControlledObjectPrivate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* === This file is part of ALICE O² ===
*
* Copyright 2018 CERN and copyright holders of ALICE O².
* Author: Teo Mrnjavac <[email protected]>
* Sylvain Chapeland <[email protected]>
*
* 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.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* In applying this license CERN does not waive the privileges and
* immunities granted to it by virtue of its status as an
* Intergovernmental Organization or submit itself to any jurisdiction.
*/

class RuntimeControlledObjectPrivate {
explicit RuntimeControlledObjectPrivate(const std::string objectName)
: mCurrentState(t_State::undefined)
, mName(objectName)
, mCurrentRunNumber(RunNumber_UNDEFINED)
{}

virtual ~RuntimeControlledObjectPrivate() = default;

friend class RuntimeControlledObject;
friend class OccServer;
private:
t_State mCurrentState;
std::string mName;
RunNumber mCurrentRunNumber;

int getState(t_State &currentState)
{
currentState=mCurrentState;
return 0;
}

void setState(t_State newState)
{
mCurrentState=newState;
}
};

0 comments on commit 956cc15

Please sign in to comment.