1classdef (Abstract) Value < matlab.mixin.Copyable
2    % Value   Summary of Value
3    %
4    % The base class for instances of Slice classes.
5    %
6    % Value Methods:
7    %   ice_preMarshal - The Ice run time invokes this method prior to
8    %     marshaling an object's data members.
9    %   ice_postUnmarshal - The Ice run time invokes this method after
10    %     unmarshaling an object's data members.
11    %   ice_getSlicedData - Returns the sliced data if the value has a
12    %     preserved-slice base class and has been sliced during unmarshaling.
13
14    % Copyright (c) ZeroC, Inc. All rights reserved.
15
16    methods
17        function obj = Value()
18            % Value constructor
19
20            %
21            % We need to assign each Value instance a unique identifier for marshaling purposes. This persistent
22            % variable retains its setting as long as there is at least one Value instance still active. Once the
23            % last instance is collected, the variable gets cleared and we start over again.
24            %
25            persistent index;
26            if isempty(index)
27                index = int32(0);
28            end
29            index = index + 1;
30            assert(index > 0); % Check for rollover
31            obj.iceInternal_ = index;
32        end
33        function ice_preMarshal(obj)
34            % ice_preMarshal - The Ice run time invokes this method prior to
35            %   marshaling an object's data members. This allows a subclass
36            %   to override this method in order to validate its data members.
37        end
38        function ice_postUnmarshal(obj)
39            % ice_postUnmarshal - The Ice run time invokes this method after
40            %   unmarshaling an object's data members. This allows a subclass
41            %   to override this method in order to perform additional
42            %   initialization.
43        end
44        function r = ice_getSlicedData(obj)
45            % ice_getSlicedData - Returns the sliced data if the value has a
46            %   preserve-slice base class and has been sliced during
47            %   unmarshaling of the value; an empty array is returned otherwise.
48
49            %
50            % Overridden by subclasses that have the "preserve-slice" metadata.
51            %
52            r = [];
53        end
54    end
55    methods(Abstract)
56        id = ice_id(obj)
57    end
58    methods(Static)
59        function id = ice_staticId()
60            id = '::Ice::Object';
61        end
62    end
63    methods(Hidden=true)
64        function iceWrite(obj, os)
65            os.startValue([]);
66            obj.iceWriteImpl(os);
67            os.endValue();
68        end
69        function iceRead(obj, is)
70            is.startValue();
71            obj.iceReadImpl(is);
72            is.endValue(false);
73        end
74        function r = iceDelayPostUnmarshal(obj)
75            %
76            % Overridden by subclasses that need to do some post-processing after the initial round of
77            % unmarshaling is complete.
78            %
79            r = false;
80        end
81        function icePostUnmarshal(obj)
82            %
83            % Overridden by subclasses that need to do some post-processing after the initial round of
84            % unmarshaling is complete.
85            %
86        end
87    end
88    methods(Abstract,Access=protected)
89        iceWriteImpl(obj, os)
90        iceReadImpl(obj, is)
91    end
92    properties(Hidden, NonCopyable)
93        iceInternal_ int32
94    end
95end
96