Add a C++ client for presents.

It provides code generators for streamables, services and receivers, but not DObject.  It uses
Apple's CFNetwork for its sockets and builds with XCode, so it's limited to OS X and iOS. It should
be straightforward to replace both to make it cross-platform.



git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6264 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Charlie Groves
2010-11-13 21:58:45 +00:00
parent f0970bc5bc
commit 1f010f0a4e
119 changed files with 4830 additions and 3 deletions
+22
View File
@@ -0,0 +1,22 @@
#include "presents/stable.h"
#include "ClientObject.h"
using namespace presents::data;
DEFINE_STREAMABLE("com.threerings.presents.data.ClientObject", ClientObject);
void ClientObject::readObject (ObjectInputStream& in)
{
presents::dobj::DObject::readObject(in);
username = boost::static_pointer_cast<util::Name>(in.readObject());
receivers = boost::static_pointer_cast<presents::dobj::DSet>(in.readObject());
permPolicy = boost::static_pointer_cast<presents::data::PermissionPolicy>(in.readObject());
}
void ClientObject::writeObject (ObjectOutputStream& out) const
{
presents::dobj::DObject::writeObject(out);
out.writeObject(username);
out.writeObject(receivers);
out.writeObject(permPolicy);
}
+27
View File
@@ -0,0 +1,27 @@
#pragma once
#include "presents/Streamable.h"
#include "presents/ObjectInputStream.h"
#include "presents/ObjectOutputStream.h"
#include "presents/streamers/StreamableStreamer.h"
#include "presents/dobj/DObject.h"
#include "util/Name.h"
#include "presents/data/PermissionPolicy.h"
#include "presents/dobj/DSet.h"
namespace presents { namespace data {
class ClientObject : public presents::dobj::DObject {
public:
DECLARE_STREAMABLE();
Shared<util::Name> username;
Shared<presents::dobj::DSet> receivers;
Shared<presents::data::PermissionPolicy> permPolicy;
virtual void readObject(ObjectInputStream& in);
virtual void writeObject(ObjectOutputStream& out) const;
};
}}
@@ -0,0 +1,18 @@
#include "presents/stable.h"
#include "InvocationMarshaller.h"
using namespace presents::data;
DEFINE_STREAMABLE("com.threerings.presents.data.InvocationMarshaller", InvocationMarshaller);
void InvocationMarshaller::readObject (ObjectInputStream& in)
{
invOid = int32(in.readInt());
invCode = int32(in.readInt());
}
void InvocationMarshaller::writeObject (ObjectOutputStream& out) const
{
out.writeInt(invOid);
out.writeInt(invCode);
}
@@ -0,0 +1,27 @@
#pragma once
#include "presents/Streamable.h"
#include "presents/ObjectInputStream.h"
#include "presents/ObjectOutputStream.h"
#include "presents/streamers/StreamableStreamer.h"
#include "presents/Streamable.h"
namespace presents {
class PresentsClient;
namespace data {
class InvocationMarshaller : public Streamable {
public:
DECLARE_STREAMABLE();
int32 invOid;
int32 invCode;
virtual void readObject(ObjectInputStream& in);
virtual void writeObject(ObjectOutputStream& out) const;
};
}}
@@ -0,0 +1,14 @@
#include "presents/stable.h"
#include "PermissionPolicy.h"
using namespace presents::data;
DEFINE_STREAMABLE("com.threerings.presents.data.PermissionPolicy", PermissionPolicy);
void PermissionPolicy::readObject (ObjectInputStream& /*in*/)
{
}
void PermissionPolicy::writeObject (ObjectOutputStream& /*out*/) const
{
}
+21
View File
@@ -0,0 +1,21 @@
#pragma once
#include "presents/Streamable.h"
#include "presents/ObjectInputStream.h"
#include "presents/ObjectOutputStream.h"
#include "presents/streamers/StreamableStreamer.h"
#include "presents/Streamable.h"
namespace presents { namespace data {
class PermissionPolicy : public Streamable {
public:
DECLARE_STREAMABLE();
virtual void readObject(ObjectInputStream& in);
virtual void writeObject(ObjectOutputStream& out) const;
};
}}
@@ -0,0 +1,21 @@
#include "presents/stable.h"
#include "RegistrationMarshaller.h"
#include "presents/PresentsClient.h"
using namespace presents::data;
DEFINE_STREAMABLE("com.threerings.presents.data.RegistrationMarshaller", RegistrationMarshaller);
void RegistrationMarshaller::registerReceiver (Shared<presents::PresentsClient> client, Shared<presents::client::Registration> arg1)
{
typedef std::vector< Shared<Streamable> > StreamableList;
Shared<StreamableList> args(new StreamableList);
args->push_back(arg1);
args->push_back(getSharedThis());
client->sendRequest(invOid, invCode, 1, args);
}
Shared<RegistrationMarshaller> RegistrationMarshaller::getSharedThis()
{
return shared_from_this();
}
@@ -0,0 +1,24 @@
#pragma once
#include "presents/Streamable.h"
#include "presents/ObjectInputStream.h"
#include "presents/ObjectOutputStream.h"
#include "presents/data/InvocationMarshaller.h"
#include "presents/streamers/StreamableStreamer.h"
#include <boost/enable_shared_from_this.hpp>
#include "presents/client/Registration.h"
namespace presents { namespace data {
class RegistrationMarshaller : public presents::data::InvocationMarshaller, public boost::enable_shared_from_this<RegistrationMarshaller> {
public:
DECLARE_STREAMABLE();
virtual ~RegistrationMarshaller () {}
void registerReceiver (Shared<presents::PresentsClient> client, Shared<presents::client::Registration> arg1);
protected:
Shared<RegistrationMarshaller> getSharedThis();
};
}}