summaryrefslogtreecommitdiff
path: root/php/src/IcePHP/Marshal.h
blob: 620c33c7ddf5084033dabd2d3cbc6b144cfaaaf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// **********************************************************************
//
// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

#ifndef ICE_PHP_MARSHAL_H
#define ICE_PHP_MARSHAL_H

#include <Config.h>

namespace IcePHP
{

//
// The object map associates a Zend object handle to an Ice object.
//
typedef std::map<unsigned int, Ice::ObjectPtr> ObjectMap;

class Marshaler;
typedef IceUtil::Handle<Marshaler> MarshalerPtr;

class Marshaler : public IceUtil::SimpleShared
{
public:
    virtual ~Marshaler();

    static MarshalerPtr createMarshaler(const Slice::TypePtr& TSRMLS_DC);
    static MarshalerPtr createMemberMarshaler(const std::string&, const Slice::TypePtr& TSRMLS_DC);
    static MarshalerPtr createExceptionMarshaler(const Slice::ExceptionPtr& TSRMLS_DC);

    virtual bool marshal(zval*, const Ice::OutputStreamPtr&, ObjectMap& TSRMLS_DC) = 0;
    virtual bool unmarshal(zval*, const Ice::InputStreamPtr& TSRMLS_DC) = 0;

    virtual void destroy() = 0;

protected:
    Marshaler();
};

//
// Associates a scoped type id to its marshaler.
//
typedef std::map<std::string, MarshalerPtr> MarshalerMap;

//
// Associates a scoped type id to its factory.
//
typedef std::map<std::string, zval*> ObjectFactoryMap;

//
// This class is raised as an exception when object marshaling needs to be aborted.
//
class AbortMarshaling
{
};

//
// PHPObjectFactory is an implementation of Ice::ObjectFactory that creates PHP objects.
// It is also the registry for user-defined PHP factory implementations. A single instance
// can be used for all types.
//
class PHPObjectFactory : public Ice::ObjectFactory
{
public:
    PHPObjectFactory(TSRMLS_D);

    virtual Ice::ObjectPtr create(const std::string&);
    virtual void destroy();

#ifdef ZTS
private:
    TSRMLS_D;
#endif
};
typedef IceUtil::Handle<PHPObjectFactory> PHPObjectFactoryPtr;

} // End of namespace IcePHP

#endif