File tree Expand file tree Collapse file tree 3 files changed +70
-0
lines changed
src/tools/fdsdump/src/common Expand file tree Collapse file tree 3 files changed +70
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ set(COMMON_SRC
66 filelist.cpp
77 flowProvider.cpp
88 ipaddr.cpp
9+ ieMgr.cpp
910)
1011
1112add_library (common_obj OBJECT ${COMMON_SRC} )
Original file line number Diff line number Diff line change 1+ /* *
2+ * @file
3+ * @author Michal Sedlak <[email protected] > 4+ * @brief Information element manager singleton
5+ */
6+
7+ #include < common/ieMgr.hpp>
8+
9+ #include < string>
10+ #include < stdexcept>
11+
12+ namespace fdsdump {
13+
14+ IEMgr &
15+ IEMgr::instance ()
16+ {
17+ static IEMgr iemgr;
18+ return iemgr;
19+ }
20+
21+ IEMgr::IEMgr () :
22+ m_iemgr (fds_iemgr_create(), &fds_iemgr_destroy)
23+ {
24+ if (!m_iemgr) {
25+ throw std::runtime_error (" fds_iemgr_create() has failed" );
26+ }
27+
28+ const std::string dir = fds_api_cfg_dir ();
29+ int ret = fds_iemgr_read_dir (m_iemgr.get (), dir.c_str ());
30+ if (ret != FDS_OK) {
31+ const std::string err_msg = fds_iemgr_last_err (m_iemgr.get ());
32+ throw std::runtime_error (" fds_iemgr_read_dir() failed: " + err_msg);
33+ }
34+ }
35+
36+ } // fdsdump
Original file line number Diff line number Diff line change 1+ /* *
2+ * @file
3+ * @author Michal Sedlak <[email protected] > 4+ * @brief Information element manager singleton
5+ */
6+
7+ #pragma once
8+
9+ #include < libfds.h>
10+
11+ #include < memory>
12+
13+ namespace fdsdump {
14+
15+ class IEMgr {
16+ public:
17+ /* *
18+ * @brief Get the iemgr singleton instance
19+ */
20+ static IEMgr &instance ();
21+
22+ /* *
23+ * @brief Get the pointer to the underlying fds_iemgr
24+ */
25+ fds_iemgr_t *ptr () { return m_iemgr.get (); }
26+
27+ private:
28+ std::unique_ptr<fds_iemgr_t , decltype (&fds_iemgr_destroy)> m_iemgr;
29+
30+ IEMgr ();
31+ };
32+
33+ } // fdsdump
You can’t perform that action at this time.
0 commit comments