Commit fc35a4d0 authored by unknown's avatar unknown
Browse files

added using table object reference in event creation


ndb/examples/ndbapi_event_example/ndbapi_event.cpp:
  changed using new event constructor
parent 93831097
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -140,6 +140,7 @@ int main()
		eventTableName,
		eventColumnName,
		noEventColumnName);

  int j= 0;
  while (j < 5) {

@@ -238,8 +239,10 @@ int myCreateEvent(Ndb* myNdb,
  NdbDictionary::Dictionary *myDict= myNdb->getDictionary();
  if (!myDict) APIERROR(myNdb->getNdbError());

  NdbDictionary::Event myEvent(eventName);
  myEvent.setTable(eventTableName);
  const NdbDictionary::Table *table= myDict->getTable(eventTableName);
  if (!table) APIERROR(myDict->getNdbError());

  NdbDictionary::Event myEvent(eventName, *table);
  myEvent.addTableEvent(NdbDictionary::Event::TE_ALL); 
  //  myEvent.addTableEvent(NdbDictionary::Event::TE_INSERT); 
  //  myEvent.addTableEvent(NdbDictionary::Event::TE_UPDATE); 
+25 −2
Original line number Diff line number Diff line
@@ -929,15 +929,38 @@ public:
#endif
    };

    /*
     *  Constructor
     *  @param  name  Name of event
     */
    Event(const char *name);
    /*
     *  Constructor
     *  @param  name  Name of event
     *  @param  table Reference retrieved from NdbDictionary
     */
    Event(const char *name, const NdbDictionary::Table& table);
    virtual ~Event();
    /**
     * Set/get unique identifier for the event
     */
    void setName(const char *name);
    const char *getName() const;
    /**
     * Define table on which events should be detected
     *
     * @note calling this method will default to detection
     *       of events on all columns. Calling subsequent
     *       addEventColumn calls will override this.
     *
     * @param table reference retrieved from NdbDictionary
     */
    void setTable(const NdbDictionary::Table& table);
    /**
     * Set table for which events should be detected
     *
     * @note preferred way is using setTable(const NdbDictionary::Table)
     *       or constructor with table object parameter
     */
    void setTable(const char *tableName);
    /**
@@ -971,7 +994,7 @@ public:
     *
     * @param columnName Column name
     *
     * @note errors will mot be detected until createEvent() is called
     * @note errors will not be detected until createEvent() is called
     */
    void addEventColumn(const char * columnName);
    /**
+13 −0
Original line number Diff line number Diff line
@@ -585,6 +585,13 @@ NdbDictionary::Event::Event(const char * name)
  setName(name);
}

NdbDictionary::Event::Event(const char * name, const Table& table)
  : m_impl(* new NdbEventImpl(* this))
{
  setName(name);
  setTable(table);
}

NdbDictionary::Event::Event(NdbEventImpl & impl)
  : m_impl(impl) 
{
@@ -610,6 +617,12 @@ NdbDictionary::Event::getName() const
  return m_impl.getName();
}

void 
NdbDictionary::Event::setTable(const Table& table)
{
  m_impl.setTable(table);
}

void 
NdbDictionary::Event::setTable(const char * table)
{
+7 −0
Original line number Diff line number Diff line
@@ -551,6 +551,13 @@ const char *NdbEventImpl::getName() const
  return m_externalName.c_str();
}

void 
NdbEventImpl::setTable(const NdbDictionary::Table& table)
{
  m_tableImpl= &NdbTableImpl::getImpl(table);
  m_tableName.assign(m_tableImpl->getName());
}

void 
NdbEventImpl::setTable(const char * table)
{
+1 −0
Original line number Diff line number Diff line
@@ -195,6 +195,7 @@ public:

  void setName(const char * name);
  const char * getName() const;
  void setTable(const NdbDictionary::Table& table);
  void setTable(const char * table);
  const char * getTableName() const;
  void addTableEvent(const NdbDictionary::Event::TableEvent t);