Python: wrap std::ostream/ofstream, for ascii tracing.

This commit is contained in:
Gustavo J. A. M. Carneiro committed 2009-02-18 12:23:08 +00:00
1 parent 468b7837f4
commit f4fbfd63c8
4 files changed
+23 -1

No files matched your search

+1
View File
@@ -86,6 +86,7 @@ def main():
ns3modulegen_core_customizations.Simulator_customizations(root_module)
ns3modulegen_core_customizations.CommandLine_customizations(root_module)
ns3modulegen_core_customizations.TypeId_customizations(root_module)
ns3modulegen_core_customizations.add_std_ofstream(root_module)
for local_module in LOCAL_MODULES:
@@ -530,3 +530,20 @@ def TypeId_customizations(module):
flags=["METH_VARARGS", "METH_KEYWORDS", "METH_STATIC"])
def add_std_ofstream(module):
module.add_include('<fstream>')
ostream = module.add_class('ostream', foreign_cpp_namespace='::std')
ostream.set_cannot_be_constructed("abstract base class")
ofstream = module.add_class('ofstream', foreign_cpp_namespace='::std', parent=ostream)
ofstream.add_enum('openmode', [
('app', 'std::ios_base::app'),
('ate', 'std::ios_base::ate'),
('binary', 'std::ios_base::binary'),
('in', 'std::ios_base::in'),
('out', 'std::ios_base::out'),
('trunc', 'std::ios_base::trunc'),
])
ofstream.add_constructor([Parameter.new("const char *", 'filename'),
Parameter.new("::std::ofstream::openmode", 'mode', default_value="std::ios_base::out")])
ofstream.add_method('close', None, [])
+1 -1
View File
@@ -15,7 +15,7 @@ import Build
import Utils
## https://launchpad.net/pybindgen/
REQUIRED_PYBINDGEN_VERSION = (0, 9, 0, 605)
REQUIRED_PYBINDGEN_VERSION = (0, 10, 0, 626)
REQUIRED_PYGCCXML_VERSION = (0, 9, 5)
+4
View File
@@ -154,9 +154,13 @@ def main(argv):
# Config::Connect ("/NodeList/*/DeviceList/*/Phy/Tx", MakeCallback (&PhyTxTrace));
# Config::Connect ("/NodeList/*/DeviceList/*/Phy/State", MakeCallback (&PhyStateTrace));
ascii = ns3.ofstream("wifi-ap.tr")
ns3.YansWifiPhyHelper.EnableAsciiAll(ascii)
ns3.Simulator.Run()
ns3.Simulator.Destroy()
ascii.close()
return 0