Coverage for /Syzygy/bard/events/linked_event.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%440.C++source

Line-by-line coverage:

   1    :  // Copyright 2015 Google Inc. All Rights Reserved.
   2    :  //
   3    :  // Licensed under the Apache License, Version 2.0 (the "License");
   4    :  // you may not use this file except in compliance with the License.
   5    :  // You may obtain a copy of the License at
   6    :  //
   7    :  //     http://www.apache.org/licenses/LICENSE-2.0
   8    :  //
   9    :  // Unless required by applicable law or agreed to in writing, software
  10    :  // distributed under the License is distributed on an "AS IS" BASIS,
  11    :  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12    :  // See the License for the specific language governing permissions and
  13    :  // limitations under the License.
  14    :  //
  15    :  // Composition of the Event interface that admits dependencies between
  16    :  // events.
  17    :  #ifndef SYZYGY_BARD_EVENTS_LINKED_EVENT_H_
  18    :  #define SYZYGY_BARD_EVENTS_LINKED_EVENT_H_
  19    :  
  20    :  #include <set>
  21    :  
  22    :  #include "base/memory/scoped_ptr.h"
  23    :  #include "base/synchronization/waitable_event.h"
  24    :  #include "syzygy/bard/event.h"
  25    :  
  26    :  namespace bard {
  27    :  namespace events {
  28    :  
  29    :  // Specialization of EventInterface that allows for cross-event dependencies to
  30    :  // be expressed.
  31    :  class LinkedEvent : public EventInterface {
  32    :   public:
  33    :    // Constructor.
  34    :    // @param event Wrapped event.
  35    :    explicit LinkedEvent(scoped_ptr<EventInterface> event);
  36  E :    ~LinkedEvent() override {}
  37    :  
  38    :    // @name EventInterface implementation.
  39    :    // @{
  40  E :    EventType type() const override { return kLinkedEvent; }
  41    :    bool Play(void* backdrop) override;
  42    :    bool Equals(const EventInterface* rhs) const override;
  43    :    // @}
  44    :  
  45    :    // @name Serialization methods.
  46    :    // @{
  47    :    // This method only saves the contained event, and not the actual list of
  48    :    // deps.
  49    :    static bool Save(const EventInterface* const event,
  50    :                     core::OutArchive* out_archive);
  51    :    static scoped_ptr<LinkedEvent> Load(core::InArchive* in_archive);
  52    :    // @}
  53    :  
  54    :    // Adds a dependency to this event.
  55    :    // @param dep an event that must happen before this one. This must itself
  56    :    //     be a linked event.
  57    :    // @returns true on success, false otherwise.
  58    :    // @note This method is not thread safe, so BYOL.
  59    :    bool AddDep(EventInterface* dep);
  60    :  
  61    :    // @name Accessors.
  62    :    // @{
  63  E :    const EventInterface* event() const { return event_.get(); }
  64  E :    const std::vector<LinkedEvent*>& deps() const { return deps_; }
  65    :    // @}
  66    :  
  67    :   private:
  68    :    // This is only allocated if this event becomes an output dependency of any
  69    :    // others.
  70    :    scoped_ptr<base::WaitableEvent> waitable_event_;
  71    :  
  72    :    // The event that this LinkedEvent refers to.
  73    :    scoped_ptr<EventInterface> event_;
  74    :    // The list of input dependencies. These are events that must be played
  75    :    // before this event is played.
  76    :    std::vector<LinkedEvent*> deps_;
  77    :  
  78    :    DISALLOW_COPY_AND_ASSIGN(LinkedEvent);
  79    :  };
  80    :  
  81    :  }  // namespace events
  82    :  }  // namespace bard
  83    :  
  84    :  #endif  // SYZYGY_BARD_EVENTS_LINKED_EVENT_H_

Coverage information generated Thu Jan 14 17:40:38 2016.