Commit e5beb9ef authored by ics's avatar ics

Merge branch variable into master

parent bf9718e4
......@@ -16,6 +16,7 @@ proto:
protoc -I=$(PROTO_PATH) --cpp_out=$(PROTO_GEN_PATH) $(PROTO_PATH)/ConditionManagerRequests.proto
protoc -I=$(PROTO_PATH) --cpp_out=$(PROTO_GEN_PATH) $(PROTO_PATH)/CommandZoneRequests.proto
protoc -I=$(PROTO_PATH) --cpp_out=$(PROTO_GEN_PATH) $(PROTO_PATH)/SessionRequests.proto
protoc -I=$(PROTO_PATH) --cpp_out=$(PROTO_GEN_PATH) $(PROTO_PATH)/VariableManagerRequests.proto
# copy script
serverexecdir=$(scriptdir)
......
......@@ -40,6 +40,7 @@ using namespace core;
const std::string DirectApplication::SIMULATION = "sim";
const std::string DirectApplication::TEST_EXECUTION = "-test";
const std::string DirectApplication::REPLACE_PROPERTY_NAMES = "-replace-property-names-with-alias";
const std::string DirectApplication::STATEFILENAME = ".nomadstate";
const std::string DirectApplication::INIT_STATE = "init";
const std::string DirectApplication::EXEC_STATE = "exec";
......@@ -48,6 +49,7 @@ const std::string DirectApplication::EXIT_STATE = "exit";
DirectApplication::DirectApplication() :
_console(0),
_testExecution(false),
_replacePropertyNamesWithAlias(false),
_state(STARTING),
_commandProcessorStarted(2),
_terminated(2),
......@@ -83,6 +85,8 @@ void DirectApplication::init(int argc, char* argv[]) {
Simulated::activated = true;
} else if (string(argv[i]) == TEST_EXECUTION) {
_testExecution = true;
} else if (string(argv[i]) == REPLACE_PROPERTY_NAMES) {
_replacePropertyNamesWithAlias = true;
}
}
......@@ -154,6 +158,12 @@ void DirectApplication::run() {
return;
}
// If the server is started to replace property names.
if (_replacePropertyNamesWithAlias) {
replacePropertyNamesWithAlias();
return;
}
if (_console != 0) {
_console->run();
}
......@@ -245,6 +255,16 @@ void DirectApplication::test() {
_dataprovider->quit(std::vector<std::string>(), false);
}
void DirectApplication::replacePropertyNamesWithAlias() {
_core->replacePropertyNamesWithAlias();
// quit
_core->quit(std::vector<std::string>(), false);
_commandprocessor->quit(std::vector<std::string>(), false);
_dataprovider->quit(std::vector<std::string>(), false);
}
int DirectApplication::getReturnCode() const {
return _returnCode;
}
......@@ -117,6 +117,7 @@ public :
private:
void setFileState(std::string const & state);
void test();
void replacePropertyNamesWithAlias();
common::Console* _console;
......@@ -125,6 +126,7 @@ private:
core::DirectCore * _core;
bool _testExecution;
bool _replacePropertyNamesWithAlias;
enum State {STARTING, STARTED, STOPPING};
State _state;
......@@ -136,6 +138,7 @@ private:
static const std::string SIMULATION;
static const std::string TEST_EXECUTION;
static const std::string REPLACE_PROPERTY_NAMES;
static const std::string STATEFILENAME;
static const std::string INIT_STATE;
static const std::string EXEC_STATE;
......
......@@ -16,6 +16,7 @@ libnomad_la_SOURCES = \
common/protobuf/generated/ConditionManagerRequests.pb.cc \
common/protobuf/generated/CommandZoneRequests.pb.cc \
common/protobuf/generated/SessionRequests.pb.cc \
common/protobuf/generated/VariableManagerRequests.pb.cc \
\
common/Application.cpp \
common/Console.cpp \
......@@ -35,7 +36,6 @@ libnomad_la_SOURCES = \
common/base/Duration.cpp \
common/base/Real.cpp \
common/base/Equals.cpp \
common/base/String.cpp \
common/base/FileUtilities.cpp \
common/base/Ticker.cpp \
common/base/TimeCondition.cpp \
......@@ -77,6 +77,8 @@ libnomad_la_SOURCES = \
dataprovider/message/notification/IcsPropertyChangedMessage.cpp \
dataprovider/message/notification/ConditionStateChangedMessage.cpp \
dataprovider/message/notification/ConditionActionsStateChangedMessage.cpp \
dataprovider/message/notification/UserVariableValueChangedMessage.cpp \
dataprovider/message/notification/UserVariableStateChangedMessage.cpp \
dataprovider/message/notification/LogMessage.cpp \
dataprovider/message/notification/LogXMLMessage.cpp \
dataprovider/message/notification/SurveyXMLMessage.cpp \
......@@ -166,7 +168,7 @@ libnomad_la_SOURCES = \
dataprovider/transportlayer/dataprovider/CommandAccessorDirectImpl.cpp \
dataprovider/transportlayer/dataprovider/DataChangePublisherDirectImpl.cpp \
dataprovider/transportlayer/dataprovider/LogAccessorDirectImpl.cpp \
dataprovider/transportlayer/dataprovider/ConditionAccessorDirectImpl.cpp \
dataprovider/transportlayer/dataprovider/PropertyExpressionAccessorDirectImpl.cpp \
dataprovider/transportlayer/dataprovider/DirectServerLogAccessor.cpp \
dataprovider/transportlayer/dataprovider/SurveyAccessorDirectImpl.cpp \
dataprovider/transportlayer/MultiThreadCommunication.cpp \
......@@ -288,6 +290,8 @@ libnomad_la_SOURCES = \
core/parser/survey/SurveyParser.cpp \
core/parser/conditions/ConditionElement.cpp \
core/parser/conditions/ConditionsParser.cpp \
core/parser/variables/VariableElement.cpp \
core/parser/variables/VariablesParser.cpp \
\
core/conditions/Condition.cpp \
core/conditions/Alarm.cpp \
......@@ -296,6 +300,9 @@ libnomad_la_SOURCES = \
core/conditions/CommandZoneTermination.cpp \
core/conditions/ConditionManager.cpp \
\
core/variables/UserVariable.cpp \
core/variables/UserVariableManager.cpp \
\
core/spy/Spy.cpp \
\
core/scheduler/Scheduler.cpp \
......@@ -392,7 +399,6 @@ libnomad_la_SOURCES = \
core/commandzone/generic/SetZeroCommandBox.cpp \
core/commandzone/generic/PrintCommandBox.cpp \
core/commandzone/generic/SetCommandBox.cpp \
core/commandzone/control/ConditionCommandBox.cpp \
core/commandzone/control/ControlCommandBox.cpp \
core/commandzone/control/IfCommandBox.cpp \
core/commandzone/control/BreakCommandBox.cpp \
......@@ -400,7 +406,6 @@ libnomad_la_SOURCES = \
core/commandzone/CommandBoxMap.cpp \
core/commandzone/CommandZone.cpp \
core/commandzone/PropertyState.cpp \
core/commandzone/DirectCommandPropertyState.cpp \
core/commandzone/MathParserCommandPropertyState.cpp \
core/commandzone/CommandSequencer.cpp \
core/commandzone/CommandBoxParent.cpp \
......@@ -413,7 +418,10 @@ libnomad_la_SOURCES = \
core/base/BaseValueWrapper.cpp \
core/base/BasePropertyWrapper.cpp \
core/base/VariableWrapper.cpp \
core/base/UserVariableWrapper.cpp \
core/base/MathExpression.cpp \
core/base/BooleanExpression.cpp \
core/base/MathExpressionRenamer.cpp \
\
core/transportlayer/command/CommandLauncher.cpp \
core/transportlayer/command/DirectCommandLauncher.cpp \
......@@ -423,6 +431,7 @@ libnomad_la_SOURCES = \
core/transportlayer/core/ServantManagerResponder.cpp \
core/transportlayer/core/ConditionManagerResponder.cpp \
core/transportlayer/core/SessionResponder.cpp \
core/transportlayer/core/UserVariableManagerResponder.cpp \
core/transportlayer/core/commandline/CommandLineResponder.cpp \
core/transportlayer/core/commandzone/CommandZoneEventPublisher.cpp \
core/transportlayer/core/commandzone/CommandZoneEventSubscriber.cpp \
......@@ -438,10 +447,10 @@ libnomad_la_SOURCES = \
core/transportlayer/dataprovider/LogAccessor.cpp \
core/transportlayer/dataprovider/DirectLogAccessor.cpp \
core/transportlayer/dataprovider/DirectServerLogAccessor.cpp \
core/transportlayer/dataprovider/ConditionAccessor.cpp \
core/transportlayer/dataprovider/PropertyExpressionAccessor.cpp \
core/transportlayer/dataprovider/SurveyAccessor.cpp \
core/transportlayer/dataprovider/DirectSurveyAccessor.cpp \
core/transportlayer/dataprovider/DirectConditionAccessor.cpp \
core/transportlayer/dataprovider/DirectPropertyExpressionAccessor.cpp \
core/transportlayer/MultiThreadCommunication.cpp \
core/DirectCore.cpp \
\
......
......@@ -238,7 +238,7 @@ int main(int argc, char* argv[]) {
}
}
info.setpoint = setpoint;
info.alias = infoItem.shortPropertyName;
info.alias = infoItem.aliasPropertyName;
pinfo.push_back(info);
}
}
......
......@@ -23,11 +23,6 @@ struct IcsValueTypeConverter {
typedef ValueType result;
};
template<>
struct IcsValueTypeConverter<common::String> {
typedef std::string result;
};
template<>
struct IcsValueTypeConverter<std::string> {
typedef std::string result;
......
......@@ -316,13 +316,7 @@ void ProcessorManager::verifyProcessorTimeoutLoop() {
processorsToDelete.push_back(processorItem);
} else if (processorItem->isInitialising()) {
// TODO set the timeout?
/*if (!_instance->_shuttingDown && delay > processorCreationTimeoutms) {
// a processor creation request has failed - kill it.
processorCreationToAbortIDs.push_back(processorItem->getID());
out << "added processor to abort " << processorItem->getID() << ", delay is " << processorCreationTimeoutms << eol;
}*/
// Do nothing.
}
}
......@@ -862,8 +856,8 @@ void ProcessorManager::processMessage(BaseExecuteSetValueMessage* message) {
ProcessorManagerSetValueMessageHelper<float64>::apply(static_cast<ExecuteSetValueMessage<float64>*>(message));
} else if (dynamic_cast<ExecuteSetValueMessage<bool>*>(message) != 0) {
ProcessorManagerSetValueMessageHelper<bool>::apply(static_cast<ExecuteSetValueMessage<bool>*>(message));
} else if (dynamic_cast<ExecuteSetValueMessage<String>*>(message) != 0) {
ProcessorManagerSetValueMessageHelper<String>::apply(static_cast<ExecuteSetValueMessage<String>*>(message));
} else if (dynamic_cast<ExecuteSetValueMessage<string>*>(message) != 0) {
ProcessorManagerSetValueMessageHelper<string>::apply(static_cast<ExecuteSetValueMessage<string>*>(message));
} else if (dynamic_cast<ExecuteSetValueMessage<std::string>*>(message) != 0) {
ProcessorManagerSetValueMessageHelper<std::string>::apply(static_cast<ExecuteSetValueMessage<std::string>*>(message));
}
......@@ -1384,8 +1378,8 @@ void ProcessorManager::executePendingOperation(ProcessorItem* processorItem) {
ProcessorManagerExecutePendingSetterHelper<float64>::apply(processorItem, item);
} else if (dynamic_cast<SetterItem<bool>*>(item) != 0) {
ProcessorManagerExecutePendingSetterHelper<bool>::apply(processorItem, item);
} else if (dynamic_cast<SetterItem<String>*>(item) != 0) {
ProcessorManagerExecutePendingSetterHelper<String>::apply(processorItem, item);
} else if (dynamic_cast<SetterItem<string>*>(item) != 0) {
ProcessorManagerExecutePendingSetterHelper<string>::apply(processorItem, item);
} else if (dynamic_cast<SetterItem<std::string>*>(item) != 0) {
ProcessorManagerExecutePendingSetterHelper<std::string>::apply(processorItem, item);
}
......@@ -1556,18 +1550,6 @@ void ProcessorManagerExecutePendingSetterHelper<bool>::apply(ProcessorItem* proc
processorItem->getProxy()->setBooleanValue(setterItem->getDatabaseID(), setterItem->getServantID(), setterItem->getPropertyID(), setterItem->getSetterID(), setterItem->getValue());
}
void ProcessorManagerExecutePendingSetterHelper<common::String>::apply(ProcessorItem* processorItem, OperationItem* item) {
SetterItem<String>* setterItem = static_cast<SetterItem<String>*>(item);
// Launching setter
processorItem->setActive(true);
processorItem->updateLastOperationDate();
processorItem->setOperationItem(setterItem);
processorItem->getProxy()->setStringValue(setterItem->getDatabaseID(), setterItem->getServantID(), setterItem->getPropertyID(), setterItem->getSetterID(), setterItem->getValue());
}
void ProcessorManagerExecutePendingSetterHelper<std::string>::apply(ProcessorItem* processorItem, OperationItem* item) {
SetterItem<std::string>* setterItem = static_cast<SetterItem<std::string>*>(item);
......
......@@ -431,13 +431,6 @@ struct ProcessorManagerExecutePendingSetterHelper<bool> {
};
template<>
struct ProcessorManagerExecutePendingSetterHelper<common::String> {
static void apply(ProcessorItem* processorItem, OperationItem* item);
};
template<>
struct ProcessorManagerExecutePendingSetterHelper<std::string> {
......
......@@ -111,7 +111,7 @@ void CommandLauncherDirectImpl::setFloat64Value(unsigned long requestID, unsigne
void CommandLauncherDirectImpl::setStringValue(unsigned long requestID, unsigned long databaseID, unsigned long servantID, unsigned long propertyID, const std::string& value, core::CompletionHandlerDirectImpl* completionHandler) {
// Creating the DirectCompletionHandler and passing it to the Processor
ProcessorManager::getInstance()->setValue<String>(requestID, databaseID, servantID, propertyID, String(value), new DirectCompletionHandler(completionHandler));
ProcessorManager::getInstance()->setValue<string>(requestID, databaseID, servantID, propertyID, string(value), new DirectCompletionHandler(completionHandler));
}
void CommandLauncherDirectImpl::setBooleanValue(unsigned long requestID, unsigned long databaseID, unsigned long servantID, unsigned long propertyID, bool value, core::CompletionHandlerDirectImpl* completionHandler) {
......
......@@ -112,7 +112,7 @@ void ProcessorProxyDirectImpl::setFloat64Value(unsigned long databaseID, unsigne
}
void ProcessorProxyDirectImpl::setStringValue(unsigned long databaseID, unsigned long servantID, unsigned long propertyID, unsigned long propertySetterID, const std::string& value) {
Processor::getInstance(_processorID)->setValue<String>(databaseID, servantID, propertyID, propertySetterID, String(value));
Processor::getInstance(_processorID)->setValue<string>(databaseID, servantID, propertyID, propertySetterID, string(value));
}
void ProcessorProxyDirectImpl::setBooleanValue(unsigned long databaseID, unsigned long servantID, unsigned long propertyID, unsigned long propertySetterID, bool value) {
......
......@@ -82,7 +82,7 @@ void CommandStateChangeSubscriberDirectImpl::commandInterruptChanged(unsigned lo
void CommandStateChangeSubscriberDirectImpl::commandProgressionChanged(unsigned long databaseID, unsigned long dataID, double progression) {
}
void CommandStateChangeSubscriberDirectImpl::configurationChanged(unsigned long databaseID, unsigned long servantID, common::EnableState enable) {
void CommandStateChangeSubscriberDirectImpl::configurationChanged(unsigned long databaseID, unsigned long servantID, common::ConfigurationState enable) {
}
void CommandStateChangeSubscriberDirectImpl::conditionStateChanged(unsigned long conditionId, bool on, common::ConditionState state) {
......
......@@ -87,7 +87,7 @@ public:
/**
* Notifies the subscriber that the configuration has changed.
*/
virtual void configurationChanged(unsigned long databaseID, unsigned long servantID, common::EnableState enable);
virtual void configurationChanged(unsigned long databaseID, unsigned long servantID, common::ConfigurationState enable);
/**
* Notifies the condition state.
......
......@@ -88,7 +88,6 @@ void DirectCommandAccessor::setCommandState(unsigned long servantID, unsigned lo
common::SetCommandActiveResult DirectCommandAccessor::setCommandActive(DataHolder::Type type, unsigned long servantID, unsigned long commandID, const std::string& servantType) {
// TODO remove the concept of thread here.
unsigned long threadID = 0;
CommandStateChangeSubscriberDirectImpl* commandStateChangeSubscriber = new CommandStateChangeSubscriberDirectImpl(_dataChangePublisher, type, servantID, commandID);
......@@ -140,7 +139,6 @@ common::SetCommandActiveResult DirectCommandAccessor::setCommandActive(DataHolde
bool DirectCommandAccessor::hasTerminated(unsigned long commandID) {
try {
// TODO remove the concept of thread.
unsigned long threadID = 0;
bool found = true;
......@@ -176,7 +174,6 @@ void DirectCommandAccessor::finishTermination(unsigned long commandID) {
// unsubscribe, delete, erase the subscriber
try {
// TODO remove the concept of thread.
unsigned long threadID = 0;
CommandStateChangeSubscriberDirectImpl* subscriber = _commandStateChangeSubscribers.get(commandID).get(threadID);
......
......@@ -460,10 +460,12 @@ PropertyAccessor::PropertyInfoItem DirectPropertyAccessor::getPropertyInfoItem(c
try {
dataprovider::Database::PropertyInfoItem item = _proxy->getPropertyInfoItem(DatabaseIDKeeper::getID(), controllerType, wantedPropertyName);
result.actualPropertyName = item.actualPropertyName;
result.setpointPropertyName = wantedPropertyName;
result.offsetPropertyName = item.offsetPropertyName;
result.shortPropertyName = item.shortPropertyName;
result.shortPropertyName = item.setpointPropertyName;
result.isScan = item.isScan;
result.isSpy = item.isSpy;
result.isDynamic = item.isDynamic;
} catch (PropertyAccessorDirectImpl::NoSuchPropertyException & e) {
throw NoSuchPropertyException(wantedPropertyName);
......@@ -472,8 +474,30 @@ PropertyAccessor::PropertyInfoItem DirectPropertyAccessor::getPropertyInfoItem(c
return result;
}
void DirectPropertyAccessor::addPropertyInfoItem(const std::string & controllerType, const std::string & wantedPropertyName, const std::string & actualPropertyName, const std::string & offsetPropertyName, const std::string & shortPropertyName, bool isScan, bool isSpy) const {
_proxy->addPropertyInfoItem(DatabaseIDKeeper::getID(), controllerType, wantedPropertyName, actualPropertyName, offsetPropertyName, shortPropertyName, isScan, isSpy);
std::vector<PropertyAccessor::PropertyInfoItem> DirectPropertyAccessor::getPropertyInfoItems(const std::string & controllerType) const {
vector<PropertyAccessor::PropertyInfoItem> result;
vector<Database::PropertyInfoItem> items = _proxy->getPropertyInfoItems(DatabaseIDKeeper::getID(), controllerType);
for (auto i : items) {
PropertyAccessor::PropertyInfoItem item;
item.actualPropertyName = i.actualPropertyName;
item.setpointPropertyName = i.setpointPropertyName;
item.offsetPropertyName = i.offsetPropertyName;
item.shortPropertyName = i.aliasPropertyName;
item.isScan = i.isScan;
item.isSpy = i.isSpy;
item.isDynamic = i.isDynamic;
result.push_back(item);
}
return result;
}
void DirectPropertyAccessor::addPropertyInfoItem(const std::string & controllerType, const std::string & wantedPropertyName, const std::string & actualPropertyName, const std::string & offsetPropertyName, const std::string & shortPropertyName, bool isScan, bool isSpy, bool isDynamic) const {
_proxy->addPropertyInfoItem(DatabaseIDKeeper::getID(), controllerType, wantedPropertyName, actualPropertyName, offsetPropertyName, shortPropertyName, isScan, isSpy, isDynamic);
}
int32 DirectPropertyAccessor::getNumberOfScannableProperties(const std::string & controllerType) const {
......
......@@ -286,10 +286,15 @@ public:
*/
virtual PropertyInfoItem getPropertyInfoItem(const std::string & controllerType, const std::string & wantedPropertyName) const;
/**
* Gets the property items.
*/
virtual std::vector<PropertyInfoItem> getPropertyInfoItems(const std::string & controllerType) const;
/**
* Adds the item.
*/
virtual void addPropertyInfoItem(const std::string & controllerType, const std::string & wantedPropertyName, const std::string & actualPropertyName, const std::string & offsetPropertyName, const std::string & shortPropertyName, bool isScan, bool isSpy) const;
virtual void addPropertyInfoItem(const std::string & controllerType, const std::string & wantedPropertyName, const std::string & actualPropertyName, const std::string & offsetPropertyName, const std::string & shortPropertyName, bool isScan, bool isSpy, bool isDynamic) const;
/**
* Returns the number of properties for a controller type.
......
......@@ -371,12 +371,14 @@ public:
*/
struct PropertyInfoItem {
std::string actualPropertyName;
std::string setpointPropertyName;
std::string offsetPropertyName;
std::string shortPropertyName;
bool isScan;
bool isSpy;
bool isDynamic;
PropertyInfoItem() : isScan(false), isSpy(false) {}
PropertyInfoItem() : isScan(false), isSpy(false), isDynamic(false) {}
};
/**
......@@ -389,10 +391,15 @@ public:
*/
virtual PropertyInfoItem getPropertyInfoItem(const std::string & controllerType, const std::string & wantedPropertyName) const = 0;
/**
* Gets the property items.
*/
virtual std::vector<PropertyInfoItem> getPropertyInfoItems(const std::string & controllerType) const = 0;
/**
* Adds the item.
*/
virtual void addPropertyInfoItem(const std::string & controllerType, const std::string & wantedPropertyName, const std::string & actualPropertyName, const std::string & offsetPropertyName, const std::string & shortPropertyName, bool isScan, bool isSpy) const = 0;
virtual void addPropertyInfoItem(const std::string & controllerType, const std::string & wantedPropertyName, const std::string & actualPropertyName, const std::string & offsetPropertyName, const std::string & shortPropertyName, bool isScan, bool isSpy, bool isDynamic) const = 0;
/**
* Returns the number of properties for a controller type.
......
......@@ -42,9 +42,9 @@ namespace common {
typedef enum {NORMAL, ERROR, DEBUGGING, STARTUP, SHUTDOWN} OutputType;
/**
* Enable state.
* Configuration state.
*/
typedef enum {ENABLED, DISABLED, NO_CHANGE} EnableState;
typedef enum {ENABLED, DISABLED, TREE, PROPERTY} ConfigurationState;
/**
* Log type.
......@@ -76,6 +76,15 @@ namespace common {
*/
typedef enum {INACTIVE, PENDING, STARTING, ACTIVE, PAUSED, PAUSING, STOPPED, STOPPING, RESUMING, UNKNOWN} CommandState;
/**
* Expression status.
*/
typedef enum {VALID_EXPRESSION, INVALID_EXPRESSION} ExpressionStatus;
/**
* Expression error.
*/
typedef enum {NO_EXPRESSION_ERROR = 0, DISABLED_CONTROLLER_ERROR, ENUMERATED_VALUE_ERROR, UNDEFINED_VARIABLE_ERROR, PARSER_ERROR} ExpressionError;
}
#endif /*COMMON_COMMONTYPES_H_*/
......@@ -468,26 +468,25 @@ std::string convertStringToXML(std::string const & value) {
string xmlValue;
for (int i = 0; i < value.length(); i++) {
// Do not manage ≡ as it seems to be ok to keep it as is (at least in the Nomad GUI log viewer).
if (value[i] == '&') {
xmlValue += "&amp;";
}
else if (value[i] == '>') {
xmlValue += "&gt;";
}
else if (value[i] == '"') {
xmlValue += "&quot;";
}
else if (value[i] == '<') {
xmlValue += "&lt;";
}
else if (value[i] == '\'') {
xmlValue += "&apos;";
} else {
}
else {
xmlValue += value[i];
}
}
......
......@@ -57,11 +57,6 @@ PropertyType::Type PropertyTypeHelper<bool>::getStaticType() {
return PropertyType::BOOLEAN;
}
PropertyType::Type PropertyTypeHelper<String>::getStaticType() {
return PropertyType::STRING;
}
PropertyType::Type PropertyTypeHelper<string>::getStaticType() {
return PropertyType::STRING;
......@@ -107,11 +102,6 @@ PropertyType::Type PropertyTypeHelper<float64>::getStaticArrayType() {
return PropertyType::FLOAT64_ARRAY;
}
PropertyType::Type PropertyTypeHelper<String>::getStaticArrayType() {
return PropertyType::STRING_ARRAY;
}
PropertyType::Type PropertyTypeHelper<string>::getStaticArrayType() {
return PropertyType::STRING_ARRAY;
......
......@@ -19,7 +19,7 @@
#ifndef COMMON_PROPERTYTYPE_H_
#define COMMON_PROPERTYTYPE_H_
#include <common/base/String.h>
#include <string>
namespace common {
......
......@@ -82,14 +82,6 @@ struct PropertyTypeHelper<bool> {
static common::PropertyType::Type getStaticArrayType();
};
template<>
struct PropertyTypeHelper<String> {
static common::PropertyType::Type getStaticType();
static common::PropertyType::Type getStaticArrayType();
};
template<>
struct PropertyTypeHelper<std::string> {
......
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "String.h"
using namespace std;
namespace common {
const std::string String::BAD_SIZE = "String bad size";
const std::string String::STL_ERROR = "String STL error";
const std::string String::INDEX_OUT_OF_BOUNDS = "String index out of bounds";
String::String() {
}
String::String(const char * string) :
std::string(string) {
}
String::String(const std::string& string) :
std::string(string) {
}
String String::operator+(String const & value) const {
string result = static_cast<string const &>(*this) + static_cast<string const &>(value);
return String(result);
}
int32 String::_size() const {
return size();
}
common::String String::_resize(int32 size) {
try {
String result = *this;
result.resize(size, ' ');
return result;
} catch (const std::exception& e) {
}
return String();
}
int8 String::_getChar(int32 index) const {
if (index < 0 || index > size()) {
}
try {
return at(index);
} catch (const std::exception& e) {
//throw STLError(e.what());
}
return int8();
}
String String::_substring(int32 beginIndex, int32 endIndex) const {
if (beginIndex < 0 || beginIndex > size()) {
}
if (endIndex < 0 || endIndex > size()) {
}
try {
if (endIndex <= beginIndex) {
return String();
}
return String(substr(beginIndex, endIndex - beginIndex));
} catch (const std::exception& e) {
}
return String();
}
bool String::_startsWith(String sequence) const {
try {
if (find_first_of(sequence) == 0) {
return true;
}