summaryrefslogtreecommitdiffstats
path: root/src/stateless/trex_stateless_api.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/stateless/trex_stateless_api.h')
-rw-r--r--src/stateless/trex_stateless_api.h62
1 files changed, 48 insertions, 14 deletions
diff --git a/src/stateless/trex_stateless_api.h b/src/stateless/trex_stateless_api.h
index 6406a946..358ab339 100644
--- a/src/stateless/trex_stateless_api.h
+++ b/src/stateless/trex_stateless_api.h
@@ -49,20 +49,32 @@ public:
class TrexStatelessPort {
public:
- TrexStatelessPort(uint8_t port_id) : m_port_id(port_id) {
- }
+ /**
+ * describess error codes for starting traffic
+ */
+ enum traffic_rc_e {
+ TRAFFIC_OK,
+ TRAFFIC_ERR_ALREADY_STARTED,
+ TRAFFIC_ERR_NO_STREAMS,
+ TRAFFIC_ERR_FAILED_TO_COMPILE_STREAMS
+ };
+
+ TrexStatelessPort(uint8_t port_id);
+
+ traffic_rc_e start_traffic(void);
+
+ void stop_traffic(void);
/**
* access the stream table
*
*/
- TrexStreamTable *get_stream_table() {
- return &m_stream_table;
- }
+ TrexStreamTable *get_stream_table();
private:
TrexStreamTable m_stream_table;
uint8_t m_port_id;
+ bool m_started;
};
/**
@@ -71,26 +83,48 @@ private:
*/
class TrexStateless {
public:
+
/**
- * create a T-Rex stateless object
- *
- * @author imarom (31-Aug-15)
+ * configure the stateless object singelton
+ * reconfiguration is not allowed
+ * an exception will be thrown
+ */
+ static void configure(uint8_t port_count);
+
+ /**
+ * singleton public get instance
*
- * @param port_count
*/
- TrexStateless(uint8_t port_count);
- ~TrexStateless();
+ static TrexStateless& get_instance() {
+ TrexStateless& instance = get_instance_internal();
+
+ if (!instance.m_is_configured) {
+ throw TrexException("object is not configured");
+ }
+
+ return instance;
+ }
TrexStatelessPort *get_port_by_id(uint8_t port_id);
uint8_t get_port_count();
protected:
+ TrexStateless();
+ ~TrexStateless();
+
+ static TrexStateless& get_instance_internal () {
+ static TrexStateless instance;
+ return instance;
+ }
+
+ /* c++ 2011 style singleton */
+ TrexStateless(TrexStateless const&) = delete;
+ void operator=(TrexStateless const&) = delete;
+
+ bool m_is_configured;
TrexStatelessPort **m_ports;
uint8_t m_port_count;
};
-/****** HACK *******/
-TrexStateless *get_trex_stateless();
-
#endif /* __TREX_STATELESS_API_H__ */