libdas2
das2 core C utilities
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stream.h
Go to the documentation of this file.
1 /* Copyright (C) 2004-2017 Jeremy Faden <jeremy-faden@uiowa.edu>
2  * Chris Piker <chris-piker@uiowa.edu>
3  *
4  * This file is part of libdas2, the Core Das2 C Library.
5  *
6  * Libdas2 is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * Libdas2 is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * version 2.1 along with libdas2; if not, see <http://www.gnu.org/licenses/>.
17  */
18 
21 #ifndef _das_stream_h_
22 #define _das_stream_h_
23 
24 #include <stdbool.h>
25 #include <das2/packet.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #define STREAMDESC_CMP_SZ 48
32 #define STREAMDESC_VER_SZ 48
33 
34 #define MAX_PKTIDS 100
35 
46 typedef struct stream_descriptor{
49 
59  PktDesc* pktDesc[MAX_PKTIDS];
60 
61  /* Common properties */
62  char compression[STREAMDESC_CMP_SZ];
63  char version[STREAMDESC_VER_SZ];
64  bool bDescriptorSent;
65 
73  void* pUser;
74 } StreamDesc;
75 
76 
84 
85 StreamDesc* new_StreamDesc_str(DasBuf* pBuf);
86 
100 StreamDesc* StreamDesc_copy(const StreamDesc* pThis);
101 
102 
108 void del_StreamDesc(StreamDesc* pThis);
109 
124 size_t StreamDesc_getNPktDesc(const StreamDesc* pThis);
125 
135 DasErrCode StreamDesc_addPktDesc(StreamDesc* pThis, PktDesc* pPd, int nPktId);
136 
137 
142 void StreamDesc_setMonotonic(StreamDesc* pThis, bool isMonotonic );
143 
150 
155 void StreamDesc_addCmdLineProp(StreamDesc* pThis, int argc, char* argv[] );
156 
181  das_units xUnits );
182 
195 
209  StreamDesc* pThis, const StreamDesc* pOther, int nPktId
210 );
211 
219 bool StreamDesc_isValidId(const StreamDesc* pThis, int nPktId);
220 
230 PktDesc* StreamDesc_getPktDesc(const StreamDesc* pThis, int id);
231 
236 DasErrCode StreamDesc_freePktDesc(StreamDesc* pThis, int nPktId);
237 
241 int StreamDesc_getOffset(StreamDesc* pThis);
242 
251 
258 
259 #ifdef __cplusplus
260 }
261 #endif
262 
263 #endif /* _das_stream_h_ */
DasErrCode StreamDesc_freePktDesc(StreamDesc *pThis, int nPktId)
Free any resources associated with this PacketDescriptor, and release it&#39;s id number for use with a n...
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition: util.h:117
PktDesc * StreamDesc_clonePktDescById(StreamDesc *pThis, const StreamDesc *pOther, int nPktId)
Deepcopy a PacketDescriptor from one stream to another.
void * pUser
User data pointer.
Definition: stream.h:73
PktDesc * StreamDesc_createPktDesc(StreamDesc *pThis, DasEncoding *pXEncoder, das_units xUnits)
Creates a descriptor structure that for a stream packet type.
Holds information for a single packet type in a Das2 stream.
Definition: packet.h:138
bool StreamDesc_isValidId(const StreamDesc *pThis, int nPktId)
Check to see if an packet ID has been defined for the stream.
Little buffer class to handle accumulating string data.
Definition: buffer.h:49
StreamDesc * new_StreamDesc(void)
Creates a new blank StreamDesc.
Base structure for Stream Header Items.
Definition: descriptor.h:80
PktDesc * StreamDesc_getPktDesc(const StreamDesc *pThis, int id)
Get the packet descriptor associated with an ID.
void StreamDesc_addCmdLineProp(StreamDesc *pThis, int argc, char *argv[])
Adds the command line into the property set of the StreamDesc.
Reading and writing values on das2 streams.
Definition: encoding.h:108
DasErrCode StreamDesc_addPktDesc(StreamDesc *pThis, PktDesc *pPd, int nPktId)
Attach a standalone packet descriptor to this stream.
StreamDesc * StreamDesc_copy(const StreamDesc *pThis)
Creates a deep-copy of an existing StreamDesc object.
void StreamDesc_setMonotonic(StreamDesc *pThis, bool isMonotonic)
Indicates if the xtags on the stream are monotonic, in which case there might be optimal ways of proc...
Describes the stream itself, in particular the compression used, current packetDescriptors, etc.
Definition: stream.h:46
PktDesc * StreamDesc_clonePktDesc(StreamDesc *pThis, const PktDesc *pd)
Make a deep copy of a PacketDescriptor on a new stream.
DasDesc base
The base structure.
Definition: stream.h:48
size_t StreamDesc_getNPktDesc(const StreamDesc *pThis)
Get the number of packet descriptors defined for this stream.
void StreamDesc_addStdProps(StreamDesc *pThis)
Adds metadata into the property set of the StreamDesc.
DasErrCode StreamDesc_encode(StreamDesc *pThis, DasBuf *pBuf)
Encode a StreamDesc to an XML string.
void del_StreamDesc(StreamDesc *pThis)
Delete a stream descriptor and all it&#39;s sub objects.
DasDesc * Das2Desc_decode(DasBuf *pBuf)
Das2 Stream Descriptor Factory Function.
int StreamDesc_getOffset(StreamDesc *pThis)
An I/O function that makes sense to use for either operation.
const char * das_units
Enumeration of unit types, that correspond to physical unit types.
Definition: units.h:135