[ndnSIM] Error: cannot convert ‘ns3::ndn::PitTracer*’ to ‘ns3::ObjectBase*’ in initialization

Sai Gautam Mandapati saigautam96 at gmail.com
Wed Mar 1 22:51:37 PST 2023


Can anyone please respond to this? I really need this.



On Wed, Mar 1, 2023 at 5:03 PM Sai Gautam Mandapati <saigautam96 at gmail.com>
wrote:

> Hi everyone,
>
> I have a question.  I'm trying to develop a PitTracer for my simulations.
> Currently, I'm facing one error.
>
> *From the header file: .hpp*
> class PitTracer : public L3Tracer {
> public:
>   static TypeId GetTypeId();
>   PitTracer();
>   /**
>    * @brief Constructor
>    *
>    * @param filename Output filename.
>    */
>    PitTracer(const std::string& filename);
>   /**
>    * @brief Destructor
>    */
>  virtual ~PitTracer();
>  virtual void Trace(std::string context, Ptr<const Packet> packet,
> Ptr<L3Protocol> l3);
>
> *From the implementation file: .cpp*
>
> NS_OBJECT_ENSURE_REGISTERED(PitTracer);
>
> TypeId PitTracer::GetTypeId(void)
> {
>   static TypeId tid =
>    TypeId("ns3::ndn::PitTracer")
>     .SetParent<L3Protocol>()
>     .SetGroupName("Ndn")
>     .AddConstructor<PitTracer>()
>     .AddConstructor<PitTracer , const std::string&>()
>     //.AddConstructor<PitTracer>()
>     .AddAttribute("Filename", "Output filename",
>                   StringValue("pit-sizes.txt"),
>                   MakeStringAccessor(&PitTracer::m_outputFilename),
>                   MakeStringChecker())
>     .AddAttribute("Interval", "Interval at which to write PIT sizes to
> output file",
>                   TimeValue(Seconds(1.0)),
>                   MakeTimeAccessor(&PitTracer::m_interval),
>                   MakeTimeChecker());
>
>   return tid;
> }
>
> *Error:*
> ./ns3/type-id.h: In instantiation of ‘static ns3::ObjectBase*
> ns3::TypeId::AddConstructor()::Maker::Create() [with T =
> ns3::ndn::PitTracer]’:
> ./ns3/type-id.h:659:3:   required from ‘ns3::TypeId
> ns3::TypeId::AddConstructor() [with T = ns3::ndn::PitTracer]’
> ../src/ndnSIM/utils/tracers/pit-tracer.cpp:41:32:   required from here
> ./ns3/type-id.h:656:20: error: cannot convert ‘ns3::ndn::PitTracer*’ to
> ‘ns3::ObjectBase*’ in initialization
>   656 |       ObjectBase * base = new T ();
>       |                    ^~~~
> --
> Please help me out in resolving this error. Thank you so much in advance.
>
> Sai Gautam
>


-- 
Sai Gautam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20230301/19236073/attachment.html>


More information about the ndnSIM mailing list