aboutsummaryrefslogtreecommitdiffstats
path: root/src/bts.h
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-17 19:41:11 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-30 21:20:45 +0100
commitb6acfdaa24851e1aa95bfc4611709737aaafa5f1 (patch)
tree77ccb6c9ba4d387381fd82e3768189a6e7a334a7 /src/bts.h
parent67ed34eedb59320095396ff2f65f360c046d88c5 (diff)
bts: Introduce a singleton for the BTS and use it in the code
Compared to the previous code there will be a branch to get the global pointer so the code will be slightly slower than the previous version but it allows us to start creating objects but still use the code from C. It is best approach I have found so far. One downside of C++ is that by default talloc will not be used (unless we override the new operator to use talloc. Right now we need to memset the C data structure by hand. The benefit of enforcing a better structure should is more important though.
Diffstat (limited to 'src/bts.h')
-rw-r--r--src/bts.h39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/bts.h b/src/bts.h
index f17b3b72..9a5b570a 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -31,6 +31,7 @@ extern "C" {
#include <stdint.h>
struct gprs_rlcmac_tbf;
+struct BTS;
/*
* PDCH instance
@@ -54,7 +55,10 @@ struct gprs_rlcmac_trx {
struct gprs_rlcmac_tbf *dl_tbf[32]; /* array of DL TBF, by DL TFI */
};
-
+/**
+ * This is the data from C. As soon as our minimal compiler is gcc 4.7
+ * we can start to compile pcu_vty.c with c++ and remove the split.
+ */
struct gprs_rlcmac_bts {
uint8_t bsic;
uint8_t fc_interval;
@@ -80,4 +84,37 @@ struct gprs_rlcmac_bts {
uint32_t alloc_algorithm_curst; /* options to customize algorithm */
uint8_t force_two_phase;
uint8_t alpha, gamma;
+
+ /**
+ * Point back to the C++ object. This is used during the transition
+ * period.
+ */
+ struct BTS *bts;
+};
+
+#ifdef __cplusplus
+/**
+ * I represent a GSM BTS. I have one or more TRX, I know the current
+ * GSM time and I have controllers that help with allocating resources
+ * on my TRXs.
+ */
+struct BTS {
+public:
+ BTS();
+
+ static BTS* main_bts();
+
+ struct gprs_rlcmac_bts *bts_data();
+
+private:
+ struct gprs_rlcmac_bts m_bts;
};
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ struct gprs_rlcmac_bts *bts_main_data();
+#ifdef __cplusplus
+}
+#endif