StreamBase C++ API  7.6.2dev
StreamProperties.hpp
1 // Copyright (c) 2004-2016 Cloud Software Group, Inc. All rights reserved.
2 
3 #ifndef STREAMBASE_STREAMPROPERTIES_H
4 #define STREAMBASE_STREAMPROPERTIES_H
5 
6 #include "StreamBase.hpp"
7 
8 #include "Exceptions.hpp"
9 #include "Schema.hpp"
10 
11 SB_INTERNAL_FWD(StreamPropertiesUtil)
12 
13 SB_NAMESPACE_BEGIN;
14 
15 /// Properties of a single stream. Returned by
16 /// StreamBaseClient::getStreamProperties().
18  public:
19  /// Determines the method StreamBase will use to expose capture fields to
20  /// client dequeuers. The default is FLATTEN.
22  FLATTEN,
23  NEST,
24  RAW
25  };
26 
27  /// Null constructor. Object will have no name and no schema.
29 
30  /// Returns the fully qualified name of the stream.
31  const std::string &getQualifiedName() const { return _qualifiedName; }
32 
33  /// Returns the name part of the stream.
34  const std::string &getName() const { return _name; }
35 
36  /// Returns the container part of the stream.
37  const std::string &getContainerName() const { return _containerName; }
38 
39  /// Returns the schema of the stream.
40  const Schema &getSchema() const { return _schema ;}
41 
42  // Returns the CaptureTransformStrategy that this stream is using
43  CaptureTransformStrategy getCaptureTransformStrategy() const { return _captureStrategy; }
44 
45  /// Returns the hash of the stream in binary
46  const std::string &hashString() const { return _hash; }
47 
48  // Return the hashString as converted into HEX
49  const std::string &hexString() const { return _hexString; }
50 
51  // hash value of this StreamProperties, used for hash_maps
52  const size_t hashValue() const { return _hashValue; }
53 
54  bool operator <(const StreamProperties& other) const {
55  return hashString() < other.hashString();
56  }
57 
58  bool operator == (const StreamProperties& other) const {
59  return hashString() == other.hashString();
60  }
61  bool operator != (const StreamProperties& other) const {
62  return !(*this == other);
63  }
64 
65  /// Parse and return a StreamProperties from an XML String. The root tag must be
66  /// &lt;stream&gt;.
67  static StreamProperties fromXml(const std::string &input) ;
68 
69  private:
70  /// Construct a StreamProperties with the given name and schema.
71  StreamProperties(const std::string &name, const std::string &hash, const Schema &schema);
72  /// Construct a StreamProperties with the given name, schema, schema for its parent app, and schema for its app
73  StreamProperties(const std::string &name, const std::string &hash, const Schema &schema, const CaptureTransformStrategy captureStrategy);
74 
75  void init(const std::string &name);
76 
77  std::string _containerName;
78  std::string _name;
79  std::string _hash;
80  std::string _qualifiedName;
81  Schema _schema;
82  CaptureTransformStrategy _captureStrategy;
83  size_t _hashValue;
84  std::string _hexString;
85  friend class sb_internal::StreamPropertiesUtil;
86 };
87 
88 
89 SB_NAMESPACE_END;
90 #endif