-// Copyright (C) 2006-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2006-2021 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "AnyInputPort.hxx"
#include "TypeCode.hxx"
-#include <iostream>
-#include <sstream>
#include "Mutex.hxx"
+#include "AutoLocker.hxx"
//#define _DEVDEBUG_
#include "YacsTrace.hxx"
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+
using namespace YACS::ENGINE;
using namespace std;
_value->incrRef();
}
-void AnyInputPort::put(Any *data)
+void AnyInputPort::releaseDataUnsafe()
{
- YACS::BASES::Lock lock(&_mutex);
if(_value)
_value->decrRef();
+ _value = nullptr;
+}
+
+void AnyInputPort::releaseData()
+{
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> lock(&_mutex);
+ releaseDataUnsafe();
+}
+
+void AnyInputPort::put(Any *data)
+{
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> lock(&_mutex);
+ releaseDataUnsafe();
_value=data;
- if (_value) {
- _value->incrRef();
- DEBTRACE("value ref count: " << _value->getRefCnt());
- }
+ if (_value)
+ {
+ _value->incrRef();
+ DEBTRACE("value ref count: " << _value->getRefCnt());
+ }
}
bool AnyInputPort::isEmpty()
std::string AnyInputPort::getAsString()
{
- YACS::BASES::Lock lock(&_mutex);
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> lock(&_mutex);
return getRuntime()->convertNeutralAsString(edGetType(),_value);
}
-void AnyInputPort::put(const void *data) throw(ConversionException)
+void AnyInputPort::put(const void *data)
{
put((Any *)data);
}
switch (_value->getType()->kind())
{
case Double:
- xmldump << "<value><double>" << _value->getDoubleValue() << "</double></value>" << endl;
+ xmldump << "<value><double>" << setprecision(16) << _value->getDoubleValue() << "</double></value>" << endl;
break;
case Int:
xmldump << "<value><int>" << _value->getIntValue() << "</int></value>" << endl;