File: memorybridge.yo

package info (click to toggle)
bobcat 6.11.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,292 kB
  • sloc: cpp: 21,370; fortran: 6,507; makefile: 2,787; sh: 724; perl: 401; ansic: 26
file content (206 lines) | stat: -rw-r--r-- 8,355 bytes parent folder | download
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
includefile(include/header)

COMMENT(manpage, section, releasedate, archive, short name)
manpage(FBB::MemoryBridge)(3bobcat)(_CurYrs_)(libbobcat-dev__CurVers_)
                    (Memory Segments)

manpagename(FBB::MemoryBridge)(Memory Segments Data Structure)

manpagesynopsis()
    bf(#include <bobcat/memorybridge>)nl()
    Linking option: tt(-lbobcat )

manpagedescription()

    The class bf(FBB::MemoryBridge) provides the interface to the memory
segments used by Bobcat's tt(Memory...) classes. Bobcat's tt(MemoryBridge)
class accesses or modifies those segments via bf(FBB::MemoryAccess) wrapper
class objects. bf(FBB::MemoryAccess) objects are normally not directly defined
by user programs but only by bf(FBB::MemoryBridge) objects, controlling all
read and write operations to the shared memory blocks. 

Although multiple programs executed in parallel may access the same shared
memory bf(FBB::MemoryBridge) objects do not offer mutex facilities to prevent
those programs from accessing information while it's being modified. Such
mutex facilities could be made available using bf(flock)(2).

includefile(include/namespace)

manpagesection(INHERITS FROM)
    -

manpagesection(CONSTRUCTORS)

    itemization(
    itb(MemoryBridge())
       The default constructor defines a stub bf(MemoryBridge) object that
        cannot immediately be used to access memory segments. The class's
        move-assignment operator can be used to turn it into a usable object.

    itb(MemoryBridge(std::string const &bufSize, bool erase,
            size_t access = 0600))
       Constructs a bf(MemoryBridge) object. Its default capacity is specified
        by tt(bufSize) (cf. section tt(BUFSIZE)), using memory segments
        containing the stream's bytes.

        The access rights of the data stored in bf(MemoryStream) objects are
        defined by the tt(access) parameter, interpreted as an octal value,
        using the specifications used by (bf(chmod)(1)).

        The tt(erase) parameter is used to specify what happens to the memory
        segments once the bf(MemoryBridge) object goes out of scope. When
        specified as tt(false) the allocated memory segments are not destroyed
        when the object goes out of scope (and can be reaccessed until the
        computer is rebooted) using the memory object's tt(ID) (see the next
        constructor). When specified as tt(true) the memory segments are
        erased from memory when the object goes out of scope.nl()
        If construction fails, an tt(FBB::Exception) is thrown.

    itb(MemoryBridge(int id, bool erase))
       This constructor connects to a memory segment having ID
        tt(id).

        The tt(erase) parameter is used as it is used by the previous
        constructor.

        An tt(FBB::Exception) is thrown if construction fails (e.g., no
        memory segment having ID tt(id) exists),
    )

    The move constructor and move-assignment operator are available, the copy
    constructor and copy-assignment operator are not available.

manpagesection(BUFSIZE)

    includefile(bufsize.inc)

manpagesection(MEMBER FUNCTIONS)

    Most of the following members throw exceptions when called from a
bf(MemoryBridge) object that was initialized by its default constructor.

    itemization(
    itb(char *beginPtr() const)
       Returns a pointer to the first byte of the memory block
        (cf. bf(memoryblock)(3bobcat)) corresponding to the current offset
        (cf. member tt(offset()), below). 

    itb(std::streamsize blockBegin() const)
       Returns the offset of the  first byte of the memory block corresponding
        to the current offset.

    itb(std::streamsize blockEnd() const)
       Returns the offset just beyond the last byte of the memory block
        corresponding to the current offset.

    itb(std::streamsize blockSize() const)
       Returns the size of the used memory blocks.

    itb(std::streamsize bufLimits())
       Computes the values returned by tt(blockBegin) and tt(blockEnd)
        corresponding to the current offset.

    itb(char *endPtr() const)
       Returns a pointer to the memory block's byte corresponding to offset
        tt(blockEnd()).

    itb(char *endReadPtr() const)
       Returns a pointer to the position in the current memory block 
        corresponding to the last written byte in that block.

    itb(void extend())
       Extends the amount of memory blocks so that the current offsets is
        located in a memory block that's available when bytes are written into
        that block.
    
    itb(int id() const)
       The ID of the memory block (cf. bf(MemoryAccess)(3bobcat)) controlling
        access to the memory data blocks is returned.

    itb(void info(std::ostream &out))
       Information about the tt(MemoryBridge) is inserted into tt(out): the
        IDs of the memory data blocks, their sizes, the current maximum number
        of memory data blocks, the number of bytes that can be read from
        the memory segments, and its actual storage capacity.

    itb(void load())
       Loads (makes available) the memory block corresponding to the current
        tt(offset).

    itb(std::streamsize maxEnd() const)
       Returns the offset position corresponding to tt(blockEnd) of the
        current last available memory block. The value returned by this member
        can be updated to a larger value after calling tt(extend()).

    itb(std::streamsize offset() const)
       Returns the current absolute offset position.

    itb(void offset(std::streamsize pos) const)
       Sets the current absolute offset position to tt(pos).

    itb(char *offsetPtr() const)
       Returns a pointer to the byte of the memory block corresponding to 
        the current offset.

    itb(size_t read(char *dest, std::streamsize len))
       Copies at most tt(len) bytes from the tt(MemoryBridge's) data to
        tt(dest), returning the actual number of copied bytes. Reading always
        stops when reaching the value returned by tt(writtenUntil()) (see
        below).

    itb(void setErase(bool erase))
       This member is used to change the tt(erase) setting of a
        bf(MemoryBridge) object. It can be used by, e.g., forking programs
        where the program constructs a bf(MemoryBridge) object specifying
        tt(erase == false), but whose memory segments should be erased when
        the parent process ends but not also when the child process ends. This
        is accomplished by calling tt(setErase(true)) in the parent process.

    itb(std::streamsize showmanyc() const)
       Returns the number of characters that can be read from the current
        offset to the offset returned by tt(writtenUntil()).

    itb(void swap(MemoryBridge &other))
       The information of the current tt(MemoryBridge) object is swapped with
        the information of the tt(other) object.

    itb(bool truncate(std::streamsize offset))
       This member reduces or enlarges the available memory size of a
        bf(MemoryBridge) object to tt(size). If it's reduced then the memory
        segments' data bytes from tt(size) to its original size are set to 0:
        newly allocated memory sements are always initialized to 0 byte
        values.

    itb(size_t write(char *src, std::streamsize len))
       Copies tt(len) bytes from tt(src) to the tt(MemoryBridge's) data,
        starting at tt(offset), returning the actual number of copied
        bytes. Unless there's no more physical memory available writing
        succeeds. If the physical memory is exhausted an exception is thrown.

    itb(std::streamsize writtenUntil() const)
       Returns the highest offset of the byte that was ever written to the
        tt(MemoryBridge). 

    itb(void writtenUntil(std::streamsize offset) const)
       Updates the value returned by tt(writtenUntil()) to tt(offset) if
        tt(offset) is larger than that value.
    )


manpagesection(EXAMPLE)
    See the bf(memorystream)(3bobcat) man page.

manpagefiles()
    em(bobcat/memorybridge) - defines the class interface

manpageseealso()
    bf(bobcat)(7), bf(chmod)(1), bf(flock)(2),
        bf(memoryaccess)(3bobcat),
        bf(memorybuf)(3bobcat),
        bf(memoryreadme)(7bobcat),
        bf(memorystream)(3bobcat),

manpagebugs()
    None Reported.

includefile(include/trailer)