calling dynamic variable of the class

hello everyone,
I defined a variable (invalid_content) in the content-stote-impl.h function as below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
template<class Policy>
class ContentStoreImpl : public ContentStore,
                         protected ndnSIM::trie_with_policy< Name,
                                                             ndnSIM::smart_pointer_payload_traits
< EntryImpl< ContentStoreImpl< Policy > >, Entry >,
                                                             Policy >
{
public:
  typedef ndnSIM::trie_with_policy< Name,
                                   
 ndnSIM::smart_pointer_payload_traits< EntryImpl< ContentStoreImpl< Policy > >, Entry >,
                                    Policy > super;

  typedef EntryImpl< ContentStoreImpl< Policy > > entry;

  static TypeId
  GetTypeId ();

  ContentStoreImpl () { };
  virtual ~ContentStoreImpl () { };

  // from ContentStore

  
virtual void
  Remove (const Name fullKey,Ptr<const Data> data);
double invalid_content; };


and change this variable in the same function as below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  template<class Policy>
bool
ContentStoreImpl<Policy>::Add (Ptr<const Data> data)
{
  NS_LOG_FUNCTION (this << data->GetName ());

  Ptr< entry > newEntry = Create< entry > (this, data);
  std::pair< typename super::iterator, bool > result = super::insert (data->GetName (), newEntry);

  if (result.first != super::end ())
    {
      if (result.second)
        {
          newEntry->SetTrie (result.first);

          m_didAddEntry (newEntry);
//*************5/13 for caculationg poison contenet
Ptr<Node> node = this->GetObject<Node> ();
if (data->GetSignature ()!=0){
invalid_content++;

}


I want to call this variable in another function (test1.cc) as below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "ns3/ndnSIM/model/cs/content-store-impl.h"

using namespace ns3;
void
CacheEntryRemoved(std::string context, 
Ptr<const ndn::cs::Entry> entry, Time lifetime)
{
   // std::string s=Simulator::GetContext();
    //if ((entry->GetData()->GetSignature()!=0)&&(Simulator::GetContext()==11)){
if (entry->GetData()->GetSignature()!=0){
ContentStoreImpl *Content=new ContentStoreImpl ();
Content ()->invalid_content--;
      }
}


However, I have received error :
In function ‘void CacheEntryRemoved(std::string, ns3::Ptr<const ns3::ndn::cs::Entry>, ns3::Time)’:
../scratch/test1.cc:35:1: error: ‘ContentStoreImpl’ was not declared in this scope
ContentStoreImpl *Content=new ContentStoreImpl ();

I will become thankful, if you guide me to solve this problem
Thanks in advance
best regards
Last edited on
closed account (48bpfSEw)
Did you forget to use the namespace of the class ContentStoreImpl?

By the way : you didn't initialize invalid_content with 0
Thanx u so much for replying.
yes I have not defined namespace but if I define like below
using namespace ns3::ndn::cs::ContentStoreImpl;

I have received the error :
error: ‘ContentStoreImpl’ is not a namespace-name
using namespace ns3::ndn::cs::ContentStoreImpl;

May you please help me how I can access this class(ContentStoreImpl) in test.cc function. However,I think the default value for invalid_content should be zero, if I do not initialize it.
please accept my apologize, since my programming is not good
thanks
regards

Topic archived. No new replies allowed.