Wrap a subset of the LLFloaterReg API with an event API

meow-7.2.2
Nat Goodspeed 2009-08-14 14:40:43 -04:00
parent 9695162dc2
commit 2da8eb43d5
5 changed files with 100 additions and 0 deletions

View File

@ -40,6 +40,7 @@ set(llui_SOURCE_FILES
llfiltereditor.cpp
llfloater.cpp
llfloaterreg.cpp
llfloaterreglistener.cpp
llflyoutbutton.cpp
llfocusmgr.cpp
llfunctorregistry.cpp
@ -115,6 +116,7 @@ set(llui_HEADER_FILES
llfiltereditor.h
llfloater.h
llfloaterreg.h
llfloaterreglistener.h
llflyoutbutton.h
llfocusmgr.h
llfunctorregistry.h

View File

@ -36,6 +36,7 @@
#include "llfloater.h"
#include "llmultifloater.h"
#include "llfloaterreglistener.h"
//*******************************************************
@ -45,6 +46,8 @@ LLFloaterReg::instance_map_t LLFloaterReg::sInstanceMap;
LLFloaterReg::build_map_t LLFloaterReg::sBuildMap;
std::map<std::string,std::string> LLFloaterReg::sGroupMap;
static LLFloaterRegListener sFloaterRegListener("LLFloaterReg");
//*******************************************************
//static

View File

@ -70,6 +70,7 @@ public:
typedef std::map<std::string, BuildData> build_map_t;
private:
friend class LLFloaterRegListener;
static instance_list_t sNullInstanceList;
static instance_map_t sInstanceMap;
static build_map_t sBuildMap;

View File

@ -0,0 +1,60 @@
/**
* @file llfloaterreglistener.cpp
* @author Nat Goodspeed
* @date 2009-08-12
* @brief Implementation for llfloaterreglistener.
*
* $LicenseInfo:firstyear=2009&license=viewergpl$
* Copyright (c) 2009, Linden Research, Inc.
* $/LicenseInfo$
*/
// Precompiled header
#include "linden_common.h"
// associated header
#include "llfloaterreglistener.h"
// STL headers
// std headers
// external library headers
// other Linden headers
#include "llfloaterreg.h"
LLFloaterRegListener::LLFloaterRegListener(const std::string& pumpName):
LLDispatchListener(pumpName, "op")
{
add("getBuildMap", &LLFloaterRegListener::getBuildMap, LLSD().insert("reply", LLSD()));
LLSD requiredName;
requiredName["name"] = LLSD();
add("showInstance", &LLFloaterRegListener::showInstance, requiredName);
add("hideInstance", &LLFloaterRegListener::hideInstance, requiredName);
}
void LLFloaterRegListener::getBuildMap(const LLSD& event) const
{
// Honor the "reqid" convention by echoing event["reqid"] in our reply packet.
LLReqID reqID(event);
LLSD reply(reqID.makeResponse());
// Build an LLSD map that mirrors sBuildMap. Since we have no good way to
// represent a C++ callable in LLSD, the only part of BuildData we can
// store is the filename. For each LLSD map entry, it would be more
// extensible to store a nested LLSD map containing a single key "file" --
// but we don't bother, simply storing the string filename instead.
for (LLFloaterReg::build_map_t::const_iterator mi(LLFloaterReg::sBuildMap.begin()),
mend(LLFloaterReg::sBuildMap.end());
mi != mend; ++mi)
{
reply[mi->first] = mi->second.mFile;
}
// Send the reply to the LLEventPump named in event["reply"].
LLEventPumps::instance().obtain(event["reply"]).post(reply);
}
void LLFloaterRegListener::showInstance(const LLSD& event) const
{
LLFloaterReg::showInstance(event["name"], event["key"], event["focus"]);
}
void LLFloaterRegListener::hideInstance(const LLSD& event) const
{
LLFloaterReg::hideInstance(event["name"], event["key"]);
}

View File

@ -0,0 +1,34 @@
/**
* @file llfloaterreglistener.h
* @author Nat Goodspeed
* @date 2009-08-12
* @brief Wrap (subset of) LLFloaterReg API with an event API
*
* $LicenseInfo:firstyear=2009&license=viewergpl$
* Copyright (c) 2009, Linden Research, Inc.
* $/LicenseInfo$
*/
#if ! defined(LL_LLFLOATERREGLISTENER_H)
#define LL_LLFLOATERREGLISTENER_H
#include "lleventdispatcher.h"
#include <string>
class LLSD;
/// Event API wrapper for LLFloaterReg
class LLFloaterRegListener: public LLDispatchListener
{
public:
/// As all public LLFloaterReg methods are static, there's no point in
/// binding an LLFloaterReg instance.
LLFloaterRegListener(const std::string& pumpName);
private:
void getBuildMap(const LLSD& event) const;
void showInstance(const LLSD& event) const;
void hideInstance(const LLSD& event) const;
};
#endif /* ! defined(LL_LLFLOATERREGLISTENER_H) */