You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by fi...@apache.org on 2012/08/02 17:09:57 UTC
svn commit: r1368513 - in /incubator/etch/trunk/binding-cpp/runtime:
include/support/ include/transport/ lib/capu/modules/capu/test/os/
src/main/serialization/ src/main/support/ src/main/transport/
src/main/util/ src/test/ src/test/support/ src/test/tr...
Author: fitzner
Date: Thu Aug 2 15:09:56 2012
New Revision: 1368513
URL: http://svn.apache.org/viewvc?rev=1368513&view=rev
Log:
ETCH-197: Implementation of Remote base and some other improvements
Implementation of Remote Base and some improvements
Change-Id: Ibd7edc42d18f27b8b5277d041b186cced67080bb
Added:
incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp
Modified:
incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h
incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDeliveryService.h
incubator/etch/trunk/binding-cpp/runtime/include/support/EtchMonitor.h
incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRemoteBase.h
incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchDefaultDeliveryService.h
incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchMessage.h
incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchMessagizer.h
incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPacketizer.h
incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h
incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpConnection.h
incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h
incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h
incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransport.h
incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/test/os/CondVarTest.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchMonitor.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRemoteBase.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessage.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpListener.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp
incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchCircularQueue.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt
incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchMonitorTest.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchPlainMailboxTest.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPlainMailboxManagerTest.cpp
incubator/etch/trunk/binding-cpp/runtime/src/test/util/EtchCircularQueueTest.cpp
Modified: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDefaultServerFactory.h Thu Aug 2 15:09:56 2012
@@ -78,7 +78,7 @@ public:
/**
* @see EtchTransport<EtchSession>
*/
- virtual status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result);
+ virtual status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result);
private:
EtchSession* mSession;
Modified: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDeliveryService.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDeliveryService.h?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDeliveryService.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchDeliveryService.h Thu Aug 2 15:09:56 2012
@@ -52,6 +52,4 @@ public:
virtual status_t endcall(EtchMailbox* mb, EtchType* responseType, capu::SmartPointer<EtchObject>& result) = 0;
};
-
-
#endif
Modified: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchMonitor.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchMonitor.h?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchMonitor.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchMonitor.h Thu Aug 2 15:09:56 2012
@@ -36,7 +36,7 @@ public:
* @param description a description of this monitor.
* @param initialValue the initial value of this monitor.
*/
- EtchMonitor(EtchString& description, EtchString& initialValue);
+ EtchMonitor(EtchString description, EtchString initialValue);
/**
* Destructor
@@ -59,7 +59,7 @@ public:
* @param newValue the value to be set.
* @param the old value.
*/
- status_t set(EtchString& value, EtchString& oldValue);
+ status_t set(EtchString value, EtchString& oldValue);
/**
* Waits until value equals the desired value and
@@ -156,6 +156,16 @@ private:
/////////////////////
/**
+ * waitUntilEq internal
+ */
+ status_t waitUntilEqIntern(EtchString& desiredValue, capu::int32_t maxDelay);
+
+ /**
+ * waitUntilNotEq internal
+ */
+ status_t waitUntilNotEqIntern(EtchString& undesiredValue, capu::uint32_t maxDelay, EtchString& current);
+
+ /**
* Compares the specified values.
*
* @param v1 a value to compare, which may be null.
Modified: incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRemoteBase.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRemoteBase.h?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRemoteBase.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/support/EtchRemoteBase.h Thu Aug 2 15:09:56 2012
@@ -29,8 +29,7 @@
/**
* Base class for call to message translators.
*/
-class EtchRemoteBase
-{
+class EtchRemoteBase {
public:
/**
* Constructs the RemoteBase.
@@ -43,7 +42,7 @@ public:
/**
* Destructor
*/
- virtual ~EtchRemoteBase() {};
+ virtual ~EtchRemoteBase();
/**
* Constructs a new message to send using {@link #send(Message)} or
@@ -69,7 +68,7 @@ public:
* @return a mailbox which can be used to read the response, using
* {@link #endcall(Mailbox, Type)}.
*/
- status_t beginCall(EtchMessage* msg, EtchMailbox** result);
+ status_t begincall(capu::SmartPointer<EtchMessage> msg, EtchMailbox *&result);
/**
* Finishes a call sequence by waiting for the response message.
@@ -81,7 +80,7 @@ public:
* @return an error if there is a problem sending or a timeout waiting or
* if the result value was an exception.
*/
- status_t endCall(EtchMailbox* mb, EtchType* responseType, EtchObject** result);
+ status_t endcall(EtchMailbox* mb, EtchType* responseType, capu::SmartPointer<EtchObject> &result);
/**
* Gets a configuration or operational value from the source. The
@@ -96,7 +95,7 @@ public:
*
* @return an error if there is a problem
*/
- status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result);
+ status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result);
/**
* Sets a configuration or operational value in the source. The
@@ -126,7 +125,7 @@ public:
*
* @return an error if there is a problem
*/
- status_t transportNotify(capu::SmartPointer<EtchObject> event );
+ status_t transportNotify(capu::SmartPointer<EtchObject> event);
////////////////////////////
// Convenience operations //
@@ -186,7 +185,7 @@ public:
status_t stopAndWaitDown(capu::int32_t maxDelay);
private:
- EtchDeliveryService* mSvc;
+ EtchDeliveryService * mSvc;
EtchValueFactory* mVf;
};
Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchDefaultDeliveryService.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchDefaultDeliveryService.h?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchDefaultDeliveryService.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchDefaultDeliveryService.h Thu Aug 2 15:09:56 2012
@@ -101,7 +101,7 @@ public:
/**
* @see EtchTransportMessage
*/
- virtual status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result);
+ virtual status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result);
/**
* @see EtchTransportMessage
Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchMessage.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchMessage.h?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchMessage.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchMessage.h Thu Aug 2 15:09:56 2012
@@ -82,7 +82,7 @@ public:
* send process overwrites any value the user might set here. So
* don't bother trying to set it.
*/
- void setMessageId(capu::int64_t msgid);
+ status_t setMessageId(capu::int64_t msgid);
/**
* @param the message-id of the message that this is a response to.
Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchMessagizer.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchMessagizer.h?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchMessagizer.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchMessagizer.h Thu Aug 2 15:09:56 2012
@@ -79,7 +79,7 @@ public:
/**
* @see EtchTransport
*/
- status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result);
+ status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result);
/**
* @see EtchTransport
Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPacketizer.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPacketizer.h?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPacketizer.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPacketizer.h Thu Aug 2 15:09:56 2012
@@ -92,7 +92,7 @@ public:
/**
* @see EtchTransport
*/
- status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result);
+ status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result);
/**
* @see EtchTransport
Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h Thu Aug 2 15:09:56 2012
@@ -92,7 +92,7 @@ public:
////////////////////
// Source methods //
////////////////////
- status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result);
+ status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result);
status_t transportControl(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value);
status_t transportNotify(capu::SmartPointer<EtchObject> event);
EtchSessionMessage* getSession();
Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpConnection.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpConnection.h?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpConnection.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpConnection.h Thu Aug 2 15:09:56 2012
@@ -18,18 +18,21 @@
#ifndef __ETCHTCPCONNECTION_H__
#define __ETCHTCPCONNECTION_H__
-#include "transport/EtchConnection.h"
+
+#include "capu/util/Runnable.h"
+
#include "common/EtchObject.h"
#include "common/EtchError.h"
#include "common/EtchString.h"
+#include "common/EtchSocket.h"
#include "util/EtchURL.h"
#include "util/EtchResources.h"
+#include "transport/EtchConnection.h"
#include "transport/EtchTransportData.h"
-#include "common/EtchSocket.h"
#include "transport/EtchFlexBuffer.h"
#include "transport/EtchSessionData.h"
#include "transport/EtchTcpOption.h"
-#include "capu/util/Runnable.h"
+
/**
* Implementation of connection which handles a tcp connection.
@@ -70,7 +73,7 @@ public:
/**
* @see TransportData
*/
- virtual status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result);
+ virtual status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result);
/**
* @return Session
Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpListener.h Thu Aug 2 15:09:56 2012
@@ -68,7 +68,7 @@ public:
/**
* @see TransportData
*/
- virtual status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result);
+ virtual status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result);
/**
* @return Session
Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTcpTransportFactory.h Thu Aug 2 15:09:56 2012
@@ -97,7 +97,7 @@ private:
/**
* @see EtchTransport
*/
- status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result);
+ status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result);
/**
* @see EtchTransport
Modified: incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransport.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransport.h?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransport.h (original)
+++ incubator/etch/trunk/binding-cpp/runtime/include/transport/EtchTransport.h Thu Aug 2 15:09:56 2012
@@ -28,7 +28,6 @@
* Out-of-band query, control, and notification interface for transports.
* @param <S> the subclass of Session for this Transport.
*/
-
template <class S>
class EtchTransport {
public:
@@ -59,12 +58,11 @@ public:
* @param query an object representing a query, which could be as
* simple as a string, integer, or enum, or more complex such as
* a class with instance variables for query terms.
- *
* @param result contains the result of given query
* @return ETCH_EUNIMPL if unimplemented
*
*/
- virtual status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) = 0;
+ virtual status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) = 0;
/**
* Sets a configuration or operational value in the transport. The
@@ -154,7 +152,7 @@ public:
/**
* EtchObjectType for WaitUp
*/
- static const EtchObjectType* WaitUp::TYPE() {
+ static const EtchObjectType* TYPE() {
const static EtchObjectType TYPE(EOTID_WAIT_UP, NULL);
return &TYPE;
}
@@ -162,7 +160,8 @@ public:
/**
* @param maxDelay max delay in milliseconds.
*/
- WaitUp(capu::int32_t maxDelay) : EtchObject(WaitUp::TYPE()), mMaxDelay(maxDelay) {
+ WaitUp(capu::int32_t maxDelay)
+ : EtchObject(WaitUp::TYPE()), mMaxDelay(maxDelay) {
}
/**
@@ -180,7 +179,7 @@ public:
/**
* EtchObjectType for WaitUp
*/
- static const EtchObjectType* WaitDown::TYPE() {
+ static const EtchObjectType* TYPE() {
const static EtchObjectType TYPE(EOTID_WAIT_DOWN, NULL);
return &TYPE;
}
@@ -189,7 +188,8 @@ public:
/**
* @param maxDelay max delay in milliseconds.
*/
- WaitDown(capu::int32_t maxDelay) : EtchObject(WaitDown::TYPE()), mMaxDelay(maxDelay) {
+ WaitDown(capu::int32_t maxDelay)
+ : EtchObject(WaitDown::TYPE()), mMaxDelay(maxDelay) {
}
/**
@@ -219,4 +219,4 @@ const EtchString EtchTransport<S>::START
template <class S>
const EtchString EtchTransport<S>::START_AND_WAIT_UP("START_AND_WAIT_UP");
-#endif
\ No newline at end of file
+#endif
Modified: incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/test/os/CondVarTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/test/os/CondVarTest.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/test/os/CondVarTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/lib/capu/modules/capu/test/os/CondVarTest.cpp Thu Aug 2 15:09:56 2012
@@ -149,3 +149,5 @@ TEST(CondVar,TimedWaitTest)
EXPECT_TRUE(condvar.wait(&mutex, 2000) == capu::CAPU_ETIMEOUT);
mutex.unlock();
}
+
+//TODO add recursive mutext condvar test
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/serialization/EtchDefaultValueFactory.cpp Thu Aug 2 15:09:56 2012
@@ -288,7 +288,10 @@ status_t EtchDefaultValueFactory::setMes
if (msg == NULL)
return ETCH_EINVAL;
capu::SmartPointer<EtchObject> value = new EtchLong(msgid);
- msg->put((EtchField&) _mf__messageId, value);
+ status_t res = msg->put((EtchField&) _mf__messageId, value);
+ if (res != ETCH_OK) {
+ return res;
+ }
return ETCH_OK;
}
@@ -310,7 +313,10 @@ status_t EtchDefaultValueFactory::setInR
if (msg == NULL)
return ETCH_EINVAL;
capu::SmartPointer<EtchObject> value = new EtchLong(msgid);
- msg->put((EtchField&) _mf__inReplyTo, value);
+ status_t res = msg->put((EtchField&) _mf__inReplyTo, value);
+ if (res != ETCH_OK) {
+ return res;
+ }
return ETCH_OK;
}
@@ -340,4 +346,3 @@ EtchLevel EtchDefaultValueFactory::setLe
void EtchDefaultValueFactory::addMixin(EtchValueFactory* vf) {
mMixins->add(vf);
}
-
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchDefaultServerFactory.cpp Thu Aug 2 15:09:56 2012
@@ -80,7 +80,7 @@ status_t EtchDefaultServerFactory::trans
return mListener->transportNotify( event );
}
-status_t EtchDefaultServerFactory::transportQuery( capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result ) {
+status_t EtchDefaultServerFactory::transportQuery( capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result ) {
if(mListener == NULL) {
return ETCH_ERANGE;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchMonitor.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchMonitor.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchMonitor.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchMonitor.cpp Thu Aug 2 15:09:56 2012
@@ -19,7 +19,7 @@
#include "capu/os/NumericLimits.h"
#include "support/EtchMonitor.h"
-EtchMonitor::EtchMonitor(EtchString& description, EtchString& initialValue) {
+EtchMonitor::EtchMonitor(EtchString description, EtchString initialValue) {
mDescription = description;
mValue = initialValue;
}
@@ -34,7 +34,7 @@ EtchString EtchMonitor::get() {
return mValue;
}
-status_t EtchMonitor::set(EtchString& value, EtchString& oldValue) {
+status_t EtchMonitor::set(EtchString value, EtchString& oldValue) {
mMutex.lock();
oldValue = mValue;
mValue = value;
@@ -49,7 +49,7 @@ status_t EtchMonitor::waitUntilEqAndSet(
status_t EtchMonitor::waitUntilEqAndSet(EtchString& desiredValue, capu::int32_t maxDelay, EtchString& newValue, EtchString &old) {
mMutex.lock();
- if (waitUntilEq(desiredValue, maxDelay) != ETCH_OK) {
+ if (waitUntilEqIntern(desiredValue, maxDelay) != ETCH_OK) {
mMutex.unlock();
return ETCH_TIMEOUT;
}
@@ -58,30 +58,33 @@ status_t EtchMonitor::waitUntilEqAndSet(
return ETCH_OK;
}
-status_t EtchMonitor::waitUntilEq(EtchString& desiredValue) {
- return waitUntilEq(desiredValue, 0);
-}
-
-status_t EtchMonitor::waitUntilEq(EtchString& desiredValue, capu::int32_t maxDelay) {
- mMutex.lock();
-
- capu::uint32_t now = capu::Time::GetMilliseconds();
- capu::uint32_t end = (maxDelay > 0) ? now + maxDelay : capu::NumericLimitMax<capu::uint32_t>();
+status_t EtchMonitor::waitUntilEqIntern(EtchString& desiredValue, capu::int32_t maxDelay) {
+ capu::uint64_t now = capu::Time::GetMilliseconds();
+ capu::uint64_t end = (maxDelay > 0) ? now + maxDelay : capu::NumericLimitMax<capu::uint32_t>();
- capu::int32_t d = end - now;
+ capu::int64_t d = end - now;
while (!eq(mValue, desiredValue) && d > 0) {
- mCv.wait(&mMutex, d);
+ mCv.wait(&mMutex, static_cast<capu::uint32_t>(d));
now = capu::Time::GetMilliseconds();
d = end - now;
}
if (!eq(mValue, desiredValue)) {
- mMutex.unlock();
return ETCH_TIMEOUT;
}
+ return ETCH_OK;
+}
+status_t EtchMonitor::waitUntilEq(EtchString& desiredValue) {
+ return waitUntilEq(desiredValue, 0);
+}
+
+status_t EtchMonitor::waitUntilEq(EtchString& desiredValue, capu::int32_t maxDelay) {
+ status_t status;
+ mMutex.lock();
+ status = waitUntilEqIntern(desiredValue, maxDelay);
mMutex.unlock();
- return ETCH_OK;
+ return status;
}
status_t EtchMonitor::waitUntilNotEqAndSet(EtchString& undesiredValue, EtchString& newValue, EtchString& old) {
@@ -91,7 +94,7 @@ status_t EtchMonitor::waitUntilNotEqAndS
status_t EtchMonitor::waitUntilNotEqAndSet(EtchString& undesiredValue, capu::int32_t maxDelay, EtchString& newValue, EtchString& old) {
mMutex.lock();
EtchString str;
- if (waitUntilNotEq(undesiredValue, maxDelay, str) != ETCH_OK) {
+ if (waitUntilNotEqIntern(undesiredValue, maxDelay, str) != ETCH_OK) {
mMutex.unlock();
return ETCH_TIMEOUT;
}
@@ -105,29 +108,34 @@ status_t EtchMonitor::waitUntilNotEq(Etc
}
status_t EtchMonitor::waitUntilNotEq(EtchString& undesiredValue, capu::uint32_t maxDelay, EtchString& current) {
+ status_t status;
mMutex.lock();
+ status = waitUntilNotEqIntern(undesiredValue, maxDelay, current);
+ mMutex.unlock();
+ return status;
+}
- capu::uint32_t now = capu::Time::GetMilliseconds();
- capu::uint32_t end = (maxDelay > 0) ? now + maxDelay : capu::NumericLimitMax<capu::uint32_t>();
+status_t EtchMonitor::waitUntilNotEqIntern(EtchString& undesiredValue, capu::uint32_t maxDelay, EtchString& current) {
+ capu::uint64_t now = capu::Time::GetMilliseconds();
+ capu::uint64_t end = (maxDelay > 0) ? now + maxDelay : capu::NumericLimitMax<capu::uint32_t>();
- capu::int32_t d = end - now;
+ capu::int64_t d = end - now;
while (eq(mValue, undesiredValue) && d > 0) {
- mCv.wait(&mMutex, d);
+ mCv.wait(&mMutex, static_cast<capu::uint32_t>(d));
now = capu::Time::GetMilliseconds();
d = end - now;
}
if (eq(mValue, undesiredValue)) {
- mMutex.unlock();
return ETCH_TIMEOUT;
}
current = mValue;
- mMutex.unlock();
return ETCH_OK;
}
+
capu::bool_t EtchMonitor::eq(EtchString& v1, EtchString& v2) {
return v1.equals(&v2);
}
\ No newline at end of file
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRemoteBase.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRemoteBase.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRemoteBase.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/support/EtchRemoteBase.cpp Thu Aug 2 15:09:56 2012
@@ -17,10 +17,13 @@
*/
#include "support/EtchRemoteBase.h"
+#include "transport/EtchTransportData.h"
-EtchRemoteBase::EtchRemoteBase(EtchDeliveryService* svc, EtchValueFactory* vf )
- : mSvc(svc)
- , mVf(vf) {
+EtchRemoteBase::EtchRemoteBase(EtchDeliveryService* svc, EtchValueFactory* vf)
+ : mSvc(svc), mVf(vf) {
+}
+
+EtchRemoteBase::~EtchRemoteBase() {
}
status_t EtchRemoteBase::newMessage( EtchType* type, capu::SmartPointer<EtchMessage> *message) {
@@ -32,54 +35,55 @@ status_t EtchRemoteBase::newMessage( Etc
}
status_t EtchRemoteBase::send(capu::SmartPointer<EtchMessage> msg) {
- return ETCH_EUNIMPL;
+ return mSvc->transportMessage(NULL, msg);
}
-
-status_t EtchRemoteBase::beginCall(EtchMessage* msg, EtchMailbox** result) {
- return ETCH_EUNIMPL;
+status_t EtchRemoteBase::begincall(capu::SmartPointer<EtchMessage> msg, EtchMailbox *&result) {
+ return mSvc->begincall(msg, result);
}
-status_t EtchRemoteBase::endCall(EtchMailbox* mb, EtchType* responseType, EtchObject** result) {
- return ETCH_EUNIMPL;
+status_t EtchRemoteBase::endcall(EtchMailbox* mb, EtchType* responseType, capu::SmartPointer<EtchObject> &result) {
+ return mSvc->endcall(mb, responseType, result);
}
-status_t EtchRemoteBase::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) {
- return ETCH_EUNIMPL;
+status_t EtchRemoteBase::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) {
+ return mSvc->transportQuery(query, result);
}
status_t EtchRemoteBase::transportControl(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value) {
- return ETCH_EUNIMPL;
+ return mSvc->transportControl(control, value);
}
-status_t EtchRemoteBase::transportNotify(capu::SmartPointer<EtchObject> event ) {
- return ETCH_EUNIMPL;
+status_t EtchRemoteBase::transportNotify(capu::SmartPointer<EtchObject> event) {
+ return mSvc->transportNotify(event);
}
-////////////////////////////
-// Convenience operations //
-////////////////////////////
-
status_t EtchRemoteBase::start() {
- return ETCH_EUNIMPL;
+ return transportControl(new EtchString(EtchTransportData::START), NULL);
}
status_t EtchRemoteBase::waitUp(capu::int32_t maxDelay) {
- return ETCH_EUNIMPL;
+ return transportQuery(new WaitUp(maxDelay), NULL);
}
status_t EtchRemoteBase::startAndWaitUp(capu::int32_t maxDelay) {
- return ETCH_EUNIMPL;
+ status_t res = start();
+ if (res != ETCH_OK)
+ return res;
+ return waitUp(maxDelay);
}
status_t EtchRemoteBase::stop() {
- return ETCH_EUNIMPL;
+ return transportControl(new EtchString(EtchTransportData::STOP), NULL);
}
status_t EtchRemoteBase::waitDown(capu::int32_t maxDelay) {
- return ETCH_EUNIMPL;
+ return transportQuery(new WaitDown(maxDelay), NULL);
}
status_t EtchRemoteBase::stopAndWaitDown(capu::int32_t maxDelay) {
- return ETCH_EUNIMPL;
+ status_t res = stop();
+ if (res != ETCH_OK)
+ return res;
+ return waitDown(maxDelay);
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchDefaultDeliveryService.cpp Thu Aug 2 15:09:56 2012
@@ -91,7 +91,7 @@ status_t EtchDefaultDeliveryService::tra
return mTransport->transportMessage(recipient, message);
}
-status_t EtchDefaultDeliveryService::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) {
+status_t EtchDefaultDeliveryService::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) {
if (query->getObjectType()->equals(WaitUp::TYPE())) {
waitUp(((WaitUp*) query.get())->mMaxDelay);
result = NULL;
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessage.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessage.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessage.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessage.cpp Thu Aug 2 15:09:56 2012
@@ -62,8 +62,8 @@ status_t EtchMessage::getMessageId(capu:
return mVf->getMessageId(this, result);
}
-void EtchMessage::setMessageId(capu::int64_t msgid) {
- mVf->setMessageId(this, msgid);
+status_t EtchMessage::setMessageId(capu::int64_t msgid) {
+ return mVf->setMessageId(this, msgid);
}
status_t EtchMessage::getInReplyToMessageId(capu::int64_t &result) {
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchMessagizer.cpp Thu Aug 2 15:09:56 2012
@@ -69,7 +69,7 @@ status_t EtchMessagizer::transportNotify
return mTransport->transportNotify(event);
}
-status_t EtchMessagizer::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) {
+status_t EtchMessagizer::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) {
return mTransport->transportQuery(query, result);
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPacketizer.cpp Thu Aug 2 15:09:56 2012
@@ -80,7 +80,7 @@ status_t EtchPacketizer::transportNotify
return mTransport->transportNotify(event);
}
-status_t EtchPacketizer::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) {
+status_t EtchPacketizer::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) {
return mTransport->transportQuery(query, result);
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp Thu Aug 2 15:09:56 2012
@@ -104,14 +104,15 @@ status_t EtchPlainMailboxManager::transp
}
capu::int64_t msgid = mIdGen.next();
- msg->setMessageId(msgid);
+ if (msg->setMessageId(msgid) != ETCH_OK) {
+ return ETCH_ERROR;
+ }
EtchMailbox *mb = new EtchPlainMailbox(this, msgid);
if (registerMailbox(mb) != ETCH_OK) {
delete mb;
return ETCH_ERROR;
}
- //Log.report( "MailboxManager.send", "msg", msg );
if (mTransport->transportMessage(recipient, msg) == ETCH_OK) {
result = mb;
@@ -130,8 +131,9 @@ status_t EtchPlainMailboxManager::transp
return ETCH_ERROR;
}
- message->setMessageId(mIdGen.next());
-
+ if(message->setMessageId(mIdGen.next()) != ETCH_OK) {
+ return ETCH_ERROR;
+ }
return mTransport->transportMessage(recipient, message);
}
@@ -159,7 +161,7 @@ status_t EtchPlainMailboxManager::sessio
return mSession->sessionNotify(event);
}
-status_t EtchPlainMailboxManager::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) {
+status_t EtchPlainMailboxManager::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) {
return mTransport->transportQuery(query, result);
}
@@ -181,4 +183,4 @@ void EtchPlainMailboxManager::setSession
capu::uint64_t EtchPlainMailboxManager::count() {
return mMailboxes.count();
-}
\ No newline at end of file
+}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpConnection.cpp Thu Aug 2 15:09:56 2012
@@ -137,7 +137,7 @@ status_t EtchTcpConnection::transportNot
return ETCH_OK;
}
-status_t EtchTcpConnection::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) {
+status_t EtchTcpConnection::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) {
//Nothing to do
return ETCH_EUNIMPL;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpListener.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpListener.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpListener.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpListener.cpp Thu Aug 2 15:09:56 2012
@@ -170,7 +170,7 @@ status_t EtchTcpListener::transportNotif
return ETCH_OK;
}
-status_t EtchTcpListener::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) {
+status_t EtchTcpListener::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) {
//Nothing to do
return ETCH_EUNIMPL;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/transport/EtchTcpTransportFactory.cpp Thu Aug 2 15:09:56 2012
@@ -107,7 +107,7 @@ void EtchTcpTransportFactory::MySessionL
mSession = session;
}
-status_t EtchTcpTransportFactory::MySessionListener::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) {
+status_t EtchTcpTransportFactory::MySessionListener::transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) {
return mTransport->transportQuery(query, result);
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchCircularQueue.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchCircularQueue.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchCircularQueue.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/main/util/EtchCircularQueue.cpp Thu Aug 2 15:09:56 2012
@@ -124,10 +124,10 @@ status_t EtchCircularQueue::get(EtchMail
}
// the queue is empty, not closed, and caller has requested a delay...
- capu::uint32_t now = capu::Time::GetMilliseconds();
- capu::uint32_t end = (maxDelay > 0) ? now + maxDelay : capu::NumericLimitMax<capu::uint32_t>();
+ capu::int64_t now = capu::Time::GetMilliseconds();
+ capu::int64_t end = (maxDelay > 0) ? now + maxDelay : capu::NumericLimitMax<capu::uint32_t>();
- capu::int32_t d;
+ capu::int64_t d;
while ((d = end - now) > 0) {
// the queue is empty, not closed, and delay has not run out...
if(!isEmpty() || isClosed() || d <= 0) {
@@ -136,7 +136,7 @@ status_t EtchCircularQueue::get(EtchMail
return ETCH_ERROR;
}
// wait
- mCondVar.wait(&mMutex, d);
+ mCondVar.wait(&mMutex, static_cast<capu::uint32_t>(d));
if (!isEmpty()) {
status = getAndNotify(element);
@@ -191,10 +191,10 @@ capu::status_t EtchCircularQueue::put(Et
}
// the queue is full, not closed, and the caller has requested a delay...
- capu::uint32_t now = capu::Time::GetMilliseconds();
- capu::uint32_t end = (maxDelay > 0) ? now + maxDelay : capu::NumericLimitMax<capu::uint32_t>();
+ capu::uint64_t now = capu::Time::GetMilliseconds();
+ capu::uint64_t end = (maxDelay > 0) ? now + maxDelay : capu::NumericLimitMax<capu::uint32_t>();
- capu::int32_t d;
+ capu::int64_t d;
while((d = end - now) > 0) {
// the queue is full, not closed, and delay has not run out...
if (!isFull() || isClosed() || d <= 0) {
@@ -202,7 +202,7 @@ capu::status_t EtchCircularQueue::put(Et
return ETCH_ERROR;
}
// wait
- mCondVar.wait(&mMutex, d);
+ mCondVar.wait(&mMutex, static_cast<capu::uint32_t>(d));
if(isClosed()) {
mMutex.unlock();
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/CMakeLists.txt Thu Aug 2 15:09:56 2012
@@ -87,6 +87,7 @@ add_executable (etch-cpp-test
support/EtchFreePoolTest.cpp
support/EtchPlainMailboxTest.cpp
support/EtchMonitorTest.cpp
+ support/EtchRemoteBaseTest.cpp
util/EtchCircularQueueTest.cpp
util/EtchUtilTest.cpp
${GTEST}/src/gtest-all.cc
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchMonitorTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchMonitorTest.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchMonitorTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchMonitorTest.cpp Thu Aug 2 15:09:56 2012
@@ -20,6 +20,7 @@
#include <gtest/gtest.h>
+#include "capu/os/Thread.h"
#include "support/EtchMonitor.h"
TEST(EtchMonitorTest, constructorTest) {
@@ -67,6 +68,26 @@ TEST(EtchMonitorTest, waitUntilEqTest) {
delete m;
}
+namespace {
+
+class R1 : public capu::Runnable {
+public:
+ R1(EtchMonitor *monitor) {
+ mMonitor = monitor;
+ }
+
+ void operator()(void* param) {
+ capu::Thread::Sleep(2000);
+ EtchString str;
+ mMonitor->set("tmp1", str);
+ }
+
+private:
+ EtchMonitor *mMonitor;
+};
+
+}
+
TEST(EtchMonitorTest, waitUntilNotEqTest) {
EtchString init("init");
EtchMonitor *m = new EtchMonitor(EtchString("desc"), init);
@@ -80,10 +101,18 @@ TEST(EtchMonitorTest, waitUntilNotEqTest
EXPECT_EQ(ETCH_OK, m->waitUntilNotEq(tmp2, current));
EXPECT_EQ(ETCH_OK, m->waitUntilNotEq(tmp2, 0, current));
+ // blocking test
m->set(tmp2, current);
- EXPECT_EQ(ETCH_TIMEOUT, m->waitUntilNotEq(tmp2, current));
- EXPECT_EQ(ETCH_TIMEOUT, m->waitUntilNotEq(tmp2, 2000, current));
- EXPECT_EQ(ETCH_OK, m->waitUntilNotEq(tmp1, 2000, current));
+ R1* r1 = new R1(m);
+ capu::Thread* t1 = new capu::Thread(r1);
+ EXPECT_EQ(ETCH_OK, m->waitUntilNotEq(tmp2, current));
+ t1->join();
+ delete r1;
+ delete t1;
+
+ // blocking timeout test
+ EXPECT_EQ(ETCH_OK, m->waitUntilNotEq(tmp2, 2000, current));
+ EXPECT_EQ(ETCH_TIMEOUT, m->waitUntilNotEq(tmp1, 2000, current));
delete m;
}
@@ -102,7 +131,15 @@ TEST(EtchMonitorTest, waitUntilEqAndSetT
EXPECT_EQ(ETCH_OK, m->waitUntilEqAndSet(tmp2, 0, tmp2, current));
m->set(tmp2, current);
- EXPECT_EQ(ETCH_TIMEOUT, m->waitUntilEqAndSet(tmp1, tmp2, current));
+ // blocking test
+ m->set(tmp2, current);
+ R1* r1 = new R1(m);
+ capu::Thread* t1 = new capu::Thread(r1);
+ EXPECT_EQ(ETCH_OK, m->waitUntilEqAndSet(tmp1, tmp2, current));
+ t1->join();
+ delete r1;
+ delete t1;
+
EXPECT_EQ(ETCH_TIMEOUT, m->waitUntilEqAndSet(init, 2000, tmp2, current));
EXPECT_EQ(ETCH_OK, m->waitUntilEqAndSet(tmp2, 2000, tmp2, current));
@@ -123,9 +160,17 @@ TEST(EtchMonitorTest, waitUntilNotEqAndS
EXPECT_EQ(ETCH_OK, m->waitUntilNotEqAndSet(tmp2, 0, tmp2, current));
m->set(tmp2, current);
- EXPECT_EQ(ETCH_TIMEOUT, m->waitUntilNotEqAndSet(tmp2, tmp1, current));
- EXPECT_EQ(ETCH_TIMEOUT, m->waitUntilNotEqAndSet(tmp2, 2000, tmp2, current));
- EXPECT_EQ(ETCH_OK, m->waitUntilNotEqAndSet(tmp1, 2000, tmp2, current));
+ // blocking test
+ m->set(tmp2, current);
+ R1* r1 = new R1(m);
+ capu::Thread* t1 = new capu::Thread(r1);
+ EXPECT_EQ(ETCH_OK, m->waitUntilNotEqAndSet(tmp2, tmp1, current));
+ t1->join();
+ delete r1;
+ delete t1;
+
+ EXPECT_EQ(ETCH_OK, m->waitUntilNotEqAndSet(tmp2, 2000, tmp2, current));
+ EXPECT_EQ(ETCH_TIMEOUT, m->waitUntilNotEqAndSet(tmp2, 2000, tmp1, current));
delete m;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchPlainMailboxTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchPlainMailboxTest.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchPlainMailboxTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchPlainMailboxTest.cpp Thu Aug 2 15:09:56 2012
@@ -47,7 +47,7 @@ public:
MOCK_METHOD2(transportMessage, status_t(capu::SmartPointer<EtchWho> recipient, capu::SmartPointer<EtchMessage> message));
- MOCK_METHOD2(transportQuery, status_t(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result));
+ MOCK_METHOD2(transportQuery, status_t(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result));
MOCK_METHOD2(transportControl, status_t(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value));
Added: incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp?rev=1368513&view=auto
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp (added)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/support/EtchRemoteBaseTest.cpp Thu Aug 2 15:09:56 2012
@@ -0,0 +1,319 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include "support/EtchRemoteBase.h"
+#include "transport/EtchDefaultDeliveryService.h"
+#include "serialization/EtchDefaultValueFactory.h"
+#include "support/EtchPlainMailbox.h"
+#include "transport/EtchPlainMailboxManager.h"
+
+class MockSession2 : public EtchSessionMessage {
+public:
+
+ status_t sessionMessage(capu::SmartPointer<EtchWho> receipent, capu::SmartPointer<EtchMessage> buf) {
+ return ETCH_OK;
+ }
+
+ status_t sessionQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) {
+ return ETCH_OK;
+ }
+
+ status_t sessionControl(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value) {
+ return ETCH_OK;
+ }
+
+ status_t sessionNotify(capu::SmartPointer<EtchObject> event) {
+ return ETCH_OK;
+ }
+};
+
+class MockTransport2 : public EtchTransportMessage {
+public:
+
+ status_t transportMessage(capu::SmartPointer<EtchWho> recipient, capu::SmartPointer<EtchMessage> message) {
+ return ETCH_OK;
+ }
+
+ MOCK_METHOD0(getSession, EtchSessionMessage* ());
+
+ void setSession(EtchSessionMessage* session) {
+
+ }
+
+ status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) {
+ return ETCH_OK;
+ }
+
+ status_t transportControl(capu::SmartPointer<EtchObject> control, capu::SmartPointer<EtchObject> value) {
+ return ETCH_OK;
+ }
+
+ status_t transportNotify(capu::SmartPointer<EtchObject> event) {
+ return ETCH_OK;
+ }
+};
+
+class MockDefaultValueFactory2 {
+public:
+ EtchTypeMap types;
+ EtchClass2TypeMap class2type;
+ EtchDefaultValueFactory * factory;
+ /**
+ * Constructs the MyValueFactory.
+ * @param uri
+ */
+public:
+
+ MockDefaultValueFactory2(EtchString uri) {
+ EtchDefaultValueFactory::Init(&types, &class2type);
+ factory = new EtchDefaultValueFactory(uri, &types, &class2type);
+ }
+
+ ~MockDefaultValueFactory2() {
+ delete factory;
+ types.clear();
+ }
+};
+
+TEST(EtchRemoteBaseTest, constructorTest) {
+ MockSession2 session;
+ MockTransport2 transport;
+ MockDefaultValueFactory2 *factory;
+ EtchString uri("tcp://127.0.0.1:4001");
+ factory = new MockDefaultValueFactory2(uri);
+ //created value factory
+ EtchURL u(uri);
+ EtchPlainMailboxManager * manager = NULL;
+ manager = new EtchPlainMailboxManager(&transport, &u, NULL);
+ EtchDeliveryService * service = NULL;
+ service = new EtchDefaultDeliveryService(manager, &u);
+ EtchRemoteBase * remote = NULL;
+ remote = new EtchRemoteBase(service, factory->factory);
+
+ EXPECT_TRUE(remote != NULL);
+ manager->setSession(service);
+ service->setSession(&session);
+
+ delete remote;
+ delete manager;
+ delete service;
+ delete factory;
+}
+
+TEST(EtchRemoteBaseTest, newMessageTest) {
+ MockSession2 session;
+ MockTransport2 transport;
+ MockDefaultValueFactory2 *factory;
+ EtchString uri("tcp://127.0.0.1:4001");
+ factory = new MockDefaultValueFactory2(uri);
+ //created value factory
+ EtchURL u(uri);
+
+ EtchPlainMailboxManager * manager = NULL;
+ manager = new EtchPlainMailboxManager(&transport, &u, NULL);
+ EtchDeliveryService * service = NULL;
+ service = new EtchDefaultDeliveryService(manager, &u);
+ EtchRemoteBase * remote = NULL;
+ remote = new EtchRemoteBase(service, factory->factory);
+
+ EXPECT_TRUE(remote != NULL);
+ manager->setSession(service);
+ service->setSession(&session);
+
+ //create type
+ EtchString typeName("foo");
+ EtchType mt(typeName);
+ //create new message
+ capu::SmartPointer<EtchMessage> msg;
+ remote->newMessage(&mt, &msg);
+
+ //check type
+ EXPECT_TRUE(msg->isType(&mt));
+
+ //check the assigned factory
+ EXPECT_TRUE(factory->factory == msg->getValueFactory());
+
+ delete remote;
+ delete manager;
+ delete service;
+ delete factory;
+}
+
+TEST(EtchRemoteBaseTest, sendTest) {
+ MockSession2 session;
+ MockTransport2 transport;
+ MockDefaultValueFactory2 *factory;
+ EtchString uri("tcp://127.0.0.1:4001");
+ factory = new MockDefaultValueFactory2(uri);
+ //created value factory
+ EtchURL u(uri);
+
+ EtchPlainMailboxManager * manager = NULL;
+ manager = new EtchPlainMailboxManager(&transport, &u, NULL);
+ EtchDeliveryService * service = NULL;
+ service = new EtchDefaultDeliveryService(manager, &u);
+ EtchRemoteBase * remote = NULL;
+ remote = new EtchRemoteBase(service, factory->factory);
+
+ EXPECT_TRUE(remote != NULL);
+ manager->setSession(service);
+ service->setSession(&session);
+
+ //get the validator
+ capu::SmartPointer<EtchValidator> val = NULL;
+ EtchValidatorLong::Get(0, val);
+ //create type
+ EtchType *mt;
+ factory->types.get("add", mt);
+ mt->putValidator(EtchDefaultValueFactory::_mf__messageId, val);
+ //create new message
+ capu::SmartPointer<EtchMessage> msg;
+ remote->newMessage(mt, &msg);
+
+ //check type
+ EXPECT_TRUE(msg->isType(mt));
+ //remote send
+ EXPECT_TRUE(remote->send(msg) == ETCH_OK);
+
+ factory->types.clear();
+ delete remote;
+ delete manager;
+ delete service;
+ delete factory;
+}
+
+TEST(EtchRemoteBaseTest, beginCallTest) {
+ MockSession2 session;
+ MockTransport2 transport;
+ MockDefaultValueFactory2 *factory;
+ EtchString uri("tcp://127.0.0.1:4001");
+ factory = new MockDefaultValueFactory2(uri);
+ //created value factory
+ EtchURL u(uri);
+
+ EtchPlainMailboxManager * manager = NULL;
+ manager = new EtchPlainMailboxManager(&transport, &u, NULL);
+ EtchDeliveryService * service = NULL;
+ service = new EtchDefaultDeliveryService(manager, &u);
+ EtchRemoteBase * remote = NULL;
+ remote = new EtchRemoteBase(service, factory->factory);
+
+ EXPECT_TRUE(remote != NULL);
+ manager->setSession(service);
+ service->setSession(&session);
+
+ //get the validator
+ capu::SmartPointer<EtchValidator> val = NULL;
+ EtchValidatorLong::Get(0, val);
+ //create type
+ EtchType *mt;
+ factory->types.get("add", mt);
+ mt->putValidator(EtchDefaultValueFactory::_mf__messageId, val);
+
+ //create new message
+ capu::SmartPointer<EtchMessage> msg;
+ remote->newMessage(mt, &msg);
+
+ //check type
+ EXPECT_TRUE(msg->isType(mt));
+
+ manager->sessionNotify(new EtchString(EtchSession::UP));
+
+ EtchMailbox *mail = NULL;
+ EXPECT_TRUE(remote->begincall(msg, mail) == ETCH_OK);
+ EXPECT_TRUE(mail != NULL);
+
+ factory->types.clear();
+ delete remote;
+ delete manager;
+ delete service;
+ delete factory;
+}
+
+TEST(EtchRemoteBaseTest, endCallTest) {
+ MockSession2 session;
+ MockTransport2 transport;
+ MockDefaultValueFactory2 *factory;
+ EtchString uri("tcp://127.0.0.1:4001");
+ factory = new MockDefaultValueFactory2(uri);
+ //created value factory
+ EtchURL u(uri);
+
+ EtchPlainMailboxManager * manager = NULL;
+ manager = new EtchPlainMailboxManager(&transport, &u, NULL);
+ EtchDeliveryService * service = NULL;
+ service = new EtchDefaultDeliveryService(manager, &u);
+ EtchRemoteBase * remote = NULL;
+ remote = new EtchRemoteBase(service, factory->factory);
+
+ EXPECT_TRUE(remote != NULL);
+ manager->setSession(service);
+ service->setSession(&session);
+
+ //create type
+ EtchType * type;
+ EtchType * replyType;
+ capu::SmartPointer<EtchValidator> val = NULL;
+ EtchValidatorLong::Get(0, val);
+
+ factory->types.get("add_result", replyType);
+ factory->types.get("add", type);
+ type->putValidator(EtchDefaultValueFactory::_mf__messageId, val);
+ replyType->putValidator(EtchDefaultValueFactory::_mf__inReplyTo, val);
+ replyType->putValidator(EtchDefaultValueFactory::_mf__messageId, val);
+ replyType->putValidator(EtchDefaultValueFactory::_mf_result, val);
+ replyType->setResponseField(EtchDefaultValueFactory::_mf_result);
+
+ //create new message
+ capu::SmartPointer<EtchMessage> replyMessage;
+ capu::SmartPointer<EtchMessage> message;
+ remote->newMessage(type, &message);
+
+ manager->sessionNotify(new EtchString(EtchSession::UP));
+
+ EtchMailbox *mail = NULL;
+ EXPECT_TRUE(remote->begincall(message, mail) == ETCH_OK);
+
+ EXPECT_TRUE(mail != NULL);
+
+ capu::int64_t id;
+ message->getMessageId(id);
+ //create a reply message
+ message->createReplyMessage(replyType, replyMessage);
+ EXPECT_TRUE(ETCH_OK == replyMessage->getInReplyToMessageId(id));
+ capu::SmartPointer<EtchMessage> replymess = replyMessage;
+ capu::SmartPointer<EtchObject> data = new EtchLong(123);
+ capu::SmartPointer<EtchObject> old;
+ EtchField field = replyType->getResponseField();
+ replyMessage->put(field, data, &old);
+ //call the sessionMessage of mailbox manager as if it is called from messagizer to deliver data from
+ EXPECT_TRUE(ETCH_OK == manager->sessionMessage(NULL, replymess));
+ capu::SmartPointer<EtchObject> result;
+ EXPECT_TRUE(remote->endcall(mail, replyType, result) == ETCH_OK);
+ EXPECT_TRUE(mail != NULL);
+ EXPECT_TRUE(result == data);
+
+ factory->types.clear();
+ delete mail;
+ delete remote;
+ delete manager;
+ delete service;
+ delete factory;
+}
\ No newline at end of file
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchDefaultDeliveryServiceTest.cpp Thu Aug 2 15:09:56 2012
@@ -58,7 +58,7 @@ public:
}
- status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) {
+ status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) {
return ETCH_OK;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPlainMailboxManagerTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPlainMailboxManagerTest.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPlainMailboxManagerTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/transport/EtchPlainMailboxManagerTest.cpp Thu Aug 2 15:09:56 2012
@@ -55,7 +55,7 @@ public:
}
- status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> &result) {
+ status_t transportQuery(capu::SmartPointer<EtchObject> query, capu::SmartPointer<EtchObject> *result) {
return ETCH_OK;
}
Modified: incubator/etch/trunk/binding-cpp/runtime/src/test/util/EtchCircularQueueTest.cpp
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/runtime/src/test/util/EtchCircularQueueTest.cpp?rev=1368513&r1=1368512&r2=1368513&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/runtime/src/test/util/EtchCircularQueueTest.cpp (original)
+++ incubator/etch/trunk/binding-cpp/runtime/src/test/util/EtchCircularQueueTest.cpp Thu Aug 2 15:09:56 2012
@@ -154,6 +154,7 @@ TEST(EtchCirclerQueueTest, closeTest) {
delete queue;
}
+namespace {
class R1 : public capu::Runnable {
public:
@@ -170,7 +171,7 @@ public:
}
private:
-EtchCircularQueue* mQueue;
+ EtchCircularQueue* mQueue;
};
class R2 : public capu::Runnable {
@@ -189,9 +190,11 @@ public:
}
private:
-EtchCircularQueue* mQueue;
+ EtchCircularQueue* mQueue;
};
+}
+
TEST(EtchCirclerQueueTest, concurrency) {
EtchCircularQueue* queue = new EtchCircularQueue(5);